|
@@ -1,4 +1,150 @@
|
|
|
package com.example.neurea.views.screens
|
|
|
|
|
|
-class AuthorizationScreen {
|
|
|
+import androidx.compose.foundation.background
|
|
|
+import androidx.compose.foundation.layout.Column
|
|
|
+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.width
|
|
|
+import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
+import androidx.compose.foundation.text.KeyboardOptions
|
|
|
+import androidx.compose.material3.Button
|
|
|
+import androidx.compose.material3.ButtonDefaults
|
|
|
+import androidx.compose.material3.ExperimentalMaterial3Api
|
|
|
+import androidx.compose.material3.Icon
|
|
|
+import androidx.compose.material3.IconButton
|
|
|
+import androidx.compose.material3.MaterialTheme
|
|
|
+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
|
|
|
+import androidx.compose.runtime.remember
|
|
|
+import androidx.compose.runtime.setValue
|
|
|
+import androidx.compose.ui.Alignment
|
|
|
+import androidx.compose.ui.Modifier
|
|
|
+import androidx.compose.ui.draw.clip
|
|
|
+import androidx.compose.ui.graphics.Brush
|
|
|
+import androidx.compose.ui.graphics.Color
|
|
|
+import androidx.compose.ui.res.painterResource
|
|
|
+import androidx.compose.ui.text.TextStyle
|
|
|
+import androidx.compose.ui.text.font.FontWeight
|
|
|
+import androidx.compose.ui.text.input.KeyboardType
|
|
|
+import androidx.compose.ui.text.input.PasswordVisualTransformation
|
|
|
+import androidx.compose.ui.text.input.VisualTransformation
|
|
|
+import androidx.compose.ui.tooling.preview.Preview
|
|
|
+import androidx.compose.ui.unit.dp
|
|
|
+import androidx.compose.ui.unit.sp
|
|
|
+import androidx.navigation.NavController
|
|
|
+import com.example.neurea.R
|
|
|
+
|
|
|
+@OptIn(ExperimentalMaterial3Api::class)
|
|
|
+@Composable
|
|
|
+fun AuthorizationScreen(navController: NavController) { // navController: NavController
|
|
|
+ var email = remember { mutableStateOf("") }
|
|
|
+ var password = remember { mutableStateOf("") }
|
|
|
+ val maxLength = 20
|
|
|
+ val emailPattern = Regex("[^@ \\t\\r\\n]+@[^@ \\t\\r\\n]+\\.[^@ \\t\\r\\n]+")
|
|
|
+ var passwordVisibility: Boolean by remember { mutableStateOf(false) }
|
|
|
+
|
|
|
+ Column(modifier = Modifier
|
|
|
+ .fillMaxSize()
|
|
|
+ .background(color = MaterialTheme.colorScheme.secondary)){
|
|
|
+ Text(text="Добро пожаловать!", color = MaterialTheme.colorScheme.primary, modifier = Modifier
|
|
|
+ .padding(top = 70.dp, bottom = 24.dp, start = 24.dp)
|
|
|
+ .align(Alignment.Start),
|
|
|
+ fontSize = 35.sp, fontWeight = FontWeight.SemiBold)
|
|
|
+ TextField( modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .padding(horizontal = 20.dp, vertical = 10.dp)
|
|
|
+ .clip(shape = RoundedCornerShape(8.dp)),
|
|
|
+ value = email.value,
|
|
|
+ keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Email),
|
|
|
+ colors = TextFieldDefaults.textFieldColors(
|
|
|
+ containerColor = MaterialTheme.colorScheme.secondary,
|
|
|
+ focusedIndicatorColor = MaterialTheme.colorScheme.secondary,
|
|
|
+ focusedTextColor = MaterialTheme.colorScheme.onPrimary,
|
|
|
+ unfocusedTextColor = MaterialTheme.colorScheme.secondary,
|
|
|
+ disabledIndicatorColor = Color.Transparent,
|
|
|
+ unfocusedIndicatorColor = Color.Transparent,
|
|
|
+ cursorColor = MaterialTheme.colorScheme.primary,
|
|
|
+ disabledPlaceholderColor = MaterialTheme.colorScheme.onSecondary,
|
|
|
+ focusedPlaceholderColor = MaterialTheme.colorScheme.onSecondary,
|
|
|
+ unfocusedPlaceholderColor = MaterialTheme.colorScheme.onSecondary
|
|
|
+ ),
|
|
|
+
|
|
|
+ onValueChange = {
|
|
|
+ if (it.length <= maxLength) email.value = it
|
|
|
+ /*if (email.value.isNotEmpty() and emailPattern.matches(email.value)) {
|
|
|
+ colorOfButton = lavender.value
|
|
|
+ } else {
|
|
|
+ colorOfButton = gainsboro.value
|
|
|
+ }*/
|
|
|
+ },
|
|
|
+ placeholder = {Text("Email")},
|
|
|
+ singleLine = true
|
|
|
+ )
|
|
|
+
|
|
|
+ TextField(modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .padding(horizontal = 20.dp, vertical = 10.dp)
|
|
|
+ .clip(shape = RoundedCornerShape(8.dp)),
|
|
|
+ value = password.value,
|
|
|
+ colors = TextFieldDefaults.textFieldColors(
|
|
|
+ containerColor = MaterialTheme.colorScheme.secondary,
|
|
|
+ focusedIndicatorColor = MaterialTheme.colorScheme.secondary,
|
|
|
+ focusedTextColor = MaterialTheme.colorScheme.onPrimary,
|
|
|
+ unfocusedTextColor = MaterialTheme.colorScheme.secondary,
|
|
|
+ disabledIndicatorColor = Color.Transparent,
|
|
|
+ unfocusedIndicatorColor = Color.Transparent,
|
|
|
+ cursorColor = MaterialTheme.colorScheme.primary,
|
|
|
+ disabledPlaceholderColor = MaterialTheme.colorScheme.onSecondary,
|
|
|
+ focusedPlaceholderColor = MaterialTheme.colorScheme.onSecondary,
|
|
|
+ unfocusedPlaceholderColor = MaterialTheme.colorScheme.onSecondary
|
|
|
+ ),
|
|
|
+ visualTransformation = if (passwordVisibility) VisualTransformation.None else PasswordVisualTransformation(),
|
|
|
+ trailingIcon = {
|
|
|
+ IconButton(onClick = {
|
|
|
+ passwordVisibility = !passwordVisibility
|
|
|
+ }) {
|
|
|
+ if (passwordVisibility) {
|
|
|
+ Icon(
|
|
|
+ painter = painterResource(id = R.drawable.baseline_visibility_24),
|
|
|
+ contentDescription = ""
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ Icon(
|
|
|
+ painter = painterResource(id = R.drawable.baseline_visibility_off_24),
|
|
|
+ contentDescription = ""
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onValueChange = {
|
|
|
+ if (it.length <= maxLength) password.value = it
|
|
|
+ },
|
|
|
+ placeholder = {Text("Введите пароль")},
|
|
|
+ singleLine = true)
|
|
|
+
|
|
|
+ Button(onClick = {
|
|
|
+ },
|
|
|
+ modifier = Modifier
|
|
|
+ .width(260.dp)
|
|
|
+ .padding(top=20.dp, bottom = 10.dp, start = 30.dp, end = 30.dp)
|
|
|
+ .height(50.dp)
|
|
|
+ , shape = RoundedCornerShape(8.dp),
|
|
|
+ colors = ButtonDefaults.buttonColors(
|
|
|
+ containerColor = MaterialTheme.colorScheme.primary),
|
|
|
+
|
|
|
+ ){
|
|
|
+
|
|
|
+ Text("Войти", fontSize = 20.sp, color = MaterialTheme.colorScheme.secondary)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
}
|