Skip to content

Commit

Permalink
Merge pull request #51 from PetJournal/fix/fix-gender-screen
Browse files Browse the repository at this point in the history
Added NameGenderScreen
  • Loading branch information
gusoliveira21 authored Feb 4, 2024
2 parents cb82167 + 4d31aec commit a4d63ae
Show file tree
Hide file tree
Showing 53 changed files with 2,539 additions and 829 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import com.soujunior.petjournal.ui.appArea.home.homeScreen.HomeScreenViewModel
import com.soujunior.petjournal.ui.appArea.home.homeScreen.HomeScreenViewModelImpl
import com.soujunior.petjournal.ui.appArea.pets.introRegisterPetScreen.IntroIntroRegisterPetViewModelImpl
import com.soujunior.petjournal.ui.appArea.pets.introRegisterPetScreen.IntroRegisterPetViewModel
import com.soujunior.petjournal.ui.appArea.pets.petNameAndGenderScreen.ViewModelNameGender
import com.soujunior.petjournal.ui.appArea.pets.petNameAndGenderScreen.ViewModelNameGenderImpl
import com.soujunior.petjournal.ui.appArea.pets.speciesChoiceScreen.ViewModelChoiceSpecies
import com.soujunior.petjournal.ui.appArea.pets.speciesChoiceScreen.ViewModelChoiceSpeciesImpl
import com.soujunior.petjournal.ui.apresentation.splashScreen.SplashViewModel
Expand Down Expand Up @@ -118,4 +120,5 @@ val mainModule = module {
viewModel<ChangePasswordViewModel> { ChangePasswordViewModelImpl(get(), get()) }
viewModel { SplashViewModel(get()) }
viewModel<ViewModelChoiceSpecies> { ViewModelChoiceSpeciesImpl(get(), get()) }
viewModel<ViewModelNameGender> {ViewModelNameGenderImpl(get())}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.soujunior.petjournal.ui.accountManager.awaitingCodeScreen.components
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -12,7 +11,6 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.soujunior.petjournal.ui.components.CreateTitleAndImageLogo
import com.soujunior.petjournal.ui.components.ImageLogo

@Composable
fun Header() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,129 @@
package com.soujunior.petjournal.ui.accountManager.awaitingCodeScreen.components

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.soujunior.petjournal.ui.accountManager.awaitingCodeScreen.AwaitingCodeFormEvent
import com.soujunior.petjournal.ui.accountManager.awaitingCodeScreen.AwaitingCodeViewModel
import com.soujunior.petjournal.ui.components.Button2
import com.soujunior.petjournal.ui.components.CreateTitleAndImageLogo
import com.soujunior.petjournal.ui.states.TaskState
import com.soujunior.petjournal.ui.theme.FredokaRegular

@Composable
fun Screen(navController: NavController, viewModel: AwaitingCodeViewModel) {
Box(modifier = Modifier.navigationBarsPadding().background(MaterialTheme.colorScheme.background)){
val buttonIsEnable by viewModel.buttonIsEnable.collectAsState()
val taskState by viewModel.taskState.collectAsState()
val systemUiController = rememberSystemUiController()
systemUiController.setSystemBarsColor(color = Color.Transparent, darkIcons = true)
systemUiController.setNavigationBarColor(Color.Black)
val state by viewModel.state.collectAsState()
val resendCodeStyle = TextStyle(
fontFamily = FontFamily(FredokaRegular),
fontSize = 14.sp,
textDecoration = TextDecoration.Underline,
)
Box(
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colorScheme.background)
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Top,
modifier = Modifier
.navigationBarsPadding()
.clip(RoundedCornerShape(topStart = 30.dp, topEnd = 30.dp))
.padding(horizontal = 16.dp)
.padding(top = 32.dp)
.background(MaterialTheme.colorScheme.background),
.padding(top = 32.dp),
content = {
Header()
VerificationCodeInput(viewModel)
Footer(navController, viewModel)
Spacer(modifier = Modifier.weight(0.1f))
CreateTitleAndImageLogo(
title = "Acabamos de enviar um código para seu e-mail",
spaceBetween = 16.dp,
textAlign = TextAlign.Center
)
Spacer(modifier = Modifier.weight(0.1f))
Text(
text = "Insira no campo abaixo o código de verificação de 6 digitos enviado para o seu email.",
style = MaterialTheme.typography.titleLarge,
textAlign = TextAlign.Center,
color = if (isSystemInDarkTheme()) MaterialTheme.colorScheme.primary else Color.Unspecified
)
Spacer(modifier = Modifier.weight(0.1f))

OTPTextField(
textValue = state.codeOTP,
onEvent = { code: String ->
viewModel.onEvent(AwaitingCodeFormEvent.CodeOTPChanged(code))
},
textError = state.codeOTPError
)
Box(
modifier = Modifier
.padding(top = 10.dp, end = 14.5.dp)
.fillMaxWidth(),
contentAlignment = Alignment.CenterEnd
) {
Text(
text = "Reenviar código?",
style = resendCodeStyle,
color = if (isSystemInDarkTheme()) MaterialTheme.colorScheme.primary else Color.Unspecified,
modifier = Modifier.clickable {
viewModel.onEvent(AwaitingCodeFormEvent.ResendCode)
}
)
}

Spacer(modifier = Modifier.weight(0.1f))
Button2(
text = "Enviar",
border = null,
submit = { viewModel.onEvent(AwaitingCodeFormEvent.Submit) },
enableButton = buttonIsEnable,
modifier = Modifier.size(height = 50.dp, width = 240.dp),
buttonColor = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.primary
),
isLoading = taskState is TaskState.Loading
)
Spacer(modifier = Modifier.weight(0.1f))
Text(
text = "Dica: Caso não encontre o e-mail na sua caixa de entrada, verifique a pasta de Spam!",
style = MaterialTheme.typography.titleLarge,
textAlign = TextAlign.Center,
color = if (isSystemInDarkTheme()) MaterialTheme.colorScheme.primary else Color.Unspecified
)
Spacer(modifier = Modifier.weight(0.1f))

}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import com.soujunior.petjournal.ui.theme.FredokaRegular
@Composable
fun VerificationCodeInput(viewModel: AwaitingCodeViewModel) {
val state by viewModel.state.collectAsState()

val resendCodeStyle = TextStyle(
fontFamily = FontFamily(FredokaRegular),
fontSize = 14.sp,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.soujunior.petjournal.ui.accountManager.changePasswordScreen

import android.util.Log
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
Expand All @@ -9,8 +8,8 @@ import com.soujunior.domain.model.request.ChangePasswordModel
import com.soujunior.domain.repository.ValidationRepository
import com.soujunior.domain.use_case.auth.ChangePasswordUseCase
import com.soujunior.domain.use_case.util.ValidationResult
import com.soujunior.petjournal.ui.util.ValidationEvent
import com.soujunior.petjournal.ui.states.TaskState
import com.soujunior.petjournal.ui.util.ValidationEvent
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
Expand Down Expand Up @@ -76,6 +75,7 @@ class ChangePasswordViewModelImpl(
if (hasError(passwordResult)) state.copy(passwordError = passwordResult.errorMessage)
else state.copy(passwordError = null)
change(repeatedPassword = state.repeatedPassword)

}

repeatedPassword != null -> {
Expand All @@ -99,17 +99,14 @@ class ChangePasswordViewModelImpl(
when (event) {
is ChangePasswordFormEvent.PasswordChanged -> {
change(password = event.password)
Log.e("testar", "${state.password}")
}

is ChangePasswordFormEvent.ConfirmPasswordChanged -> {
change(repeatedPassword = event.confirmPassword)
Log.e("testar", "${state.repeatedPassword}")
}

is ChangePasswordFormEvent.DisconnectOtherDevices -> {
change(disconnect = event.disconnect)
Log.e("testar", "${state.disconnectOtherDevices}")
}

is ChangePasswordFormEvent.Submit -> submitNewPassword()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,79 @@
package com.soujunior.petjournal.ui.accountManager.changePasswordScreen.components

import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.layout.size
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.soujunior.petjournal.R
import com.soujunior.petjournal.ui.accountManager.changePasswordScreen.ChangePasswordFormEvent
import com.soujunior.petjournal.ui.accountManager.changePasswordScreen.ChangePasswordViewModel
import com.soujunior.petjournal.ui.components.Button2
import com.soujunior.petjournal.ui.components.CheckboxWithText
import com.soujunior.petjournal.ui.components.CreateTitleAndImageLogo
import com.soujunior.petjournal.ui.components.ImageLogo
import com.soujunior.petjournal.ui.components.InputText
import com.soujunior.petjournal.ui.states.TaskState

@Composable
fun Screen(
viewModel: ChangePasswordViewModel
) {
fun Screen(viewModel: ChangePasswordViewModel) {
val taskState by viewModel.taskState.collectAsState()
val systemUiController = rememberSystemUiController()
systemUiController.setSystemBarsColor(color = Color.Transparent, darkIcons = true)
systemUiController.setNavigationBarColor(Color.Black)

Box(modifier = Modifier.fillMaxWidth()) {
LazyColumn(
modifier = Modifier
.fillMaxHeight()
.fillMaxWidth()
.padding(start = 20.dp, end = 20.dp),
) {
item {
CreateTitleAndImageLogo(
title = stringResource(id = R.string.change_password_title),
styleTitle = MaterialTheme.typography.displayMedium,
spaceTop = 60.dp,
spaceBetween = 40.dp,
spaceBottom = 30.dp
Box(
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colorScheme.background)
) {
Column(modifier = Modifier.padding(start = 20.dp, end = 20.dp)) {
Spacer(modifier = Modifier.weight(0.1f))

Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center,
modifier = Modifier.fillMaxWidth()
) {
ImageLogo(
modifier = Modifier
.size(width = 150.dp, height = 150.dp)
)
}
Spacer(modifier = Modifier.weight(0.1f))

Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center,
modifier = Modifier
.fillMaxWidth(),
) {
Text(
text = stringResource(id = R.string.change_password_title),
style = MaterialTheme.typography.displayMedium,
color = if (isSystemInDarkTheme()) MaterialTheme.colorScheme.primary else Color.Unspecified,
textAlign = null
)
}
item {
Spacer(modifier = Modifier.weight(0.1f))
Row(modifier = Modifier.padding(bottom = 16.dp)) {
InputText(
textTop = stringResource(id = R.string.password_label),
textHint = stringResource(id = R.string.password_hint),
Expand All @@ -61,8 +89,7 @@ fun Screen(
},
)
}
item { Spacer(modifier = Modifier.height(30.dp)) }
item {
Row(modifier = Modifier.padding(top = 16.dp)) {
InputText(
textTop = stringResource(id = R.string.confirm_password_label),
textHint = stringResource(id = R.string.confirm_password_hint),
Expand All @@ -78,8 +105,7 @@ fun Screen(
},
)
}
item { Spacer(modifier = Modifier.height(30.dp)) }
item {
Row(modifier = Modifier.padding(top = 16.dp)){
CheckboxWithText(
textResourceId = R.string.disconnect_devices_question,
checkbox = viewModel.state.disconnectOtherDevices,
Expand All @@ -92,17 +118,16 @@ fun Screen(
}
)
}
item { Spacer(modifier = Modifier.height(30.dp)) }
item {
Button2(
submit = {
viewModel.onEvent(event = ChangePasswordFormEvent.Submit)
},
enableButton = viewModel.enableButton(),
text = stringResource(id = R.string.reset_password_button),
isLoading = taskState is TaskState.Loading
)
}
Spacer(modifier = Modifier.weight(0.1f))
Button2(
submit = {
viewModel.onEvent(event = ChangePasswordFormEvent.Submit)
},
enableButton = viewModel.enableButton(),
text = stringResource(id = R.string.reset_password_button),
isLoading = taskState is TaskState.Loading
)
Spacer(modifier = Modifier.weight(0.4f))
}
}
}
Loading

0 comments on commit a4d63ae

Please sign in to comment.