Skip to content

Commit fba7d7d

Browse files
Show move to notice upon selecting items.
1 parent 05e2468 commit fba7d7d

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Split Shipments/WooShippingSplitShipmentsDetailView.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ struct WooShippingSplitShipmentsDetailView: View {
4646
}
4747
}
4848
}
49-
.notice($viewModel.instructionsNotice, autoDismiss: false)
5049
.onAppear {
5150
viewModel.onAppear()
5251
}
@@ -60,6 +59,11 @@ private extension WooShippingSplitShipmentsDetailView {
6059
InstructionsSnackbar(message: message) {
6160
viewModel.dismissInstructions()
6261
}
62+
}
63+
64+
if let moveTo = viewModel.moveToNoticeViewModel {
65+
MoveToShipmentNotice(viewModel: moveTo)
66+
}
6367
}
6468
}
6569
}
@@ -102,9 +106,13 @@ fileprivate extension WooShippingSplitShipmentsDetailView {
102106
enum Layout {
103107
static let contentPadding: CGFloat = 16
104108
static let borderCornerRadius: CGFloat = 8
109+
static let shadowRadius: CGFloat = 8
110+
static let shadowYOffset: CGFloat = 2
105111
static let borderWidth: CGFloat = 0.5
106112
static let verticalSpacing: CGFloat = 8
113+
static let cornerRadius: CGFloat = 8
107114
}
115+
108116
enum Localization {
109117
static let title = NSLocalizedString(
110118
"wooShippingSplitShipmentsDetailView.title",

WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Split Shipments/WooShippingSplitShipmentsViewModel.swift

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ final class WooShippingSplitShipmentsViewModel: ObservableObject {
2828

2929
let shipmentCardViewModels: [CollapsibleShipmentCardViewModel]
3030

31+
@Published private(set) var moveToNoticeViewModel: MoveToShipmentNoticeViewModel?
32+
3133
@Published private(set) var instructions: String?
3234
private var dismissedInstructions: Bool = false
3335

@@ -77,6 +79,7 @@ final class WooShippingSplitShipmentsViewModel: ObservableObject {
7779

7880
func onAppear() {
7981
showInstructionsNotice()
82+
showMoveToNotice()
8083
}
8184

8285
func selectAll() {
@@ -95,7 +98,7 @@ private extension WooShippingSplitShipmentsViewModel {
9598
func configureSelectionCallback() {
9699
shipmentCardViewModels.forEach { viewModel in
97100
viewModel.onSelectionChange = { [weak self] in
98-
self?.checkSelectionAndHideInstructions()
101+
self?.showMoveToNotice()
99102
}
100103
}
101104
}
@@ -106,14 +109,32 @@ private extension WooShippingSplitShipmentsViewModel {
106109
}
107110
}
108111

109-
func checkSelectionAndHideInstructions() {
110-
if hasSelectedAnItem() {
111-
instructionsNotice = nil
112+
func showMoveToNotice() {
113+
let selectedItemsCount = {
114+
shipmentCardViewModels.map { $0.selectedShipmentIds.count }.reduce(0, +)
115+
}()
116+
117+
guard selectedItemsCount > 0 else {
118+
return self.moveToNoticeViewModel = nil
112119
}
113-
}
114120

115-
func hasSelectedAnItem() -> Bool {
116-
shipmentCardViewModels.contains(where: { $0.hasSelectedAnItem })
121+
// TODO: Use count and index values from shipment tabs
122+
moveToNoticeViewModel = MoveToShipmentNoticeViewModel(selectedItemsCount: selectedItemsCount,
123+
existingShipmentsCount: 3,
124+
currentShipmentIndex: 2,
125+
actionHandler: { [weak self] moveTo in
126+
guard let self else { return }
127+
128+
self.moveToNoticeViewModel = nil
129+
self.instructions = nil
130+
131+
switch moveTo {
132+
case .existingShipment:
133+
break
134+
case .newShipment:
135+
break
136+
}
137+
})
117138
}
118139

119140
/// Configures the labels in the section header.

0 commit comments

Comments
 (0)