Дезигн авторизаций и регистраций
This commit is contained in:
parent
002af1f624
commit
55aeb5f83a
@ -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()
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,6 +12,7 @@ fun SlideGraph(
|
||||
navHostController: NavHostController
|
||||
) {
|
||||
NavHost(navController = navHostController, startDestination = "Profile"){
|
||||
|
||||
composable("Profile"){
|
||||
ScreenProfile()
|
||||
}
|
||||
|
@ -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))
|
||||
|
||||
}
|
||||
}
|
@ -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),
|
||||
|
5
app/src/main/res/drawable/baseline_visibility.xml
Normal file
5
app/src/main/res/drawable/baseline_visibility.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z"/>
|
||||
</vector>
|
5
app/src/main/res/drawable/baseline_visibility_off.xml
Normal file
5
app/src/main/res/drawable/baseline_visibility_off.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12,7c2.76,0 5,2.24 5,5 0,0.65 -0.13,1.26 -0.36,1.83l2.92,2.92c1.51,-1.26 2.7,-2.89 3.43,-4.75 -1.73,-4.39 -6,-7.5 -11,-7.5 -1.4,0 -2.74,0.25 -3.98,0.7l2.16,2.16C10.74,7.13 11.35,7 12,7zM2,4.27l2.28,2.28 0.46,0.46C3.08,8.3 1.78,10.02 1,12c1.73,4.39 6,7.5 11,7.5 1.55,0 3.03,-0.3 4.38,-0.84l0.42,0.42L19.73,22 21,20.73 3.27,3 2,4.27zM7.53,9.8l1.55,1.55c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.66 1.34,3 3,3 0.22,0 0.44,-0.03 0.65,-0.08l1.55,1.55c-0.67,0.33 -1.41,0.53 -2.2,0.53 -2.76,0 -5,-2.24 -5,-5 0,-0.79 0.2,-1.53 0.53,-2.2zM11.84,9.02l3.15,3.15 0.02,-0.16c0,-1.66 -1.34,-3 -3,-3l-0.17,0.01z"/>
|
||||
</vector>
|
Loading…
Reference in New Issue
Block a user