-
Notifications
You must be signed in to change notification settings - Fork 136
[WOOMOB-1511] - Booking details cancel flow #14752
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
Changes from 5 commits
b0ec359
1916d68
bf3935b
b8ea834
37a98a6
cbf1857
d0c3f31
841bba3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,7 +70,11 @@ private fun BookingAttendanceStatusSelection( | |
| color = MaterialTheme.colorScheme.onSurfaceVariant, | ||
| modifier = Modifier.padding(bottom = 22.dp) | ||
| ) | ||
| BookingAttendanceStatus.entries.forEachIndexed { index, status -> | ||
| listOf( | ||
| BookingAttendanceStatus.BOOKED, | ||
| BookingAttendanceStatus.CHECKED_IN, | ||
| BookingAttendanceStatus.NO_SHOW, | ||
| ).forEachIndexed { index, status -> | ||
| AttendanceStatusRow( | ||
| status = status, | ||
| onClick = { onSelect(status) } | ||
|
|
@@ -92,12 +96,14 @@ private fun AttendanceStatusRow( | |
| verticalAlignment = Alignment.CenterVertically, | ||
| horizontalArrangement = Arrangement.spacedBy(16.dp) | ||
| ) { | ||
| Icon( | ||
| painter = painterResource(status.iconRes), | ||
| contentDescription = status.text(), | ||
| tint = MaterialTheme.colorScheme.onSurfaceVariant, | ||
| modifier = Modifier.size(24.dp) | ||
| ) | ||
| status.iconRes?.let { iconRes -> | ||
| Icon( | ||
| painter = painterResource(iconRes), | ||
| contentDescription = status.text(), | ||
| tint = MaterialTheme.colorScheme.onSurfaceVariant, | ||
| modifier = Modifier.size(24.dp) | ||
| ) | ||
| } | ||
|
Comment on lines
+99
to
+106
|
||
| Column(modifier = Modifier.weight(1f)) { | ||
| Text( | ||
| text = status.text(), | ||
|
|
@@ -118,16 +124,16 @@ private fun AttendanceStatusRow( | |
| private fun BookingAttendanceStatus.description(): String = when (this) { | ||
| BookingAttendanceStatus.BOOKED -> R.string.booking_attendance_status_booked_desc | ||
| BookingAttendanceStatus.CHECKED_IN -> R.string.booking_attendance_status_checked_in_desc | ||
| BookingAttendanceStatus.CANCELLED -> R.string.booking_attendance_status_cancelled_desc | ||
| BookingAttendanceStatus.NO_SHOW -> R.string.booking_attendance_status_no_show_desc | ||
| }.let { stringResource(it) } | ||
| else -> null | ||
| }?.let { stringResource(it) } ?: "" | ||
|
|
||
| private val BookingAttendanceStatus.iconRes: Int | ||
| private val BookingAttendanceStatus.iconRes: Int? | ||
| get() = when (this) { | ||
| BookingAttendanceStatus.BOOKED -> R.drawable.ic_attendance_booked | ||
| BookingAttendanceStatus.CHECKED_IN -> R.drawable.ic_attendance_checked_in | ||
| BookingAttendanceStatus.CANCELLED -> R.drawable.ic_attendance_cancelled | ||
| BookingAttendanceStatus.NO_SHOW -> R.drawable.ic_attendance_no_show | ||
| else -> null | ||
| } | ||
|
|
||
| @LightDarkThemePreviews | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package com.woocommerce.android.ui.bookings.compose | ||
|
|
||
| import androidx.compose.material3.ButtonDefaults | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.material3.TextButton | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.res.stringResource | ||
| import com.woocommerce.android.R | ||
| import com.woocommerce.android.ui.compose.component.AlertDialog | ||
|
|
||
| @Composable | ||
| fun CancelBookingDialog( | ||
| message: String, | ||
| onDismiss: () -> Unit, | ||
| onConfirmCancel: () -> Unit, | ||
| ) { | ||
| AlertDialog( | ||
| onDismissRequest = onDismiss, | ||
| title = { | ||
| Text( | ||
| text = stringResource(id = R.string.booking_cancel_dialog_title), | ||
| style = MaterialTheme.typography.titleLarge | ||
| ) | ||
| }, | ||
| text = { Text(text = message) }, | ||
| confirmButton = { | ||
| TextButton( | ||
| onClick = onConfirmCancel, | ||
| colors = ButtonDefaults.textButtonColors(contentColor = MaterialTheme.colorScheme.error), | ||
| ) { | ||
| Text(text = stringResource(id = R.string.booking_cancel_dialog_confirm)) | ||
| } | ||
| }, | ||
| dismissButton = { | ||
| TextButton( | ||
| onClick = onDismiss, | ||
| colors = ButtonDefaults.textButtonColors(contentColor = MaterialTheme.colorScheme.onSurface), | ||
| ) { | ||
| Text(text = stringResource(id = R.string.booking_cancel_dialog_keep)) | ||
| } | ||
| }, | ||
| neutralButton = { } | ||
| ) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,10 @@ data class BookingDetailsViewState( | |
| val loadingState: BookingDetailsLoadingState = BookingDetailsLoadingState.Idle, | ||
| val onCancelBooking: () -> Unit = {}, | ||
| val onAttendanceStatusSelected: (BookingAttendanceStatus) -> Unit = { _ -> }, | ||
| val showCancelBookingDialog: Boolean = false, | ||
| val cancelDialogMessage: String = "", | ||
| val onDismissCancelDialog: () -> Unit = {}, | ||
| val onConfirmCancelBooking: () -> Unit = {}, | ||
|
||
| val onRefresh: () -> Unit = {}, | ||
| ) { | ||
| val shouldShowSkeleton: Boolean = bookingUiState == null && loadingState == BookingDetailsLoadingState.Refreshing | ||
|
|
@@ -30,3 +34,8 @@ data class BookingUiState( | |
| val bookingCustomerDetails: BookingCustomerDetailsModel, | ||
| val bookingPaymentDetails: BookingPaymentDetailsModel?, | ||
| ) | ||
|
|
||
| sealed interface CancelState { | ||
| data object Idle : CancelState | ||
| data object InProgress : CancelState | ||
| } | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor remark, WDYT about updating
WCOutlinedButtonto accept aloadingparameter like what we do withWCColoredButtonhere, and move this logic to the component.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do, please also make sure to update
WCColoredButton's implementation to passenabled = enabled && !loading, to make sure we disable button during loading.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't mind, I would prefer to open a separate PR with it just to isolate the change that goes beyond Booking Details screen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR is here #14768