Крутим вертим, кнопку добавить починили
This commit is contained in:
parent
b622cb235b
commit
1984f32b8a
app/src/main/java/com/example/labwork
button_navigation
pages
@ -1,5 +1,6 @@
|
|||||||
package com.example.labwork.button_navigation
|
package com.example.labwork.button_navigation
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.fillMaxHeight
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
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.database.DAO.BicycleDao
|
||||||
import com.example.labwork.models.Bicycle
|
import com.example.labwork.models.Bicycle
|
||||||
import com.example.labwork.pages.ListInfo
|
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.product.ListProduct
|
||||||
import com.example.labwork.pages.RegisteryOrLogin
|
import com.example.labwork.pages.user.RegisteryOrLogin
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
@ -41,11 +43,14 @@ fun ScreenListProduct(bicycleDao: BicycleDao, navHostController: NavHostControll
|
|||||||
bicycles.addAll(fetchedBicycles)
|
bicycles.addAll(fetchedBicycles)
|
||||||
}
|
}
|
||||||
|
|
||||||
LazyColumn(
|
Column(
|
||||||
modifier = Modifier.fillMaxHeight().padding(bottom = 65.dp)
|
modifier = Modifier.fillMaxHeight().padding(bottom = 65.dp)
|
||||||
) {
|
) {
|
||||||
items(bicycles) { item ->
|
FormNewProduct(bicycleDao, navHostController)
|
||||||
ListProduct(item = item, bicycleDao = bicycleDao, navHostController = navHostController)
|
LazyColumn {
|
||||||
|
items(bicycles) { item ->
|
||||||
|
ListProduct(item = item, bicycleDao = bicycleDao, navHostController = navHostController)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,8 @@ import com.example.labwork.models.Bicycle
|
|||||||
import com.example.labwork.ui.theme.LightBluePolitech
|
import com.example.labwork.ui.theme.LightBluePolitech
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun FormProduct(item: Bicycle, bicycleDao: BicycleDao, navHostController: NavHostController) {
|
fun FormNewProduct(bicycleDao: BicycleDao, navHostController: NavHostController) {
|
||||||
val isFormVisible = remember { mutableStateOf(false) }
|
val isFormVisible = remember { mutableStateOf(false) }
|
||||||
var brand by remember { mutableStateOf("") }
|
var brand by remember { mutableStateOf("") }
|
||||||
var model 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) {
|
if (isFormVisible.value) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
@ -19,8 +19,6 @@ import androidx.compose.material.Button
|
|||||||
import androidx.compose.material.ButtonDefaults
|
import androidx.compose.material.ButtonDefaults
|
||||||
import androidx.compose.material.Card
|
import androidx.compose.material.Card
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.material.TextField
|
|
||||||
import androidx.compose.material.TextFieldDefaults
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
@ -45,14 +43,13 @@ import com.example.labwork.ui.theme.LightBluePolitech
|
|||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ListProduct(item: Bicycle, bicycleDao: BicycleDao, navHostController: NavHostController) {
|
fun ListProduct(item: Bicycle, bicycleDao: BicycleDao, navHostController: NavHostController) {
|
||||||
var isFullAbout by remember { mutableStateOf(false) }
|
var isFullAbout by remember { mutableStateOf(false) }
|
||||||
val scale by animateFloatAsState(if (isFullAbout) 1f else 0f)
|
val scale by animateFloatAsState(if (isFullAbout) 1f else 0f)
|
||||||
val textSize by animateDpAsState(if (isFullAbout) 18.dp else 24.dp)
|
val textSize by animateDpAsState(if (isFullAbout) 18.dp else 24.dp)
|
||||||
|
|
||||||
FormProduct(item, bicycleDao, navHostController)
|
|
||||||
|
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.labwork.pages
|
package com.example.labwork.pages.user
|
||||||
|
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
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.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.navigation.NavController
|
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.R
|
||||||
import com.example.labwork.ui.theme.LightBluePolitech
|
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
|
@Composable
|
||||||
fun LoginPage(navController: NavController) {
|
fun LoginPage(navController: NavController) {
|
||||||
var username by remember { mutableStateOf("") }
|
var username by remember { mutableStateOf("") }
|
||||||
@ -114,7 +98,8 @@ fun LoginPage(navController: NavController) {
|
|||||||
onClick = { showPassword = !showPassword }
|
onClick = { showPassword = !showPassword }
|
||||||
) {
|
) {
|
||||||
Image(
|
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",
|
contentDescription = "LogoVissable",
|
||||||
modifier = Modifier.size(24.dp)
|
modifier = Modifier.size(24.dp)
|
||||||
)
|
)
|
||||||
@ -144,101 +129,4 @@ fun LoginPage(navController: NavController) {
|
|||||||
Text(text = "Регистрация", color = Color.White)
|
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))
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
52
app/src/main/java/com/example/labwork/pages/user/RegOrLog.kt
Normal file
52
app/src/main/java/com/example/labwork/pages/user/RegOrLog.kt
Normal file
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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))
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user