Skip to content

Commit

Permalink
Merge pull request #42 from ronaldocoding/feature/minor-improvements-…
Browse files Browse the repository at this point in the history
…crud-user-auth

Addd minor improvements in crud-user-auth feature
  • Loading branch information
ronaldocoding authored Aug 27, 2023
2 parents 3dce314 + ccc1d78 commit 99bdd35
Show file tree
Hide file tree
Showing 25 changed files with 830 additions and 777 deletions.
4 changes: 2 additions & 2 deletions .idea/deploymentTargetDropDown.xml

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

Binary file modified app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ private fun EditAccountResumeScreen(
onValueChange = { changedValue ->
viewModel.sendAction(EditAccountAction.Action.OnTypeNameField(changedValue))
},
label = stringResource(id = R.string.name_text_field_label),
placeholder = uiModel.editNameFieldUiState.placeholder,
isError = uiModel.editNameFieldUiState.isError,
supportingText = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ private fun Cocktail() {
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Spacer(modifier = Modifier.padding(Spacing.large))
Spacer(modifier = Modifier.padding(Spacing.mediumLarge))
Image(
painter = painterResource(id = R.drawable.ic_cocktail),
painter = painterResource(id = R.drawable.ic_wine),
contentDescription = stringResource(id = R.string.cocktail_icon_description)
)
Spacer(modifier = Modifier.padding(Spacing.extraSmaller))
Expand Down Expand Up @@ -179,6 +179,7 @@ private fun LoginFields(
)
},
leadingIcon = ImageVector.vectorResource(id = R.drawable.ic_mail),
label = stringResource(id = R.string.email_text_field_label),
placeholder = stringResource(id = R.string.email_text_field_placeholder),
supportingText = {
Text(
Expand All @@ -202,6 +203,7 @@ private fun LoginFields(
)
)
},
label = stringResource(id = R.string.password_text_field_label),
placeholder = stringResource(id = R.string.password_text_field_placeholder),
supportingText = {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private fun PasswordResetInitialScreen(
viewModel: PasswordResetViewModel
) {
Column(
verticalArrangement = Arrangement.SpaceAround,
verticalArrangement = Arrangement.SpaceBetween,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxSize()
Expand All @@ -165,7 +165,8 @@ private fun PasswordResetInitialScreen(
) {
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.padding(top = Spacing.small)
) {
Image(
painter = painterResource(id = R.drawable.ic_repair),
Expand All @@ -187,6 +188,7 @@ private fun PasswordResetInitialScreen(
)
},
isError = uiModel.emailUiState.isError,
label = stringResource(id = R.string.email_text_field_label),
placeholder = stringResource(id = R.string.email_text_field_placeholder),
leadingIcon = ImageVector.vectorResource(id = R.drawable.ic_mail),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Email),
Expand All @@ -200,7 +202,7 @@ private fun PasswordResetInitialScreen(
)
ActionButton(
text = stringResource(id = R.string.send_button_label),
modifier = Modifier.padding(horizontal = Spacing.small),
modifier = Modifier.padding(Spacing.small),
onClick = {
viewModel.sendAction(PasswordResetAction.Action.OnClickSendButton)
}
Expand All @@ -224,7 +226,7 @@ fun PasswordResetLoadingScreen() {
@Composable
fun PasswordResetSuccessScreen(innerPadding: PaddingValues, viewModel: PasswordResetViewModel) {
Column(
verticalArrangement = Arrangement.SpaceAround,
verticalArrangement = Arrangement.SpaceBetween,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxSize()
Expand All @@ -233,7 +235,8 @@ fun PasswordResetSuccessScreen(innerPadding: PaddingValues, viewModel: PasswordR
) {
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.padding(top = Spacing.small)
) {
Image(
painter = painterResource(id = R.drawable.ic_coffee),
Expand All @@ -249,7 +252,7 @@ fun PasswordResetSuccessScreen(innerPadding: PaddingValues, viewModel: PasswordR
}
ActionButton(
text = stringResource(id = R.string.ok_button_label),
modifier = Modifier.padding(horizontal = Spacing.small),
modifier = Modifier.padding(Spacing.small),
onClick = {
viewModel.sendAction(PasswordResetAction.Action.OnClickOkButton)
}
Expand All @@ -260,7 +263,7 @@ fun PasswordResetSuccessScreen(innerPadding: PaddingValues, viewModel: PasswordR
@Composable
fun PasswordResetErrorScreen(innerPadding: PaddingValues, viewModel: PasswordResetViewModel) {
Column(
verticalArrangement = Arrangement.SpaceAround,
verticalArrangement = Arrangement.SpaceBetween,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxSize()
Expand All @@ -269,7 +272,8 @@ fun PasswordResetErrorScreen(innerPadding: PaddingValues, viewModel: PasswordRes
) {
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.padding(top = Spacing.small)
) {
Image(
painter = painterResource(id = R.drawable.ic_drink),
Expand All @@ -285,7 +289,7 @@ fun PasswordResetErrorScreen(innerPadding: PaddingValues, viewModel: PasswordRes
}
ActionButton(
text = stringResource(id = R.string.try_again_button_label),
modifier = Modifier.padding(horizontal = Spacing.small),
modifier = Modifier.padding(Spacing.small),
onClick = {
viewModel.sendAction(PasswordResetAction.Action.OnClickTryAgainButton)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private fun Cocktail() {
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
painter = painterResource(id = R.drawable.ic_cocktail),
painter = painterResource(id = R.drawable.ic_wine),
contentDescription = stringResource(
id = R.string.cocktail_icon_description
)
Expand Down Expand Up @@ -167,6 +167,7 @@ private fun RegisterFields(
)
},
leadingIcon = ImageVector.vectorResource(id = R.drawable.ic_user),
label = stringResource(id = R.string.name_text_field_label),
placeholder = stringResource(id = R.string.name_text_field_placeholder),
supportingText = {
Text(
Expand All @@ -188,6 +189,7 @@ private fun RegisterFields(
)
},
leadingIcon = ImageVector.vectorResource(id = R.drawable.ic_mail),
label = stringResource(id = R.string.email_text_field_label),
placeholder = stringResource(id = R.string.email_text_field_placeholder),
supportingText = {
Text(
Expand All @@ -211,6 +213,7 @@ private fun RegisterFields(
)
)
},
label = stringResource(id = R.string.password_text_field_label),
placeholder = stringResource(id = R.string.password_text_field_placeholder),
supportingText = {
Text(
Expand All @@ -231,6 +234,7 @@ private fun RegisterFields(
)
)
},
label = stringResource(id = R.string.password_confirmation_text_field_label),
placeholder = stringResource(
id = R.string.password_confirmation_text_field_placeholder
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package br.com.sommelier.ui.component

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
Expand All @@ -13,6 +17,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.vector.ImageVector
Expand All @@ -25,6 +30,7 @@ import androidx.compose.ui.tooling.preview.Preview
import br.com.sommelier.R
import br.com.sommelier.ui.theme.ColorReference
import br.com.sommelier.ui.theme.Sizing
import br.com.sommelier.ui.theme.Spacing
import br.com.sommelier.ui.theme.Typography
import br.com.sommelier.util.emptyString

Expand All @@ -35,6 +41,8 @@ fun OutlinedPasswordInput(
value: String = emptyString(),
valueStyle: TextStyle = Typography.bodyLarge,
onValueChange: (String) -> Unit = {},
label: String = emptyString(),
labelStyle: TextStyle = Typography.bodyLarge,
placeholder: String = emptyString(),
placeholderStyle: TextStyle = Typography.bodyLarge,
leadingIconContentDescription: String? = null,
Expand Down Expand Up @@ -73,72 +81,90 @@ fun OutlinedPasswordInput(
} else {
ColorReference.taupeGray
}
val labelColor = if (isError) {
ColorReference.bitterSweet
} else {
ColorReference.taupeGray
}

OutlinedTextField(
visualTransformation = if (isPasswordVisible) {
VisualTransformation.None
} else {
PasswordVisualTransformation()
},
value = value,
onValueChange = onValueChange,
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.Start,
modifier = modifier
.fillMaxWidth()
.onFocusChanged {
isTextFieldFocused = it.isFocused
}
.testTag("OutlinedPasswordInput"),
textStyle = valueStyle.copy(color = textColor),
enabled = isEnabled,
isError = isError,
singleLine = singleLine,
maxLines = maxLines,
supportingText = supportingText,
colors = TextFieldDefaults.outlinedTextFieldColors(
focusedBorderColor = ColorReference.antiFlashWhite,
unfocusedBorderColor = ColorReference.antiFlashWhite,
containerColor = containerColor,
errorBorderColor = ColorReference.seaShell,
errorCursorColor = ColorReference.bitterSweet,
errorSupportingTextColor = ColorReference.bitterSweet,
errorLeadingIconColor = ColorReference.bitterSweet
),
shape = RoundedCornerShape(Sizing.normal),
placeholder = {
Text(
text = placeholder,
style = placeholderStyle,
color = placeholderColor,
modifier = Modifier.testTag("OutlinedPasswordInputPlaceholder")
)
},
leadingIcon = {
Icon(
imageVector = ImageVector.vectorResource(id = R.drawable.ic_lock),
contentDescription = leadingIconContentDescription,
tint = lockIconColor,
modifier = Modifier.testTag("OutlinedPasswordInputLeadingIcon")
)
},
trailingIcon = {
IconButton(onClick = {
if (isPasswordVisible) {
isPasswordVisible = false
passwordEye = R.drawable.ic_opened_eye
} else {
isPasswordVisible = true
passwordEye = R.drawable.ic_closed_eye
) {
Text(
text = label,
style = labelStyle,
color = labelColor,
modifier = Modifier.testTag("OutlinedPasswordInputLabel")
)
Spacer(modifier = Modifier.padding(Spacing.smallest))
OutlinedTextField(
visualTransformation = if (isPasswordVisible) {
VisualTransformation.None
} else {
PasswordVisualTransformation()
},
value = value,
onValueChange = onValueChange,
modifier = Modifier
.fillMaxWidth()
.onFocusChanged {
isTextFieldFocused = it.isFocused
}
}) {
.testTag("OutlinedPasswordInput"),
textStyle = valueStyle.copy(color = textColor),
enabled = isEnabled,
isError = isError,
singleLine = singleLine,
maxLines = maxLines,
supportingText = supportingText,
colors = TextFieldDefaults.outlinedTextFieldColors(
focusedBorderColor = ColorReference.antiFlashWhite,
unfocusedBorderColor = ColorReference.antiFlashWhite,
containerColor = containerColor,
errorBorderColor = ColorReference.seaShell,
errorCursorColor = ColorReference.bitterSweet,
errorSupportingTextColor = ColorReference.bitterSweet,
errorLeadingIconColor = ColorReference.bitterSweet
),
shape = RoundedCornerShape(Sizing.normal),
placeholder = {
Text(
text = placeholder,
style = placeholderStyle,
color = placeholderColor,
modifier = Modifier.testTag("OutlinedPasswordInputPlaceholder")
)
},
leadingIcon = {
Icon(
imageVector = ImageVector.vectorResource(id = passwordEye),
contentDescription = "Visibility",
tint = eyeIconColor,
modifier = Modifier.testTag("OutlinedPasswordInputTrailingIcon")
imageVector = ImageVector.vectorResource(id = R.drawable.ic_lock),
contentDescription = leadingIconContentDescription,
tint = lockIconColor,
modifier = Modifier.testTag("OutlinedPasswordInputLeadingIcon")
)
},
trailingIcon = {
IconButton(onClick = {
if (isPasswordVisible) {
isPasswordVisible = false
passwordEye = R.drawable.ic_opened_eye
} else {
isPasswordVisible = true
passwordEye = R.drawable.ic_closed_eye
}
}) {
Icon(
imageVector = ImageVector.vectorResource(id = passwordEye),
contentDescription = "Visibility",
tint = eyeIconColor,
modifier = Modifier.testTag("OutlinedPasswordInputTrailingIcon")
)
}
}
}
)
)
}
}

@Preview(showBackground = true)
Expand Down
Loading

0 comments on commit 99bdd35

Please sign in to comment.