-
Notifications
You must be signed in to change notification settings - Fork 133
[WOOMOB-1346] Booking details - payment section #14666
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
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
885192d
Introduce the payment section in the booking details screen
AdamGrzybkowski 47d8a86
Show different buttons states in payment status section
AdamGrzybkowski f535694
Open order from the payment section
AdamGrzybkowski 4407afe
Handle the onMarkAsPaid and onMarkAsRefunded callbacks
AdamGrzybkowski 9acb842
Move onCancelBooking to BookingDetailsViewState
AdamGrzybkowski 2c99833
Move onAttendanceStatusSelected to BookingDetailsViewState
AdamGrzybkowski 874459f
Adjust code after rebasing with trunk
AdamGrzybkowski d6d88ef
Adjust the spacing beteew two buttons in the booking payment section
AdamGrzybkowski 174a412
Rename the `Mark as refunded` button to `Issue refund`
AdamGrzybkowski d82dc68
Use temporary action for payment section buttons
AdamGrzybkowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
175 changes: 175 additions & 0 deletions
175
...erce/src/main/kotlin/com/woocommerce/android/ui/bookings/compose/BookingPaymentSection.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
package com.woocommerce.android.ui.bookings.compose | ||
|
||
import androidx.annotation.StringRes | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.ButtonDefaults | ||
import androidx.compose.material3.HorizontalDivider | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import androidx.compose.ui.unit.dp | ||
import com.woocommerce.android.R | ||
import com.woocommerce.android.ui.compose.component.WCColoredButton | ||
import com.woocommerce.android.ui.compose.component.WCOutlinedButton | ||
import com.woocommerce.android.ui.compose.preview.LightDarkThemePreviews | ||
import com.woocommerce.android.ui.compose.theme.WooThemeWithBackground | ||
|
||
@Composable | ||
fun BookingPaymentSection( | ||
model: BookingPaymentDetailsModel, | ||
status: BookingStatus, | ||
onMarkAsPaid: () -> Unit, | ||
onMarkAsRefunded: () -> Unit, | ||
onViewOrder: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Column(modifier = modifier) { | ||
BookingSectionHeader(R.string.booking_payment_header) | ||
HorizontalDivider(thickness = 0.5.dp) | ||
Column( | ||
modifier = Modifier | ||
.background(color = MaterialTheme.colorScheme.surfaceContainer) | ||
.padding(vertical = 16.dp) | ||
) { | ||
Column( | ||
verticalArrangement = Arrangement.spacedBy(4.dp), | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 16.dp) | ||
) { | ||
PaymentRow(label = R.string.booking_payment_label_service, value = model.service) | ||
PaymentRow(label = R.string.tax, value = model.tax) | ||
PaymentRow(label = R.string.discount, value = model.discount) | ||
PaymentRow(label = R.string.total, value = model.total, fontWeight = FontWeight.Medium) | ||
} | ||
Spacer(modifier = Modifier.height(16.dp)) | ||
HorizontalDivider( | ||
thickness = 0.5.dp, | ||
modifier = Modifier.padding(start = 16.dp) | ||
) | ||
Spacer(modifier = Modifier.height(16.dp)) | ||
// TODO Change the logic and use Order info when available | ||
if (status == BookingStatus.Paid) { | ||
WCOutlinedButton( | ||
onClick = onMarkAsRefunded, | ||
colors = ButtonDefaults.outlinedButtonColors( | ||
contentColor = MaterialTheme.colorScheme.onSurface | ||
), | ||
text = stringResource(id = R.string.orderdetail_issue_refund_button), | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 16.dp) | ||
) | ||
} else { | ||
WCColoredButton( | ||
onClick = onMarkAsPaid, | ||
text = stringResource(id = R.string.booking_payment_mark_as_paid), | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 16.dp) | ||
) | ||
} | ||
Spacer(modifier = Modifier.height(8.dp)) | ||
WCOutlinedButton( | ||
onClick = onViewOrder, | ||
colors = ButtonDefaults.outlinedButtonColors( | ||
contentColor = MaterialTheme.colorScheme.onSurface | ||
), | ||
text = stringResource(id = R.string.booking_payment_view_order), | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 16.dp) | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun PaymentRow( | ||
@StringRes label: Int, | ||
value: String, | ||
fontWeight: FontWeight = FontWeight.Normal, | ||
) { | ||
Row( | ||
horizontalArrangement = Arrangement.SpaceBetween, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
) { | ||
PaymentText(stringResource(label), fontWeight = fontWeight) | ||
PaymentText(value, modifier = Modifier.padding(start = 8.dp), fontWeight = fontWeight) | ||
} | ||
} | ||
|
||
@Composable | ||
private fun PaymentText( | ||
text: String, | ||
fontWeight: FontWeight, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Text( | ||
text = text, | ||
style = MaterialTheme.typography.bodyMedium.copy(fontWeight = fontWeight), | ||
color = MaterialTheme.colorScheme.onSurface, | ||
maxLines = 1, | ||
overflow = TextOverflow.Ellipsis, | ||
modifier = modifier | ||
) | ||
} | ||
|
||
data class BookingPaymentDetailsModel( | ||
val service: String, | ||
val tax: String, | ||
val discount: String, | ||
val total: String | ||
) | ||
irfano marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@LightDarkThemePreviews | ||
@Composable | ||
private fun BookingPaymentSectionPreview() { | ||
WooThemeWithBackground { | ||
BookingPaymentSection( | ||
model = BookingPaymentDetailsModel( | ||
service = "$55.00", | ||
tax = "$4.50", | ||
discount = "-", | ||
total = "$59.50" | ||
), | ||
status = BookingStatus.Complete, | ||
onMarkAsPaid = {}, | ||
onViewOrder = {}, | ||
onMarkAsRefunded = {}, | ||
modifier = Modifier.fillMaxWidth() | ||
) | ||
} | ||
} | ||
|
||
@LightDarkThemePreviews | ||
@Composable | ||
private fun BookingPaymentSectionWithRefundOptionPreview() { | ||
WooThemeWithBackground { | ||
BookingPaymentSection( | ||
model = BookingPaymentDetailsModel( | ||
service = "$55.00", | ||
tax = "$4.50", | ||
discount = "-", | ||
total = "$59.50" | ||
), | ||
status = BookingStatus.Paid, | ||
onMarkAsPaid = {}, | ||
onViewOrder = {}, | ||
onMarkAsRefunded = {}, | ||
modifier = Modifier.fillMaxWidth() | ||
) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.