Skip to content

Commit 800dfb6

Browse files
committed
Adjust TotalsView to fit content
1 parent c8e80f3 commit 800dfb6

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

WooCommerce/Classes/POS/Presentation/TotalsView.swift

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,19 @@ struct TotalsView: View {
4242
.padding(.top, dynamicTypeSize.isAccessibilitySize ? nil : cardReaderViewLayout.topPadding)
4343
.transition(.opacity)
4444
.accessibilityShowsLargeContentViewer()
45-
.layoutPriority(1)
4645
.background(backgroundColor)
46+
.dynamicTypeSize(...DynamicTypeSize.accessibility2)
47+
.minimumScaleFactor(isShowingTotalsFields ? 0.5 : 1)
48+
.geometryGroup()
4749
}
4850

4951
if isShowingTotalsFields {
5052
totalsFieldsView
5153
.transition(.opacity)
5254
.animation(.default, value: posModel.orderState.isSyncing)
5355
.opacity(viewHelper.shouldShowTotalsFields(for: posModel.paymentState) ? 1 : 0)
54-
.layoutPriority(2)
56+
.layoutPriority(1)
57+
.dynamicTypeSize(...DynamicTypeSize.accessibility2)
5558
}
5659
}
5760
.animation(.default, value: posModel.cardPresentPaymentInlineMessage)
@@ -65,11 +68,12 @@ struct TotalsView: View {
6568
}, label: {
6669
Text(Localization.cashPaymentButtonTitle)
6770
.font(POSFontStyle.posBodyLargeBold)
68-
.minimumScaleFactor(0.5)
6971
})
72+
.layoutPriority(1)
73+
.dynamicTypeSize(...DynamicTypeSize.accessibility2)
7074
.buttonStyle(POSOutlinedButtonStyle(size: .normal))
7175
.padding(.horizontal, Constants.buttonHorizontalPadding)
72-
.padding(.bottom, Constants.cashButtonBottomPadding)
76+
.safeAreaPadding(.bottom, Constants.cashButtonBottomPadding)
7377
.renderedIf(viewHelper.shouldShowCollectCashPaymentButton(orderState: posModel.orderState,
7478
paymentState: posModel.paymentState))
7579
}
@@ -86,7 +90,7 @@ struct TotalsView: View {
8690
isShowingTotalsFields = shouldShowTotalsFields
8791
}
8892
.onChange(of: shouldShowTotalsFields, perform: hideTotalsFieldsWithDelay)
89-
.geometryGroupIfSupported()
93+
.geometryGroup()
9094
}
9195

9296
private var backgroundColor: Color {
@@ -344,7 +348,7 @@ private extension TotalsView {
344348
static let pricesIdealWidth: CGFloat = 382
345349
static let verticalSpacing: CGFloat = 56
346350
static let buttonHorizontalPadding: CGFloat = 48
347-
static let cashButtonBottomPadding: CGFloat = 16
351+
static let cashButtonBottomPadding: CGFloat = 24
348352

349353
static let totalsLineViewPadding: EdgeInsets = .init(top: 20, leading: 24, bottom: 20, trailing: 24)
350354
static let subtotalsVerticalSpacing: CGFloat = 8
@@ -407,20 +411,6 @@ private extension TotalsView {
407411
}
408412
}
409413

410-
private extension View {
411-
/// Force the position and size values to be resolved and animated by the parent
412-
/// before being passed down to each subview.
413-
/// GeometryGroup is created to ensure that childs views stay locked together as animations are applied.
414-
/// It results in the whole TotalsView animated together when transitioning.
415-
func geometryGroupIfSupported() -> some View {
416-
if #available(iOS 17.0, *) {
417-
return self.geometryGroup()
418-
} else {
419-
return self
420-
}
421-
}
422-
}
423-
424414
#if DEBUG
425415
@available(iOS 17.0, *)
426416
#Preview {

0 commit comments

Comments
 (0)