diff Simoleon/Helpers/ConversionBox.swift @ 35:41a905e591e4

Fixes minor bugs
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Sat, 24 Jul 2021 23:14:10 +0100
parents a8d76aa51da2
children d25b02d439d4
line wrap: on
line diff
--- a/Simoleon/Helpers/ConversionBox.swift	Fri Jul 23 13:57:30 2021 +0100
+++ b/Simoleon/Helpers/ConversionBox.swift	Sat Jul 24 23:14:10 2021 +0100
@@ -9,7 +9,7 @@
 
 struct ConversionBox: View {
     @Binding var currencyPair: String
-    @Binding var amountToConvert: String { willSet { print(newValue) }}
+    @Binding var amountToConvert: String
     @Binding var price: Double
     @Binding var showingConversion: Bool
     @Binding var showingCurrencySelector: Bool
@@ -65,12 +65,10 @@
     
     
     private func makeConversion() -> Double {
-        if amountToConvert.isEmpty {  /// Avoid nil error when string is empty
-            return 0
+        if let amountToConvert = Double(amountToConvert) {
+            return amountToConvert * price  /// Conversion
         } else {
-            let conversion = Double(amountToConvert) ?? 0  * price
-
-            return conversion
+            return 0
         }
     }
 }