Skip to content

Commit 0451803

Browse files
authored
Shipping Label: Edit and remove HAZMAT category (#15405)
2 parents 3ee7fe0 + f1ddaf0 commit 0451803

File tree

1 file changed

+54
-4
lines changed

1 file changed

+54
-4
lines changed

WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Hazmat Section/WooShippingHazmatDetailView.swift

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,38 @@ struct WooShippingHazmatDetailView: View {
3535
}
3636
.tint(Color.accentColor)
3737

38-
Button(Localization.selectCategory) {
39-
isShowingCategoryList = true
38+
if isHazardous {
39+
if let selectedCategory {
40+
HStack {
41+
Text(Localization.category)
42+
.headlineStyle()
43+
Spacer()
44+
Button {
45+
isShowingCategoryList = true
46+
} label: {
47+
Image(systemName: "pencil")
48+
}
49+
.buttonStyle(.plain)
50+
.font(.body)
51+
.foregroundStyle(Color.accentColor)
52+
}
53+
54+
Text(selectedCategory.localizedName)
55+
.font(.body)
56+
.frame(maxWidth: .infinity, alignment: .leading)
57+
.multilineTextAlignment(.leading)
58+
.padding(Constants.verticalSpacing)
59+
.background(
60+
Color(.quaternarySystemFill)
61+
.clipShape(RoundedRectangle(cornerSize: Constants.cornerSize))
62+
)
63+
} else {
64+
Button(Localization.selectCategory) {
65+
isShowingCategoryList = true
66+
}
67+
.buttonStyle(PrimaryButtonStyle())
68+
}
4069
}
41-
.buttonStyle(PrimaryButtonStyle())
42-
.renderedIf(isHazardous)
4370

4471
Divider()
4572

@@ -67,6 +94,18 @@ struct WooShippingHazmatDetailView: View {
6794
}
6895
.toolbarBackground(Color.clear, for: .navigationBar)
6996
}
97+
.safeAreaInset(edge: .bottom) {
98+
VStack {
99+
Button(Localization.save) {
100+
selectionHandler(nil)
101+
dismiss()
102+
}
103+
.buttonStyle(PrimaryButtonStyle())
104+
.padding(Constants.verticalSpacing)
105+
}
106+
.background(Color(.systemBackground))
107+
.renderedIf(selectedCategory != nil && isHazardous == false)
108+
}
70109
.sheet(isPresented: $isShowingCategoryList) {
71110
WooShippingHazmatCategoryList(selectedItem: selectedCategory,
72111
selectionHandler: { category in
@@ -128,6 +167,7 @@ private extension WooShippingHazmatDetailView {
128167
private extension WooShippingHazmatDetailView {
129168
enum Constants {
130169
static let verticalSpacing: CGFloat = 16
170+
static let cornerSize = CGSize(width: 8, height: 8)
131171
static let hazmatURL = "https://www.usps.com/hazmat"
132172
static let searchToolURL = "https://pe.usps.com/hazmat/index"
133173
static let DHLExpressName = "DHL Express"
@@ -154,6 +194,16 @@ private extension WooShippingHazmatDetailView {
154194
value: "Select Category",
155195
comment: "Button to select hazardous material category on the HAZMAT detail view in the shipping label creation flow"
156196
)
197+
static let category = NSLocalizedString(
198+
"wooShippingHazmatDetailView.category",
199+
value: "Category",
200+
comment: "Label for the existing category on the HAZMAT detail view in the shipping label creation flow"
201+
)
202+
static let save = NSLocalizedString(
203+
"wooShippingHazmatDetailView.save",
204+
value: "Save",
205+
comment: "Button to confirm selection on the HAZMAT detail view in the shipping label creation flow"
206+
)
157207
static let detailLine1 = NSLocalizedString(
158208
"wooShippingHazmatDetailView.detailLine1",
159209
value: "Potentially hazardous material includes items such as batteries, dry ice, " +

0 commit comments

Comments
 (0)