Skip to content

Commit 28502c8

Browse files
Improve dynamic size of shipment details bottom sheet (#15648)
2 parents 0429875 + fe75fb8 commit 28502c8

File tree

2 files changed

+31
-13
lines changed

2 files changed

+31
-13
lines changed

WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShippingCreateLabelsView.swift

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,13 @@ private extension WooShippingCreateLabelsView {
305305
if isiPhonePortrait {
306306
VStack(spacing: Layout.bottomSheetSpacing) {
307307
if isShipmentDetailsExpanded {
308-
Toggle(Localization.BottomSheet.markComplete, isOn: $viewModel.markOrderComplete)
309-
.font(.subheadline)
310-
.tint(Color(.primary))
308+
Toggle(isOn: $viewModel.markOrderComplete) {
309+
Text(Localization.BottomSheet.markComplete)
310+
.font(.subheadline)
311+
.lineLimit(Layout.toggleTextLineLimit)
312+
.dynamicTypeSize(...Layout.toggleTextMaxDynamicTypeSizePortrait)
313+
}
314+
.tint(Color(.primary))
311315
}
312316
if isShipmentDetailsExpanded || viewModel.currentShipmentDetailsViewModel.selectedPackage != nil {
313317
purchaseButton
@@ -317,10 +321,14 @@ private extension WooShippingCreateLabelsView {
317321
else {
318322
HStack(spacing: Layout.bottomSheetSpacing) {
319323
if viewModel.currentShipmentDetailsViewModel.selectedPackage != nil || isShipmentDetailsExpanded {
320-
Toggle(Localization.BottomSheet.markComplete, isOn: $viewModel.markOrderComplete)
321-
.font(.subheadline)
322-
.tint(Color(.primary))
323-
.fixedSize(horizontal: false, vertical: true)
324+
Toggle(isOn: $viewModel.markOrderComplete) {
325+
Text(Localization.BottomSheet.markComplete)
326+
.font(.subheadline)
327+
.lineLimit(Layout.toggleTextLineLimit)
328+
.dynamicTypeSize(...Layout.toggleTextMaxDynamicTypeSizeLandscape)
329+
}
330+
.tint(Color(.primary))
331+
.fixedSize(horizontal: false, vertical: true)
324332
purchaseButton
325333
}
326334
}
@@ -400,17 +408,16 @@ private extension WooShippingCreateLabelsView {
400408
Text(Localization.BottomSheet.orderDetails)
401409
.footnoteStyle()
402410
}
403-
AdaptiveStack {
411+
HStack {
404412
Image(uiImage: .productIcon)
405413
.frame(width: Layout.iconSize)
406414
Text(viewModel.orderItems.itemsCountLabel)
407415
.bold()
408416
Spacer()
409417
Text(viewModel.orderItems.itemsPriceLabel)
410418
}
411-
.frame(idealHeight: Layout.rowHeight)
412419
ForEach(viewModel.shippingLines) { shippingLine in
413-
AdaptiveStack {
420+
HStack {
414421
Image(uiImage: .shippingIcon)
415422
.frame(width: Layout.iconSize)
416423
Text(shippingLine.title)
@@ -419,7 +426,6 @@ private extension WooShippingCreateLabelsView {
419426
Spacer()
420427
Text(shippingLine.formattedTotal)
421428
}
422-
.frame(idealHeight: Layout.rowHeight)
423429
}
424430
}
425431
}
@@ -491,12 +497,11 @@ private extension WooShippingCreateLabelsView {
491497
shippingRateRow(label: Localization.BottomSheet.total, amount: viewModel.totalCost)
492498
.bold()
493499
}
494-
.frame(idealHeight: Layout.rowHeight)
495500
}
496501
}
497502

498503
func shippingRateRow(label: String, amount: String?) -> some View {
499-
AdaptiveStack {
504+
HStack {
500505
Text(label)
501506
Spacer()
502507
Text(amount ?? "$0.00")
@@ -611,6 +616,10 @@ private extension WooShippingCreateLabelsView {
611616
static let gradientViewWidth: CGFloat = 32
612617
static let purchasedIconWidth: CGFloat = 16
613618
static let purchasedIcon = UIImage(systemName: "checkmark.circle.fill")?.withRenderingMode(.alwaysTemplate)
619+
620+
static let toggleTextLineLimit = 3
621+
static let toggleTextMaxDynamicTypeSizePortrait = DynamicTypeSize.accessibility1
622+
static let toggleTextMaxDynamicTypeSizeLandscape = DynamicTypeSize.xxxLarge
614623
}
615624

616625
enum Localization {

WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/TopTabView.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ struct TopTabView<Content: View>: View {
164164
scrollFocusTab(in: scrollViewProxy, at: index)
165165
}
166166
}
167+
.onChange(of: geometry.size) { newSize in
168+
/// Support dynamic type size change
169+
if index < tabWidths.count {
170+
tabWidths[index] = newSize.width
171+
if index == selectedTab {
172+
underlineTabWith(tabGeometry: geometry)
173+
}
174+
}
175+
}
167176
})
168177
}
169178
}

0 commit comments

Comments
 (0)