-
Notifications
You must be signed in to change notification settings - Fork 136
[Woo POS] Adapt the UI to be usable on smaller devices #11940
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
kidinov
merged 15 commits into
trunk
from
11937-woo-pos-adapt-the-ui-to-be-usable-on-smaller-devices
Jul 12, 2024
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
482931a
Preview to simualte min supported device size
kidinov 91ec0e5
Simulate home screen situation for the cart
kidinov 3512308
Cart adopted for nerow screens
kidinov b1af679
Adaptive margisn for home screen
kidinov a901362
Fixed items showing on the totals screen
kidinov 5920f74
Adaptive margins to the totals screen
kidinov a801070
Adaptive margins to the cart screen
kidinov bbc0790
Adaptive margins to the payment success screen
kidinov 0a2fd63
Removed adaptive margin from the icon size
kidinov 63489a8
Adaptive padding to the toolbar
kidinov de9ff71
Fixed formatting
kidinov 6baaf09
Merge branch 'refs/heads/11895-woo-pos-entry-point-eligibility-condit…
kidinov 0ad2907
Merge branch 'refs/heads/11895-woo-pos-entry-point-eligibility-condit…
kidinov 1c4591d
Merge branch '11895-woo-pos-entry-point-eligibility-conditions-improv…
backwardstruck ca81f37
Merge branch 'trunk' into 11937-woo-pos-adapt-the-ui-to-be-usable-on-…
kidinov 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
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
35 changes: 35 additions & 0 deletions
35
...ommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/common/composeui/WooPosSizes.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,35 @@ | ||
| package com.woocommerce.android.ui.woopos.common.composeui | ||
|
|
||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.platform.LocalContext | ||
| import androidx.compose.ui.unit.Dp | ||
| import androidx.compose.ui.unit.dp | ||
| import com.woocommerce.android.ui.woopos.util.ext.getLongestScreenSideDp | ||
|
|
||
| @Composable | ||
| fun Dp.toAdaptivePadding(): Dp { | ||
| val longestSide = LocalContext.current.getLongestScreenSideDp() | ||
| return when { | ||
| longestSide < 880.dp -> { | ||
| val calculatedMargin = this * 0.5f | ||
| calculatedMargin.makeDividableByFour() | ||
| } | ||
|
|
||
| longestSide < 1200.dp -> { | ||
| val calculatedMargin = this * 0.75f | ||
| calculatedMargin.makeDividableByFour() | ||
| } | ||
|
|
||
| else -> this | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun Dp.makeDividableByFour(): Dp { | ||
| val remainder = this.value % 4 | ||
| return if (remainder == 0f) { | ||
| this | ||
| } else { | ||
| this + (4 - remainder).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
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.
Nice way to ensure padding is adjusted based on screen size.
Uh oh!
There was an error while loading. Please reload this page.
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.
@samiuelson wdyt about this approach? That's kinda naive, but it seems to be working
Also, if we go with this, we should not forget to use that on all the paddings