-
Notifications
You must be signed in to change notification settings - Fork 137
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
[Woo POS][Cash & Receipts] Implement receipts UI #13123
Open
kidinov
wants to merge
19
commits into
13106-woo-poscash-receipts-implement-navigation-via-nav-component-to-the-full-receipts-sending-screen
Choose a base branch
from
13117-woo-poscash-receipts-implement-receipts-ui
base: 13106-woo-poscash-receipts-implement-navigation-via-nav-component-to-the-full-receipts-sending-screen
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 13 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
6becc7f
Extracted toolbar in a component
kidinov 943c4c5
Merge branch '13106-woo-poscash-receipts-implement-navigation-via-nav…
kidinov 3a2a88c
Use extracted toolbar on the receipts screen
kidinov c46479f
Somewhat similar to the text field from the design
kidinov 4134532
UI that looks like the design
kidinov a0bd1ab
Handle email change logic
kidinov 6272567
Sending email VM logic
kidinov c36950f
Show keyboard, request focus
kidinov c9ce785
Keyboard type email
kidinov e17a9d4
Disable autocorrection
kidinov dfd0676
Outline color has transparent background now
kidinov 75a3898
Outline color has transparent background now
kidinov 4a04efb
Fixed formatting
kidinov 4968e9f
Workaround to keep cursor to the left when label is visible
kidinov be18ca8
Correct color for cursor
kidinov 7e7917d
Fixed formatting
kidinov 5f987f6
Refactor repositry to make it unit testable
kidinov 04aed4f
Fixed and added missing tests
kidinov f089bd9
Vm tests
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 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 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 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 |
---|---|---|
@@ -1,10 +1,15 @@ | ||
package com.woocommerce.android.ui.woopos.common.composeui.component | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.interaction.MutableInteractionSource | ||
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.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.text.BasicTextField | ||
import androidx.compose.foundation.text.KeyboardActions | ||
import androidx.compose.foundation.text.KeyboardOptions | ||
import androidx.compose.material.MaterialTheme | ||
|
@@ -13,8 +18,10 @@ | |
import androidx.compose.material.TextFieldDefaults | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.input.VisualTransformation | ||
import androidx.compose.ui.text.style.TextAlign | ||
|
@@ -92,9 +99,50 @@ | |
} | ||
} | ||
|
||
@Composable | ||
fun WooPosInputField( | ||
value: String, | ||
onValueChange: (String) -> Unit, | ||
label: String = "", | ||
textStyle: TextStyle = MaterialTheme.typography.h6, | ||
textColor: Color = MaterialTheme.colors.onBackground, | ||
keyboardOptions: KeyboardOptions = KeyboardOptions.Default, | ||
keyboardActions: KeyboardActions = KeyboardActions.Default, | ||
contentAlignment: Alignment = Alignment.CenterStart, | ||
modifier: Modifier = Modifier, | ||
) { | ||
BasicTextField( | ||
value = value, | ||
onValueChange = onValueChange, | ||
textStyle = textStyle.copy(color = textColor), | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.background(Color.Transparent), | ||
singleLine = true, | ||
decorationBox = { innerTextField -> | ||
Box( | ||
modifier = Modifier | ||
.padding(horizontal = 8.dp), | ||
contentAlignment = contentAlignment | ||
) { | ||
if (value.isEmpty()) { | ||
Text( | ||
text = label, | ||
style = textStyle.copy(color = textColor.copy(alpha = 0.2f)), | ||
) | ||
} | ||
|
||
innerTextField() | ||
} | ||
}, | ||
keyboardActions = keyboardActions, | ||
keyboardOptions = keyboardOptions | ||
) | ||
} | ||
|
||
@WooPosPreview | ||
@Composable | ||
fun WooPosInputFieldPreview() { | ||
fun WooPosTypedInputFieldPreview() { | ||
WooPosTheme { | ||
Column(modifier = Modifier.padding(16.dp)) { | ||
WooPosTypedInputField( | ||
|
@@ -125,3 +173,32 @@ | |
} | ||
} | ||
} | ||
|
||
@WooPosPreview | ||
@Composable | ||
fun WooPosInputFieldPreview() { | ||
WooPosTheme { | ||
Column( | ||
modifier = Modifier | ||
.padding(16.dp) | ||
.fillMaxSize(), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
) { | ||
WooPosInputField( | ||
value = "[email protected]", | ||
onValueChange = {}, | ||
textStyle = MaterialTheme.typography.h3, | ||
contentAlignment = Alignment.Center | ||
) | ||
|
||
Spacer(modifier = Modifier.size(8.dp)) | ||
|
||
WooPosInputField( | ||
value = "", | ||
onValueChange = {}, | ||
textStyle = MaterialTheme.typography.h3, | ||
label = "Label", | ||
) | ||
} | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
...main/kotlin/com/woocommerce/android/ui/woopos/common/composeui/component/WooPosToolbar.kt
This file contains 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,86 @@ | ||
package com.woocommerce.android.ui.woopos.common.composeui.component | ||
|
||
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.foundation.layout.size | ||
import androidx.compose.material.Icon | ||
import androidx.compose.material.IconButton | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.res.vectorResource | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.dp | ||
import androidx.constraintlayout.compose.ConstraintLayout | ||
import com.woocommerce.android.R | ||
import com.woocommerce.android.ui.woopos.common.composeui.WooPosPreview | ||
import com.woocommerce.android.ui.woopos.common.composeui.WooPosTheme | ||
import com.woocommerce.android.ui.woopos.common.composeui.toAdaptivePadding | ||
|
||
@Composable | ||
fun WooPosToolbar( | ||
titleText: String, | ||
onBackClicked: () -> Unit | ||
) { | ||
ConstraintLayout( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(top = 40.dp.toAdaptivePadding()) | ||
.height(40.dp) | ||
) { | ||
val (backButton, title) = createRefs() | ||
IconButton( | ||
onClick = { onBackClicked() }, | ||
modifier = Modifier | ||
.constrainAs(backButton) { | ||
start.linkTo(parent.start) | ||
top.linkTo(parent.top) | ||
centerVerticallyTo(parent) | ||
} | ||
.padding(start = 8.dp.toAdaptivePadding()) | ||
) { | ||
Icon( | ||
imageVector = ImageVector.vectorResource(R.drawable.ic_back_24dp), | ||
contentDescription = stringResource(R.string.woopos_toolbar_icon_content_description), | ||
tint = MaterialTheme.colors.onBackground, | ||
modifier = Modifier.size(28.dp) | ||
) | ||
} | ||
|
||
val iconTitlePadding = 8.dp.toAdaptivePadding() | ||
Text( | ||
text = titleText, | ||
style = MaterialTheme.typography.h4, | ||
color = MaterialTheme.colors.onBackground, | ||
fontWeight = FontWeight.Bold, | ||
maxLines = 1, | ||
modifier = Modifier | ||
.constrainAs(title) { | ||
top.linkTo(backButton.top) | ||
start.linkTo(backButton.end, margin = iconTitlePadding) | ||
centerVerticallyTo(parent) | ||
} | ||
) | ||
} | ||
} | ||
|
||
@WooPosPreview | ||
@Composable | ||
fun WooPosToolbarPreview() { | ||
WooPosTheme { | ||
Column { | ||
WooPosToolbar( | ||
titleText = "Title", | ||
onBackClicked = { } | ||
) | ||
|
||
Spacer(modifier = Modifier.weight(1f)) | ||
} | ||
} | ||
} |
This file contains 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.
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.
Check warning
Code scanning / Android Lint
Guidelines for Modifier parameters in a Composable function Warning