From c27246f3a696b4f4a266315e58aa442abf7ce13f Mon Sep 17 00:00:00 2001 From: Greg O'Neill Date: Wed, 8 Aug 2018 17:28:35 -0400 Subject: [PATCH] add auto-fill/auto-suggest feature to form fields Co-authored-by: Vui Nguyen Co-authored-by: Greg O'Neill --- NYPLCardCreator/AddressViewController.swift | 8 ++++++++ NYPLCardCreator/NameAndEmailViewController.swift | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/NYPLCardCreator/AddressViewController.swift b/NYPLCardCreator/AddressViewController.swift index aedfafc..a850318 100644 --- a/NYPLCardCreator/AddressViewController.swift +++ b/NYPLCardCreator/AddressViewController.swift @@ -114,6 +114,14 @@ final class AddressViewController: FormTableViewController { self.zipCell.textField.addTarget(self, action: #selector(zipTextFieldDidChange), for: .allEditingEvents) + + if #available(iOS 10.0, *) { + self.street1Cell.textField.textContentType = .streetAddressLine1 + self.street2Cell.textField.textContentType = .streetAddressLine2 + self.cityCell.textField.textContentType = .addressCity + self.regionCell.textField.textContentType = .addressState + self.zipCell.textField.textContentType = .postalCode + } } func checkToPrefillForm() { diff --git a/NYPLCardCreator/NameAndEmailViewController.swift b/NYPLCardCreator/NameAndEmailViewController.swift index 7cf018d..aec8e81 100644 --- a/NYPLCardCreator/NameAndEmailViewController.swift +++ b/NYPLCardCreator/NameAndEmailViewController.swift @@ -81,6 +81,13 @@ final class NameAndEmailViewController: FormTableViewController { self.emailCell.textField.keyboardType = .emailAddress self.emailCell.textField.autocapitalizationType = .none self.emailCell.textField.autocorrectionType = .no + + if #available(iOS 10.0, *) { + self.firstNameCell.textField.textContentType = .givenName + self.middleInitialCell.textField.textContentType = .middleName + self.lastNameCell.textField.textContentType = .familyName + self.emailCell.textField.textContentType = .emailAddress + } } func checkToPrefillForm() {