Skip to content

Commit

Permalink
Adding support to text field's prompt for iOS 15
Browse files Browse the repository at this point in the history
  • Loading branch information
lchinigioli-eb committed May 12, 2022
1 parent 34f62c5 commit 104fb96
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Sources/ToggleableSecureField/ToggleableSecureField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,17 @@ public struct ToggleableSecureField: View {
public var body: some View {
VStack {
if isSecure {
SecureField(title, text: text)
if #available(iOS 15.0, *) {
SecureField(title, text: text, prompt: prompt)
} else {
SecureField(title, text: text)
}
} else {
TextField(title, text: text)
if #available(iOS 15.0, *) {
TextField(title, text: text, prompt: prompt)
} else {
TextField(title, text: text)
}
}
}
.textFieldStyle(
Expand Down Expand Up @@ -81,6 +89,9 @@ struct ToggleableSecureField_Previews: PreviewProvider {

static var previews: some View {
VStack {
Text("ToggleableSecureField")
.padding()
.font(.headline)
fieldGroup.colorScheme(.light)
fieldGroup.colorScheme(.dark)
}
Expand Down

0 comments on commit 104fb96

Please sign in to comment.