Skip to content

Commit 079af3d

Browse files
authored
Merge pull request #13977 from woocommerce/issue/woomob-356-woo-pos-replace-a-product-banner-with-a-menu-item
[WooPos] Replace Product Banner With Menu Item
2 parents 3551dd5 + c138ada commit 079af3d

File tree

15 files changed

+81
-364
lines changed

15 files changed

+81
-364
lines changed

RELEASE-NOTES.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*** For entries which are touching the Android Wear app's, start entry with `[WEAR]` too.
44
22.3
55
-----
6-
6+
- [*] Move info about available product types in the POS to the POS menu [https://github.com/woocommerce/woocommerce-android/pull/13977]
77

88
22.2
99
-----

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/WooPosHomeChildToParentCommunication.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ sealed class ChildToParentEvent {
3434
data object GoBackToCheckoutAfterFailedPayment : ChildToParentEvent()
3535
data object OrderSuccessfullyPaidByCard : ChildToParentEvent()
3636
data object ExitPosClicked : ChildToParentEvent()
37-
data object ProductsDialogInfoIconClicked : ChildToParentEvent()
37+
data object SimpleProductExplanationMenuItemClicked : ChildToParentEvent()
3838

3939
data class ToastMessageDisplayed(val message: String) : ChildToParentEvent()
4040
sealed class NavigationEvent : ChildToParentEvent() {

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/WooPosHomeViewModel.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class WooPosHomeViewModel @Inject constructor(
168168
)
169169
}
170170

171-
ChildToParentEvent.ProductsDialogInfoIconClicked -> {
171+
ChildToParentEvent.SimpleProductExplanationMenuItemClicked -> {
172172
_state.value = _state.value.copy(
173173
productsInfoDialog = ProductsInfoDialog(isVisible = true)
174174
)

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosBanner.kt

-205
This file was deleted.

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsUIEvent.kt

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package com.woocommerce.android.ui.woopos.home.items
22

33
sealed class WooPosItemsUIEvent {
4-
data object SimpleProductsBannerClosed : WooPosItemsUIEvent()
5-
data object SimpleProductsBannerLearnMoreClicked : WooPosItemsUIEvent()
6-
data object SimpleProductsDialogInfoIconClicked : WooPosItemsUIEvent()
74
data class OnTabClicked(val tab: WooPosItemsViewState.Tab) : WooPosItemsUIEvent()
85
data object BackButtonClicked : WooPosItemsUIEvent()
96

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsViewModel.kt

-35
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ import androidx.lifecycle.ViewModel
55
import androidx.lifecycle.viewModelScope
66
import com.woocommerce.android.R
77
import com.woocommerce.android.ui.woopos.featureflags.WooPosIsProductsSearchEnabled
8-
import com.woocommerce.android.ui.woopos.home.ChildToParentEvent
9-
import com.woocommerce.android.ui.woopos.home.WooPosChildrenToParentEventSender
108
import com.woocommerce.android.ui.woopos.home.items.WooPosItemsViewState.Tab
119
import com.woocommerce.android.ui.woopos.home.items.navigation.WooPosItemsNavigator
1210
import com.woocommerce.android.ui.woopos.home.items.navigation.WooPosItemsNavigator.WooPosItemsScreenNavigationEvent
13-
import com.woocommerce.android.ui.woopos.util.datastore.WooPosPreferencesRepository
1411
import dagger.hilt.android.lifecycle.HiltViewModel
1512
import kotlinx.coroutines.flow.MutableStateFlow
1613
import kotlinx.coroutines.flow.SharingStarted
@@ -22,8 +19,6 @@ import javax.inject.Inject
2219

2320
@HiltViewModel
2421
class WooPosItemsViewModel @Inject constructor(
25-
private val fromChildToParentEventSender: WooPosChildrenToParentEventSender,
26-
private val preferencesRepository: WooPosPreferencesRepository,
2722
private val navigator: WooPosItemsNavigator,
2823
private val searchHelper: WooPosItemsSearchHelper,
2924
private val isProductsSearchEnabled: WooPosIsProductsSearchEnabled,
@@ -52,18 +47,6 @@ class WooPosItemsViewModel @Inject constructor(
5247

5348
fun onUIEvent(event: WooPosItemsUIEvent) {
5449
when (event) {
55-
WooPosItemsUIEvent.SimpleProductsBannerClosed -> {
56-
onSimpleProductsOnlyBannerClosed()
57-
}
58-
59-
WooPosItemsUIEvent.SimpleProductsBannerLearnMoreClicked -> {
60-
onSimpleProductsOnlyBannerLearnMoreClicked()
61-
}
62-
63-
WooPosItemsUIEvent.SimpleProductsDialogInfoIconClicked -> {
64-
onSimpleProductsDialogInfoClicked()
65-
}
66-
6750
WooPosItemsUIEvent.BackButtonClicked -> {
6851
navigateBackToItemListScreen()
6952
}
@@ -89,24 +72,6 @@ class WooPosItemsViewModel @Inject constructor(
8972
}
9073
}
9174

92-
private fun onSimpleProductsOnlyBannerLearnMoreClicked() {
93-
onSimpleProductsDialogInfoClicked()
94-
}
95-
96-
private fun onSimpleProductsDialogInfoClicked() {
97-
viewModelScope.launch {
98-
fromChildToParentEventSender.sendToParent(ChildToParentEvent.ProductsDialogInfoIconClicked)
99-
}
100-
}
101-
102-
private fun onSimpleProductsOnlyBannerClosed() {
103-
viewModelScope.launch {
104-
val currentState = _viewState.value as WooPosItemsViewState.ProductList
105-
preferencesRepository.setSimpleProductsOnlyBannerWasHiddenByUser(true)
106-
_viewState.value = currentState.copy(banner = WooPosItemsViewState.BannerState.Hidden)
107-
}
108-
}
109-
11075
private fun selectTab(selectedTab: Tab) {
11176
if (_viewState.value.tabs.size == 1) return
11277

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/products/WooPosProductsScreen.kt

-40
Original file line numberDiff line numberDiff line change
@@ -322,46 +322,6 @@ fun WooPosProductsScreenErrorPreview() {
322322
}
323323
}
324324

325-
@OptIn(ExperimentalMaterialApi::class)
326-
@Composable
327-
@WooPosPreview
328-
fun WooPosHomeScreenItemsWithSimpleProductsOnlyBannerPreview() {
329-
val productState = MutableStateFlow(
330-
WooPosProductsViewState.Content(
331-
items = listOf(
332-
Product.Simple(
333-
1,
334-
name = "Product 1, Product 1, Product 1, " +
335-
"Product 1, Product 1, Product 1, Product 1, Product 1" +
336-
"Product 1, Product 1, Product 1, Product 1, Product 1",
337-
price = "10.0$",
338-
imageUrl = null,
339-
),
340-
Product.Simple(
341-
2,
342-
name = "Product 2",
343-
price = "2000.00$",
344-
imageUrl = null,
345-
),
346-
Product.Simple(
347-
3,
348-
name = "Product 3",
349-
price = "1.0$",
350-
imageUrl = null,
351-
),
352-
),
353-
pullToRefreshState = WooPosPullToRefreshState.Refreshing,
354-
)
355-
)
356-
WooPosTheme {
357-
WooPosProductsScreen(
358-
itemsStateFlow = productState,
359-
listState = rememberLazyListState(),
360-
onUIEvent = {},
361-
)
362-
}
363-
}
364-
365325
@OptIn(ExperimentalMaterialApi::class)
366326
@Composable
367327
@WooPosPreview

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/toolbar/WooPosToolbarViewModel.kt

+11
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.woocommerce.android.ui.woopos.home.toolbar.WooPosToolbarUIEvent.OnOut
1717
import com.woocommerce.android.ui.woopos.home.toolbar.WooPosToolbarUIEvent.OnToolbarMenuClicked
1818
import com.woocommerce.android.ui.woopos.support.WooPosGetSupportFacade
1919
import com.woocommerce.android.ui.woopos.util.WooPosNetworkStatus
20+
import com.woocommerce.android.ui.woopos.util.analytics.WooPosAnalyticsEvent
2021
import com.woocommerce.android.ui.woopos.util.analytics.WooPosAnalyticsEvent.Event.ExitTapped
2122
import com.woocommerce.android.ui.woopos.util.analytics.WooPosAnalyticsEvent.Event.GetSupportTapped
2223
import com.woocommerce.android.ui.woopos.util.analytics.WooPosAnalyticsEvent.Event.ViewDocsTapped
@@ -89,6 +90,12 @@ class WooPosToolbarViewModel @Inject constructor(
8990
hideMenu()
9091

9192
when (event.menuItem.title) {
93+
R.string.woopos_product_limitations_title -> {
94+
viewModelScope.launch {
95+
childrenToParentEventSender.sendToParent(ChildToParentEvent.SimpleProductExplanationMenuItemClicked)
96+
analyticsTracker.track(WooPosAnalyticsEvent.Event.SimpleProductExplanationDialogShown)
97+
}
98+
}
9299
R.string.woopos_get_support_title -> {
93100
getSupportFacade.openSupportForm()
94101
viewModelScope.launch {
@@ -145,6 +152,10 @@ class WooPosToolbarViewModel @Inject constructor(
145152

146153
private companion object {
147154
val toolbarMenuItems = listOf(
155+
WooPosToolbarState.Menu.MenuItem(
156+
title = R.string.woopos_product_limitations_title,
157+
icon = R.drawable.ic_not_found,
158+
),
148159
WooPosToolbarState.Menu.MenuItem(
149160
title = R.string.woopos_documentation_title,
150161
icon = R.drawable.woo_pos_info_ic,

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/util/analytics/WooPosAnalyticsEvent.kt

+3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ sealed class WooPosAnalyticsEvent : IAnalyticsEvent {
102102
data object ViewDocsTapped : Event() {
103103
override val name: String = "view_docs_tapped"
104104
}
105+
data object SimpleProductExplanationDialogShown : Event() {
106+
override val name: String = "simple_products_explanation_dialog_shown"
107+
}
105108
}
106109

107110
sealed class PaymentFlowTrackerEvent : WooPosAnalyticsEvent() {

0 commit comments

Comments
 (0)