Skip to content

Commit 03cf0da

Browse files
authored
Merge pull request #14014 from woocommerce/issue/woomob-192-woo-pos-handle-state-when-there-are-no-coupons-in-a-store
[WOOMOB-192] Update Empty Coupon Screen
2 parents 74e339c + 35b78fb commit 03cf0da

File tree

5 files changed

+59
-1
lines changed

5 files changed

+59
-1
lines changed

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

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import coil.request.ImageRequest
5050
import com.woocommerce.android.R
5151
import com.woocommerce.android.ui.woopos.common.composeui.WooPosPreview
5252
import com.woocommerce.android.ui.woopos.common.composeui.component.ShadowType
53+
import com.woocommerce.android.ui.woopos.common.composeui.component.WooPosButton
5354
import com.woocommerce.android.ui.woopos.common.composeui.component.WooPosCard
5455
import com.woocommerce.android.ui.woopos.common.composeui.component.WooPosLazyColumn
5556
import com.woocommerce.android.ui.woopos.common.composeui.component.WooPosShimmerBox
@@ -478,6 +479,44 @@ fun WooPosItemsEmptyList(
478479
title: String,
479480
message: String,
480481
contentDescription: String,
482+
) {
483+
WooPosItemsEmptyListInternal(
484+
modifier = modifier,
485+
title = title,
486+
message = message,
487+
contentDescription = contentDescription,
488+
actionLabel = null,
489+
onActionClicked = null
490+
)
491+
}
492+
493+
@Composable
494+
fun WooPosItemsEmptyList(
495+
modifier: Modifier = Modifier,
496+
title: String,
497+
message: String,
498+
contentDescription: String,
499+
actionLabel: String,
500+
onActionClicked: (() -> Unit),
501+
) {
502+
WooPosItemsEmptyListInternal(
503+
modifier = modifier,
504+
title = title,
505+
message = message,
506+
contentDescription = contentDescription,
507+
actionLabel = actionLabel,
508+
onActionClicked = onActionClicked
509+
)
510+
}
511+
512+
@Composable
513+
private fun WooPosItemsEmptyListInternal(
514+
modifier: Modifier = Modifier,
515+
title: String,
516+
message: String,
517+
contentDescription: String,
518+
actionLabel: String?,
519+
onActionClicked: (() -> Unit)? = null,
481520
) {
482521
Box(
483522
modifier = modifier.verticalScroll(rememberScrollState()),
@@ -510,7 +549,17 @@ fun WooPosItemsEmptyList(
510549
textAlign = TextAlign.Center
511550
)
512551

513-
Spacer(modifier = Modifier.height(WooPosSpacing.Medium.value.toAdaptivePadding()))
552+
Spacer(modifier = Modifier.height(WooPosSpacing.XLarge.value.toAdaptivePadding()))
553+
554+
if (onActionClicked != null && actionLabel != null) {
555+
WooPosButton(
556+
text = actionLabel,
557+
onClick = onActionClicked,
558+
modifier = Modifier
559+
.fillMaxWidth(0.5f)
560+
.height(80.dp)
561+
)
562+
}
514563
}
515564
}
516565
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,12 @@ private fun WooPosCouponsScreen(
9292
)
9393

9494
is WooPosCouponsViewState.Empty -> WooPosItemsEmptyList(
95+
modifier = Modifier.fillMaxSize(),
9596
title = stringResource(id = R.string.woopos_coupons_empty_list_title),
9697
message = stringResource(id = R.string.woopos_coupons_empty_list_message),
9798
contentDescription = stringResource(id = R.string.woopos_coupons_empty_list_image_description),
99+
actionLabel = stringResource(id = R.string.woopos_coupons_empty_list_create_coupon_label),
100+
onActionClicked = { onUIEvent(WooPosCouponsUIEvent.CreateCouponClicked) }
98101
)
99102

100103
is WooPosCouponsViewState.Error -> CouponsError { onUIEvent(WooPosCouponsUIEvent.RetryTriggered) }

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ sealed class WooPosCouponsUIEvent {
66
data object RetryLoadMoreTriggered : WooPosCouponsUIEvent()
77
data object RetryTriggered : WooPosCouponsUIEvent()
88
data class CouponClicked(val couponId: Long) : WooPosCouponsUIEvent()
9+
data object CreateCouponClicked : WooPosCouponsUIEvent()
910
data object BackButtonClicked : WooPosCouponsUIEvent()
1011
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ class WooPosCouponsViewModel @Inject constructor(
7070
}
7171

7272
RetryTriggered -> fetchCoupons()
73+
74+
is WooPosCouponsUIEvent.CreateCouponClicked -> {
75+
error("Create coupon clicked event not implemented yet")
76+
}
7377
}
7478
}
7579

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4336,6 +4336,7 @@
43364336
<string name="woopos_coupons_empty_list_image_description">No coupons</string>
43374337
<string name="woopos_coupons_empty_list_title">No coupons found</string>
43384338
<string name="woopos_coupons_empty_list_message">Boost your business by sending customers special offers and discounts.</string>
4339+
<string name="woopos_coupons_empty_list_create_coupon_label">Create coupon</string>
43394340
<string name="woopos_coupons_loading_error_title">Error loading coupons</string>
43404341
<string name="woopos_coupons_loading_error_message">Give it another go?</string>
43414342
<string name="woopos_coupons_loading_error_retry_button">Retry</string>

0 commit comments

Comments
 (0)