Преглед изворни кода

Implement Secure Inputs for Dexcom and Nightscout Credentials

Jonas Björkert пре 1 година
родитељ
комит
bf43688ab0

+ 12 - 14
LoopFollow/Nightscout/NightscoutSettingsView.swift

@@ -25,35 +25,33 @@ struct NightscoutSettingsView: View {
     // MARK: - Subviews / Computed Properties
 
     private var urlSection: some View {
-        Section {
-            TextField("URL", text: $viewModel.nightscoutURL)
+        Section(header: Text("URL")) {
+            TextField("Enter URL", text: $viewModel.nightscoutURL)
                 .textContentType(.URL)
                 .autocapitalization(.none)
                 .disableAutocorrection(true)
                 .onChange(of: viewModel.nightscoutURL) { newValue in
                     viewModel.processURL(newValue)
                 }
-        } header: {
-            Text("URL")
         }
     }
 
     private var tokenSection: some View {
-        Section {
-            TextField("Token", text: $viewModel.nightscoutToken)
-                .textContentType(.password)
-                .autocapitalization(.none)
-                .disableAutocorrection(true)
-        } header: {
-            Text("Token")
+        Section(header: Text("Token")) {
+            HStack {
+                Text("Access Token")
+                TogglableSecureInput(
+                    placeholder: "Enter Token",
+                    text: $viewModel.nightscoutToken,
+                    style: .singleLine
+                )
+            }
         }
     }
 
     private var statusSection: some View {
-        Section {
+        Section(header: Text("Status")) {
             Text(viewModel.nightscoutStatus)
-        } header: {
-            Text("Status")
         }
     }
 }

+ 15 - 6
LoopFollow/Settings/DexcomSettingsView.swift

@@ -11,13 +11,22 @@ struct DexcomSettingsView: View {
         NavigationView {
             Form {
                 Section(header: Text("Dexcom Settings")) {
-                    TextField("User Name", text: $viewModel.userName)
-                        .autocapitalization(.none)
-                        .disableAutocorrection(true)
+                    HStack {
+                        Text("User Name")
+                        TextField("Enter User Name", text: $viewModel.userName)
+                            .autocapitalization(.none)
+                            .disableAutocorrection(true)
+                            .multilineTextAlignment(.trailing)
+                    }
 
-                    TextField("Password", text: $viewModel.password)
-                        .autocapitalization(.none)
-                        .disableAutocorrection(true)
+                    HStack {
+                        Text("Password")
+                        TogglableSecureInput(
+                            placeholder: "Enter Password",
+                            text: $viewModel.password,
+                            style: .singleLine
+                        )
+                    }
 
                     Picker("Server", selection: $viewModel.server) {
                         Text("US").tag("US")