|
@@ -1,37 +1,108 @@
|
|
|
package com.example.wabi.view.screens.signIn
|
|
|
|
|
|
-import androidx.compose.foundation.layout.Row
|
|
|
+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.view.common_elements.textfields.CodeTextField
|
|
|
+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
|
|
|
|
|
|
@Composable
|
|
|
fun SignIn(navController: NavHostController, vm: SignInViewModel = hiltViewModel()) {
|
|
|
val data = vm.data
|
|
|
+ val printError = remember { mutableStateOf(false) }
|
|
|
|
|
|
- Row {
|
|
|
- Text("Это вход")
|
|
|
- }
|
|
|
+ Column(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxSize()
|
|
|
+ .verticalScroll(rememberScrollState()),
|
|
|
+ verticalArrangement = Arrangement.SpaceAround,
|
|
|
+ horizontalAlignment = Alignment.CenterHorizontally
|
|
|
+ ) {
|
|
|
|
|
|
- CodeTextField(
|
|
|
- value = data.email,
|
|
|
- input = { vm.UpdateData(data.copy(email = it)) },
|
|
|
- )
|
|
|
- MainTextField(
|
|
|
- value = data.email,
|
|
|
- input = { vm.UpdateData(data.copy(email = it)) },
|
|
|
- placeholder = "Почта",
|
|
|
- lable = "Введите почту:",
|
|
|
- trailingText = ""
|
|
|
- )
|
|
|
- PasswordTextField(
|
|
|
- value = data.password,
|
|
|
- input = { vm.UpdateData(data.copy(password = it)) },
|
|
|
- placeholder = "Пароль",
|
|
|
- lable = "Введите пароль:"
|
|
|
- )
|
|
|
+ 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
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|