From 4af2754ea44a5112c1e794ac2e73613a1bcbfda6 Mon Sep 17 00:00:00 2001 From: Huong Do Date: Mon, 24 Mar 2025 14:50:25 +0700 Subject: [PATCH 1/3] Show category detail if there exists one --- .../WooShippingHazmatDetailView.swift | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Hazmat Section/WooShippingHazmatDetailView.swift b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Hazmat Section/WooShippingHazmatDetailView.swift index 0ba1db3465b..7b82fdc14c0 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Hazmat Section/WooShippingHazmatDetailView.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Hazmat Section/WooShippingHazmatDetailView.swift @@ -35,11 +35,38 @@ struct WooShippingHazmatDetailView: View { } .tint(Color.accentColor) - Button(Localization.selectCategory) { - isShowingCategoryList = true + if isHazardous { + if let selectedCategory { + HStack { + Text(Localization.category) + .headlineStyle() + Spacer() + Button { + isShowingCategoryList = true + } label: { + Image(systemName: "pencil") + } + .buttonStyle(.plain) + .font(.body) + .foregroundStyle(Color.accentColor) + } + + Text(selectedCategory.localizedName) + .font(.body) + .frame(maxWidth: .infinity, alignment: .leading) + .multilineTextAlignment(.leading) + .padding(Constants.verticalSpacing) + .background( + Color(.quaternarySystemFill) + .clipShape(RoundedRectangle(cornerSize: Constants.cornerSize)) + ) + } else { + Button(Localization.selectCategory) { + isShowingCategoryList = true + } + .buttonStyle(PrimaryButtonStyle()) + } } - .buttonStyle(PrimaryButtonStyle()) - .renderedIf(isHazardous) Divider() @@ -128,6 +155,7 @@ private extension WooShippingHazmatDetailView { private extension WooShippingHazmatDetailView { enum Constants { static let verticalSpacing: CGFloat = 16 + static let cornerSize = CGSize(width: 8, height: 8) static let hazmatURL = "https://www.usps.com/hazmat" static let searchToolURL = "https://pe.usps.com/hazmat/index" static let DHLExpressName = "DHL Express" @@ -154,6 +182,11 @@ private extension WooShippingHazmatDetailView { value: "Select Category", comment: "Button to select hazardous material category on the HAZMAT detail view in the shipping label creation flow" ) + static let category = NSLocalizedString( + "wooShippingHazmatDetailView.category", + value: "Category", + comment: "Label for the existing category on the HAZMAT detail view in the shipping label creation flow" + ) static let detailLine1 = NSLocalizedString( "wooShippingHazmatDetailView.detailLine1", value: "Potentially hazardous material includes items such as batteries, dry ice, " + From 18591fdb0013a02deb64f9919871be8043f2f37c Mon Sep 17 00:00:00 2001 From: Huong Do Date: Mon, 24 Mar 2025 14:53:04 +0700 Subject: [PATCH 2/3] Clear select category upon disable hazmat --- .../WooShippingHazmatDetailView.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Hazmat Section/WooShippingHazmatDetailView.swift b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Hazmat Section/WooShippingHazmatDetailView.swift index 7b82fdc14c0..49719929cf1 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Hazmat Section/WooShippingHazmatDetailView.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Hazmat Section/WooShippingHazmatDetailView.swift @@ -101,6 +101,11 @@ struct WooShippingHazmatDetailView: View { dismiss() }) } + .onChange(of: isHazardous) { newValue in + if newValue == false { + selectedCategory = nil + } + } } } } From f1ddaf0e9d9b5574409eff75814c62ae1c95aaba Mon Sep 17 00:00:00 2001 From: Huong Do Date: Mon, 24 Mar 2025 15:05:25 +0700 Subject: [PATCH 3/3] Add save button for confirm disabling hazmat --- .../WooShippingHazmatDetailView.swift | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Hazmat Section/WooShippingHazmatDetailView.swift b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Hazmat Section/WooShippingHazmatDetailView.swift index 49719929cf1..c9235aa8ea2 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Hazmat Section/WooShippingHazmatDetailView.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Hazmat Section/WooShippingHazmatDetailView.swift @@ -94,6 +94,18 @@ struct WooShippingHazmatDetailView: View { } .toolbarBackground(Color.clear, for: .navigationBar) } + .safeAreaInset(edge: .bottom) { + VStack { + Button(Localization.save) { + selectionHandler(nil) + dismiss() + } + .buttonStyle(PrimaryButtonStyle()) + .padding(Constants.verticalSpacing) + } + .background(Color(.systemBackground)) + .renderedIf(selectedCategory != nil && isHazardous == false) + } .sheet(isPresented: $isShowingCategoryList) { WooShippingHazmatCategoryList(selectedItem: selectedCategory, selectionHandler: { category in @@ -101,11 +113,6 @@ struct WooShippingHazmatDetailView: View { dismiss() }) } - .onChange(of: isHazardous) { newValue in - if newValue == false { - selectedCategory = nil - } - } } } } @@ -192,6 +199,11 @@ private extension WooShippingHazmatDetailView { value: "Category", comment: "Label for the existing category on the HAZMAT detail view in the shipping label creation flow" ) + static let save = NSLocalizedString( + "wooShippingHazmatDetailView.save", + value: "Save", + comment: "Button to confirm selection on the HAZMAT detail view in the shipping label creation flow" + ) static let detailLine1 = NSLocalizedString( "wooShippingHazmatDetailView.detailLine1", value: "Potentially hazardous material includes items such as batteries, dry ice, " +