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 32de18a..29fd5e0 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,5 +1,6 @@ package com.example.labwork.button_navigation +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn @@ -14,8 +15,9 @@ import androidx.navigation.NavHostController import com.example.labwork.database.DAO.BicycleDao import com.example.labwork.models.Bicycle import com.example.labwork.pages.ListInfo +import com.example.labwork.pages.product.FormNewProduct import com.example.labwork.pages.product.ListProduct -import com.example.labwork.pages.RegisteryOrLogin +import com.example.labwork.pages.user.RegisteryOrLogin import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @@ -41,11 +43,14 @@ fun ScreenListProduct(bicycleDao: BicycleDao, navHostController: NavHostControll bicycles.addAll(fetchedBicycles) } - LazyColumn( + Column( modifier = Modifier.fillMaxHeight().padding(bottom = 65.dp) ) { - items(bicycles) { item -> - ListProduct(item = item, bicycleDao = bicycleDao, navHostController = navHostController) + FormNewProduct(bicycleDao, navHostController) + LazyColumn { + items(bicycles) { item -> + ListProduct(item = item, bicycleDao = bicycleDao, navHostController = navHostController) + } } } } diff --git a/app/src/main/java/com/example/labwork/pages/product/FormProduct.kt b/app/src/main/java/com/example/labwork/pages/product/FormProduct.kt index 176597e..e2d7c72 100644 --- a/app/src/main/java/com/example/labwork/pages/product/FormProduct.kt +++ b/app/src/main/java/com/example/labwork/pages/product/FormProduct.kt @@ -25,9 +25,8 @@ import com.example.labwork.models.Bicycle import com.example.labwork.ui.theme.LightBluePolitech import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch - @Composable -fun FormProduct(item: Bicycle, bicycleDao: BicycleDao, navHostController: NavHostController) { +fun FormNewProduct(bicycleDao: BicycleDao, navHostController: NavHostController) { val isFormVisible = remember { mutableStateOf(false) } var brand by remember { mutableStateOf("") } var model by remember { mutableStateOf("") } @@ -52,7 +51,6 @@ fun FormProduct(item: Bicycle, bicycleDao: BicycleDao, navHostController: NavHos ) } -// После кнопки "Добавить" добавьте код, который будет отображать форму при isFormVisible равном true if (isFormVisible.value) { Column( modifier = Modifier.fillMaxWidth() diff --git a/app/src/main/java/com/example/labwork/pages/product/ListProduct.kt b/app/src/main/java/com/example/labwork/pages/product/ListProduct.kt index aae6f3f..58ada9c 100644 --- a/app/src/main/java/com/example/labwork/pages/product/ListProduct.kt +++ b/app/src/main/java/com/example/labwork/pages/product/ListProduct.kt @@ -19,8 +19,6 @@ import androidx.compose.material.Button import androidx.compose.material.ButtonDefaults import androidx.compose.material.Card 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 @@ -45,14 +43,13 @@ import com.example.labwork.ui.theme.LightBluePolitech import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch + @Composable fun ListProduct(item: Bicycle, bicycleDao: BicycleDao, navHostController: NavHostController) { var isFullAbout by remember { mutableStateOf(false) } val scale by animateFloatAsState(if (isFullAbout) 1f else 0f) val textSize by animateDpAsState(if (isFullAbout) 18.dp else 24.dp) - FormProduct(item, bicycleDao, navHostController) - Card( modifier = Modifier .fillMaxWidth() diff --git a/app/src/main/java/com/example/labwork/pages/ListAuthorization.kt b/app/src/main/java/com/example/labwork/pages/user/LoginPage.kt similarity index 54% rename from app/src/main/java/com/example/labwork/pages/ListAuthorization.kt rename to app/src/main/java/com/example/labwork/pages/user/LoginPage.kt index 3c79668..0f00e18 100644 --- a/app/src/main/java/com/example/labwork/pages/ListAuthorization.kt +++ b/app/src/main/java/com/example/labwork/pages/user/LoginPage.kt @@ -1,4 +1,4 @@ -package com.example.labwork.pages +package com.example.labwork.pages.user import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement @@ -30,25 +30,9 @@ 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("") } @@ -114,7 +98,8 @@ fun LoginPage(navController: NavController) { onClick = { showPassword = !showPassword } ) { Image( - painter = if(showPassword) painterResource(R.drawable.baseline_visibility) else painterResource(R.drawable.baseline_visibility_off), + painter = if(showPassword) painterResource(R.drawable.baseline_visibility) else painterResource( + R.drawable.baseline_visibility_off), contentDescription = "LogoVissable", modifier = Modifier.size(24.dp) ) @@ -144,101 +129,4 @@ fun LoginPage(navController: NavController) { 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/pages/user/RegOrLog.kt b/app/src/main/java/com/example/labwork/pages/user/RegOrLog.kt new file mode 100644 index 0000000..1f15b72 --- /dev/null +++ b/app/src/main/java/com/example/labwork/pages/user/RegOrLog.kt @@ -0,0 +1,52 @@ +package com.example.labwork.pages.user + +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) + } + } +} + diff --git a/app/src/main/java/com/example/labwork/pages/user/RegisteryPage.kt b/app/src/main/java/com/example/labwork/pages/user/RegisteryPage.kt new file mode 100644 index 0000000..7c0ed58 --- /dev/null +++ b/app/src/main/java/com/example/labwork/pages/user/RegisteryPage.kt @@ -0,0 +1,129 @@ +package com.example.labwork.pages.user + +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.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.unit.dp +import androidx.compose.ui.unit.sp +import androidx.navigation.NavController +import com.example.labwork.R +import com.example.labwork.ui.theme.LightBluePolitech + +@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