From 55aeb5f83a2708b593044c8b90f5b2017feec903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D1=88=D0=B8=D0=BD=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC?= Date: Sat, 28 Oct 2023 00:41:11 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=B5=D0=B7=D0=B8=D0=B3=D0=BD=20=D0=B0?= =?UTF-8?q?=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B9=20?= =?UTF-8?q?=D0=B8=20=D1=80=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../labwork/button_navigation/Screens.kt | 13 +- .../labwork/button_navigation/SlideGraph.kt | 1 + .../labwork/pages/ListAuthorization.kt | 242 +++++++++++++++++- .../com/example/labwork/ui/theme/Theme.kt | 4 +- .../main/res/drawable/baseline_visibility.xml | 5 + .../res/drawable/baseline_visibility_off.xml | 5 + 6 files changed, 257 insertions(+), 13 deletions(-) create mode 100644 app/src/main/res/drawable/baseline_visibility.xml create mode 100644 app/src/main/res/drawable/baseline_visibility_off.xml diff --git a/app/src/main/java/com/example/labwork/button_navigation/Screens.kt b/app/src/main/java/com/example/labwork/button_navigation/Screens.kt index 2d20773..60f322b 100644 --- a/app/src/main/java/com/example/labwork/button_navigation/Screens.kt +++ b/app/src/main/java/com/example/labwork/button_navigation/Screens.kt @@ -1,18 +1,16 @@ package com.example.labwork.button_navigation import androidx.compose.foundation.layout.fillMaxHeight -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.itemsIndexed -import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import com.example.labwork.models.getItemProducts import com.example.labwork.pages.ListInfo import com.example.labwork.pages.ListProduct -import com.example.labwork.models.getItemProducts +import com.example.labwork.pages.RegisteryOrLogin @Composable fun ScreenInfo() { @@ -21,12 +19,7 @@ fun ScreenInfo() { @Composable fun ScreenProfile() { - Text( - modifier = Modifier - .fillMaxSize() - .wrapContentHeight(), - text = "Тут будет профиль экран..." - ) + RegisteryOrLogin() } diff --git a/app/src/main/java/com/example/labwork/button_navigation/SlideGraph.kt b/app/src/main/java/com/example/labwork/button_navigation/SlideGraph.kt index 5588a19..24363d5 100644 --- a/app/src/main/java/com/example/labwork/button_navigation/SlideGraph.kt +++ b/app/src/main/java/com/example/labwork/button_navigation/SlideGraph.kt @@ -12,6 +12,7 @@ fun SlideGraph( navHostController: NavHostController ) { NavHost(navController = navHostController, startDestination = "Profile"){ + composable("Profile"){ ScreenProfile() } diff --git a/app/src/main/java/com/example/labwork/pages/ListAuthorization.kt b/app/src/main/java/com/example/labwork/pages/ListAuthorization.kt index c91347f..3c79668 100644 --- a/app/src/main/java/com/example/labwork/pages/ListAuthorization.kt +++ b/app/src/main/java/com/example/labwork/pages/ListAuthorization.kt @@ -1,4 +1,244 @@ package com.example.labwork.pages -class ListAuthorization { +import androidx.compose.foundation.Image +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.padding +import androidx.compose.foundation.layout.size +import androidx.compose.material.Button +import androidx.compose.material.ButtonDefaults +import androidx.compose.material.IconButton +import androidx.compose.material.Text +import androidx.compose.material.TextField +import androidx.compose.material.TextFieldDefaults +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.input.PasswordVisualTransformation +import androidx.compose.ui.text.input.VisualTransformation +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.navigation.NavController +import androidx.navigation.compose.NavHost +import androidx.navigation.compose.composable +import androidx.navigation.compose.rememberNavController +import com.example.labwork.R +import com.example.labwork.ui.theme.LightBluePolitech + +@Composable +fun RegisteryOrLogin() { + val navController = rememberNavController() + + NavHost(navController, startDestination = "login") { + composable("login") { + LoginPage(navController) + } + composable("register") { + RegisteryPage(navController) + } + } +} +@Composable +fun LoginPage(navController: NavController) { + var username by remember { mutableStateOf("") } + var password by remember { mutableStateOf("") } + var showPassword by remember { mutableStateOf(false) } + + Column( + modifier = Modifier + .fillMaxSize() + .padding(16.dp), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally + ) { + Image( + painter = painterResource(R.drawable.logo_ulstu), + contentDescription = "Logo", + modifier = Modifier.size(200.dp) + ) + Spacer(modifier = Modifier.height(16.dp)) + + TextField( + value = username, + onValueChange = { username = it }, + label = { Text("Логин") }, + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp), + textStyle = TextStyle(fontSize = 16.sp), + colors = TextFieldDefaults.textFieldColors( + cursorColor = LightBluePolitech, + backgroundColor = Color.White, + textColor = LightBluePolitech, + unfocusedLabelColor = LightBluePolitech, + focusedIndicatorColor = LightBluePolitech, + unfocusedIndicatorColor = LightBluePolitech, + focusedLabelColor = LightBluePolitech + ), + singleLine = true + ) + Spacer(modifier = Modifier.height(8.dp)) + + TextField( + value = password, + onValueChange = { password = it }, + label = { Text("Пароль") }, + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp), + textStyle = TextStyle(fontSize = 16.sp), + colors = TextFieldDefaults.textFieldColors( + cursorColor = LightBluePolitech, + backgroundColor = Color.White, + textColor = LightBluePolitech, + unfocusedLabelColor = LightBluePolitech, + focusedIndicatorColor = LightBluePolitech, + unfocusedIndicatorColor = LightBluePolitech, + focusedLabelColor = LightBluePolitech + ), + singleLine = true, + visualTransformation = if (showPassword) VisualTransformation.None else PasswordVisualTransformation(), + trailingIcon = { + IconButton( + onClick = { showPassword = !showPassword } + ) { + Image( + painter = if(showPassword) painterResource(R.drawable.baseline_visibility) else painterResource(R.drawable.baseline_visibility_off), + contentDescription = "LogoVissable", + modifier = Modifier.size(24.dp) + ) + } + } + ) + Spacer(modifier = Modifier.height(8.dp)) + + Button( + onClick = { /* Login logic */ }, + colors = ButtonDefaults.buttonColors(backgroundColor = LightBluePolitech, ), + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp) + ) { + Text(text = "Авторизоваться", color = Color.White) + } + Spacer(modifier = Modifier.height(8.dp)) + + Button( + onClick = { navController.navigate("register") }, + colors = ButtonDefaults.buttonColors(backgroundColor = LightBluePolitech), + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp) + ) { + Text(text = "Регистрация", color = Color.White) + } + } +} + +@Composable +fun RegisteryPage(navController: NavController) { + var username by remember { mutableStateOf("") } + var password by remember { mutableStateOf("") } + var confirmPassword by remember { mutableStateOf("") } + + Column( + modifier = Modifier + .fillMaxSize() + .padding(16.dp), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally + ) { + Image( + painter = painterResource(R.drawable.logo_ulstu), + contentDescription = "Logo", + modifier = Modifier.size(200.dp) + ) + Spacer(modifier = Modifier.height(16.dp)) + + TextField( + value = username, + onValueChange = { username = it }, + label = { Text("Логин") }, + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp), + textStyle = TextStyle(fontSize = 16.sp), + colors = TextFieldDefaults.textFieldColors( + cursorColor = LightBluePolitech, + backgroundColor = Color.White, + textColor = LightBluePolitech, + unfocusedLabelColor = LightBluePolitech, + focusedIndicatorColor = LightBluePolitech, + unfocusedIndicatorColor = LightBluePolitech, + focusedLabelColor = LightBluePolitech + ), + singleLine = true + ) + Spacer(modifier = Modifier.height(8.dp)) + + TextField( + value = password, + onValueChange = { password = it }, + label = { Text("Пароль") }, + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp), + textStyle = TextStyle(fontSize = 16.sp), + colors = TextFieldDefaults.textFieldColors( + backgroundColor = Color.White, + textColor = LightBluePolitech, + unfocusedLabelColor = LightBluePolitech, + focusedIndicatorColor = LightBluePolitech, + unfocusedIndicatorColor = LightBluePolitech, + focusedLabelColor = LightBluePolitech + ), + singleLine = true, + visualTransformation = PasswordVisualTransformation() + ) + Spacer(modifier = Modifier.height(8.dp)) + + TextField( + value = confirmPassword, + onValueChange = { confirmPassword = it }, + label = { Text("Подтвердите пароль") }, + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp), + textStyle = TextStyle(fontSize = 16.sp), + colors = TextFieldDefaults.textFieldColors( + backgroundColor = Color.White, + textColor = LightBluePolitech, + unfocusedLabelColor = LightBluePolitech, + focusedIndicatorColor = LightBluePolitech, + unfocusedIndicatorColor = LightBluePolitech, + focusedLabelColor = LightBluePolitech + ), + singleLine = true, + visualTransformation = PasswordVisualTransformation() + ) + Spacer(modifier = Modifier.height(8.dp)) + + Button( + onClick = { /* Register logic */ }, + colors = ButtonDefaults.buttonColors(backgroundColor = LightBluePolitech), + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp) + ) { + Text(text = "Зарегистрироваться", color = Color.White) + } + Spacer(modifier = Modifier.height(8.dp)) + + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/labwork/ui/theme/Theme.kt b/app/src/main/java/com/example/labwork/ui/theme/Theme.kt index e76b34b..4d25afd 100644 --- a/app/src/main/java/com/example/labwork/ui/theme/Theme.kt +++ b/app/src/main/java/com/example/labwork/ui/theme/Theme.kt @@ -22,9 +22,9 @@ private val DarkColorScheme = darkColorScheme( ) private val LightColorScheme = lightColorScheme( - primary = Purple40, + primary = DarkBluePolitech, secondary = PurpleGrey40, - tertiary = Pink40 + tertiary = LightBluePolitech /* Other default colors to override background = Color(0xFFFFFBFE), diff --git a/app/src/main/res/drawable/baseline_visibility.xml b/app/src/main/res/drawable/baseline_visibility.xml new file mode 100644 index 0000000..b923c39 --- /dev/null +++ b/app/src/main/res/drawable/baseline_visibility.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/baseline_visibility_off.xml b/app/src/main/res/drawable/baseline_visibility_off.xml new file mode 100644 index 0000000..00c8a20 --- /dev/null +++ b/app/src/main/res/drawable/baseline_visibility_off.xml @@ -0,0 +1,5 @@ + + +