Skip to content

Commit

Permalink
Merge pull request #182 from hieuwu/compose-migration-p2
Browse files Browse the repository at this point in the history
Migrate sign in and sign up screen
  • Loading branch information
hieuwu committed Oct 1, 2023
2 parents d714baa + f9eea07 commit d539e86
Show file tree
Hide file tree
Showing 19 changed files with 587 additions and 556 deletions.
2 changes: 0 additions & 2 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

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 = {}
)
}
Loading

0 comments on commit d539e86

Please sign in to comment.