Skip to content

[WOOMOB-192] Update Empty Coupon Screen #14014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import coil.request.ImageRequest
import com.woocommerce.android.R
import com.woocommerce.android.ui.woopos.common.composeui.WooPosPreview
import com.woocommerce.android.ui.woopos.common.composeui.component.ShadowType
import com.woocommerce.android.ui.woopos.common.composeui.component.WooPosButton
import com.woocommerce.android.ui.woopos.common.composeui.component.WooPosCard
import com.woocommerce.android.ui.woopos.common.composeui.component.WooPosLazyColumn
import com.woocommerce.android.ui.woopos.common.composeui.component.WooPosShimmerBox
Expand Down Expand Up @@ -478,6 +479,44 @@ fun WooPosItemsEmptyList(
title: String,
message: String,
contentDescription: String,
) {
WooPosItemsEmptyListInternal(
modifier = modifier,
title = title,
message = message,
contentDescription = contentDescription,
actionLabel = null,
onActionClicked = null
)
}

@Composable
fun WooPosItemsEmptyList(
modifier: Modifier = Modifier,
title: String,
message: String,
contentDescription: String,
actionLabel: String,
onActionClicked: (() -> Unit),
) {
WooPosItemsEmptyListInternal(
modifier = modifier,
title = title,
message = message,
contentDescription = contentDescription,
actionLabel = actionLabel,
onActionClicked = onActionClicked
)
}

@Composable
private fun WooPosItemsEmptyListInternal(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📓 I've considered creating a sealed class to ensure actionLabel and onActionClicked either need to be both null or both non-null, but in the end I opted for making this function private and include Internal in its name instead and provide two overloads. Let me know what you think.

modifier: Modifier = Modifier,
title: String,
message: String,
contentDescription: String,
actionLabel: String?,
onActionClicked: (() -> Unit)? = null,
) {
Box(
modifier = modifier.verticalScroll(rememberScrollState()),
Expand Down Expand Up @@ -510,7 +549,17 @@ fun WooPosItemsEmptyList(
textAlign = TextAlign.Center
)

Spacer(modifier = Modifier.height(WooPosSpacing.Medium.value.toAdaptivePadding()))
Spacer(modifier = Modifier.height(WooPosSpacing.XLarge.value.toAdaptivePadding()))

if (onActionClicked != null && actionLabel != null) {
WooPosButton(
text = actionLabel,
onClick = onActionClicked,
modifier = Modifier
.fillMaxWidth(0.5f)
.height(80.dp)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡n.p.: Text size in the button can be scaled up in the accessibility settings. Maybe let's use top padding instead of fixed height 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I see what you mean and I tend to agree, however, this was copied and there are 5+ other buttons like this in the POS. Considering we tested other projects for accessibility and didn't report this an issue I believe it might look fine even with the biggest font. At the moment, it's imo not worth the effort to diving more into this.

)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,12 @@ private fun WooPosCouponsScreen(
)

is WooPosCouponsViewState.Empty -> WooPosItemsEmptyList(
modifier = Modifier.fillMaxSize(),
title = stringResource(id = R.string.woopos_coupons_empty_list_title),
message = stringResource(id = R.string.woopos_coupons_empty_list_message),
contentDescription = stringResource(id = R.string.woopos_coupons_empty_list_image_description),
actionLabel = stringResource(id = R.string.woopos_coupons_empty_list_create_coupon_label),
onActionClicked = { onUIEvent(WooPosCouponsUIEvent.CreateCouponClicked) }
)

is WooPosCouponsViewState.Error -> CouponsError { onUIEvent(WooPosCouponsUIEvent.RetryTriggered) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ sealed class WooPosCouponsUIEvent {
data object RetryLoadMoreTriggered : WooPosCouponsUIEvent()
data object RetryTriggered : WooPosCouponsUIEvent()
data class CouponClicked(val couponId: Long) : WooPosCouponsUIEvent()
data object CreateCouponClicked : WooPosCouponsUIEvent()
data object BackButtonClicked : WooPosCouponsUIEvent()
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class WooPosCouponsViewModel @Inject constructor(
}

RetryTriggered -> fetchCoupons()

is WooPosCouponsUIEvent.CreateCouponClicked -> {
error("Create coupon clicked event not implemented yet")
}
}
}

Expand Down
1 change: 1 addition & 0 deletions WooCommerce/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4333,6 +4333,7 @@
<string name="woopos_coupons_empty_list_image_description">No coupons</string>
<string name="woopos_coupons_empty_list_title">No coupons found</string>
<string name="woopos_coupons_empty_list_message">Boost your business by sending customers special offers and discounts.</string>
<string name="woopos_coupons_empty_list_create_coupon_label">Create coupon</string>
<string name="woopos_coupons_loading_error_title">Error loading coupons</string>
<string name="woopos_coupons_loading_error_message">Give it another go?</string>
<string name="woopos_coupons_loading_error_retry_button">Retry</string>
Expand Down