|
@@ -2,37 +2,26 @@ package com.example.wabi.view.screens.signIn
|
|
|
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
-import androidx.compose.foundation.layout.Spacer
|
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
|
-import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
-import androidx.compose.foundation.layout.height
|
|
|
-import androidx.compose.foundation.layout.offset
|
|
|
-import androidx.compose.foundation.layout.padding
|
|
|
import androidx.compose.foundation.rememberScrollState
|
|
|
import androidx.compose.foundation.verticalScroll
|
|
|
-import androidx.compose.material3.Text
|
|
|
import androidx.compose.runtime.Composable
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
import androidx.compose.runtime.remember
|
|
|
import androidx.compose.ui.Alignment
|
|
|
import androidx.compose.ui.Modifier
|
|
|
-import androidx.compose.ui.unit.dp
|
|
|
import androidx.hilt.navigation.compose.hiltViewModel
|
|
|
import androidx.navigation.NavHostController
|
|
|
import com.example.wabi.domain.navigation.Routes
|
|
|
import com.example.wabi.domain.repository.UserData
|
|
|
-import com.example.wabi.ui.theme.WabiTheme
|
|
|
-import com.example.wabi.view.common_elements.button.ButtonLink
|
|
|
-import com.example.wabi.view.common_elements.button.MainButton
|
|
|
-import com.example.wabi.view.common_elements.text.error.ErrorList
|
|
|
-import com.example.wabi.view.common_elements.text.error.ErrorPrint
|
|
|
-import com.example.wabi.view.common_elements.textfields.MainTextField
|
|
|
-import com.example.wabi.view.common_elements.textfields.PasswordTextField
|
|
|
+import com.example.wabi.view.screens.signIn.states.EmailForReset
|
|
|
+import com.example.wabi.view.screens.signIn.states.Login
|
|
|
|
|
|
@Composable
|
|
|
fun SignIn(navController: NavHostController, vm: SignInViewModel = hiltViewModel()) {
|
|
|
val data = vm.data
|
|
|
val printError = remember { mutableStateOf(false) }
|
|
|
+ val visible = remember { mutableStateOf(true) }
|
|
|
|
|
|
UserData.currentScreen = Routes.SIGNIN
|
|
|
|
|
@@ -43,70 +32,18 @@ fun SignIn(navController: NavHostController, vm: SignInViewModel = hiltViewModel
|
|
|
verticalArrangement = Arrangement.SpaceAround,
|
|
|
horizontalAlignment = Alignment.CenterHorizontally
|
|
|
) {
|
|
|
-
|
|
|
- Text(
|
|
|
- text = "Добро\nпожаловать!",
|
|
|
- style = WabiTheme.fonts.headerFont,
|
|
|
- maxLines = 2,
|
|
|
- minLines = 2,
|
|
|
- color = WabiTheme.colors.mainColor
|
|
|
- )
|
|
|
- Text(
|
|
|
- text = "Войдите, чтобы\nпользоваться функциями приложения",
|
|
|
- style = WabiTheme.fonts.mainFont,
|
|
|
- color = WabiTheme.colors.mainColor
|
|
|
- )
|
|
|
- ErrorPrint(text = if (printError.value) ErrorList.errorPassOrEmail else "")
|
|
|
- Column(
|
|
|
- modifier = Modifier.fillMaxWidth()
|
|
|
- ) {
|
|
|
- MainTextField(
|
|
|
- value = data.email,
|
|
|
- input = { vm.updateData(data.copy(email = it)) },
|
|
|
- placeholder = "Почта",
|
|
|
- lable = "Введите почту:",
|
|
|
- trailingText = ""
|
|
|
- )
|
|
|
- Spacer(modifier = Modifier.height(10.dp))
|
|
|
- PasswordTextField(
|
|
|
- value = data.password,
|
|
|
- input = { vm.updateData(data.copy(password = it)) },
|
|
|
- placeholder = "Пароль",
|
|
|
- lable = "Введите пароль:"
|
|
|
- )
|
|
|
- }
|
|
|
- Column(
|
|
|
- horizontalAlignment = Alignment.CenterHorizontally
|
|
|
- ) {
|
|
|
- Text(
|
|
|
- text = "Нет аккаунта?",
|
|
|
- style = WabiTheme.fonts.acentFont,
|
|
|
- color = WabiTheme.colors.mainColor
|
|
|
- )
|
|
|
- ButtonLink(
|
|
|
- onClick = {
|
|
|
- vm.goToRegistration(navController = navController)
|
|
|
- },
|
|
|
- textContent = "Зарегистирируйтесь!",
|
|
|
- modifierButton = Modifier.offset(y = (-15).dp),
|
|
|
- colorContent = WabiTheme.colors.mainColor
|
|
|
- )
|
|
|
- MainButton(
|
|
|
- onClick = {
|
|
|
- vm.signIn(navController = navController, printError = printError)
|
|
|
- },
|
|
|
- enabled = data.email != "" && data.password != "",
|
|
|
- textContent = "Войти",
|
|
|
- modifierButton = Modifier
|
|
|
- .padding(30.dp, 0.dp)
|
|
|
- .fillMaxWidth()
|
|
|
- )
|
|
|
- Spacer(Modifier.height(5.dp))
|
|
|
- ButtonLink(
|
|
|
- onClick = {
|
|
|
- //привязать переход на страницу регистрации
|
|
|
- }, textContent = "Забыли пароль?", colorContent = WabiTheme.colors.mainColor
|
|
|
+ if (visible.value) {
|
|
|
+ Login(
|
|
|
+ navController = navController,
|
|
|
+ printError = printError,
|
|
|
+ visible = visible,
|
|
|
+ data = data,
|
|
|
+ vm = vm
|
|
|
)
|
|
|
+ } else {
|
|
|
+ EmailForReset(data.email, vm, visible)
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+
|