Skip to content
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

Migrate sign in and sign up screen #182

Merged
merged 27 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading