Skip to content

Commit 6f047c4

Browse files
Display the booking.note if not empty
1 parent 303a9bf commit 6f047c4

File tree

4 files changed

+43
-5
lines changed

4 files changed

+43
-5
lines changed

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/bookings/compose/BookingNoteSection.kt

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import com.woocommerce.android.ui.compose.theme.WooThemeWithBackground
2222

2323
@Composable
2424
fun BookingNoteSection(
25+
note: String,
2526
onClick: () -> Unit,
2627
modifier: Modifier = Modifier,
2728
) {
@@ -36,13 +37,30 @@ fun BookingNoteSection(
3637
modifier = Modifier
3738
.fillMaxWidth()
3839
.clickable { onClick() }
39-
.padding(horizontal = 16.dp, vertical = 12.dp)
40+
.padding(horizontal = 16.dp)
4041
) {
41-
BookingDetailsLabel(label = R.string.booking_note_label_add_note, modifier = Modifier.weight(1f))
42+
if (note.isEmpty()) {
43+
BookingDetailsLabel(
44+
label = R.string.booking_note_label_add_note,
45+
modifier = Modifier
46+
.weight(1f)
47+
.padding(vertical = 12.dp)
48+
)
49+
} else {
50+
Text(
51+
text = note,
52+
style = MaterialTheme.typography.bodyLarge,
53+
color = MaterialTheme.colorScheme.onSurface,
54+
modifier = Modifier
55+
.weight(1f)
56+
.padding(vertical = 16.dp)
57+
)
58+
}
4259
Icon(
4360
painter = painterResource(id = R.drawable.ic_arrow_right),
4461
contentDescription = null,
45-
tint = MaterialTheme.colorScheme.surfaceVariant
62+
tint = MaterialTheme.colorScheme.surfaceVariant,
63+
modifier = Modifier.padding(start = 8.dp)
4664
)
4765
}
4866
HorizontalDivider(thickness = 0.5.dp)
@@ -61,6 +79,22 @@ fun BookingNoteSection(
6179
private fun BookingNoteSectionPreview() {
6280
WooThemeWithBackground {
6381
BookingNoteSection(
82+
note = "",
83+
onClick = {},
84+
modifier = Modifier.fillMaxWidth()
85+
)
86+
}
87+
}
88+
89+
@LightDarkThemePreviews
90+
@Composable
91+
private fun BookingNoteSectionWithNotePreview() {
92+
WooThemeWithBackground {
93+
BookingNoteSection(
94+
note = "The customer prefers eco-friendly products and shorter length cuts. Please ensure the stylist " +
95+
"recommends sustainable options and is prepared for a trim focusing on shorter lengths. " +
96+
"If there are any special requests or allergies, please confirm with the customer " +
97+
"prior to the appointment.",
6498
onClick = {},
6599
modifier = Modifier.fillMaxWidth()
66100
)

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/bookings/details/BookingDetailsScreen.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ private fun BookingDetailsContent(
157157
)
158158
}
159159
BookingNoteSection(
160+
note = booking.note,
160161
onClick = {},
161162
modifier = Modifier.fillMaxWidth()
162163
)
@@ -256,7 +257,8 @@ private fun BookingDetailsPreview() {
256257
tax = "$4.50",
257258
discount = "-",
258259
total = "$59.50"
259-
)
260+
),
261+
note = ""
260262
),
261263
),
262264
onBack = {},

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/bookings/details/BookingDetailsViewModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ class BookingDetailsViewModel @Inject constructor(
214214
cancelStatus = cancelStatus
215215
),
216216
bookingCustomerDetails = booking.order.customerInfo.toCustomerDetailsModel(),
217-
bookingPaymentDetails = booking.order.paymentInfo?.toPaymentDetailsModel(booking.currency)
217+
bookingPaymentDetails = booking.order.paymentInfo?.toPaymentDetailsModel(booking.currency),
218+
note = booking.note
218219
)
219220

220221
private fun buildStaffMemberStatus(

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/bookings/details/BookingDetailsViewState.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ data class BookingUiState(
2525
val bookingsAppointmentDetails: BookingAppointmentDetailsModel,
2626
val bookingCustomerDetails: BookingCustomerDetailsModel,
2727
val bookingPaymentDetails: BookingPaymentDetailsModel?,
28+
val note: String,
2829
)
2930

3031
sealed interface BookingDetailsLoadingState {

0 commit comments

Comments
 (0)