changeset 188:e4f5dcf4d596

add keyboard resign option
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Thu, 23 Dec 2021 16:23:16 +0100
parents 13d5a8deb6c2
children 9f044d33d8ac
files Simoleon.xcodeproj/project.pbxproj Simoleon/ConversionView.swift Simoleon/Helpers/CurrencyTextfield.swift
diffstat 3 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Simoleon.xcodeproj/project.pbxproj	Thu Dec 23 16:12:22 2021 +0100
+++ b/Simoleon.xcodeproj/project.pbxproj	Thu Dec 23 16:23:16 2021 +0100
@@ -560,6 +560,7 @@
 				ENABLE_PREVIEWS = YES;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = Simoleon/Info.plist;
+				INFOPLIST_KEY_CFBundleDisplayName = Simoleon;
 				INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
 				INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
 				INFOPLIST_KEY_UILaunchScreen_Generation = YES;
@@ -591,6 +592,7 @@
 				ENABLE_PREVIEWS = YES;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = Simoleon/Info.plist;
+				INFOPLIST_KEY_CFBundleDisplayName = Simoleon;
 				INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
 				INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
 				INFOPLIST_KEY_UILaunchScreen_Generation = YES;
--- a/Simoleon/ConversionView.swift	Thu Dec 23 16:12:22 2021 +0100
+++ b/Simoleon/ConversionView.swift	Thu Dec 23 16:23:16 2021 +0100
@@ -26,6 +26,9 @@
     // Update currency rates
     @State private var timer = Timer.publish(every: 3, on: .main, in: .common).autoconnect()
     
+    // CurrencyTextfield variables
+    @FocusState private var textfieldIsFocused: Bool
+    
     var body: some View {
         ScrollView(showsIndicators: false) {
             VStack(alignment: .leading, spacing: 20) {
@@ -51,6 +54,7 @@
                     .fontWeight(.semibold)
                 
                 CurrencyTextfield(currencyCode: baseCurrency.code, amount: $amount)
+                    .focused($textfieldIsFocused)
                 
                 Divider()
                 Text("\(quoteCurrency.code) - \(quoteCurrency.name)")
@@ -68,6 +72,15 @@
                 CurrencyList(baseCurrency: $baseCurrency, quoteCurrency: $quoteCurrency, selecting: selecting)
             }
         }
+        .toolbar {
+            ToolbarItem(placement: .confirmationAction) {
+                if textfieldIsFocused {
+                    Button("Done") {
+                        textfieldIsFocused = false
+                    }
+                }
+            }
+        }
         .onAppear {
             getConversion()
             timer = Timer.publish(every: 3, on: .main, in: .common).autoconnect()
--- a/Simoleon/Helpers/CurrencyTextfield.swift	Thu Dec 23 16:12:22 2021 +0100
+++ b/Simoleon/Helpers/CurrencyTextfield.swift	Thu Dec 23 16:23:16 2021 +0100
@@ -12,7 +12,6 @@
     @Binding var amount: String
     
     var body: some View {
-        VStack {
         TextField("Enter the amount", text: $amount)
             .keyboardType(.decimalPad)
             .font(.title2)
@@ -22,7 +21,6 @@
                     .cornerRadius(15)
                     .frame(height: 55)
             )
-        }
     }
 }