Skip to content

Commit 2b30a41

Browse files
committed
Hook UI item type selection with switch in aggregate model
1 parent 1aa3efc commit 2b30a41

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

WooCommerce/Classes/POS/Models/PointOfSaleAggregateModel.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ extension PointOfSaleAggregateModel {
106106
func loadNextItems(base: ItemListBaseItem) async {
107107
await itemsController.loadNextItems(base: base)
108108
}
109+
110+
func switchToItemType(_ type: ItemType) {
111+
// TODO: Switch between controllers controller: products or coupons
112+
debugPrint("🍍 Switching to \(type)")
113+
}
109114
}
110115

111116
// MARK: - Cart

WooCommerce/Classes/POS/Presentation/ItemListView.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ struct ItemListView: View {
2020
private var shouldShowCoupons: Bool {
2121
ServiceLocator.featureFlagService.isFeatureFlagEnabled(.enableCouponsInPointOfSale)
2222
}
23+
24+
@State private var selectedItemType: ItemType = .products
2325

2426
var body: some View {
2527
if #available(iOS 18.0, *) {
@@ -41,12 +43,12 @@ struct ItemListView: View {
4143

4244
HStack {
4345
Button(action: {
44-
toggleItemType()
46+
displayItemType(.products)
4547
}, label: {
4648
Text("Products")
4749
})
4850
Button(action: {
49-
toggleItemType()
51+
displayItemType(.coupons)
5052
}, label: {
5153
Text("Coupons")
5254
})
@@ -160,8 +162,9 @@ private extension ItemListView {
160162
itemListState.eligibleToShowSimpleProductsBanner && !isHeaderBannerDismissed
161163
}
162164

163-
func toggleItemType() {
164-
debugPrint("🍍 Toggle ItemType tapped")
165+
func displayItemType(_ itemType: ItemType) {
166+
selectedItemType = itemType
167+
posModel.switchToItemType(itemType)
165168
}
166169
}
167170

0 commit comments

Comments
 (0)