viewModels
This commit is contained in:
parent
00e36e16fc
commit
d67c5c7289
@ -0,0 +1,46 @@
|
||||
package com.example.testktor.ViewModel
|
||||
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ArrowBack
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.navigation.NavController
|
||||
|
||||
@Composable
|
||||
fun ButtonBack(navController: NavController, screen: String){
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 20.dp, top = 20.dp),
|
||||
horizontalArrangement = Arrangement.Start
|
||||
) {
|
||||
IconButton(onClick = { navController.navigate(screen) }) {
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier.size(56.dp)
|
||||
) {
|
||||
Canvas(modifier = Modifier.matchParentSize()) {
|
||||
drawCircle(color = Color.LightGray)
|
||||
}
|
||||
Icon(
|
||||
imageVector = Icons.Default.ArrowBack,
|
||||
contentDescription = "Назад",
|
||||
modifier = Modifier.size(28.dp),
|
||||
tint = Color.Black
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.example.testktor.ViewModel
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.ui.draw.clip
|
||||
|
||||
@Composable
|
||||
fun CircularCheckbox(
|
||||
checked: Boolean,
|
||||
onCheckedChange: (Boolean) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
size: Dp = 12.dp
|
||||
) {
|
||||
Box(
|
||||
modifier = modifier
|
||||
.size(size)
|
||||
.clip(CircleShape)
|
||||
.background(if (checked) Color.Black else Color.Transparent)
|
||||
.border(
|
||||
width = 2.dp,
|
||||
color = Color.Black,
|
||||
shape = CircleShape
|
||||
)
|
||||
.clickable { onCheckedChange(!checked) }
|
||||
.padding(start = 20.dp)
|
||||
)
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.example.testktor.ViewModel
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.text.ClickableText
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextDecoration
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.navigation.NavController
|
||||
|
||||
@Composable
|
||||
fun ClickableTextAcceptVM(
|
||||
text: String,
|
||||
style: TextStyle
|
||||
){
|
||||
ClickableText(
|
||||
text = buildAnnotatedString {
|
||||
append(text)
|
||||
addStyle(
|
||||
style = SpanStyle(
|
||||
color = Color.Black,
|
||||
textDecoration = TextDecoration.Underline
|
||||
),
|
||||
start = 0,
|
||||
end = this.length
|
||||
)
|
||||
},
|
||||
onClick = { /* */ },
|
||||
modifier = Modifier
|
||||
// .fillMaxWidth()
|
||||
.padding(bottom = 20.dp),
|
||||
style = style
|
||||
)
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.example.testktor.ViewModel
|
||||
|
||||
import androidx.compose.foundation.text.ClickableText
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.navigation.NavController
|
||||
import org.w3c.dom.Text
|
||||
|
||||
@Composable
|
||||
fun ClickableTextVM(
|
||||
text: String,
|
||||
navController: NavController?,
|
||||
screen: String,
|
||||
style: TextStyle
|
||||
) {
|
||||
ClickableText(
|
||||
text = buildAnnotatedString { append(text) },
|
||||
onClick = {
|
||||
if (navController != null){
|
||||
navController.navigate(screen)
|
||||
}
|
||||
},
|
||||
style = style
|
||||
)
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.example.testktor.ViewModel
|
||||
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextFieldDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun TextFieldVM(
|
||||
text: String,
|
||||
onTextChange: (String) -> Unit,
|
||||
placeholder: String
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = text,
|
||||
onValueChange = { onTextChange(it) },
|
||||
placeholder = { Text(text = placeholder, color = Color.Gray) },
|
||||
modifier = Modifier
|
||||
.width(350.dp)
|
||||
.height(70.dp)
|
||||
.padding(bottom = 16.dp),
|
||||
shape = RoundedCornerShape(20.dp),
|
||||
colors = TextFieldDefaults.outlinedTextFieldColors(
|
||||
focusedBorderColor = Color.Transparent,
|
||||
unfocusedBorderColor = Color.Transparent,
|
||||
containerColor = Color(0xFFE0E0E0)
|
||||
),
|
||||
singleLine = true
|
||||
)
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.example.testktor.ViewModel
|
||||
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Lock
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.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.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||
import androidx.compose.ui.text.input.VisualTransformation
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun TextFieldWithHideVM(
|
||||
text: String,
|
||||
onTextChange: (String) -> Unit,
|
||||
placeholder: String
|
||||
) {
|
||||
var passwordVisible by remember { mutableStateOf(false) }
|
||||
|
||||
OutlinedTextField(
|
||||
value = text,
|
||||
onValueChange = { onTextChange(it) },
|
||||
placeholder = { Text(text = placeholder, color = Color.Gray) },
|
||||
modifier = Modifier
|
||||
.width(350.dp)
|
||||
.height(70.dp)
|
||||
.padding(bottom = 8.dp),
|
||||
shape = RoundedCornerShape(20.dp),
|
||||
colors = TextFieldDefaults.outlinedTextFieldColors(
|
||||
focusedBorderColor = Color.Transparent,
|
||||
unfocusedBorderColor = Color.Transparent,
|
||||
containerColor = Color(0xFFE0E0E0)
|
||||
),
|
||||
singleLine = true,
|
||||
visualTransformation = if (passwordVisible) VisualTransformation.None else PasswordVisualTransformation(),
|
||||
trailingIcon = {
|
||||
IconButton(onClick = { passwordVisible = !passwordVisible }) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Lock,
|
||||
contentDescription = "Lock",
|
||||
tint = Color.Gray
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
@ -4,20 +4,25 @@ import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
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.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.ClickableText
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.Lock
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.material3.TextFieldDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
@ -35,33 +40,9 @@ import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.navigation.NavController
|
||||
|
||||
@Composable
|
||||
fun ButtonBack(navController: NavController){
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 20.dp, top = 20.dp),
|
||||
horizontalArrangement = Arrangement.Start
|
||||
) {
|
||||
IconButton(onClick = { navController.navigate("slider_screen") }) {
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier.size(56.dp)
|
||||
) {
|
||||
Canvas(modifier = Modifier.matchParentSize()) {
|
||||
drawCircle(color = Color.LightGray)
|
||||
}
|
||||
Icon(
|
||||
imageVector = Icons.Default.ArrowBack,
|
||||
contentDescription = "Назад",
|
||||
modifier = Modifier.size(28.dp),
|
||||
tint = Color.Black
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
import com.example.testktor.ViewModel.ClickableTextVM
|
||||
import com.example.testktor.ViewModel.TextFieldVM
|
||||
import com.example.testktor.ViewModel.TextFieldWithHideVM
|
||||
|
||||
@Composable
|
||||
fun TopBar(email: String,
|
||||
@ -69,47 +50,32 @@ fun TopBar(email: String,
|
||||
password: String,
|
||||
onPasswordChange: (String) -> Unit
|
||||
){
|
||||
var passwordVisible by remember { mutableStateOf(false) }
|
||||
|
||||
Text(
|
||||
text = "Привет!",
|
||||
style = TextStyle(fontSize = 32.sp, fontWeight = FontWeight.Bold),
|
||||
style = TextStyle(fontSize = 32.sp, fontWeight = FontWeight.Medium),
|
||||
modifier = Modifier.height(60.dp).padding(bottom = 8.dp)
|
||||
)
|
||||
|
||||
Text(
|
||||
text = "Заполните Свои Данные Или Продолжите Через Социальные Медиа",
|
||||
text = "Заполните Свои Данные Или\nПродолжите Через Социальные Медиа",
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 20.dp),
|
||||
style = TextStyle(fontSize = 16.sp),
|
||||
color = Color.Gray,
|
||||
style = TextStyle(fontSize = 18.sp, fontWeight = FontWeight.Light),
|
||||
textAlign = TextAlign.Center,
|
||||
softWrap = true,
|
||||
maxLines = 2
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.padding(top = 20.dp))
|
||||
|
||||
Text(text = "Email", modifier = Modifier.padding(end = 280.dp))
|
||||
TextField(
|
||||
modifier = Modifier.width(350.dp).height(70.dp).padding(bottom = 16.dp),
|
||||
value = email,
|
||||
onValueChange = { onEmailChange(it)},
|
||||
)
|
||||
TextFieldVM(email, {onEmailChange(it)}, "xyz@gmail.com")
|
||||
Spacer(modifier = Modifier.padding(top = 20.dp))
|
||||
|
||||
Text(text = "Password", modifier = Modifier.padding(end = 250.dp))
|
||||
TextField(
|
||||
modifier = Modifier.width(350.dp).height(70.dp).padding(bottom = 16.dp),
|
||||
value = password,
|
||||
onValueChange = {onPasswordChange(it)},
|
||||
visualTransformation = if (!passwordVisible) PasswordVisualTransformation() else VisualTransformation.None,
|
||||
trailingIcon = {
|
||||
IconButton(onClick = { passwordVisible = !passwordVisible }) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Lock,
|
||||
contentDescription = "Lock",
|
||||
tint = Color.Gray
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
TextFieldWithHideVM(password, {onPasswordChange(it)}, "******")
|
||||
}
|
||||
|
||||
@Composable
|
||||
@ -117,18 +83,14 @@ fun Restore(navController: NavController) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 6.dp, bottom = 20.dp, end = 16.dp),
|
||||
.padding(bottom = 20.dp, end = 36.dp),
|
||||
horizontalArrangement = Arrangement.End
|
||||
) {
|
||||
ClickableText(
|
||||
text = buildAnnotatedString { append("Восстановить") },
|
||||
onClick = {
|
||||
navController.navigate("forgotPassword_screen")
|
||||
},
|
||||
style = TextStyle(
|
||||
fontSize = 16.sp,
|
||||
color = Color.LightGray
|
||||
),
|
||||
ClickableTextVM(
|
||||
"Восстановить",
|
||||
navController,
|
||||
"forgotPassword_screen",
|
||||
TextStyle(fontSize = 12.sp, color = Color.Gray)
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -143,7 +105,7 @@ fun BotBar(navController: NavController) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.align(Alignment.BottomCenter)
|
||||
.padding(bottom = 16.dp),
|
||||
.padding(bottom = 30.dp),
|
||||
horizontalArrangement = Arrangement.Center
|
||||
) {
|
||||
Text(
|
||||
@ -151,15 +113,11 @@ fun BotBar(navController: NavController) {
|
||||
style = TextStyle(fontSize = 16.sp, color = Color.Gray)
|
||||
)
|
||||
|
||||
ClickableText(
|
||||
text = buildAnnotatedString { append("Создать пользователя") },
|
||||
onClick = {
|
||||
navController.navigate("registration_screen")
|
||||
},
|
||||
style = TextStyle(
|
||||
fontSize = 16.sp,
|
||||
color = Color.Black
|
||||
),
|
||||
ClickableTextVM(
|
||||
"Создать пользователя",
|
||||
navController,
|
||||
"registration_screen",
|
||||
TextStyle(fontSize = 16.sp, color = Color.Black)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,26 @@
|
||||
package com.example.testktor.method.auth
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Slider
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.font.FontStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
@ -21,46 +29,63 @@ fun Textik(imageId: Int, textList: List<String>, textList2: List<String>, curren
|
||||
Image(
|
||||
painter = painterResource(id = imageId),
|
||||
contentDescription = "Изображение",
|
||||
modifier = androidx.compose.ui.Modifier.width(670.dp).height(600.dp).padding(start = 20.dp)
|
||||
modifier = Modifier.width(670.dp).height(600.dp).padding(start = 20.dp)
|
||||
)
|
||||
|
||||
Text(
|
||||
color = Color.White,
|
||||
fontStyle = FontStyle.Italic,
|
||||
text = textList[currentIndex],
|
||||
fontSize = 24.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = androidx.compose.ui.Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 40.dp)
|
||||
.width(700.dp).height(30.dp)
|
||||
)
|
||||
Text(
|
||||
color = Color.White,
|
||||
fontStyle = FontStyle.Italic,
|
||||
text = textList2[currentIndex],
|
||||
fontSize = 18.sp,
|
||||
fontSize = 38.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = androidx.compose.ui.Modifier
|
||||
lineHeight = 42.sp,
|
||||
softWrap = true,
|
||||
maxLines = 2,
|
||||
overflow = TextOverflow.Clip,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 40.dp)
|
||||
.padding(top = 10.dp)
|
||||
.width(700.dp)
|
||||
.height(100.dp)
|
||||
)
|
||||
Text(
|
||||
text = textList2[currentIndex],
|
||||
color = Color.White,
|
||||
fontStyle = FontStyle.Italic,
|
||||
fontSize = 16.sp,
|
||||
fontWeight = FontWeight.Light,
|
||||
textAlign = TextAlign.Center,
|
||||
lineHeight = 20.sp,
|
||||
maxLines = 2,
|
||||
overflow = TextOverflow.Clip,
|
||||
softWrap = true,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 15.dp)
|
||||
.height(40.dp)
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Sliderik(sliderValue: Float, maxIndex: Int, onClick: (Float) -> Unit, ){
|
||||
Slider(
|
||||
value = sliderValue,
|
||||
onValueChange = onClick,
|
||||
valueRange = 0f..maxIndex.toFloat(),
|
||||
steps = maxIndex - 1,
|
||||
colors = androidx.compose.material3.SliderDefaults.colors(
|
||||
thumbColor = Color.White,
|
||||
activeTrackColor = Color(0xFF0076B1),
|
||||
inactiveTrackColor = Color(0xFFB0B0B0)
|
||||
),
|
||||
modifier = androidx.compose.ui.Modifier.fillMaxWidth()
|
||||
)
|
||||
fun Sliderik(currentIndex: Int, maxIndex: Int, onClick: (Int) -> Unit) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 16.dp),
|
||||
horizontalArrangement = Arrangement.Center
|
||||
) {
|
||||
for (i in 0..maxIndex) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 8.dp)
|
||||
.height(4.dp)
|
||||
.width(if (i == currentIndex) 40.dp else 20.dp)
|
||||
.background(
|
||||
color = if (i == currentIndex) Color.White else Color.Gray,
|
||||
shape = RoundedCornerShape(50)
|
||||
)
|
||||
.clickable { onClick(i) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.example.testktor.method.auth
|
||||
|
||||
import android.widget.Space
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
@ -8,35 +10,36 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.example.testktor.ViewModel.TextFieldVM
|
||||
|
||||
|
||||
@Composable
|
||||
fun BarForgot(emailIn: String, onEmailChane: (String) -> Unit){
|
||||
fun BarForgot(emailIn: String, onEmailChange: (String) -> Unit){
|
||||
Text(
|
||||
text = "Забыл Пароль",
|
||||
style = TextStyle(fontSize = 32.sp, fontWeight = FontWeight.Bold),
|
||||
modifier = Modifier.height(60.dp).padding(bottom = 20.dp)
|
||||
style = TextStyle(fontSize = 32.sp, fontWeight = FontWeight.Medium),
|
||||
modifier = Modifier.height(60.dp).padding(bottom = 8.dp)
|
||||
)
|
||||
|
||||
Text(
|
||||
text = "Введите свою учетную запись для сброса",
|
||||
text = "Введите Свою Учетную Запись\nДля Сброса",
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 20.dp),
|
||||
style = TextStyle(fontSize = 16.sp),
|
||||
color = Color.Gray,
|
||||
style = TextStyle(fontSize = 18.sp, fontWeight = FontWeight.Light),
|
||||
textAlign = TextAlign.Center,
|
||||
softWrap = true,
|
||||
maxLines = 2
|
||||
)
|
||||
|
||||
Text(text = "Email", modifier = Modifier.padding(end = 255.dp))
|
||||
TextField(
|
||||
modifier = Modifier.width(300.dp).height(70.dp).padding(bottom = 16.dp),
|
||||
value = emailIn,
|
||||
onValueChange = {onEmailChane(it)}
|
||||
)
|
||||
Spacer(modifier = Modifier.padding(top = 10.dp))
|
||||
|
||||
TextFieldVM(emailIn, {onEmailChange(it)}, "xyz@gmail.com")
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.example.testktor.method.auth
|
||||
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
@ -8,9 +9,11 @@ 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.foundation.layout.width
|
||||
import androidx.compose.foundation.text.ClickableText
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.Lock
|
||||
import androidx.compose.material3.Checkbox
|
||||
import androidx.compose.material3.Icon
|
||||
@ -36,6 +39,11 @@ import androidx.compose.ui.text.style.TextDecoration
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.navigation.NavController
|
||||
import com.example.testktor.ViewModel.CircularCheckbox
|
||||
import com.example.testktor.ViewModel.ClickableTextAcceptVM
|
||||
import com.example.testktor.ViewModel.ClickableTextVM
|
||||
import com.example.testktor.ViewModel.TextFieldVM
|
||||
import com.example.testktor.ViewModel.TextFieldWithHideVM
|
||||
|
||||
@Composable
|
||||
fun TopBarReg(name: String,
|
||||
@ -45,55 +53,34 @@ fun TopBarReg(name: String,
|
||||
password: String,
|
||||
onPasswordChange: (String) -> Unit
|
||||
){
|
||||
var passwordVisible by remember { mutableStateOf(false) }
|
||||
var isChecked by remember { mutableStateOf(false) }
|
||||
|
||||
Text(
|
||||
text = "Регистрация",
|
||||
style = TextStyle(fontSize = 32.sp, fontWeight = FontWeight.Bold),
|
||||
modifier = Modifier.height(60.dp).padding(bottom = 20.dp)
|
||||
style = TextStyle(fontSize = 32.sp, fontWeight = FontWeight.Medium),
|
||||
modifier = Modifier.height(60.dp).padding(bottom = 8.dp)
|
||||
)
|
||||
|
||||
Text(
|
||||
text = "Заполните Свои данные или продолжите через социальные медиа",
|
||||
text = "Заполните Свои данные или\nпродолжите через социальные медиа",
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 20.dp),
|
||||
style = TextStyle(fontSize = 16.sp),
|
||||
color = Color.Gray,
|
||||
style = TextStyle(fontSize = 18.sp, fontWeight = FontWeight.Light),
|
||||
textAlign = TextAlign.Center,
|
||||
softWrap = true,
|
||||
maxLines = 2
|
||||
)
|
||||
|
||||
Text(text = "Ваше имя", modifier = Modifier.padding(end = 270.dp))
|
||||
TextField(
|
||||
modifier = Modifier.width(350.dp).height(70.dp).padding(bottom = 16.dp),
|
||||
value = name,
|
||||
onValueChange = {onNameChange(it)}
|
||||
)
|
||||
TextFieldVM(name, {onNameChange(it)}, "xxxxxxx")
|
||||
|
||||
Text(text = "Email", modifier = Modifier.padding(end = 290.dp))
|
||||
TextField(
|
||||
modifier = Modifier.width(350.dp).height(70.dp).padding(bottom = 16.dp),
|
||||
value = email,
|
||||
onValueChange = {onEmailChange(it)}
|
||||
)
|
||||
TextFieldVM(email, {onEmailChange(it)}, "xyz@gmail.com")
|
||||
|
||||
Text(text = "Password", modifier = Modifier.padding(end = 260.dp))
|
||||
TextField(
|
||||
modifier = Modifier.width(350.dp).height(70.dp).padding(bottom = 16.dp),
|
||||
value = password,
|
||||
onValueChange = {onPasswordChange(it)},
|
||||
visualTransformation = if (!passwordVisible) PasswordVisualTransformation() else VisualTransformation.None,
|
||||
trailingIcon = {
|
||||
IconButton(onClick = { passwordVisible = !passwordVisible }) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Lock,
|
||||
contentDescription = "Lock",
|
||||
tint = Color.Gray
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
TextFieldWithHideVM(password, {onPasswordChange(it)}, "******")
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
@ -107,25 +94,9 @@ fun TopBarReg(name: String,
|
||||
onCheckedChange = { isChecked = it }
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
|
||||
ClickableText(
|
||||
text = buildAnnotatedString {
|
||||
append("Даю согласие на обработку персональных данных")
|
||||
addStyle(
|
||||
style = SpanStyle(
|
||||
color = Color.Black,
|
||||
textDecoration = TextDecoration.Underline
|
||||
),
|
||||
start = 0,
|
||||
end = this.length
|
||||
)
|
||||
},
|
||||
onClick = { /* */ },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 20.dp),
|
||||
style = TextStyle(fontSize = 16.sp, textAlign = TextAlign.Center)
|
||||
ClickableTextAcceptVM(
|
||||
"Даю согласие на обработку\nперсональных данных",
|
||||
TextStyle(fontSize = 16.sp)
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -147,16 +118,11 @@ fun BotBarReg(navController: NavController) {
|
||||
text = "Есть аккаунт? ",
|
||||
style = TextStyle(fontSize = 16.sp, color = Color.Gray)
|
||||
)
|
||||
|
||||
ClickableText(
|
||||
text = buildAnnotatedString { append("Войти") },
|
||||
onClick = {
|
||||
navController.navigate("auth_screen")
|
||||
},
|
||||
style = TextStyle(
|
||||
fontSize = 16.sp,
|
||||
color = Color.Black
|
||||
),
|
||||
ClickableTextVM(
|
||||
"Войти",
|
||||
navController,
|
||||
"auth_screen",
|
||||
TextStyle(fontSize = 16.sp, color = Color.Black)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.example.testktor.method.auth
|
||||
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
@ -7,49 +9,83 @@ import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.example.testktor.ViewModel.ClickableTextVM
|
||||
import com.example.testktor.ViewModel.TextFieldVM
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
@Composable
|
||||
fun TopBarReset(){
|
||||
Text(
|
||||
text = "ОТР Проверка",
|
||||
style = TextStyle(fontSize = 32.sp, fontWeight = FontWeight.Bold),
|
||||
modifier = Modifier.height(60.dp).padding(bottom = 20.dp)
|
||||
style = TextStyle(fontSize = 32.sp, fontWeight = FontWeight.Medium),
|
||||
modifier = Modifier.height(60.dp).padding(bottom = 8.dp)
|
||||
)
|
||||
|
||||
Text(
|
||||
text = "Пожалуйста, проверьте свою электронную почту, чтобы увидеть код подтверждения",
|
||||
text = "Пожалуйста, Проверьте Свою, Электронную Почту, Чтобы Увидеть Код Подтверждения",
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 20.dp),
|
||||
style = TextStyle(fontSize = 16.sp),
|
||||
color = Color.Gray,
|
||||
style = TextStyle(fontSize = 18.sp, fontWeight = FontWeight.Light),
|
||||
textAlign = TextAlign.Center,
|
||||
softWrap = true,
|
||||
maxLines = 3
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
fun TextFieldsReset(codeIn: String,
|
||||
onCodeChange: (String) -> Unit,
|
||||
newPassword: String,
|
||||
onNewPasswordChange: (String) -> Unit){
|
||||
Text(text = "OTP Code", modifier = Modifier.padding(end = 255.dp))
|
||||
TextField(
|
||||
modifier = Modifier.width(350.dp).height(70.dp).padding(bottom = 16.dp),
|
||||
value = codeIn,
|
||||
onValueChange = {onCodeChange(it)}
|
||||
)
|
||||
fun TextFieldsReset(
|
||||
codeIn: String,
|
||||
onCodeChange: (String) -> Unit,
|
||||
newPassword: String,
|
||||
onNewPasswordChange: (String) -> Unit
|
||||
) {
|
||||
var timer by remember { mutableStateOf(60) }
|
||||
|
||||
Text(text = "New Password", modifier = Modifier.padding(end = 255.dp))
|
||||
TextField(
|
||||
modifier = Modifier.width(300.dp).height(70.dp).padding(bottom = 16.dp),
|
||||
value = newPassword,
|
||||
onValueChange = {onNewPasswordChange(it)}
|
||||
)
|
||||
LaunchedEffect(key1 = timer) {
|
||||
if (timer > 0) {
|
||||
delay(1000)
|
||||
timer--
|
||||
}
|
||||
}
|
||||
|
||||
Text(text = "OTP Код", modifier = Modifier.padding(end = 255.dp))
|
||||
TextFieldVM(codeIn, { onCodeChange(it) }, "")
|
||||
|
||||
Text(text = "New Password", modifier = Modifier.padding(end = 205.dp))
|
||||
TextFieldVM(newPassword, { onNewPasswordChange(it) }, "")
|
||||
|
||||
Row(){
|
||||
Spacer(modifier = Modifier.padding(start = 40.dp))
|
||||
ClickableTextVM(
|
||||
"Восстановить",
|
||||
navController = null,
|
||||
"forgotPassword_screen",
|
||||
TextStyle(fontSize = 12.sp, color = Color.Gray)
|
||||
)
|
||||
|
||||
Text(
|
||||
text = "${timer}s",
|
||||
style = TextStyle(fontSize = 12.sp, color = Color.Gray),
|
||||
color = Color.Gray,
|
||||
fontSize = 14.sp,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(end = 40.dp, bottom = 10.dp),
|
||||
textAlign = TextAlign.End
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.navigation.NavController
|
||||
import com.example.testktor.ViewModel.ButtonBack
|
||||
import com.example.testktor.authUser
|
||||
import com.example.testktor.method.auth.BotBar
|
||||
import com.example.testktor.method.auth.ButtonBack
|
||||
import com.example.testktor.method.auth.Restore
|
||||
import com.example.testktor.method.auth.TopBar
|
||||
import io.ktor.client.HttpClient
|
||||
@ -68,9 +68,9 @@ fun AuthContent(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
ButtonBack(navController)
|
||||
ButtonBack(navController, "slider_screen")
|
||||
|
||||
Spacer(modifier = Modifier.height(140.dp))
|
||||
Spacer(modifier = Modifier.height(20.dp))
|
||||
|
||||
if (authSuccess != null){
|
||||
if (authSuccess == "Success") {
|
||||
|
@ -47,8 +47,8 @@ fun FirstScreen(onNavigateToSliderScreen: () -> Unit) {
|
||||
@Composable
|
||||
fun SliderScreen(onNavigateToAuthScreen: () -> Unit) {
|
||||
var sliderValue by remember { mutableStateOf(0f) }
|
||||
val textList = listOf("ДОБРО ПОЖАЛОВАТЬ", "Начнем путешествие", "У вас есть сила, чтобы")
|
||||
val textList2 = listOf("", "Умная, великолепная и модная коллекция Изучите сейчас", "В вашей комнате много красивых и привлекательных растений")
|
||||
val textList = listOf("ДОБРО\nПОЖАЛОВАТЬ", "Начнем\nпутешествие", "У Вас Есть Сила,\nЧтобы")
|
||||
val textList2 = listOf("", "Умная, великолепная и модная\nколлекция Изучите сейчас", "В вашей комнате много красивых и\nпривлекательных растений")
|
||||
val maxIndex = textList.size - 1
|
||||
|
||||
val currentIndex = sliderValue.toInt()
|
||||
@ -70,7 +70,8 @@ fun SliderScreen(onNavigateToAuthScreen: () -> Unit) {
|
||||
|
||||
Spacer(modifier = androidx.compose.ui.Modifier.weight(1f))
|
||||
|
||||
Sliderik(sliderValue, maxIndex){ newValue -> sliderValue = newValue }
|
||||
// Sliderik(sliderValue, maxIndex){ newValue -> sliderValue = newValue }
|
||||
Sliderik(currentIndex, maxIndex) { newIndex -> sliderValue = newIndex.toFloat() }
|
||||
|
||||
Button(
|
||||
onClick = {
|
||||
|
@ -3,6 +3,7 @@ package com.example.testktor.screen.auth
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
@ -29,6 +30,7 @@ import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.navigation.NavController
|
||||
import com.example.testktor.ViewModel.ButtonBack
|
||||
import com.example.testktor.forgotPassword
|
||||
import com.example.testktor.method.auth.BarForgot
|
||||
import com.example.testktor.resetPassword
|
||||
@ -66,8 +68,12 @@ fun ForgotPasswordContent(
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
verticalArrangement = Arrangement.Top
|
||||
) {
|
||||
ButtonBack(navController, "auth_screen")
|
||||
|
||||
Spacer(modifier = Modifier.height(20.dp))
|
||||
|
||||
if (forgotSuccess != null){
|
||||
if (forgotSuccess == "Success") {
|
||||
navController.navigate("resetPassword_screen")
|
||||
@ -85,6 +91,8 @@ fun ForgotPasswordContent(
|
||||
|
||||
BarForgot(emailIn){emailIn = it}
|
||||
|
||||
Spacer(modifier = Modifier.padding(10.dp))
|
||||
|
||||
Button(
|
||||
modifier = Modifier.width(350.dp).height(50.dp),
|
||||
colors = androidx.compose.material3.ButtonDefaults.buttonColors(
|
||||
|
@ -23,6 +23,7 @@ import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.navigation.NavController
|
||||
import com.example.testktor.ViewModel.ButtonBack
|
||||
import com.example.testktor.method.auth.BotBarReg
|
||||
import com.example.testktor.method.auth.TopBarReg
|
||||
import com.example.testktor.regUser
|
||||
@ -70,6 +71,10 @@ fun RegContent(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
ButtonBack(navController, "auth_screen")
|
||||
|
||||
Spacer(modifier = Modifier.height(20.dp))
|
||||
|
||||
if (regSuccess != null){
|
||||
if (regSuccess == "Success") {
|
||||
navController.navigate("auth_screen")
|
||||
@ -85,8 +90,6 @@ fun RegContent(
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(140.dp))
|
||||
|
||||
TopBarReg(nameIn, {nameIn = it}, emailIn, {emailIn = it}, passwordIn, {passwordIn = it})
|
||||
|
||||
Button(
|
||||
|
@ -2,6 +2,7 @@ package com.example.testktor.screen.auth
|
||||
|
||||
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
|
||||
@ -26,6 +27,7 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.navigation.NavController
|
||||
import com.android.identity.cbor.Uint
|
||||
import com.example.testktor.ViewModel.ButtonBack
|
||||
import com.example.testktor.authUser
|
||||
import com.example.testktor.method.auth.TextFieldsReset
|
||||
import com.example.testktor.method.auth.TopBarReset
|
||||
@ -68,8 +70,12 @@ fun ResetPasswordContent(
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
verticalArrangement = Arrangement.Top
|
||||
) {
|
||||
ButtonBack(navController, "auth_screen")
|
||||
|
||||
Spacer(modifier = Modifier.height(20.dp))
|
||||
|
||||
if (resetSuccess != null){
|
||||
if (resetSuccess == "Success") {
|
||||
navController.navigate("auth_screen")
|
||||
|
Loading…
Reference in New Issue
Block a user