-
Notifications
You must be signed in to change notification settings - Fork 133
[POS Orders] Empty and Error states #14695
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
Open
toupper
wants to merge
13
commits into
trunk
Choose a base branch
from
feat/WOOMOB-1149-pos-historical-orders-list-error
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
53f267d
Add error screen and retry logic
toupper 5698bc9
Make error view full screen
toupper a1fc60b
Add empty state screen
toupper c88d5cd
Remove non necessary parameter
toupper 51b2c06
Add toolbar also for Error screen and refactor code
toupper e3281f7
Adjust button width
toupper f4b1c8b
Better formatting
toupper 0207015
Keep detekt happy
toupper 70e150e
Add unit test
toupper 3c3b5f4
Add a shared modifier
toupper 2aec62a
Improve state handling and simplify composables
toupper 483857a
Fix detekt
toupper 189e0a4
Extract the empty screen state to the components and better naming
toupper 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
558 changes: 558 additions & 0 deletions
558
Add_WooPosEmptyScreen_component_and_refactor_empty_list_handling.patch
Large diffs are not rendered by default.
Oops, something went wrong.
133 changes: 133 additions & 0 deletions
133
.../kotlin/com/woocommerce/android/ui/woopos/common/composeui/component/WooPosEmptyScreen.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,133 @@ | ||
package com.woocommerce.android.ui.woopos.common.composeui.component | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.rememberScrollState | ||
import androidx.compose.foundation.verticalScroll | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.painter.Painter | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.unit.dp | ||
import com.woocommerce.android.R | ||
import com.woocommerce.android.ui.woopos.common.composeui.WooPosPreview | ||
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 | ||
import com.woocommerce.android.ui.woopos.common.composeui.designsystem.toAdaptivePadding | ||
|
||
@Composable | ||
fun WooPosEmptyScreen( | ||
modifier: Modifier = Modifier, | ||
title: String, | ||
message: String, | ||
contentDescription: String, | ||
icon: Painter = painterResource(R.drawable.ic_woo_pos_not_found), | ||
) { | ||
WooPosItemsEmptyListInternal( | ||
modifier = modifier, | ||
title = title, | ||
message = message, | ||
contentDescription = contentDescription, | ||
icon = icon, | ||
actionLabel = null, | ||
onActionClicked = null | ||
) | ||
} | ||
|
||
@Composable | ||
fun WooPosEmptyScreen( | ||
modifier: Modifier = Modifier, | ||
title: String, | ||
message: String, | ||
contentDescription: String, | ||
icon: Painter = painterResource(R.drawable.ic_woo_pos_not_found), | ||
actionLabel: String, | ||
onActionClicked: (() -> Unit), | ||
) { | ||
WooPosItemsEmptyListInternal( | ||
modifier = modifier, | ||
title = title, | ||
message = message, | ||
contentDescription = contentDescription, | ||
icon = icon, | ||
actionLabel = actionLabel, | ||
onActionClicked = onActionClicked | ||
) | ||
} | ||
|
||
@Composable | ||
private fun WooPosItemsEmptyListInternal( | ||
modifier: Modifier = Modifier, | ||
title: String, | ||
message: String, | ||
contentDescription: String, | ||
icon: Painter = painterResource(R.drawable.ic_woo_pos_not_found), | ||
actionLabel: String?, | ||
onActionClicked: (() -> Unit)? = null, | ||
) { | ||
Box( | ||
modifier = modifier.verticalScroll(rememberScrollState()), | ||
contentAlignment = Alignment.Center | ||
) { | ||
Column( | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
verticalArrangement = Arrangement.Center | ||
) { | ||
Image( | ||
modifier = Modifier.size(148.dp), | ||
painter = icon, | ||
contentDescription = contentDescription, | ||
) | ||
|
||
Spacer(modifier = Modifier.height(WooPosSpacing.XLarge.value.toAdaptivePadding())) | ||
|
||
WooPosText( | ||
text = title, | ||
style = WooPosTypography.Heading, | ||
fontWeight = FontWeight.Bold, | ||
) | ||
|
||
Spacer(modifier = Modifier.height(WooPosSpacing.Medium.value.toAdaptivePadding())) | ||
|
||
WooPosText( | ||
text = message, | ||
style = WooPosTypography.BodyLarge, | ||
fontWeight = FontWeight.Normal, | ||
textAlign = TextAlign.Center | ||
) | ||
|
||
Spacer(modifier = Modifier.height(WooPosSpacing.XLarge.value.toAdaptivePadding())) | ||
|
||
if (onActionClicked != null && actionLabel != null) { | ||
WooPosButton( | ||
text = actionLabel, | ||
onClick = onActionClicked, | ||
modifier = WooPosErrorAndEmptyStateButtonModifier | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@WooPosPreview | ||
@Composable | ||
fun WooPosEmptyScreenPreview() { | ||
WooPosTheme { | ||
WooPosEmptyScreen( | ||
modifier = Modifier.fillMaxSize(), | ||
title = "Empty List", | ||
message = "This list is empty", | ||
contentDescription = "" | ||
) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...ce/android/ui/woopos/common/composeui/component/WooPosErrorAndEmptyStateButtonModifier.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,10 @@ | ||
package com.woocommerce.android.ui.woopos.common.composeui.component | ||
|
||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
|
||
val WooPosErrorAndEmptyStateButtonModifier = Modifier | ||
.fillMaxWidth(0.3f) | ||
.height(80.dp) |
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
Oops, something went wrong.
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.
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.
@kidinov In this case (and in the empty state), the button has a narrower width in the design. Let me know if you have a better idea for how to adapt it.
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.
That changes the state on all 11 places where this component is used. If this is what Wagner's idea was, then it's fine. Overall, I think it looks ok
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.
We might want to extract that constant so that changing the width will only require one change. This is because both buttons must have the same width
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.
Good idea, I created a shared modifier here 3c3b5f4
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.
Note, make it more specific by not calling it just Button