-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from hieuwu/compose-migration-p2
Migrate sign in and sign up screen
- Loading branch information
Showing
19 changed files
with
587 additions
and
556 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
77 changes: 0 additions & 77 deletions
77
app/src/main/java/com/hieuwu/groceriesstore/presentation/authentication/SignInFragment.kt
This file was deleted.
Oops, something went wrong.
71 changes: 0 additions & 71 deletions
71
app/src/main/java/com/hieuwu/groceriesstore/presentation/authentication/SignInViewModel.kt
This file was deleted.
Oops, something went wrong.
61 changes: 0 additions & 61 deletions
61
app/src/main/java/com/hieuwu/groceriesstore/presentation/authentication/SignUpFragment.kt
This file was deleted.
Oops, something went wrong.
55 changes: 0 additions & 55 deletions
55
app/src/main/java/com/hieuwu/groceriesstore/presentation/authentication/SignUpViewModel.kt
This file was deleted.
Oops, something went wrong.
86 changes: 86 additions & 0 deletions
86
...n/java/com/hieuwu/groceriesstore/presentation/authentication/composables/IconTextInput.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.hieuwu.groceriesstore.presentation.authentication.composables | ||
|
||
import androidx.compose.foundation.BorderStroke | ||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.foundation.text.KeyboardOptions | ||
import androidx.compose.material.Text | ||
import androidx.compose.material.TextField | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Email | ||
import androidx.compose.material.icons.rounded.Backspace | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.res.colorResource | ||
import androidx.compose.ui.text.input.KeyboardType | ||
import androidx.compose.ui.text.input.VisualTransformation | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.hieuwu.groceriesstore.R | ||
|
||
@Composable | ||
fun IconTextInput( | ||
leadingIcon: ImageVector, | ||
trailingIcon: ImageVector, | ||
modifier: Modifier = Modifier, | ||
value: String, | ||
placeholder: String, | ||
type: KeyboardType = KeyboardType.Email, | ||
visualTransformation: VisualTransformation = VisualTransformation.None, | ||
onValueChange: (String) -> Unit, | ||
onTrailingIconClick: () -> Unit | ||
) { | ||
TextField( | ||
keyboardOptions = KeyboardOptions(keyboardType = type), | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.border( | ||
border = BorderStroke( | ||
width = 1.dp, | ||
color = colorResource(id = R.color.colorPrimary), | ||
|
||
), | ||
shape = RoundedCornerShape(6.dp) | ||
), | ||
value = value, | ||
onValueChange = { text -> onValueChange(text) }, | ||
visualTransformation = visualTransformation, | ||
leadingIcon = { | ||
Icon( | ||
imageVector = leadingIcon, | ||
contentDescription = null, | ||
tint = colorResource(id = R.color.primary_button) | ||
) | ||
}, | ||
trailingIcon = { | ||
Icon( | ||
modifier = modifier.clickable { | ||
onTrailingIconClick() | ||
}, | ||
imageVector = trailingIcon, | ||
contentDescription = null, | ||
tint = Color.DarkGray | ||
) | ||
}, | ||
placeholder = { | ||
Text(text = placeholder, color = colorResource(id = R.color.colorPrimary)) | ||
}) | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun IconTextInputPreview() { | ||
IconTextInput( | ||
leadingIcon = Icons.Filled.Email, | ||
trailingIcon = Icons.Rounded.Backspace, | ||
value = "Please input your email", | ||
placeholder = "", | ||
onTrailingIconClick = {}, | ||
onValueChange = {} | ||
) | ||
} |
Oops, something went wrong.