Skip to content

[Order details] Capitalize addresses and surname by word #15611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

22.4
-----
- [*] Order Details: Improvements to textfield capitalization rules [https://github.com/woocommerce/woocommerce-ios/pull/15611]
- [*] POS: Scrolling search results now dismisses the keyboard [https://github.com/woocommerce/woocommerce-ios/pull/15606]
- [*] Order Creation: Display non-purchasable, zero-priced variable product variations [https://github.com/woocommerce/woocommerce-ios/pull/15620]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ final class CreateOrderAddressFormViewModel: AddressFormViewModel, AddressFormVi

var sectionTitle: String {
if showDifferentAddressForm {
return Localization.billingAddressSection
return Localization.billingTitle.uppercased()
} else {
return Localization.addressSection
return Localization.addressSection.uppercased()
}
}

var secondarySectionTitle: String {
Localization.shippingAddressSection
Localization.shippingTitle.uppercased()
}

var showAlternativeUsageToggle: Bool {
Expand Down Expand Up @@ -103,20 +103,26 @@ final class CreateOrderAddressFormViewModel: AddressFormViewModel, AddressFormVi
}

private extension CreateOrderAddressFormViewModel {

// MARK: Constants
enum Localization {
static let customerDetailsTitle = NSLocalizedString("Customer Details", comment: "Title for the Shipping Address Form for Customer Details")

static let shippingTitle = NSLocalizedString("Shipping Address", comment: "Title for the Edit Shipping Address Form")
static let billingTitle = NSLocalizedString("Billing Address", comment: "Title for the Edit Billing Address Form")

static let addressSection = NSLocalizedString("ADDRESS", comment: "Details section title in the Edit Address Form")

static let shippingAddressSection = NSLocalizedString("SHIPPING ADDRESS", comment: "Details section title in the Edit Address Form")
static let billingAddressSection = NSLocalizedString("BILLING ADDRESS", comment: "Details section title in the Edit Address Form")

static let differentAddressToggleTitle = NSLocalizedString("Add a different shipping address",
comment: "Title for the Add a Different Address switch in the Address form")
static let customerDetailsTitle = NSLocalizedString(
"createOrderAddressFormViewModel.customerDetailsTitle",
value: "Customer Details",
comment: "Title for the Shipping Address Form for Customer Details")
static let shippingTitle = NSLocalizedString(
"createOrderAddressFormViewModel.shippingTitle",
value: "Shipping Address",
comment: "Title for the Edit Shipping Address Form")
static let billingTitle = NSLocalizedString(
"createOrderAddressFormViewModel.billingTitle",
value: "Billing Address",
comment: "Title for the Edit Billing Address Form")
static let addressSection = NSLocalizedString(
"createOrderAddressFormViewModel.addressSection",
value: "Address",
comment: "Details section title in the Edit Address Form")
static let differentAddressToggleTitle = NSLocalizedString(
"createOrderAddressFormViewModel.differentAddressToggleTitle",
value: "Add a different shipping address",
comment: "Title for the Add a Different Address switch in the Address form")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ struct SingleAddressForm: View {
text: $fields.firstName,
symbol: nil,
fieldAlignment: .leading,
keyboardType: .default)
keyboardType: .default,
autocapitalization: .words)
.accessibilityIdentifier("order-address-form-first-name-field")

Divider()
Expand All @@ -264,7 +265,8 @@ struct SingleAddressForm: View {
text: $fields.lastName,
symbol: nil,
fieldAlignment: .leading,
keyboardType: .default)
keyboardType: .default,
autocapitalization: .words)
Divider()
.padding(.leading, Constants.dividerPadding)

Expand All @@ -275,7 +277,8 @@ struct SingleAddressForm: View {
text: $fields.email,
symbol: nil,
fieldAlignment: .leading,
keyboardType: .emailAddress)
keyboardType: .emailAddress,
autocapitalization: .never)
.autocapitalization(.none)
Divider()
.padding(.leading, Constants.dividerPadding)
Expand Down Expand Up @@ -318,7 +321,8 @@ struct SingleAddressForm: View {
text: $fields.company,
symbol: nil,
fieldAlignment: .leading,
keyboardType: .default)
keyboardType: .default,
autocapitalization: .words)
Divider()
.padding(.leading, Constants.dividerPadding)
TitleAndTextFieldRow(title: Localization.address1Field,
Expand All @@ -327,7 +331,8 @@ struct SingleAddressForm: View {
text: $fields.address1,
symbol: nil,
fieldAlignment: .leading,
keyboardType: .default)
keyboardType: .default,
autocapitalization: .words)
Divider()
.padding(.leading, Constants.dividerPadding)
TitleAndTextFieldRow(title: Localization.address2Field,
Expand All @@ -336,7 +341,8 @@ struct SingleAddressForm: View {
text: $fields.address2,
symbol: nil,
fieldAlignment: .leading,
keyboardType: .default)
keyboardType: .default,
autocapitalization: .words)
Divider()
.padding(.leading, Constants.dividerPadding)
TitleAndTextFieldRow(title: Localization.cityField,
Expand All @@ -345,7 +351,8 @@ struct SingleAddressForm: View {
text: $fields.city,
symbol: nil,
fieldAlignment: .leading,
keyboardType: .default)
keyboardType: .default,
autocapitalization: .words)
Divider()
.padding(.leading, Constants.dividerPadding)
TitleAndTextFieldRow(title: Localization.postcodeField,
Expand All @@ -354,7 +361,8 @@ struct SingleAddressForm: View {
text: $fields.postcode,
symbol: nil,
fieldAlignment: .leading,
keyboardType: .default)
keyboardType: .default,
autocapitalization: .characters)
Divider()
.padding(.leading, Constants.dividerPadding)
}
Expand Down Expand Up @@ -417,7 +425,8 @@ struct SingleAddressForm: View {
text: $fields.state,
symbol: nil,
fieldAlignment: .leading,
keyboardType: .default)
keyboardType: .default,
autocapitalization: .words)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ final class EditOrderAddressFormViewModel: AddressFormViewModel, AddressFormView
var sectionTitle: String {
switch type {
case .shipping:
return Localization.shippingAddressSection
return Localization.shippingTitle.uppercased()
case .billing:
return Localization.billingAddressSection
return Localization.billingTitle.uppercased()
}
}

Expand Down Expand Up @@ -194,20 +194,27 @@ private extension EditOrderAddressFormViewModel {
}
}

// MARK: Constants
enum Localization {
static let shippingTitle = NSLocalizedString("Shipping Address", comment: "Title for the Edit Shipping Address Form")
static let billingTitle = NSLocalizedString("Billing Address", comment: "Title for the Edit Billing Address Form")

static let shippingAddressSection = NSLocalizedString("SHIPPING ADDRESS", comment: "Details section title in the Edit Address Form")
static let billingAddressSection = NSLocalizedString("BILLING ADDRESS", comment: "Details section title in the Edit Address Form")

static let useAsBillingToggle = NSLocalizedString("Use as Billing Address",
comment: "Title for the Use as Billing Address switch in the Address form")
static let useAsShippingToggle = NSLocalizedString("Use as Shipping Address",
comment: "Title for the Use as Shipping Address switch in the Address form")

static let success = NSLocalizedString("Address successfully updated.", comment: "Notice text after updating the shipping or billing address")
static let shippingTitle = NSLocalizedString(
"editOrderAddressFormViewModel.shippingTitle",
value: "Shipping Address",
comment: "Title for the Edit Shipping Address Form")
static let billingTitle = NSLocalizedString(
"editOrderAddressFormViewModel.billingTitle",
value: "Billing Address",
comment: "Title for the Edit Billing Address Form")
static let useAsBillingToggle = NSLocalizedString(
"editOrderAddressFormViewModel.useAsBillingToggle",
value: "Use as Billing Address",
comment: "Title for the Use as Billing Address switch in the Address form")
static let useAsShippingToggle = NSLocalizedString(
"editOrderAddressFormViewModel.useAsShippingToggle",
value: "Use as Shipping Address",
comment: "Title for the Use as Shipping Address switch in the Address form")
static let success = NSLocalizedString(
"editOrderAddressFormViewModel.success",
value: "Address successfully updated.",
comment: "Notice text after updating the shipping or billing address")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ struct TitleAndTextFieldRow: View {
private let placeholder: String
private let symbol: String?
private let keyboardType: UIKeyboardType
private let autocapitalization: TextInputAutocapitalization
private let onEditingChanged: ((Bool) -> Void)?
private let editable: Bool
private let fieldAlignment: TextAlignment
Expand All @@ -31,6 +32,7 @@ struct TitleAndTextFieldRow: View {
editable: Bool = true,
fieldAlignment: TextAlignment = .trailing,
keyboardType: UIKeyboardType = .default,
autocapitalization: TextInputAutocapitalization = .sentences,
contentColor: Color = Color(.label),
inputFormatter: UnitInputFormatter? = nil,
minHeight: CGFloat = Constants.height,
Expand All @@ -44,6 +46,7 @@ struct TitleAndTextFieldRow: View {
self.editable = editable
self.fieldAlignment = fieldAlignment
self.keyboardType = keyboardType
self.autocapitalization = autocapitalization
self.contentColor = contentColor
self.inputFormatter = inputFormatter
self.minHeight = minHeight
Expand Down Expand Up @@ -73,6 +76,7 @@ struct TitleAndTextFieldRow: View {
.font(.body)
.keyboardType(keyboardType)
.disabled(!editable)
.textInputAutocapitalization(autocapitalization)
if let symbol = symbol {
Text(symbol)
.bodyStyle()
Expand Down