From 2e41a17625a839c2a6d2c18d5f94dd209a057727 Mon Sep 17 00:00:00 2001 From: iamgabrielma Date: Mon, 20 Jan 2025 14:22:05 +0100 Subject: [PATCH 01/13] update change due text color --- .../Classes/POS/Presentation/PointOfSaleCollectCashView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift b/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift index dd00cfafae5..8b5d47e10c2 100644 --- a/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift +++ b/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift @@ -60,7 +60,7 @@ struct PointOfSaleCollectCashView: View { if let changeDue = changeDueMessage { Text(changeDue) .font(.posBodyRegular) - .foregroundColor(.posTextSuccess) + .foregroundColor(.posSecondaryText) } if let errorMessage = errorMessage { From 61d90b931d0dee210596dad1f8abd5d1455f57cc Mon Sep 17 00:00:00 2001 From: iamgabrielma Date: Mon, 20 Jan 2025 14:47:04 +0100 Subject: [PATCH 02/13] button dynamic spacing when button shown --- .../PointOfSaleCollectCashView.swift | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift b/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift index 8b5d47e10c2..662d6f731eb 100644 --- a/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift +++ b/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift @@ -1,9 +1,30 @@ import SwiftUI +import Combine + +final class KeyboardObserver: ObservableObject { + @Published var keyboardHeight: CGFloat = 0 + private var cancellables = Set() + + init() { + let keyboardWillShow = NotificationCenter.default.publisher(for: UIResponder.keyboardWillChangeFrameNotification) + let keyboardWillHide = NotificationCenter.default.publisher(for: UIResponder.keyboardWillHideNotification) + + keyboardWillShow.merge(with: keyboardWillHide) + .sink { [weak self] notification in + guard let self = self else { return } + if let endFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect { + self.keyboardHeight = endFrame.origin.y >= UIScreen.main.bounds.height ? 0 : endFrame.height + } + } + .store(in: &cancellables) + } +} struct PointOfSaleCollectCashView: View { @Environment(\.colorScheme) var colorScheme @EnvironmentObject private var posModel: PointOfSaleAggregateModel @FocusState private var isTextFieldFocused: Bool + @StateObject private var keyboardObserver = KeyboardObserver() private let viewHelper = CollectCashViewHelper() @@ -18,13 +39,21 @@ struct PointOfSaleCollectCashView: View { String.localizedStringWithFormat(Localization.backNavigationSubtitle, orderTotal) } + private var keyboardHeight: CGFloat { + if keyboardObserver.keyboardHeight < Constants.keyboardShownButtonSpacing { + return Constants.keyboardShownButtonSpacing + } else { + return Constants.keyboardHiddenButtonSpacing + } + } + @StateObject private var textFieldViewModel = FormattableAmountTextFieldViewModel(size: .extraLarge, locale: Locale.autoupdatingCurrent, storeCurrencySettings: ServiceLocator.currencySettings, allowNegativeNumber: false) var body: some View { - VStack(alignment: .center) { + VStack(alignment: .center, spacing: 2) { HStack { Button(action: { Task { @MainActor in @@ -63,10 +92,13 @@ struct PointOfSaleCollectCashView: View { .foregroundColor(.posSecondaryText) } + Spacer().frame(height: keyboardHeight) + if let errorMessage = errorMessage { Text(errorMessage) .font(POSFontStyle.posBodyRegular) .foregroundColor(.red) + .padding(.bottom, Constants.errorMessagePadding) } Button(action: { @@ -110,6 +142,7 @@ struct PointOfSaleCollectCashView: View { .padding([.horizontal, .bottom]) .animation(.easeInOut, value: errorMessage) .animation(.easeInOut, value: changeDueMessage) + .animation(.easeInOut, value: keyboardObserver.keyboardHeight) .onChange(of: textFieldAmountInput) { _ in errorMessage = nil } @@ -146,6 +179,9 @@ private extension PointOfSaleCollectCashView { static let navigationHeaderTopPadding: CGFloat = 8 static let buttonFont: POSFontStyle = .posBodyEmphasized static let buttonCornerRadius: CGFloat = 8 + static let errorMessagePadding: CGFloat = 8 + static let keyboardShownButtonSpacing: CGFloat = 80 + static let keyboardHiddenButtonSpacing: CGFloat = 20 } private var backgroundColor: Color { From a4217eb7a85eaa98052b651f8e688ea4d9646e0d Mon Sep 17 00:00:00 2001 From: iamgabrielma Date: Mon, 20 Jan 2025 14:48:45 +0100 Subject: [PATCH 03/13] Extract KeyboardObserver --- .../PointOfSaleCollectCashView.swift | 20 ------------------ .../POS/ViewHelpers/KeyboardObserver.swift | 21 +++++++++++++++++++ .../WooCommerce.xcodeproj/project.pbxproj | 4 ++++ 3 files changed, 25 insertions(+), 20 deletions(-) create mode 100644 WooCommerce/Classes/POS/ViewHelpers/KeyboardObserver.swift diff --git a/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift b/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift index 662d6f731eb..8548ce1224e 100644 --- a/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift +++ b/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift @@ -1,24 +1,4 @@ import SwiftUI -import Combine - -final class KeyboardObserver: ObservableObject { - @Published var keyboardHeight: CGFloat = 0 - private var cancellables = Set() - - init() { - let keyboardWillShow = NotificationCenter.default.publisher(for: UIResponder.keyboardWillChangeFrameNotification) - let keyboardWillHide = NotificationCenter.default.publisher(for: UIResponder.keyboardWillHideNotification) - - keyboardWillShow.merge(with: keyboardWillHide) - .sink { [weak self] notification in - guard let self = self else { return } - if let endFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect { - self.keyboardHeight = endFrame.origin.y >= UIScreen.main.bounds.height ? 0 : endFrame.height - } - } - .store(in: &cancellables) - } -} struct PointOfSaleCollectCashView: View { @Environment(\.colorScheme) var colorScheme diff --git a/WooCommerce/Classes/POS/ViewHelpers/KeyboardObserver.swift b/WooCommerce/Classes/POS/ViewHelpers/KeyboardObserver.swift new file mode 100644 index 00000000000..86947a7dab7 --- /dev/null +++ b/WooCommerce/Classes/POS/ViewHelpers/KeyboardObserver.swift @@ -0,0 +1,21 @@ +import SwiftUI +import Combine + +final class KeyboardObserver: ObservableObject { + @Published var keyboardHeight: CGFloat = 0 + private var cancellables = Set() + + init() { + let keyboardWillShow = NotificationCenter.default.publisher(for: UIResponder.keyboardWillChangeFrameNotification) + let keyboardWillHide = NotificationCenter.default.publisher(for: UIResponder.keyboardWillHideNotification) + + keyboardWillShow.merge(with: keyboardWillHide) + .sink { [weak self] notification in + guard let self = self else { return } + if let endFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect { + self.keyboardHeight = endFrame.origin.y >= UIScreen.main.bounds.height ? 0 : endFrame.height + } + } + .store(in: &cancellables) + } +} diff --git a/WooCommerce/WooCommerce.xcodeproj/project.pbxproj b/WooCommerce/WooCommerce.xcodeproj/project.pbxproj index 4078bfa49ed..4c097638d2c 100644 --- a/WooCommerce/WooCommerce.xcodeproj/project.pbxproj +++ b/WooCommerce/WooCommerce.xcodeproj/project.pbxproj @@ -1614,6 +1614,7 @@ 68E674AB2A4DAB8C0034BA1E /* CompletedUpgradeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E674AA2A4DAB8C0034BA1E /* CompletedUpgradeView.swift */; }; 68E674AD2A4DAC010034BA1E /* CurrentPlanDetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E674AC2A4DAC010034BA1E /* CurrentPlanDetailsView.swift */; }; 68E674AF2A4DACD50034BA1E /* UpgradeTopBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E674AE2A4DACD50034BA1E /* UpgradeTopBarView.swift */; }; + 68E759F52D3E8B7E009DBC68 /* KeyboardObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E759F42D3E8B72009DBC68 /* KeyboardObserver.swift */; }; 68E952CC287536010095A23D /* SafariView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E952CB287536010095A23D /* SafariView.swift */; }; 68E952D0287587BF0095A23D /* CardReaderManualRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E952CF287587BF0095A23D /* CardReaderManualRowView.swift */; }; 68E952D22875A44B0095A23D /* CardReaderType+Manual.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E952D12875A44B0095A23D /* CardReaderType+Manual.swift */; }; @@ -4730,6 +4731,7 @@ 68E674AA2A4DAB8C0034BA1E /* CompletedUpgradeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompletedUpgradeView.swift; sourceTree = ""; }; 68E674AC2A4DAC010034BA1E /* CurrentPlanDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrentPlanDetailsView.swift; sourceTree = ""; }; 68E674AE2A4DACD50034BA1E /* UpgradeTopBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpgradeTopBarView.swift; sourceTree = ""; }; + 68E759F42D3E8B72009DBC68 /* KeyboardObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyboardObserver.swift; sourceTree = ""; }; 68E952CB287536010095A23D /* SafariView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariView.swift; sourceTree = ""; }; 68E952CF287587BF0095A23D /* CardReaderManualRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardReaderManualRowView.swift; sourceTree = ""; }; 68E952D12875A44B0095A23D /* CardReaderType+Manual.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CardReaderType+Manual.swift"; sourceTree = ""; }; @@ -7004,6 +7006,7 @@ 6891C3632D364AFB00B5B48C /* CollectCashViewHelper.swift */, 6885E2CB2C32B14B004C8D70 /* TotalsViewHelper.swift */, 6837631B2C2E847D00AD51D0 /* CartViewHelper.swift */, + 68E759F42D3E8B72009DBC68 /* KeyboardObserver.swift */, ); path = ViewHelpers; sourceTree = ""; @@ -15679,6 +15682,7 @@ 02619858256B53DD00E321E9 /* AggregatedShippingLabelOrderItems.swift in Sources */, 260520F22B83B1B7005D5D59 /* ConnectivityToolViewModel.swift in Sources */, 20762BA72C18B55100758305 /* CardPresentPaymentsTransactionAlertsProvider.swift in Sources */, + 68E759F52D3E8B7E009DBC68 /* KeyboardObserver.swift in Sources */, 0235595024496853004BE2B8 /* BottomSheetListSelectorViewController.swift in Sources */, 57A49128250A7EB2000FEF21 /* OrderListViewController.swift in Sources */, 203163BD2C1C9602001C96DA /* PointOfSaleCardPresentPaymentAlertType.swift in Sources */, From ef0296fa07111cdc4df8267d1aad1ac6646aecd8 Mon Sep 17 00:00:00 2001 From: iamgabrielma Date: Mon, 20 Jan 2025 17:37:02 +0100 Subject: [PATCH 04/13] add preview --- .../SwiftUI Components/FormattableAmountTextField.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/FormattableAmountTextField.swift b/WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/FormattableAmountTextField.swift index d6f6f87b07a..ebc81a0d00c 100644 --- a/WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/FormattableAmountTextField.swift +++ b/WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/FormattableAmountTextField.swift @@ -74,3 +74,11 @@ private extension FormattableAmountTextField { } } } + +#Preview { + let viewModel = FormattableAmountTextFieldViewModel(size: .extraLarge, + locale: .current, + storeCurrencySettings: .init(), + allowNegativeNumber: false) + FormattableAmountTextField(viewModel: viewModel, style: .pos) +} From a1ad3a03cc6c897270c909ce25736c558b2e281a Mon Sep 17 00:00:00 2001 From: iamgabrielma Date: Tue, 21 Jan 2025 11:03:19 +0100 Subject: [PATCH 05/13] Add keyboard observer to receipts view --- .../Reusable Views/POSSendReceiptView.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/WooCommerce/Classes/POS/Presentation/Reusable Views/POSSendReceiptView.swift b/WooCommerce/Classes/POS/Presentation/Reusable Views/POSSendReceiptView.swift index c77c867e00d..95dd800d2b4 100644 --- a/WooCommerce/Classes/POS/Presentation/Reusable Views/POSSendReceiptView.swift +++ b/WooCommerce/Classes/POS/Presentation/Reusable Views/POSSendReceiptView.swift @@ -6,6 +6,7 @@ struct POSSendReceiptView: View { @State private var textFieldInput: String = "" @State private var isLoading: Bool = false @State private var errorMessage: String? + @StateObject private var keyboardObserver = KeyboardObserver() @Binding private(set) var isShowingSendReceiptView: Bool @@ -13,6 +14,14 @@ struct POSSendReceiptView: View { EmailFormatValidator.validate(string: textFieldInput) } + private var keyboardHeight: CGFloat { + if keyboardObserver.keyboardHeight < Constants.keyboardShownButtonSpacing { + return Constants.keyboardShownButtonSpacing + } else { + return Constants.keyboardHiddenButtonSpacing + } + } + var body: some View { VStack(alignment: .center) { HStack { @@ -50,8 +59,11 @@ struct POSSendReceiptView: View { Text(errorMessage) .font(POSFontStyle.posBodyRegular) .foregroundColor(.red) + .padding(.bottom, Constants.errorMessagePadding) } + Spacer().frame(height: keyboardHeight) + Button(action: { sendReceipt() }, label: { @@ -79,6 +91,7 @@ struct POSSendReceiptView: View { } .padding([.horizontal, .bottom]) .animation(.easeInOut, value: errorMessage) + .animation(.easeInOut, value: keyboardObserver.keyboardHeight) .onChange(of: textFieldInput) { _ in errorMessage = nil } @@ -111,6 +124,9 @@ private extension POSSendReceiptView { static let buttonPadding: CGFloat = 32 static let buttonFont: POSFontStyle = .posBodyEmphasized static let buttonCornerRadius: CGFloat = 8 + static let errorMessagePadding: CGFloat = 8 + static let keyboardShownButtonSpacing: CGFloat = 80 + static let keyboardHiddenButtonSpacing: CGFloat = 20 } } From d0c8f85383c8d9d15e7ccf98d45ea1b0a2a3d8ed Mon Sep 17 00:00:00 2001 From: iamgabrielma Date: Tue, 21 Jan 2025 11:33:39 +0100 Subject: [PATCH 06/13] Move circle bg color to POS constants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit success text color happened to be different, but we no longer use it. Let’s move the circle success color to POS constants so we do not have different tones all around. We still keep the same values for light-dark modes --- .../PointOfSaleCardPresentPaymentSuccessMessageView.swift | 6 +----- WooCommerce/Classes/POS/Utils/Color+WooCommercePOS.swift | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Reader Messages/PointOfSaleCardPresentPaymentSuccessMessageView.swift b/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Reader Messages/PointOfSaleCardPresentPaymentSuccessMessageView.swift index c9ddc1cc390..db2d13af643 100644 --- a/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Reader Messages/PointOfSaleCardPresentPaymentSuccessMessageView.swift +++ b/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Reader Messages/PointOfSaleCardPresentPaymentSuccessMessageView.swift @@ -68,7 +68,7 @@ struct PointOfSaleCardPresentPaymentSuccessMessageView: View { .frame(width: Constants.imageSize.width, height: Constants.imageSize.height) .shadow(color: Color(.wooCommerceEmerald(.shade80)).opacity(Constants.shadowOpacity), radius: Constants.shadowRadius, x: Constants.shadowSize.width, y: Constants.shadowSize.height) - .foregroundColor(circleBackgroundColor) + .foregroundColor(.posSuccessColor) Image(PointOfSaleAssets.successCheck.imageName) .renderingMode(.template) .foregroundColor(checkmarkColor) @@ -77,10 +77,6 @@ struct PointOfSaleCardPresentPaymentSuccessMessageView: View { } } - private var circleBackgroundColor: Color { - Color(red: 8/255, green: 251/255, blue: 135/255) - } - private var checkmarkColor: Color { Color.primary } diff --git a/WooCommerce/Classes/POS/Utils/Color+WooCommercePOS.swift b/WooCommerce/Classes/POS/Utils/Color+WooCommercePOS.swift index 48df6dbc1da..fcfc96721d4 100644 --- a/WooCommerce/Classes/POS/Utils/Color+WooCommercePOS.swift +++ b/WooCommerce/Classes/POS/Utils/Color+WooCommercePOS.swift @@ -95,11 +95,11 @@ extension Color { ) } - static var posTextSuccess: Color { + static var posSuccessColor: Color { Color( UIColor( - light: UIColor(red: 10.0/255.0, green: 148.0/255.0, blue: 0.0/255.0, alpha: 1.0), - dark: UIColor(red: 10.0/255.0, green: 148.0/255.0, blue: 0.0/255.0, alpha: 1.0) + light: UIColor(red: 8.0/255.0, green: 251.0/255.0, blue: 135.0/255.0, alpha: 1.0), + dark: UIColor(red: 8.0/255.0, green: 251.0/255.0, blue: 135.0/255.0, alpha: 1.0) ) ) } From b251a6dfe381e013ce480444e95d38dbf7b8d963 Mon Sep 17 00:00:00 2001 From: iamgabrielma Date: Tue, 21 Jan 2025 11:43:41 +0100 Subject: [PATCH 07/13] update dark mode color for circle success --- WooCommerce/Classes/POS/Utils/Color+WooCommercePOS.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WooCommerce/Classes/POS/Utils/Color+WooCommercePOS.swift b/WooCommerce/Classes/POS/Utils/Color+WooCommercePOS.swift index fcfc96721d4..f1c8aa3c5e3 100644 --- a/WooCommerce/Classes/POS/Utils/Color+WooCommercePOS.swift +++ b/WooCommerce/Classes/POS/Utils/Color+WooCommercePOS.swift @@ -99,7 +99,7 @@ extension Color { Color( UIColor( light: UIColor(red: 8.0/255.0, green: 251.0/255.0, blue: 135.0/255.0, alpha: 1.0), - dark: UIColor(red: 8.0/255.0, green: 251.0/255.0, blue: 135.0/255.0, alpha: 1.0) + dark: UIColor(red: 2.0/255.0, green: 140.0/255.0, blue: 89.0/255.0, alpha: 1.0) ) ) } From 8f90faed2635c5bcf9b83cc1a6917991d8fac7d5 Mon Sep 17 00:00:00 2001 From: iamgabrielma Date: Tue, 21 Jan 2025 12:07:13 +0100 Subject: [PATCH 08/13] clean up keyboard observer --- .../POS/ViewHelpers/KeyboardObserver.swift | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/WooCommerce/Classes/POS/ViewHelpers/KeyboardObserver.swift b/WooCommerce/Classes/POS/ViewHelpers/KeyboardObserver.swift index 86947a7dab7..ce50840ab75 100644 --- a/WooCommerce/Classes/POS/ViewHelpers/KeyboardObserver.swift +++ b/WooCommerce/Classes/POS/ViewHelpers/KeyboardObserver.swift @@ -6,16 +6,30 @@ final class KeyboardObserver: ObservableObject { private var cancellables = Set() init() { - let keyboardWillShow = NotificationCenter.default.publisher(for: UIResponder.keyboardWillChangeFrameNotification) + observeKeyboardNotifications() + } + + private func observeKeyboardNotifications() { + let keyboardWillChange = NotificationCenter.default.publisher(for: UIResponder.keyboardWillChangeFrameNotification) let keyboardWillHide = NotificationCenter.default.publisher(for: UIResponder.keyboardWillHideNotification) - keyboardWillShow.merge(with: keyboardWillHide) + keyboardWillChange + .merge(with: keyboardWillHide) .sink { [weak self] notification in - guard let self = self else { return } - if let endFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect { - self.keyboardHeight = endFrame.origin.y >= UIScreen.main.bounds.height ? 0 : endFrame.height - } + self?.handleKeyboardNotification(notification) } .store(in: &cancellables) } + + private func handleKeyboardNotification(_ notification: Notification) { + // UIResponder.keyboardFrameEndUserInfoKey contains where the keyboard will be after the animation completes, + // so we know the keyboard's end position in the screen + guard let userInfo = notification.userInfo, + let endFrame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { + return + } + + let screenHeight = UIScreen.main.bounds.height + keyboardHeight = (endFrame.origin.y >= screenHeight) ? 0 : endFrame.height + } } From 5f9b8b9fa07b1de9a9a26c9dd82a9a0eaee890d0 Mon Sep 17 00:00:00 2001 From: iamgabrielma Date: Thu, 23 Jan 2025 14:26:47 +0100 Subject: [PATCH 09/13] Wrap cash view in ScrollView. Remove keyboard observer --- .../PointOfSaleCollectCashView.swift | 150 ++++++++---------- 1 file changed, 69 insertions(+), 81 deletions(-) diff --git a/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift b/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift index 8b29ef18cb2..074eb248af2 100644 --- a/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift +++ b/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift @@ -5,7 +5,6 @@ struct PointOfSaleCollectCashView: View { @Environment(\.dynamicTypeSize) var dynamicTypeSize @EnvironmentObject private var posModel: PointOfSaleAggregateModel @FocusState private var isTextFieldFocused: Bool - @StateObject private var keyboardObserver = KeyboardObserver() private let viewHelper = CollectCashViewHelper() @@ -20,99 +19,90 @@ struct PointOfSaleCollectCashView: View { String.localizedStringWithFormat(Localization.backNavigationSubtitle, orderTotal) } - private var keyboardHeight: CGFloat { - if keyboardObserver.keyboardHeight < Constants.keyboardShownButtonSpacing { - return Constants.keyboardShownButtonSpacing - } else { - return Constants.keyboardHiddenButtonSpacing - } - } - @StateObject private var textFieldViewModel = FormattableAmountTextFieldViewModel(size: .extraLarge, locale: Locale.autoupdatingCurrent, storeCurrencySettings: ServiceLocator.currencySettings, allowNegativeNumber: false) var body: some View { - VStack(alignment: .center, spacing: conditionalPadding(8)) { - HStack { + ScrollView { + VStack(alignment: .center, spacing: conditionalPadding(8)) { + HStack { + Button(action: { + Task { @MainActor in + await posModel.cancelCashPayment() + isTextFieldFocused = false + } + }, label: { + navigationHeader + }) + .disabled(isLoading) + Spacer() + .renderedIf(!dynamicTypeSize.isAccessibilitySize) + } + + FormattableAmountTextField(viewModel: textFieldViewModel, style: .pos) + .focused($isTextFieldFocused) + .dynamicTypeSize(...DynamicTypeSize.accessibility1) + .onSubmit { + Task { @MainActor in + await submitCashAmount() + } + } + .onChange(of: textFieldViewModel.amount) { newValue in + textFieldAmountInput = newValue + updateChangeDueMessage() + } + + if let changeDue = changeDueMessage { + Text(changeDue) + .font(.posBodyRegular) + .foregroundColor(.posSecondaryText) + } + + if let errorMessage = errorMessage { + Text(errorMessage) + .font(POSFontStyle.posBodyRegular) + .foregroundColor(.red) + .padding(.bottom, Constants.errorMessagePadding) + } + Button(action: { Task { @MainActor in - await posModel.cancelCashPayment() - isTextFieldFocused = false + await submitCashAmount() } }, label: { - navigationHeader + ZStack { + if isLoading { + ProgressView() + .progressViewStyle(CircularProgressViewStyle()) + .tint(Color.posPrimaryTextInverted) + } else { + Text(Localization.markPaymentCompletedButtonTitle) + .font(Constants.buttonFont) + } + } + .frame(maxWidth: .infinity, minHeight: Constants.buttonMinHeight) }) - .disabled(isLoading) - Spacer() - .renderedIf(!dynamicTypeSize.isAccessibilitySize) - } - - FormattableAmountTextField(viewModel: textFieldViewModel, style: .pos) - .focused($isTextFieldFocused) + .padding(conditionalPadding(Constants.buttonPadding)) + .frame(maxWidth: .infinity) + .foregroundColor(colorScheme == .light ? Color.white : Color.black) + .background(Color.posPrimaryButtonBackground) + .cornerRadius(Constants.buttonCornerRadius) + .contentShape(Rectangle()) .dynamicTypeSize(...DynamicTypeSize.accessibility1) - .onSubmit { - Task { @MainActor in - await submitCashAmount() - } - } - .onChange(of: textFieldViewModel.amount) { newValue in - textFieldAmountInput = newValue - updateChangeDueMessage() - } + .disabled(isLoading) - if let changeDue = changeDueMessage { - Text(changeDue) - .font(.posBodyRegular) - .foregroundColor(.posSecondaryText) + Spacer() } - - Spacer().frame(height: keyboardHeight) - - if let errorMessage = errorMessage { - Text(errorMessage) - .font(POSFontStyle.posBodyRegular) - .foregroundColor(.red) - .padding(.bottom, Constants.errorMessagePadding) + .background(backgroundColor) + .padding(.top, conditionalPadding(Constants.navigationHeaderTopPadding)) + .padding([.horizontal, .bottom]) + .animation(.easeInOut, value: errorMessage) + .animation(.easeInOut, value: changeDueMessage) + .onChange(of: textFieldAmountInput) { _ in + errorMessage = nil } - - Button(action: { - Task { @MainActor in - await submitCashAmount() - } - }, label: { - ZStack { - if isLoading { - ProgressView() - .progressViewStyle(CircularProgressViewStyle()) - .tint(Color.posPrimaryTextInverted) - } else { - Text(Localization.markPaymentCompletedButtonTitle) - .font(Constants.buttonFont) - } - } - .frame(maxWidth: .infinity, minHeight: Constants.buttonMinHeight) - }) - .padding(conditionalPadding(Constants.buttonPadding)) - .frame(maxWidth: .infinity) - .foregroundColor(colorScheme == .light ? Color.white : Color.black) - .background(Color.posPrimaryButtonBackground) - .cornerRadius(Constants.buttonCornerRadius) - .contentShape(Rectangle()) - .dynamicTypeSize(...DynamicTypeSize.accessibility1) - .disabled(isLoading) - - Spacer() - } - .background(backgroundColor) - .padding(.top, conditionalPadding(Constants.navigationHeaderTopPadding)) - .padding([.horizontal, .bottom]) - .animation(.easeInOut, value: errorMessage) - .animation(.easeInOut, value: changeDueMessage) - .animation(.easeInOut, value: keyboardObserver.keyboardHeight) - .onChange(of: textFieldAmountInput) { _ in - errorMessage = nil } } @@ -184,8 +174,6 @@ private extension PointOfSaleCollectCashView { static let buttonFont: POSFontStyle = .posBodyEmphasized static let buttonCornerRadius: CGFloat = 8 static let errorMessagePadding: CGFloat = 8 - static let keyboardShownButtonSpacing: CGFloat = 80 - static let keyboardHiddenButtonSpacing: CGFloat = 20 } private func conditionalPadding(_ padding: CGFloat) -> CGFloat { From bc427fb18c57a47fd39759c1ab1869b11808c5a6 Mon Sep 17 00:00:00 2001 From: iamgabrielma Date: Thu, 23 Jan 2025 14:42:30 +0100 Subject: [PATCH 10/13] remove keyboard observer from receipts view and adjust conditional padding --- .../Reusable Views/POSSendReceiptView.swift | 16 +-------- .../POS/ViewHelpers/KeyboardObserver.swift | 35 ------------------- .../WooCommerce.xcodeproj/project.pbxproj | 4 --- 3 files changed, 1 insertion(+), 54 deletions(-) delete mode 100644 WooCommerce/Classes/POS/ViewHelpers/KeyboardObserver.swift diff --git a/WooCommerce/Classes/POS/Presentation/Reusable Views/POSSendReceiptView.swift b/WooCommerce/Classes/POS/Presentation/Reusable Views/POSSendReceiptView.swift index e859660b1fc..7373169c114 100644 --- a/WooCommerce/Classes/POS/Presentation/Reusable Views/POSSendReceiptView.swift +++ b/WooCommerce/Classes/POS/Presentation/Reusable Views/POSSendReceiptView.swift @@ -7,7 +7,6 @@ struct POSSendReceiptView: View { @State private var textFieldInput: String = "" @State private var isLoading: Bool = false @State private var errorMessage: String? - @StateObject private var keyboardObserver = KeyboardObserver() @FocusState private var isTextFieldFocused: Bool @Binding private(set) var isShowingSendReceiptView: Bool @@ -16,14 +15,6 @@ struct POSSendReceiptView: View { EmailFormatValidator.validate(string: textFieldInput) } - private var keyboardHeight: CGFloat { - if keyboardObserver.keyboardHeight < Constants.keyboardShownButtonSpacing { - return Constants.keyboardShownButtonSpacing - } else { - return Constants.keyboardHiddenButtonSpacing - } - } - var body: some View { VStack(alignment: .center, spacing: conditionalPadding(8)) { HStack { @@ -68,8 +59,6 @@ struct POSSendReceiptView: View { .padding(.bottom, Constants.errorMessagePadding) } - Spacer().frame(height: keyboardHeight) - Button(action: { sendReceipt() }, label: { @@ -98,7 +87,6 @@ struct POSSendReceiptView: View { } .padding([.horizontal, .bottom]) .animation(.easeInOut, value: errorMessage) - .animation(.easeInOut, value: keyboardObserver.keyboardHeight) .onChange(of: textFieldInput) { _ in errorMessage = nil } @@ -133,15 +121,13 @@ private extension POSSendReceiptView { static let buttonFont: POSFontStyle = .posBodyEmphasized static let buttonCornerRadius: CGFloat = 8 static let errorMessagePadding: CGFloat = 8 - static let keyboardShownButtonSpacing: CGFloat = 80 - static let keyboardHiddenButtonSpacing: CGFloat = 20 } private func conditionalPadding(_ padding: CGFloat) -> CGFloat { if dynamicTypeSize.isAccessibilitySize { return 0 } else if dynamicTypeSize >= .xLarge { - return padding * 0.5 + return padding * 0.8 } else { return padding } diff --git a/WooCommerce/Classes/POS/ViewHelpers/KeyboardObserver.swift b/WooCommerce/Classes/POS/ViewHelpers/KeyboardObserver.swift deleted file mode 100644 index ce50840ab75..00000000000 --- a/WooCommerce/Classes/POS/ViewHelpers/KeyboardObserver.swift +++ /dev/null @@ -1,35 +0,0 @@ -import SwiftUI -import Combine - -final class KeyboardObserver: ObservableObject { - @Published var keyboardHeight: CGFloat = 0 - private var cancellables = Set() - - init() { - observeKeyboardNotifications() - } - - private func observeKeyboardNotifications() { - let keyboardWillChange = NotificationCenter.default.publisher(for: UIResponder.keyboardWillChangeFrameNotification) - let keyboardWillHide = NotificationCenter.default.publisher(for: UIResponder.keyboardWillHideNotification) - - keyboardWillChange - .merge(with: keyboardWillHide) - .sink { [weak self] notification in - self?.handleKeyboardNotification(notification) - } - .store(in: &cancellables) - } - - private func handleKeyboardNotification(_ notification: Notification) { - // UIResponder.keyboardFrameEndUserInfoKey contains where the keyboard will be after the animation completes, - // so we know the keyboard's end position in the screen - guard let userInfo = notification.userInfo, - let endFrame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { - return - } - - let screenHeight = UIScreen.main.bounds.height - keyboardHeight = (endFrame.origin.y >= screenHeight) ? 0 : endFrame.height - } -} diff --git a/WooCommerce/WooCommerce.xcodeproj/project.pbxproj b/WooCommerce/WooCommerce.xcodeproj/project.pbxproj index 5d9446092b9..22b46620bfc 100644 --- a/WooCommerce/WooCommerce.xcodeproj/project.pbxproj +++ b/WooCommerce/WooCommerce.xcodeproj/project.pbxproj @@ -1613,7 +1613,6 @@ 68E674AB2A4DAB8C0034BA1E /* CompletedUpgradeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E674AA2A4DAB8C0034BA1E /* CompletedUpgradeView.swift */; }; 68E674AD2A4DAC010034BA1E /* CurrentPlanDetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E674AC2A4DAC010034BA1E /* CurrentPlanDetailsView.swift */; }; 68E674AF2A4DACD50034BA1E /* UpgradeTopBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E674AE2A4DACD50034BA1E /* UpgradeTopBarView.swift */; }; - 68E759F52D3E8B7E009DBC68 /* KeyboardObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E759F42D3E8B72009DBC68 /* KeyboardObserver.swift */; }; 68E952CC287536010095A23D /* SafariView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E952CB287536010095A23D /* SafariView.swift */; }; 68E952D0287587BF0095A23D /* CardReaderManualRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E952CF287587BF0095A23D /* CardReaderManualRowView.swift */; }; 68E952D22875A44B0095A23D /* CardReaderType+Manual.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E952D12875A44B0095A23D /* CardReaderType+Manual.swift */; }; @@ -4730,7 +4729,6 @@ 68E674AA2A4DAB8C0034BA1E /* CompletedUpgradeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompletedUpgradeView.swift; sourceTree = ""; }; 68E674AC2A4DAC010034BA1E /* CurrentPlanDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrentPlanDetailsView.swift; sourceTree = ""; }; 68E674AE2A4DACD50034BA1E /* UpgradeTopBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpgradeTopBarView.swift; sourceTree = ""; }; - 68E759F42D3E8B72009DBC68 /* KeyboardObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyboardObserver.swift; sourceTree = ""; }; 68E952CB287536010095A23D /* SafariView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariView.swift; sourceTree = ""; }; 68E952CF287587BF0095A23D /* CardReaderManualRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardReaderManualRowView.swift; sourceTree = ""; }; 68E952D12875A44B0095A23D /* CardReaderType+Manual.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CardReaderType+Manual.swift"; sourceTree = ""; }; @@ -7005,7 +7003,6 @@ 6891C3632D364AFB00B5B48C /* CollectCashViewHelper.swift */, 6885E2CB2C32B14B004C8D70 /* TotalsViewHelper.swift */, 6837631B2C2E847D00AD51D0 /* CartViewHelper.swift */, - 68E759F42D3E8B72009DBC68 /* KeyboardObserver.swift */, ); path = ViewHelpers; sourceTree = ""; @@ -15682,7 +15679,6 @@ 02619858256B53DD00E321E9 /* AggregatedShippingLabelOrderItems.swift in Sources */, 260520F22B83B1B7005D5D59 /* ConnectivityToolViewModel.swift in Sources */, 20762BA72C18B55100758305 /* CardPresentPaymentsTransactionAlertsProvider.swift in Sources */, - 68E759F52D3E8B7E009DBC68 /* KeyboardObserver.swift in Sources */, 0235595024496853004BE2B8 /* BottomSheetListSelectorViewController.swift in Sources */, 57A49128250A7EB2000FEF21 /* OrderListViewController.swift in Sources */, 203163BD2C1C9602001C96DA /* PointOfSaleCardPresentPaymentAlertType.swift in Sources */, From 3c8757ccccf44231d5000ab2484b66dcfa62506b Mon Sep 17 00:00:00 2001 From: iamgabrielma Date: Thu, 23 Jan 2025 15:14:44 +0100 Subject: [PATCH 11/13] Use AdaptiveButtonPaddingModifier for button padding --- .../PointOfSaleCollectCashView.swift | 2 +- .../Utils/AdaptiveButtonPaddingModifier.swift | 33 +++++++++++++++++++ .../WooCommerce.xcodeproj/project.pbxproj | 4 +++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 WooCommerce/Classes/POS/Utils/AdaptiveButtonPaddingModifier.swift diff --git a/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift b/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift index 074eb248af2..0207801398f 100644 --- a/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift +++ b/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift @@ -84,7 +84,7 @@ struct PointOfSaleCollectCashView: View { } .frame(maxWidth: .infinity, minHeight: Constants.buttonMinHeight) }) - .padding(conditionalPadding(Constants.buttonPadding)) + .adaptiveButtonPadding(Constants.buttonPadding) .frame(maxWidth: .infinity) .foregroundColor(colorScheme == .light ? Color.white : Color.black) .background(Color.posPrimaryButtonBackground) diff --git a/WooCommerce/Classes/POS/Utils/AdaptiveButtonPaddingModifier.swift b/WooCommerce/Classes/POS/Utils/AdaptiveButtonPaddingModifier.swift new file mode 100644 index 00000000000..dfb10853f34 --- /dev/null +++ b/WooCommerce/Classes/POS/Utils/AdaptiveButtonPaddingModifier.swift @@ -0,0 +1,33 @@ +import SwiftUI + +struct AdaptiveButtonPaddingModifier: ViewModifier { + @Environment(\.dynamicTypeSize) private var dynamicTypeSize + let defaultButtonPadding: CGFloat + + func body(content: Content) -> some View { + content + .padding(adjustablePadding(for: dynamicTypeSize, + defaultButtonPadding: defaultButtonPadding)) + } + + private func adjustablePadding(for size: DynamicTypeSize, defaultButtonPadding: CGFloat) -> CGFloat { + switch size { + case .xxxLarge: return defaultButtonPadding * 0.7 + case .xxLarge: return defaultButtonPadding * 0.8 + case .xLarge: return defaultButtonPadding * 0.9 + case .accessibility1: return defaultButtonPadding * 0.6 + case .accessibility2: return defaultButtonPadding * 0.5 + case .accessibility3: return defaultButtonPadding * 0.4 + case .accessibility4: return defaultButtonPadding * 0.3 + case .accessibility5: return defaultButtonPadding * 0.2 + default: + return defaultButtonPadding + } + } +} + +extension View { + func adaptiveButtonPadding(_ defaultButtonPadding: CGFloat) -> some View { + modifier(AdaptiveButtonPaddingModifier(defaultButtonPadding: defaultButtonPadding)) + } +} diff --git a/WooCommerce/WooCommerce.xcodeproj/project.pbxproj b/WooCommerce/WooCommerce.xcodeproj/project.pbxproj index 22b46620bfc..93d9ee59122 100644 --- a/WooCommerce/WooCommerce.xcodeproj/project.pbxproj +++ b/WooCommerce/WooCommerce.xcodeproj/project.pbxproj @@ -1613,6 +1613,7 @@ 68E674AB2A4DAB8C0034BA1E /* CompletedUpgradeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E674AA2A4DAB8C0034BA1E /* CompletedUpgradeView.swift */; }; 68E674AD2A4DAC010034BA1E /* CurrentPlanDetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E674AC2A4DAC010034BA1E /* CurrentPlanDetailsView.swift */; }; 68E674AF2A4DACD50034BA1E /* UpgradeTopBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E674AE2A4DACD50034BA1E /* UpgradeTopBarView.swift */; }; + 68E8C04C2D4285C50094FCAC /* AdaptiveButtonPaddingModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E8C04B2D4285C30094FCAC /* AdaptiveButtonPaddingModifier.swift */; }; 68E952CC287536010095A23D /* SafariView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E952CB287536010095A23D /* SafariView.swift */; }; 68E952D0287587BF0095A23D /* CardReaderManualRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E952CF287587BF0095A23D /* CardReaderManualRowView.swift */; }; 68E952D22875A44B0095A23D /* CardReaderType+Manual.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E952D12875A44B0095A23D /* CardReaderType+Manual.swift */; }; @@ -4729,6 +4730,7 @@ 68E674AA2A4DAB8C0034BA1E /* CompletedUpgradeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompletedUpgradeView.swift; sourceTree = ""; }; 68E674AC2A4DAC010034BA1E /* CurrentPlanDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrentPlanDetailsView.swift; sourceTree = ""; }; 68E674AE2A4DACD50034BA1E /* UpgradeTopBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpgradeTopBarView.swift; sourceTree = ""; }; + 68E8C04B2D4285C30094FCAC /* AdaptiveButtonPaddingModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdaptiveButtonPaddingModifier.swift; sourceTree = ""; }; 68E952CB287536010095A23D /* SafariView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariView.swift; sourceTree = ""; }; 68E952CF287587BF0095A23D /* CardReaderManualRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardReaderManualRowView.swift; sourceTree = ""; }; 68E952D12875A44B0095A23D /* CardReaderType+Manual.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CardReaderType+Manual.swift"; sourceTree = ""; }; @@ -7010,6 +7012,7 @@ 026826972BF59D9E0036F959 /* Utils */ = { isa = PBXGroup; children = ( + 68E8C04B2D4285C30094FCAC /* AdaptiveButtonPaddingModifier.swift */, 026826982BF59DA80036F959 /* Color+WooCommercePOS.swift */, 68E4E8B42C0EF39D00CFA0C3 /* PreviewHelpers.swift */, DA4104392C247B6900E8456A /* PointOfSalePreviewOrderController.swift */, @@ -15453,6 +15456,7 @@ 01BB6C072D09DC560094D55B /* CardPresentModalLocationPreAlert.swift in Sources */, 74B5713621CD7604008F9B8E /* SharingHelper.swift in Sources */, 261F1A7929C2AB2E001D9861 /* FreeTrialBannerViewModel.swift in Sources */, + 68E8C04C2D4285C50094FCAC /* AdaptiveButtonPaddingModifier.swift in Sources */, DEF657A82C895B0500ACD61E /* BlazeCampaignObjectivePickerViewModel.swift in Sources */, 0313651328ABCB2D00EEE571 /* InPersonPaymentsOnboardingErrorMainContentView.swift in Sources */, B9F148962AD55326008FC795 /* FormattableAmountTextField.swift in Sources */, From f7cb29f1a44164ef9070a17f4a3e22d4b7a09f58 Mon Sep 17 00:00:00 2001 From: iamgabrielma Date: Thu, 23 Jan 2025 15:15:25 +0100 Subject: [PATCH 12/13] linting --- .../Classes/POS/Utils/AdaptiveButtonPaddingModifier.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WooCommerce/Classes/POS/Utils/AdaptiveButtonPaddingModifier.swift b/WooCommerce/Classes/POS/Utils/AdaptiveButtonPaddingModifier.swift index dfb10853f34..57ac85af2ba 100644 --- a/WooCommerce/Classes/POS/Utils/AdaptiveButtonPaddingModifier.swift +++ b/WooCommerce/Classes/POS/Utils/AdaptiveButtonPaddingModifier.swift @@ -3,13 +3,13 @@ import SwiftUI struct AdaptiveButtonPaddingModifier: ViewModifier { @Environment(\.dynamicTypeSize) private var dynamicTypeSize let defaultButtonPadding: CGFloat - + func body(content: Content) -> some View { content .padding(adjustablePadding(for: dynamicTypeSize, defaultButtonPadding: defaultButtonPadding)) } - + private func adjustablePadding(for size: DynamicTypeSize, defaultButtonPadding: CGFloat) -> CGFloat { switch size { case .xxxLarge: return defaultButtonPadding * 0.7 From 0cddff1d6bdc2d045c957efd2cca25b7c279638e Mon Sep 17 00:00:00 2001 From: iamgabrielma Date: Fri, 24 Jan 2025 07:01:43 +0100 Subject: [PATCH 13/13] styling --- .../Utils/AdaptiveButtonPaddingModifier.swift | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/WooCommerce/Classes/POS/Utils/AdaptiveButtonPaddingModifier.swift b/WooCommerce/Classes/POS/Utils/AdaptiveButtonPaddingModifier.swift index 57ac85af2ba..1e9325abc9d 100644 --- a/WooCommerce/Classes/POS/Utils/AdaptiveButtonPaddingModifier.swift +++ b/WooCommerce/Classes/POS/Utils/AdaptiveButtonPaddingModifier.swift @@ -12,14 +12,22 @@ struct AdaptiveButtonPaddingModifier: ViewModifier { private func adjustablePadding(for size: DynamicTypeSize, defaultButtonPadding: CGFloat) -> CGFloat { switch size { - case .xxxLarge: return defaultButtonPadding * 0.7 - case .xxLarge: return defaultButtonPadding * 0.8 - case .xLarge: return defaultButtonPadding * 0.9 - case .accessibility1: return defaultButtonPadding * 0.6 - case .accessibility2: return defaultButtonPadding * 0.5 - case .accessibility3: return defaultButtonPadding * 0.4 - case .accessibility4: return defaultButtonPadding * 0.3 - case .accessibility5: return defaultButtonPadding * 0.2 + case .xxxLarge: + return defaultButtonPadding * 0.7 + case .xxLarge: + return defaultButtonPadding * 0.8 + case .xLarge: + return defaultButtonPadding * 0.9 + case .accessibility1: + return defaultButtonPadding * 0.6 + case .accessibility2: + return defaultButtonPadding * 0.5 + case .accessibility3: + return defaultButtonPadding * 0.4 + case .accessibility4: + return defaultButtonPadding * 0.3 + case .accessibility5: + return defaultButtonPadding * 0.2 default: return defaultButtonPadding }