-
Notifications
You must be signed in to change notification settings - Fork 136
[Woo POS][Refunds] Add Issue Refund button #15024
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
base: pos-orders-fix-status-bar-handling
Are you sure you want to change the base?
Changes from 1 commit
d5f7e8b
07b4c38
59fdd82
b832c4d
f41a4ac
f2cf1bc
2001de8
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 |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| package com.woocommerce.android.ui.woopos.orders | ||
|
|
||
| import androidx.compose.foundation.layout.Column | ||
| 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.material.icons.Icons | ||
| import androidx.compose.material.icons.filled.Close | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.IconButton | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.text.font.FontWeight | ||
| import com.woocommerce.android.R | ||
| import com.woocommerce.android.ui.woopos.common.composeui.WooPosPreview | ||
| import com.woocommerce.android.ui.woopos.common.composeui.component.WooPosDialogWrapper | ||
| import com.woocommerce.android.ui.woopos.common.composeui.component.WooPosText | ||
| import com.woocommerce.android.ui.woopos.common.composeui.designsystem.WooPosSpacing | ||
| import com.woocommerce.android.ui.woopos.common.composeui.designsystem.WooPosTheme | ||
| import com.woocommerce.android.ui.woopos.common.composeui.designsystem.WooPosTypography | ||
|
|
||
| @Composable | ||
| fun WooPosIssueRefundDialog( | ||
| isVisible: Boolean, | ||
| orderId: Long, | ||
| onDismissRequest: () -> Unit | ||
| ) { | ||
| WooPosDialogWrapper( | ||
| isVisible = isVisible, | ||
| dialogBackgroundContentDescription = stringResource( | ||
| R.string.woopos_orders_issue_refund_content_description | ||
| ), | ||
| onDismissRequest = onDismissRequest | ||
| ) { | ||
| Column( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .padding(WooPosSpacing.Large.value), | ||
| horizontalAlignment = Alignment.CenterHorizontally | ||
| ) { | ||
| IconButton( | ||
| onClick = onDismissRequest, | ||
| modifier = Modifier.align(Alignment.End) | ||
| ) { | ||
| Icon( | ||
| imageVector = Icons.Default.Close, | ||
| contentDescription = stringResource(R.string.close), | ||
| tint = MaterialTheme.colorScheme.onSurface | ||
| ) | ||
| } | ||
|
|
||
| Spacer(Modifier.height(WooPosSpacing.Medium.value)) | ||
|
|
||
| WooPosText( | ||
| text = stringResource(R.string.orderdetail_issue_refund_button), | ||
| style = WooPosTypography.Heading, | ||
| fontWeight = FontWeight.Bold, | ||
| color = MaterialTheme.colorScheme.onSurface | ||
| ) | ||
|
|
||
| Spacer(Modifier.height(WooPosSpacing.Large.value)) | ||
|
|
||
| WooPosText( | ||
| text = "Refund flow coming soon for order #$orderId", | ||
| style = WooPosTypography.BodyMedium, | ||
| color = WooPosTheme.colors.onSurfaceVariantHighest | ||
| ) | ||
|
|
||
| Spacer(Modifier.height(WooPosSpacing.Large.value)) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @WooPosPreview | ||
| @Composable | ||
| fun WooPosIssueRefundDialogPreview() { | ||
| WooPosTheme { | ||
| WooPosIssueRefundDialog( | ||
| isVisible = true, | ||
| orderId = 123L, | ||
| onDismissRequest = {} | ||
| ) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| package com.woocommerce.android.ui.woopos.orders | ||
|
|
||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.Spacer | ||
|
|
@@ -16,9 +17,18 @@ import androidx.compose.foundation.shape.RoundedCornerShape | |
| import androidx.compose.foundation.verticalScroll | ||
| import androidx.compose.material.icons.Icons | ||
| import androidx.compose.material.icons.outlined.Inventory2 | ||
| import androidx.compose.material.icons.outlined.MoreVert | ||
| import androidx.compose.material3.DropdownMenu | ||
| import androidx.compose.material3.DropdownMenuItem | ||
| import androidx.compose.material3.HorizontalDivider | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.IconButton | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.mutableStateOf | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.runtime.setValue | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.draw.clip | ||
|
|
@@ -43,7 +53,8 @@ import com.woocommerce.android.ui.woopos.common.composeui.designsystem.WooPosTyp | |
| fun WooPosOrderDetails( | ||
| modifier: Modifier = Modifier, | ||
| details: OrderDetailsViewState.Computed.Details, | ||
| onEmailReceiptButtonClicked: (Long) -> Unit | ||
| onEmailReceiptButtonClicked: (Long) -> Unit, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if it's the final state or still WIP, but this is not something that is driven by the VM as you have to pass hardcoded click listeners here and everywhere instead of calling one |
||
| onIssueRefundButtonClicked: (Long) -> Unit | ||
| ) { | ||
| Column( | ||
| modifier = modifier | ||
|
|
@@ -53,7 +64,6 @@ fun WooPosOrderDetails( | |
| .padding( | ||
| start = WooPosSpacing.Medium.value, | ||
| end = WooPosSpacing.Medium.value, | ||
| top = WooPosSpacing.XLarge.value, | ||
| bottom = WooPosSpacing.XLarge.value | ||
| ) | ||
| ) { | ||
|
|
@@ -70,8 +80,15 @@ fun WooPosOrderDetails( | |
| Spacer(Modifier.weight(1f)) | ||
|
|
||
| WooPosButtonSmall( | ||
| text = stringResource(R.string.woopos_orders_email_receipt), | ||
| onClick = { onEmailReceiptButtonClicked(details.id) }, | ||
| text = stringResource(R.string.orderdetail_issue_refund_button), | ||
| onClick = { onIssueRefundButtonClicked(details.id) }, | ||
| ) | ||
|
|
||
| Spacer(Modifier.width(WooPosSpacing.Small.value)) | ||
|
|
||
| OrderDetailsOverflowMenu( | ||
| orderId = details.id, | ||
| onEmailReceiptClicked = onEmailReceiptButtonClicked | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -333,6 +350,42 @@ private fun DividerWithSpacing() { | |
| Spacer(Modifier.height(WooPosSpacing.Medium.value)) | ||
| } | ||
|
|
||
| @Composable | ||
| private fun OrderDetailsOverflowMenu( | ||
| orderId: Long, | ||
| onEmailReceiptClicked: (Long) -> Unit | ||
| ) { | ||
| var showMenu by remember { mutableStateOf(false) } | ||
|
|
||
| Box { | ||
| IconButton(onClick = { showMenu = true }) { | ||
| Icon( | ||
| imageVector = Icons.Outlined.MoreVert, | ||
| contentDescription = stringResource(R.string.more_menu), | ||
| tint = MaterialTheme.colorScheme.onSurface | ||
| ) | ||
| } | ||
|
|
||
| DropdownMenu( | ||
| expanded = showMenu, | ||
| onDismissRequest = { showMenu = false } | ||
| ) { | ||
| DropdownMenuItem( | ||
| text = { | ||
| WooPosText( | ||
| text = stringResource(R.string.woopos_orders_email_receipt), | ||
| style = WooPosTypography.BodyMedium | ||
| ) | ||
| }, | ||
| onClick = { | ||
| showMenu = false | ||
| onEmailReceiptClicked(orderId) | ||
| } | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @WooPosPreview | ||
| @Composable | ||
| fun WooPosOrderDetailsPreview() { | ||
|
|
@@ -371,7 +424,8 @@ fun WooPosOrderDetailsPreview() { | |
| WooPosTheme { | ||
| WooPosOrderDetails( | ||
| details = orderDetails, | ||
| onEmailReceiptButtonClicked = {} | ||
| onEmailReceiptButtonClicked = {}, | ||
| onIssueRefundButtonClicked = {} | ||
| ) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.