Skip to content

Commit 832ef10

Browse files
authored
Merge pull request #431 from loopandlearn/nightscout-token-autofill
Fix Nightscout token autofill by adding textContentType
2 parents 61c6323 + aa9252e commit 832ef10

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

LoopFollow/Helpers/Views/TogglableSecureInput.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ struct TogglableSecureInput: View {
1010
let placeholder: String
1111
@Binding var text: String
1212
let style: Style
13+
var textContentType: UITextContentType? = nil
1314

1415
@State private var isVisible = false
1516
@FocusState private var isFocused: Bool
@@ -20,9 +21,13 @@ struct TogglableSecureInput: View {
2021
switch style {
2122
case .singleLine:
2223
if isVisible {
23-
TextField(placeholder, text: $text).multilineTextAlignment(.trailing)
24+
TextField(placeholder, text: $text)
25+
.multilineTextAlignment(.trailing)
26+
.textContentType(textContentType)
2427
} else {
25-
SecureField(placeholder, text: $text).multilineTextAlignment(.trailing)
28+
SecureField(placeholder, text: $text)
29+
.multilineTextAlignment(.trailing)
30+
.textContentType(textContentType)
2631
}
2732

2833
case .multiLine:

LoopFollow/Nightscout/NightscoutSettingsView.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct NightscoutSettingsView: View {
2727
private var urlSection: some View {
2828
Section(header: Text("URL")) {
2929
TextField("Enter URL", text: $viewModel.nightscoutURL)
30-
.textContentType(.URL)
30+
.textContentType(.username)
3131
.autocapitalization(.none)
3232
.disableAutocorrection(true)
3333
.onChange(of: viewModel.nightscoutURL) { newValue in
@@ -43,7 +43,8 @@ struct NightscoutSettingsView: View {
4343
TogglableSecureInput(
4444
placeholder: "Enter Token",
4545
text: $viewModel.nightscoutToken,
46-
style: .singleLine
46+
style: .singleLine,
47+
textContentType: .password
4748
)
4849
}
4950
}

0 commit comments

Comments
 (0)