Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Last active July 12, 2020 18:22
Show Gist options
  • Save sturdysturge/6b3c2bce47270810afc357a931bd1224 to your computer and use it in GitHub Desktop.
Save sturdysturge/6b3c2bce47270810afc357a931bd1224 to your computer and use it in GitHub Desktop.
RevDoc TextContextType
import SwiftUI
struct TextContentTypeView: View {
#if os(macOS)
let contentTypes: [NSTextContentType] = [.username, .password, .oneTimeCode]
#else
let contentTypes: [UITextContentType] = [.URL, .addressCity, .addressCityAndState, .addressState, .countryName, .creditCardNumber, .emailAddress, .familyName, .fullStreetAddress, .givenName, .jobTitle, .location, .middleName, .name, .namePrefix, .nameSuffix, .newPassword, .nickname, .oneTimeCode, .organizationName, .password, .postalCode, .streetAddressLine1, .streetAddressLine2, .sublocality, .telephoneNumber, .username]
#endif
@State var text = ""
var body: some View {
Form {
ForEach(contentTypes, id: \.self) {
contextType in
TextField("Enter text for \(contextType.rawValue)", text: $text)
.textContentType(contextType)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment