Skip to content

Commit 13d4b26

Browse files
authored
Merge pull request #13984 from woocommerce/wooprd-471-woo-posproduct-search-do-the-design-changes-for-empty-query
[WOOPRD-471][Woo POS][Product search] Do the design changes for empty query screen
2 parents d16f51a + b4c0ea2 commit 13d4b26

File tree

6 files changed

+28
-40
lines changed

6 files changed

+28
-40
lines changed

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/common/data/WooPosPopularProductsProvider.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class WooPosPopularProductsProvider @Inject constructor(
1818
private val productsTypesFilterConfig: WooPosProductsTypesFilterConfig,
1919
) {
2020
companion object {
21-
private const val MAX_POPULAR_PRODUCTS = 3
21+
private const val MAX_POPULAR_PRODUCTS = 10
2222
}
2323

2424
private val mutex = Mutex()

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

+17-30
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ import androidx.compose.foundation.shape.RoundedCornerShape
1717
import androidx.compose.foundation.verticalScroll
1818
import androidx.compose.material.icons.Icons
1919
import androidx.compose.material.icons.automirrored.outlined.KeyboardArrowRight
20-
import androidx.compose.material.icons.automirrored.outlined.TrendingUp
21-
import androidx.compose.material.icons.filled.History
2220
import androidx.compose.material.icons.outlined.Search
2321
import androidx.compose.material3.Icon
2422
import androidx.compose.material3.MaterialTheme
2523
import androidx.compose.runtime.Composable
24+
import androidx.compose.runtime.LaunchedEffect
2625
import androidx.compose.ui.Alignment
2726
import androidx.compose.ui.Modifier
28-
import androidx.compose.ui.graphics.vector.ImageVector
27+
import androidx.compose.ui.platform.LocalFocusManager
2928
import androidx.compose.ui.res.stringResource
3029
import androidx.compose.ui.text.font.FontWeight
3130
import androidx.compose.ui.text.style.TextOverflow
@@ -50,6 +49,12 @@ fun WooPosItemsEmptySearchQueryStateScreen(
5049
onUIEvent: (WooPosItemsSearchUiEvent) -> Unit
5150
) {
5251
val scrollState = rememberScrollState()
52+
val focusManager = LocalFocusManager.current
53+
LaunchedEffect(scrollState.isScrollInProgress) {
54+
if (scrollState.isScrollInProgress) {
55+
focusManager.clearFocus()
56+
}
57+
}
5358
Column(
5459
modifier
5560
.fillMaxHeight()
@@ -104,11 +109,10 @@ private fun PopularItemsSection(
104109
onPopularItemClicked: (WooPosItemSelectionViewState.Product) -> Unit,
105110
) {
106111
SectionHeader(
107-
icon = Icons.AutoMirrored.Outlined.TrendingUp,
108112
title = stringResource(R.string.woopos_search_popular_items_title)
109113
)
110114

111-
Spacer(modifier = Modifier.height(WooPosSpacing.Small.value.toAdaptivePadding()))
115+
Spacer(modifier = Modifier.height(WooPosSpacing.Medium.value.toAdaptivePadding()))
112116

113117
popularItems.forEach { popularItem ->
114118
val itemContentDescription = stringResource(
@@ -134,11 +138,10 @@ private fun RecentSearchesSection(
134138
onRecentSearchClicked: (String) -> Unit,
135139
) {
136140
SectionHeader(
137-
icon = Icons.Filled.History,
138141
title = stringResource(R.string.woopos_search_recent_searches_title)
139142
)
140143

141-
Spacer(modifier = Modifier.height(WooPosSpacing.Small.value.toAdaptivePadding()))
144+
Spacer(modifier = Modifier.height(WooPosSpacing.Medium.value.toAdaptivePadding()))
142145

143146
state.recentSearches.forEach { recentSearch ->
144147
WooPosCard(
@@ -189,29 +192,13 @@ private fun RecentSearchesSection(
189192
}
190193

191194
@Composable
192-
private fun SectionHeader(
193-
icon: ImageVector,
194-
title: String
195-
) {
196-
Row(
197-
verticalAlignment = Alignment.CenterVertically
198-
) {
199-
Icon(
200-
imageVector = icon,
201-
contentDescription = null,
202-
tint = MaterialTheme.colorScheme.onSurface,
203-
modifier = Modifier.size(24.dp)
204-
)
205-
206-
Spacer(modifier = Modifier.width(WooPosSpacing.Small.value.toAdaptivePadding()))
207-
208-
WooPosText(
209-
text = title,
210-
style = WooPosTypography.BodyMedium,
211-
color = MaterialTheme.colorScheme.onSurface,
212-
fontWeight = FontWeight.Bold,
213-
)
214-
}
195+
private fun SectionHeader(title: String) {
196+
WooPosText(
197+
text = title,
198+
style = WooPosTypography.BodyMedium,
199+
color = MaterialTheme.colorScheme.onSurface,
200+
fontWeight = FontWeight.Bold,
201+
)
215202
}
216203

217204
@WooPosPreview

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class WooPosItemsSearchViewModel @Inject constructor(
286286
}
287287

288288
private companion object {
289-
const val MAX_ITEMS_COUNT = 3
289+
const val MAX_ITEMS_COUNT = 10
290290
const val SEARCH_DEBOUNCING_TIME = 500L
291291
}
292292
}

WooCommerce/src/main/res/values/strings.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4405,7 +4405,7 @@
44054405
<string name="woopos_search_back_content_description">Back</string>
44064406
<string name="woopos_search_clear_content_description">Clear</string>
44074407
<string name="woopos_search_products">Search products</string>
4408-
<string name="woopos_search_popular_items_title">Popular items</string>
4408+
<string name="woopos_search_popular_items_title">Popular products</string>
44094409
<string name="woopos_search_recent_searches_title">Recent searches</string>
44104410
<string name="woopos_search_items_empty_title">Nothing found</string>
44114411
<string name="woopos_search_empty_description">We couldn\'t find anything matching your search.</string>

WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/common/data/WooPosPopularProductsProviderTest.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class WooPosPopularProductsProviderTest {
6363
productStore.fetchProducts(
6464
site = siteModel,
6565
offset = 0,
66-
pageSize = 3,
66+
pageSize = 10,
6767
filterOptions = emptyMap(),
6868
includeTypes = emptyList(),
6969
sortType = ProductSorting.POPULARITY_DESC
@@ -88,7 +88,7 @@ class WooPosPopularProductsProviderTest {
8888
productStore.fetchProducts(
8989
site = siteModel,
9090
offset = 0,
91-
pageSize = 3,
91+
pageSize = 10,
9292
filterOptions = emptyMap(),
9393
includeTypes = emptyList(),
9494
sortType = ProductSorting.POPULARITY_DESC
@@ -122,7 +122,7 @@ class WooPosPopularProductsProviderTest {
122122
productStore.fetchProducts(
123123
site = siteModel,
124124
offset = 0,
125-
pageSize = 3,
125+
pageSize = 10,
126126
filterOptions = emptyMap(),
127127
includeTypes = emptyList(),
128128
sortType = ProductSorting.POPULARITY_DESC
@@ -149,7 +149,7 @@ class WooPosPopularProductsProviderTest {
149149
productStore.fetchProducts(
150150
site = siteModel,
151151
offset = 0,
152-
pageSize = 3,
152+
pageSize = 10,
153153
filterOptions = emptyMap(),
154154
includeTypes = emptyList(),
155155
sortType = ProductSorting.POPULARITY_DESC
@@ -175,7 +175,7 @@ class WooPosPopularProductsProviderTest {
175175
productStore.fetchProducts(
176176
site = siteModel,
177177
offset = 0,
178-
pageSize = 3,
178+
pageSize = 10,
179179
filterOptions = emptyMap(),
180180
includeTypes = emptyList(),
181181
sortType = ProductSorting.POPULARITY_DESC

WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/home/items/search/WooPosItemsSearchViewModelTest.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,12 @@ class WooPosItemsSearchViewModelTest {
145145
val emptySearchQuery = value as WooPosItemsSearchViewState.EmptySearchQuery
146146
assertThat(emptySearchQuery.popularItems).hasSize(2)
147147
assertThat(emptySearchQuery.popularItems.map { it.id }).containsExactly(1, 2)
148-
assertThat(emptySearchQuery.recentSearches).hasSize(3)
148+
assertThat(emptySearchQuery.recentSearches).hasSize(4)
149149
assertThat(emptySearchQuery.recentSearches).containsExactly(
150150
"Recent Search 1",
151151
"Recent Search 2",
152-
"Recent Search 3"
152+
"Recent Search 3",
153+
"Recent Search 4",
153154
)
154155
}
155156
}

0 commit comments

Comments
 (0)