diff --git a/WooCommerce/Classes/ViewModels/Booking Details/AppointmentDetailsContent.swift b/WooCommerce/Classes/ViewModels/Booking Details/AppointmentDetailsContent.swift index 997a1785a96..6d80c0d7c14 100644 --- a/WooCommerce/Classes/ViewModels/Booking Details/AppointmentDetailsContent.swift +++ b/WooCommerce/Classes/ViewModels/Booking Details/AppointmentDetailsContent.swift @@ -15,10 +15,10 @@ extension BookingDetailsViewModel { let rows: [Row] init(_ booking: Booking) { - let appointmentDate = booking.startDate.formatted(date: .numeric, time: .omitted) + let appointmentDate = booking.startDate.toString(dateStyle: .short, timeStyle: .none, timeZone: BookingListTab.utcTimeZone) let appointmentTimeFrame = [ - booking.startDate.formatted(date: .omitted, time: .shortened), - booking.endDate.formatted(date: .omitted, time: .shortened) + booking.startDate.toString(dateStyle: .none, timeStyle: .short, timeZone: BookingListTab.utcTimeZone), + booking.endDate.toString(dateStyle: .none, timeStyle: .short, timeZone: BookingListTab.utcTimeZone) ].joined(separator: " - ") rows = [ diff --git a/WooCommerce/Classes/ViewModels/Booking Details/HeaderContent.swift b/WooCommerce/Classes/ViewModels/Booking Details/HeaderContent.swift index d0dd8f591ce..870b858641b 100644 --- a/WooCommerce/Classes/ViewModels/Booking Details/HeaderContent.swift +++ b/WooCommerce/Classes/ViewModels/Booking Details/HeaderContent.swift @@ -10,9 +10,10 @@ extension BookingDetailsViewModel { @Published var serviceAndCustomerLine: String init(_ booking: Booking, customerName: String? = nil) { - bookingDate = booking.startDate.formatted( - date: .numeric, - time: .shortened + bookingDate = booking.startDate.toString( + dateStyle: .short, + timeStyle: .short, + timeZone: BookingListTab.utcTimeZone ) /// Temporary hardcode for service name diff --git a/WooCommerce/Classes/ViewRelated/Bookings/Booking Details/CustomerDetailsView.swift b/WooCommerce/Classes/ViewRelated/Bookings/Booking Details/CustomerDetailsView.swift index 643ad23c4fc..e79d792a298 100644 --- a/WooCommerce/Classes/ViewRelated/Bookings/Booking Details/CustomerDetailsView.swift +++ b/WooCommerce/Classes/ViewRelated/Bookings/Booking Details/CustomerDetailsView.swift @@ -5,6 +5,8 @@ extension BookingDetailsView { struct CustomerDetailsView: View { @ObservedObject var content: BookingDetailsViewModel.CustomerContent let showNotice: (Notice) -> Void + @State private var showingPhoneOptions = false + @State private var selectedPhoneNumber: String? private enum Row: Hashable { case name(String) @@ -77,7 +79,7 @@ extension BookingDetailsView { } .padding(.vertical, Layout.rowTextVerticalPadding) .tappable { - emailText.sendToPasteboard() + emailText.sendToPasteboard(includeTrailingNewline: false) showNotice( Notice( title: Localization.emailCopiedMessage, @@ -98,7 +100,25 @@ extension BookingDetailsView { } .padding(.vertical, Layout.rowTextVerticalPadding) .tappable { - print("On phone ellipsis") + selectedPhoneNumber = phoneText + showingPhoneOptions = true + } + .confirmationDialog( + selectedPhoneNumber ?? "", + isPresented: $showingPhoneOptions, + titleVisibility: .visible + ) { + Button(Localization.callActionTitle) { + guard let phoneNumber = selectedPhoneNumber else { return } + if PhoneHelper.callPhoneNumber(phone: phoneNumber) == false { + showNotice(Notice(title: Localization.phoneNumberErrorNotice, feedbackType: .error)) + } + } + Button(Localization.copyActionTitle) { + guard let phoneNumber = selectedPhoneNumber else { return } + phoneNumber.sendToPasteboard(includeTrailingNewline: false) + showNotice(Notice(title: Localization.phoneNumberCopied, feedbackType: .success)) + } } } @@ -127,6 +147,30 @@ private extension BookingDetailsView.CustomerDetailsView { comment: "Toast message shown when the user copies the customer's email address." ) + static let callActionTitle = NSLocalizedString( + "BookingDetailsView.phoneNumberOptions.call", + value: "Call", + comment: "Action to call the phone number." + ) + + static let copyActionTitle = NSLocalizedString( + "BookingDetailsView.phoneNumberOptions.copy", + value: "Copy", + comment: "Action to copy the phone number." + ) + + static let phoneNumberCopied = NSLocalizedString( + "BookingDetailsView.phoneNumberOptions.copied", + value: "Phone number copied", + comment: "Notice message shown when the phone number is copied." + ) + + static let phoneNumberErrorNotice = NSLocalizedString( + "BookingDetailsView.phoneNumberOptions.error", + value: "Could not place a call to this number.", + comment: "Notice message shown when a phone call cannot be initiated." + ) + /// Customer section static let billingAddressRowTitle = NSLocalizedString( "BookingDetailsView.customer.billingAddress.title",