Skip to content

Commit 00d8074

Browse files
committed
Update ShippingLabelPackagesForm view with items
1 parent 83d71fe commit 00d8074

File tree

1 file changed

+53
-2
lines changed
  • WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/Create Shipping Label Form/Package Details/Multi-package

1 file changed

+53
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,64 @@
11
import SwiftUI
22

33
struct ShippingLabelPackagesForm: View {
4+
@ObservedObject private var viewModel: ShippingLabelPackagesFormViewModel
5+
@Environment(\.presentationMode) var presentation
6+
7+
init(viewModel: ShippingLabelPackagesFormViewModel) {
8+
self.viewModel = viewModel
9+
ServiceLocator.analytics.track(.shippingLabelPurchaseFlow, withProperties: ["state": "packages_started"])
10+
}
11+
412
var body: some View {
5-
Text("Hello, World!")
13+
GeometryReader { geometry in
14+
ScrollView {
15+
ForEach(Array(viewModel.itemViewModels.enumerated()), id: \.offset) { index, element in
16+
ShippingLabelPackageItem(packageNumber: index + 1,
17+
isCollapsible: viewModel.foundMultiplePackages,
18+
safeAreaInsets: geometry.safeAreaInsets,
19+
viewModel: element)
20+
}
21+
.padding(.bottom, insets: geometry.safeAreaInsets)
22+
}
23+
.background(Color(.listBackground))
24+
.ignoresSafeArea(.container, edges: [.horizontal, .bottom])
25+
}
26+
.navigationTitle(Localization.title)
27+
.navigationBarItems(trailing: Button(action: {
28+
ServiceLocator.analytics.track(.shippingLabelPurchaseFlow,
29+
withProperties: ["state": "packages_selected"])
30+
// TODO-4599: Update selection
31+
presentation.wrappedValue.dismiss()
32+
}, label: {
33+
Text(Localization.doneButton)
34+
}))
35+
}
36+
}
37+
38+
private extension ShippingLabelPackagesForm {
39+
enum Localization {
40+
static let title = NSLocalizedString("Package Details",
41+
comment: "Navigation bar title of shipping label package details screen")
42+
static let doneButton = NSLocalizedString("Done", comment: "Done navigation button in the Package Details screen in Shipping Label flow")
43+
}
44+
45+
enum Constants {
46+
static let dividerPadding: CGFloat = 16
647
}
748
}
849

950
struct ShippingLabelPackagesForm_Previews: PreviewProvider {
1051
static var previews: some View {
11-
ShippingLabelPackagesForm()
52+
let viewModel = ShippingLabelPackagesFormViewModel(order: ShippingLabelPackagesFormViewModel.sampleOrder(),
53+
packagesResponse: ShippingLabelPackagesFormViewModel.samplePackageDetails(),
54+
selectedPackages: [])
55+
56+
ShippingLabelPackagesForm(viewModel: viewModel)
57+
.environment(\.colorScheme, .light)
58+
.previewDisplayName("Light")
59+
60+
ShippingLabelPackagesForm(viewModel: viewModel)
61+
.environment(\.colorScheme, .dark)
62+
.previewDisplayName("Dark")
1263
}
1364
}

0 commit comments

Comments
 (0)