Skip to content

Commit b896d25

Browse files
authored
Merge branch 'trunk' into issue/14869-hide-cancellation-errors-from-the-user
2 parents fd7ede1 + 1b1372a commit b896d25

File tree

1 file changed

+92
-72
lines changed

1 file changed

+92
-72
lines changed

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

Lines changed: 92 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -74,44 +74,10 @@ struct WooShippingCreateLabelsView: View {
7474
isShipmentDetailsExpanded = isExpanded
7575
}) {
7676
VStack {
77-
if !isShipmentDetailsExpanded {
78-
VStack {
79-
Text(Localization.BottomSheet.shipmentDetails)
80-
.foregroundStyle(Color(.primary))
81-
.bold()
82-
if viewModel.showAddressVerificationNotice {
83-
addressVerificationNotice
84-
.onTapGesture {
85-
// TODO: Start address editing/verification flow if needed (if destination address is unverified).
86-
}
87-
}
88-
}
89-
}
90-
if !viewModel.canViewLabel {
91-
if isiPhonePortrait {
92-
VStack(spacing: Layout.bottomSheetSpacing) {
93-
if isShipmentDetailsExpanded {
94-
Toggle(Localization.BottomSheet.markComplete, isOn: $viewModel.markOrderComplete)
95-
.font(.subheadline)
96-
.tint(Color(.primary))
97-
}
98-
if isShipmentDetailsExpanded || viewModel.selectedPackage != nil {
99-
purchaseButton
100-
}
101-
}
102-
}
103-
else {
104-
HStack(spacing: Layout.bottomSheetSpacing) {
105-
if viewModel.selectedPackage != nil || isShipmentDetailsExpanded {
106-
Toggle(Localization.BottomSheet.markComplete, isOn: $viewModel.markOrderComplete)
107-
.font(.subheadline)
108-
.tint(Color(.primary))
109-
.fixedSize(horizontal: false, vertical: true)
110-
purchaseButton
111-
}
112-
}
113-
}
114-
}
77+
collapsedBottomSheet
78+
.renderedIf(!isShipmentDetailsExpanded)
79+
bottomSheetPurchaseActions
80+
.renderedIf(!viewModel.canViewLabel)
11581
}
11682
.padding(.horizontal, Layout.bottomSheetPadding)
11783
} expandableContent: {
@@ -121,41 +87,9 @@ struct WooShippingCreateLabelsView: View {
12187
.footnoteStyle()
12288
}
12389
CollapsibleHStack(horizontalAlignment: .leading, verticalAlignment: .top, spacing: .zero) {
124-
HStack(alignment: .firstTextBaseline, spacing: Layout.bottomSheetSpacing) {
125-
Text(Localization.BottomSheet.shipFrom)
126-
.trackSize(size: $shipmentDetailsShipFromSize)
127-
Button {
128-
isOriginAddressListPresented = true
129-
} label: {
130-
HStack {
131-
Text(viewModel.originAddress)
132-
.lineLimit(1)
133-
.truncationMode(.tail)
134-
.frame(maxWidth: .infinity, alignment: .leading)
135-
Image(systemName: "ellipsis")
136-
.frame(width: Layout.ellipsisWidth)
137-
.bold()
138-
}
139-
}
140-
.buttonStyle(TextButtonStyle())
141-
}
142-
.padding(Layout.bottomSheetPadding)
90+
shipFromAddress
14391
Divider()
144-
HStack(alignment: .firstTextBaseline, spacing: Layout.bottomSheetSpacing) {
145-
Text(Localization.BottomSheet.shipTo)
146-
.frame(width: shipmentDetailsShipFromSize.width, alignment: .leading)
147-
VStack(alignment: .leading) {
148-
ForEach(viewModel.destinationAddressLines, id: \.self) { addressLine in
149-
Text(addressLine)
150-
.if(addressLine == viewModel.destinationAddressLines.first) { line in
151-
line.bold()
152-
}
153-
}
154-
addressVerificationLabel
155-
}
156-
.frame(maxWidth: .infinity, alignment: .leading)
157-
}
158-
.padding(Layout.bottomSheetPadding)
92+
shipToAddress
15993
}
16094
.font(.subheadline)
16195
.roundedBorder(cornerRadius: Layout.cornerRadius, lineColor: Color(.separator), lineWidth: 0.5)
@@ -203,6 +137,92 @@ struct WooShippingCreateLabelsView: View {
203137
}
204138

205139
private extension WooShippingCreateLabelsView {
140+
/// View for elements only displayed on the collapsed bottom sheet.
141+
var collapsedBottomSheet: some View {
142+
VStack {
143+
Text(Localization.BottomSheet.shipmentDetails)
144+
.foregroundStyle(Color(.primary))
145+
.bold()
146+
if viewModel.showAddressVerificationNotice {
147+
addressVerificationNotice
148+
.onTapGesture {
149+
// TODO: Start address editing/verification flow if needed (if destination address is unverified).
150+
}
151+
}
152+
}
153+
}
154+
155+
/// View for the purchase-related actions, such as "Mark as completed" toggle and purchase button.
156+
var bottomSheetPurchaseActions: some View {
157+
Group {
158+
if isiPhonePortrait {
159+
VStack(spacing: Layout.bottomSheetSpacing) {
160+
if isShipmentDetailsExpanded {
161+
Toggle(Localization.BottomSheet.markComplete, isOn: $viewModel.markOrderComplete)
162+
.font(.subheadline)
163+
.tint(Color(.primary))
164+
}
165+
if isShipmentDetailsExpanded || viewModel.selectedPackage != nil {
166+
purchaseButton
167+
}
168+
}
169+
}
170+
else {
171+
HStack(spacing: Layout.bottomSheetSpacing) {
172+
if viewModel.selectedPackage != nil || isShipmentDetailsExpanded {
173+
Toggle(Localization.BottomSheet.markComplete, isOn: $viewModel.markOrderComplete)
174+
.font(.subheadline)
175+
.tint(Color(.primary))
176+
.fixedSize(horizontal: false, vertical: true)
177+
purchaseButton
178+
}
179+
}
180+
}
181+
}
182+
}
183+
184+
/// View showing the origin ("Ship From") address.
185+
var shipFromAddress: some View {
186+
HStack(alignment: .firstTextBaseline, spacing: Layout.bottomSheetSpacing) {
187+
Text(Localization.BottomSheet.shipFrom)
188+
.trackSize(size: $shipmentDetailsShipFromSize)
189+
Button {
190+
isOriginAddressListPresented = true
191+
} label: {
192+
HStack {
193+
Text(viewModel.originAddress)
194+
.lineLimit(1)
195+
.truncationMode(.tail)
196+
.frame(maxWidth: .infinity, alignment: .leading)
197+
Image(systemName: "ellipsis")
198+
.frame(width: Layout.ellipsisWidth)
199+
.bold()
200+
}
201+
}
202+
.buttonStyle(TextButtonStyle())
203+
}
204+
.padding(Layout.bottomSheetPadding)
205+
}
206+
207+
/// View showing the destination ("Ship To") address.
208+
var shipToAddress: some View {
209+
HStack(alignment: .firstTextBaseline, spacing: Layout.bottomSheetSpacing) {
210+
Text(Localization.BottomSheet.shipTo)
211+
.frame(width: shipmentDetailsShipFromSize.width, alignment: .leading)
212+
VStack(alignment: .leading) {
213+
ForEach(viewModel.destinationAddressLines, id: \.self) { addressLine in
214+
Text(addressLine)
215+
.if(addressLine == viewModel.destinationAddressLines.first) { line in
216+
line.bold()
217+
}
218+
}
219+
addressVerificationLabel
220+
}
221+
.frame(maxWidth: .infinity, alignment: .leading)
222+
}
223+
.padding(Layout.bottomSheetPadding)
224+
}
225+
206226
/// View showing the order details, such as order items and shipping costs.
207227
var orderDetails: some View {
208228
VStack(alignment: .leading, spacing: Layout.verticalSpacing) {

0 commit comments

Comments
 (0)