Browse Source

update AuthScreen, RegisterScreen and add eye

КурносовИН 1 week ago
parent
commit
44a36754a2

+ 1 - 1
Project/app/src/main/java/com/example/mygymapp/view/mainActivity/MainViewModel.kt

@@ -28,7 +28,7 @@ class MainViewModel:ViewModel() {
     fun onSignUpEmail(emailUser: String, passwordUser: String) {
         viewModelScope.launch {
             try{
-                var  user =  Constants.supabase.auth.signUpWith(Email) {
+                var user =  Constants.supabase.auth.signUpWith(Email) {
                     email = emailUser
                     password = passwordUser
                 }

+ 19 - 17
Project/app/src/main/java/com/example/mygymapp/view/mainActivity/components/AuthScreen.kt

@@ -44,7 +44,6 @@ import com.example.mygymapp.ui.theme.Pearl
 import com.example.mygymapp.ui.theme.chivoFontFamily
 import com.example.mygymapp.view.mainActivity.MainViewModel
 
-
 @Composable
 fun AuthScreen(navHost: NavHostController){
     val viewModel = MainViewModel()
@@ -119,25 +118,25 @@ fun AuthScreen(navHost: NavHostController){
                 textStyle = TextStyle(fontSize = 14.sp, color = BlueDark),
                 shape = RoundedCornerShape(5.dp),
                 modifier = Modifier
-                    .padding(top = 235.dp, start = 30.dp, end = if (passwordVisibility.value) 90.dp else 30.dp) // Рассчитать отступ для текстового поля в зависимости от видимости пароля
+                    .padding(top = 235.dp, start = 30.dp, end = 30.dp)
                     .height(50.dp),
                 placeholder = {
                     Text("Введите пароль", style = TextStyle(fontSize = 14.sp))
                 }
             )
 
-            Image(
-                painter = painterResource(if (passwordVisibility.value) R.drawable.eyeoff else R.drawable.eye),
-                contentDescription = "Toggle Password Visibility",
-                modifier = Modifier
-                    .clickable { passwordVisibility.value = !passwordVisibility.value }
-                    .align(Alignment.CenterEnd)
-                    .padding(top = 100.dp)
-                    .size(48.dp)
-            )
-
-
-
+            Box(modifier = Modifier
+                .padding(top = 70.dp, end = 40.dp)
+                .clickable { passwordVisibility.value = !passwordVisibility.value }
+                .align(Alignment.CenterEnd))
+            {
+                Image(
+                    painter = painterResource(if (passwordVisibility.value) R.drawable.eyeoff else R.drawable.eye),
+                    contentDescription = "Toggle Password Visibility",
+                    modifier = Modifier
+                        .size(30.dp)
+                )
+            }
 
             Button(onClick = { viewModel.onSignInEmailPassword(email.value, password.value) },
                 colors = ButtonDefaults.buttonColors(Pearl),
@@ -149,14 +148,17 @@ fun AuthScreen(navHost: NavHostController){
                 Text("Войти")
             }
 
+            Box(modifier = Modifier
+                .padding(top = 400.dp, start = 30.dp)
+                .clickable {
+                    navHost.navigate("register_screen")
+                }) {
             Text(
                 text = "Нет аккаунта? Зарегестрироваться", fontSize = 12.sp, color = Color(0xFF3A506B),
-                modifier = Modifier
-                    .clickable { navHost.navigate("register_screen") }
-                    .padding(top = 400.dp, start = 30.dp)
             )
 
         }
     }
 
+}
 }

+ 40 - 15
Project/app/src/main/java/com/example/mygymapp/view/mainActivity/components/RegisterScreen.kt

@@ -51,6 +51,8 @@ fun RegisterScreen(navHost: NavHostController){
     val email = remember { mutableStateOf("")}
     val password = remember { mutableStateOf("")}
 
+    val passwordVisibility = remember { mutableStateOf(false    )}
+
     Column(
         Modifier
             .background(color = BlueBlack)
@@ -92,15 +94,18 @@ fun RegisterScreen(navHost: NavHostController){
             )
             TextField(
                 value = email.value,
-                onValueChange = {email.value = it},
+                onValueChange = { email.value = it },
                 textStyle = TextStyle(fontSize = 14.sp, color = BlueDark),
                 shape = RoundedCornerShape(5.dp),
                 modifier = Modifier
                     .padding(top = 140.dp, start = 30.dp, end = 30.dp)
                     .height(50.dp),
                 placeholder = {
-                    Text("youremail@gmail.com",
-                        style = TextStyle(fontSize = 14.sp)) }
+                    Text(
+                        "youremail@gmail.com",
+                        style = TextStyle(fontSize = 14.sp)
+                    )
+                }
             )
 
             Text(
@@ -112,21 +117,37 @@ fun RegisterScreen(navHost: NavHostController){
             )
             TextField(
                 value = password.value,
-                onValueChange = {password.value = it},
-                visualTransformation = PasswordVisualTransformation(),
+                onValueChange = { password.value = it },
+                visualTransformation = if (passwordVisibility.value) VisualTransformation.None else PasswordVisualTransformation(),
                 textStyle = TextStyle(fontSize = 14.sp, color = BlueDark),
                 shape = RoundedCornerShape(5.dp),
                 modifier = Modifier
                     .padding(top = 235.dp, start = 30.dp, end = 30.dp)
                     .height(50.dp),
                 placeholder = {
-                    Text("Введите пароль",
-                        style = TextStyle(fontSize = 14.sp))
+                    Text(
+                        "Введите пароль",
+                        style = TextStyle(fontSize = 14.sp)
+                    )
                 }
 
             )
 
-            Button(onClick = { viewModel.onSignUpEmail(email.value, password.value) },
+            Box(modifier = Modifier
+                .padding(top = 70.dp, end = 40.dp)
+                .clickable { passwordVisibility.value = !passwordVisibility.value }
+                .align(Alignment.CenterEnd))
+            {
+                Image(
+                    painter = painterResource(if (passwordVisibility.value) R.drawable.eyeoff else R.drawable.eye),
+                    contentDescription = "Toggle Password Visibility",
+                    modifier = Modifier
+                        .size(30.dp)
+                )
+            }
+
+            Button(
+                onClick = { viewModel.onSignUpEmail(email.value, password.value) },
                 colors = ButtonDefaults.buttonColors(Pearl),
                 modifier = Modifier
                     .padding(top = 245.dp)
@@ -136,14 +157,18 @@ fun RegisterScreen(navHost: NavHostController){
                 Text("Зарегестрироваться")
             }
 
-            Text(
-                text = "Авторизация", fontSize = 12.sp, color = Color(0xFF3A506B),
-                modifier = Modifier
-                    .clickable { navHost.navigate("auth_screen") }
-                    .padding(top = 400.dp, start = 30.dp)
-            )
+            Box(modifier = Modifier
+                .padding(top = 400.dp, start = 30.dp)
+                .clickable {
+                    navHost.navigate("auth_screen")
+                }) {
+                Text(
+                    text = "Авторизация",
+                    fontSize = 12.sp,
+                    color = Color(0xFF3A506B),
+                )
 
+            }
         }
     }
-
 }

+ 1 - 1
Project/gradle/libs.versions.toml

@@ -1,5 +1,5 @@
 [versions]
-agp = "8.6.1"
+agp = "8.5.1"
 authKt = "3.0.1"
 bom = "2.6.1"
 kotlin = "2.0.0"