Explorar o código

Fix Nightscout token autofill by adding textContentType

Jonas Björkert hai 1 ano
pai
achega
3ef056b4c6

+ 7 - 2
LoopFollow/Helpers/Views/TogglableSecureInput.swift

@@ -10,6 +10,7 @@ struct TogglableSecureInput: View {
     let placeholder: String
     @Binding var text: String
     let style: Style
+    var textContentType: UITextContentType? = nil
 
     @State private var isVisible = false
     @FocusState private var isFocused: Bool
@@ -20,9 +21,13 @@ struct TogglableSecureInput: View {
                 switch style {
                 case .singleLine:
                     if isVisible {
-                        TextField(placeholder, text: $text).multilineTextAlignment(.trailing)
+                        TextField(placeholder, text: $text)
+                            .multilineTextAlignment(.trailing)
+                            .textContentType(textContentType)
                     } else {
-                        SecureField(placeholder, text: $text).multilineTextAlignment(.trailing)
+                        SecureField(placeholder, text: $text)
+                            .multilineTextAlignment(.trailing)
+                            .textContentType(textContentType)
                     }
 
                 case .multiLine:

+ 2 - 1
LoopFollow/Nightscout/NightscoutSettingsView.swift

@@ -43,7 +43,8 @@ struct NightscoutSettingsView: View {
                 TogglableSecureInput(
                     placeholder: "Enter Token",
                     text: $viewModel.nightscoutToken,
-                    style: .singleLine
+                    style: .singleLine,
+                    textContentType: .password
                 )
             }
         }