diff 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
line wrap: on
line diff
--- a/Simoleon/Helpers/ConversionBox.swift	Mon Jul 26 18:25:03 2021 +0100
+++ b/Simoleon/Helpers/ConversionBox.swift	Mon Jul 26 20:08:20 2021 +0100
@@ -26,17 +26,17 @@
             
             ZStack(alignment: .trailing) {
                 TextField("Enter amount", text: $amountToConvert) { startedEditing in
-                if startedEditing {
-                         withAnimation {
+                    if startedEditing {
+                        withAnimation {
                             amountIsEditing = true
-                         }
-                     }
+                        }
+                    }
                 }
                 onCommit: {
-                     withAnimation {
+                    withAnimation {
                         amountIsEditing = false
-                     }
-                 }
+                    }
+                }
                 .keyboardType(.decimalPad)
                 .font(Font.title.weight(.semibold))
                 .lineLimit(1)
@@ -63,12 +63,14 @@
     }
     
     /*
-     if the amount can be converted to Double -> return amount
-     else -> return zero
+     if the amount can be converted to Double:
+     * Return amount
+     else:
+     * Return zero
      */
     private func makeConversion() -> Double {
         if let amountToConvert = Double(amountToConvert) {
-            return amountToConvert * price  /// Conversion
+            return amountToConvert * price  // Conversion
         } else {
             return 0
         }