Mercurial > public > simoleon
comparison Simoleon/Helpers/ConversionBox.swift @ 47:75c1a05176f6
Refactor code
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Mon, 26 Jul 2021 20:08:20 +0100 |
parents | d25b02d439d4 |
children | 529feb1fc8d5 cd801949925b |
comparison
equal
deleted
inserted
replaced
46:ce4eb7416b41 | 47:75c1a05176f6 |
---|---|
24 .fontWeight(.semibold) | 24 .fontWeight(.semibold) |
25 .padding(.top, 40) | 25 .padding(.top, 40) |
26 | 26 |
27 ZStack(alignment: .trailing) { | 27 ZStack(alignment: .trailing) { |
28 TextField("Enter amount", text: $amountToConvert) { startedEditing in | 28 TextField("Enter amount", text: $amountToConvert) { startedEditing in |
29 if startedEditing { | 29 if startedEditing { |
30 withAnimation { | 30 withAnimation { |
31 amountIsEditing = true | 31 amountIsEditing = true |
32 } | 32 } |
33 } | 33 } |
34 } | 34 } |
35 onCommit: { | 35 onCommit: { |
36 withAnimation { | 36 withAnimation { |
37 amountIsEditing = false | 37 amountIsEditing = false |
38 } | 38 } |
39 } | 39 } |
40 .keyboardType(.decimalPad) | 40 .keyboardType(.decimalPad) |
41 .font(Font.title.weight(.semibold)) | 41 .font(Font.title.weight(.semibold)) |
42 .lineLimit(1) | 42 .lineLimit(1) |
43 .padding(.bottom, 10) | 43 .padding(.bottom, 10) |
44 } | 44 } |
61 } | 61 } |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 /* | 65 /* |
66 if the amount can be converted to Double -> return amount | 66 if the amount can be converted to Double: |
67 else -> return zero | 67 * Return amount |
68 else: | |
69 * Return zero | |
68 */ | 70 */ |
69 private func makeConversion() -> Double { | 71 private func makeConversion() -> Double { |
70 if let amountToConvert = Double(amountToConvert) { | 72 if let amountToConvert = Double(amountToConvert) { |
71 return amountToConvert * price /// Conversion | 73 return amountToConvert * price // Conversion |
72 } else { | 74 } else { |
73 return 0 | 75 return 0 |
74 } | 76 } |
75 } | 77 } |
76 } | 78 } |