-
Notifications
You must be signed in to change notification settings - Fork 121
[Shipping Labels] Split shipment navigation #15369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8e844a7
View for split shipment row.
selanthiraiyan 84b406f
View model for split shipments.
selanthiraiyan 59885bf
Detail view for split shipments.
selanthiraiyan 8ddb741
Show shipments row in create labels view.
selanthiraiyan afd5a2d
Merge branch 'trunk' into task/15304-split-shipment-navigation
selanthiraiyan 304725a
Update alignment.
selanthiraiyan da2e8b2
Cover full screen to match design.
selanthiraiyan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
...ate Shipping Labels/WooShipping Split Shipments/WooShippingSplitShipmentsDetailView.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import SwiftUI | ||
|
|
||
| struct WooShippingSplitShipmentsDetailView: View { | ||
| @Environment(\.dismiss) private var dismiss | ||
|
|
||
| let viewModel: WooShippingSplitShipmentsViewModel | ||
|
|
||
| var body: some View { | ||
| NavigationView { | ||
| ScrollView { | ||
| VStack(alignment: .leading, spacing: Layout.contentPadding) { | ||
| AdaptiveStack(horizontalAlignment: .leading) { | ||
| Text(viewModel.itemsCountLabel) | ||
| .headlineStyle() | ||
| Spacer() | ||
| Text(viewModel.itemsDetailLabel) | ||
| .foregroundStyle(Color(.textSubtle)) | ||
| } | ||
|
|
||
| VStack { | ||
| ForEach(viewModel.items) { item in | ||
| WooShippingItemRow(viewModel: item) | ||
| .padding() | ||
| .roundedBorder(cornerRadius: Layout.borderCornerRadius, lineColor: Color(.separator), lineWidth: Layout.borderWidth) | ||
| } | ||
| } | ||
| } | ||
| .padding(Layout.contentPadding) | ||
| } | ||
| .navigationBarTitleDisplayMode(.inline) | ||
| .navigationTitle(Localization.title) | ||
| .toolbar { | ||
| ToolbarItem(placement: .cancellationAction) { | ||
| Button(Localization.selectAll) { | ||
|
|
||
| } | ||
| } | ||
| ToolbarItem(placement: .confirmationAction) { | ||
| Button(Localization.done) { | ||
| dismiss() | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private extension WooShippingSplitShipmentsDetailView { | ||
| enum Layout { | ||
| static let contentPadding: CGFloat = 16 | ||
| static let borderCornerRadius: CGFloat = 8 | ||
| static let borderWidth: CGFloat = 0.5 | ||
| } | ||
| enum Localization { | ||
| static let title = NSLocalizedString( | ||
| "wooShippingSplitShipmentsDetailView.title", | ||
| value: "Split Shipments", | ||
| comment: "Title of the split shipments detail view in the shipping label creation flow" | ||
| ) | ||
| static let selectAll = NSLocalizedString( | ||
| "wooShippingSplitShipmentsDetailView.selectAll", | ||
| value: "Select All", | ||
| comment: "Button to select all items in the shipment detail in the shipping label creation flow" | ||
| ) | ||
| static let done = NSLocalizedString( | ||
| "wooShippingSplitShipmentsDetailView.done", | ||
| value: "Done", | ||
| comment: "Button to save split shipment configurations in the shipping label creation flow" | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| #Preview { | ||
| WooShippingSplitShipmentsDetailView(viewModel: WooShippingSplitShipmentsViewModel(siteID: 123, | ||
| orderID: 123)) | ||
| } |
49 changes: 49 additions & 0 deletions
49
...ing Create Shipping Labels/WooShipping Split Shipments/WooShippingSplitShipmentsRow.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import SwiftUI | ||
|
|
||
| struct WooShippingSplitShipmentsRow: View { | ||
| @State private var isShowingDetailView = false | ||
|
|
||
| let viewModel: WooShippingSplitShipmentsViewModel | ||
|
|
||
| init(viewModel: WooShippingSplitShipmentsViewModel) { | ||
| self.viewModel = viewModel | ||
| } | ||
|
|
||
| var body: some View { | ||
| AdaptiveStack { | ||
| Text(Localization.products) | ||
| .tertiaryTitleStyle() | ||
| Spacer() | ||
| Button(Localization.splitShipments) { | ||
| isShowingDetailView = true | ||
| } | ||
| .buttonStyle(TextButtonStyle()) | ||
| } | ||
| .padding(.vertical, Layout.verticalPadding) | ||
| .fullScreenCover(isPresented: $isShowingDetailView) { | ||
| WooShippingSplitShipmentsDetailView(viewModel: viewModel) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private extension WooShippingSplitShipmentsRow { | ||
| enum Layout { | ||
| static let verticalPadding: CGFloat = 16 | ||
| } | ||
|
|
||
| enum Localization { | ||
| static let products = NSLocalizedString("wooShipping.splitShipments.products", | ||
| value: "Products", | ||
| comment: "Label for section in shipping label creation to split shipments.") | ||
|
|
||
| static let splitShipments = NSLocalizedString("wooShipping.splitShipments.splitShipmentsButtonTitle", | ||
| value: "Split shipments", | ||
| comment: "Title for button in shipping label creation to start split shipments flow.") | ||
| } | ||
| } | ||
|
|
||
| #Preview { | ||
| WooShippingSplitShipmentsRow(viewModel: WooShippingSplitShipmentsViewModel(siteID: 123, | ||
| orderID: 123)) | ||
| .padding() | ||
| } |
35 changes: 35 additions & 0 deletions
35
...eate Shipping Labels/WooShipping Split Shipments/WooShippingSplitShipmentsViewModel.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import SwiftUI | ||
| import Yosemite | ||
| import WooFoundation | ||
|
|
||
| final class WooShippingSplitShipmentsViewModel: ObservableObject { | ||
| private let siteID: Int64 | ||
| private let orderID: Int64 | ||
| private let stores: StoresManager | ||
|
|
||
| /// Label for the total number of items | ||
| let itemsCountLabel = "6 items" | ||
|
|
||
| /// Label for the total item details | ||
| let itemsDetailLabel = "825g · $135.00" | ||
|
|
||
| let items: [WooShippingItemRowViewModel] = [WooShippingItemRowViewModel(imageUrl: nil, | ||
| quantityLabel: "3", | ||
| name: "Little Nap Brazil 250g", | ||
| detailsLabel: "15×10×8cm • Espresso", | ||
| weightLabel: "275g", | ||
| priceLabel: "$60.00"), | ||
| WooShippingItemRowViewModel(imageUrl: nil, | ||
| quantityLabel: "3", | ||
| name: "Little Nap Brazil 250g", | ||
| detailsLabel: "15×10×8cm • Espresso", | ||
| weightLabel: "275g", | ||
| priceLabel: "$60.00")] | ||
| init(siteID: Int64, | ||
| orderID: Int64, | ||
| stores: StoresManager = ServiceLocator.stores) { | ||
| self.siteID = siteID | ||
| self.orderID = orderID | ||
| self.stores = stores | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this also WIP? Should we disable splitting if an order has only one item?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Yes, this is WIP.
We need to load the shipment info from the remote and show this "Split shipments" view. I will update this after adding endpoint support in #15370.