From 8f58d80118cacca8ccc2f47421d1813beae3e4f9 Mon Sep 17 00:00:00 2001 From: danyasedoy Date: Sat, 7 Oct 2023 20:36:35 +0400 Subject: [PATCH] =?UTF-8?q?=D0=AD=D0=BA=D1=80=D0=B0=D0=BD=20=D0=B0=D0=B2?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8=20+=20?= =?UTF-8?q?=D1=81=D0=BA=D1=80=D0=BE=D0=BB=D0=BB=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=D1=8F=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B8=20=D1=8D?= =?UTF-8?q?=D0=BA=D1=80=D0=B0=D0=BD=D0=BD=D0=BE=D0=B9=20=D0=BA=D0=BB=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=B0=D1=82=D1=83=D1=80=D1=8B=20+=20=D0=BC=D0=B8?= =?UTF-8?q?=D0=BD=D0=BE=D1=80=D0=BD=D1=8B=D0=B5=20=D0=B8=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 1 + .../java/com/example/shawarma/MainActivity.kt | 4 +- .../authorization/AuthorizationScreen.kt | 125 ++++++++++++++++++ .../registration/RegistrationScreen.kt | 13 +- .../example/shawarma/widgets/ShawarmaLogo1.kt | 7 +- 5 files changed, 145 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/com/example/shawarma/screens/authorization/AuthorizationScreen.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f3d46e4..30b8248 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,6 +13,7 @@ tools:targetApi="31"> diff --git a/app/src/main/java/com/example/shawarma/MainActivity.kt b/app/src/main/java/com/example/shawarma/MainActivity.kt index b19e479..429e02c 100644 --- a/app/src/main/java/com/example/shawarma/MainActivity.kt +++ b/app/src/main/java/com/example/shawarma/MainActivity.kt @@ -6,6 +6,7 @@ import androidx.activity.compose.setContent import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material.Surface import androidx.compose.ui.Modifier +import com.example.shawarma.screens.authorization.AuthorizationScreen import com.example.shawarma.screens.registration.RegistrationScreen import com.example.shawarma.ui.theme.MyLightYellow import com.example.shawarma.ui.theme.ShawarmaTheme @@ -13,6 +14,7 @@ import com.example.shawarma.ui.theme.ShawarmaTheme class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + setContent { ShawarmaTheme { // A surface container using the 'background' color from the theme @@ -21,7 +23,7 @@ class MainActivity : ComponentActivity() { modifier = Modifier.fillMaxSize() ) { - RegistrationScreen() + AuthorizationScreen() } } } diff --git a/app/src/main/java/com/example/shawarma/screens/authorization/AuthorizationScreen.kt b/app/src/main/java/com/example/shawarma/screens/authorization/AuthorizationScreen.kt new file mode 100644 index 0000000..a820d4b --- /dev/null +++ b/app/src/main/java/com/example/shawarma/screens/authorization/AuthorizationScreen.kt @@ -0,0 +1,125 @@ +package com.example.shawarma.screens.authorization + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.imePadding +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.verticalScroll +import androidx.compose.material.Button +import androidx.compose.material.ButtonDefaults +import androidx.compose.material.Card +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.input.TextFieldValue +import androidx.compose.ui.text.style.TextDecoration +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.compose.ui.zIndex +import com.example.shawarma.ui.theme.JejuFamily +import com.example.shawarma.ui.theme.MyLightRed +import com.example.shawarma.widgets.MyTextField +import com.example.shawarma.widgets.ShawarmaLogo1 + +@Composable +fun AuthorizationScreen() { + ShawarmaLogo1() + AuthorizationCard() +} + +@Composable +fun AuthorizationCard() { + val login = remember { mutableStateOf(TextFieldValue("")) } + val password = remember { mutableStateOf(TextFieldValue("")) } + + Column( + horizontalAlignment = Alignment.CenterHorizontally, + modifier = Modifier + .zIndex(2f) + .verticalScroll(rememberScrollState()) + .imePadding().padding(10.dp) + .fillMaxHeight() + ) { + Card( + shape = RoundedCornerShape(20.dp), + modifier = Modifier.size(275.dp, 290.dp + 72.dp).padding(top = 72.dp) + ) { + Column( + horizontalAlignment = Alignment.CenterHorizontally + ) { + Text( + text = "Авторизация", + fontSize = 20.sp, + modifier = Modifier.padding( + top = 20.dp + ), + style = TextStyle( + fontFamily = JejuFamily + ) + ) + MyTextField( + text = login, + onTextChanged = {login.value = it}, + modifier = Modifier + .padding( + top = (20).dp + ) + .size(208.dp, (50).dp), + placeholder = "Логин", + singleLine = true + ) + MyTextField( + text = password, + onTextChanged = {password.value = it}, + modifier = Modifier + .padding( + top = (20).dp + ) + .size(208.dp, (50).dp), + placeholder = "Пароль", + singleLine = true + ) + Button( + onClick = { /*TODO*/ }, + colors = ButtonDefaults.buttonColors(MyLightRed, Color.White), + shape = RoundedCornerShape(20.dp), + modifier = Modifier + .padding( + top = (20).dp + ) + .size(208.dp, (50).dp) + ) { + Text( + text = "Войти", + style = TextStyle( + fontFamily = JejuFamily, + fontSize = 16.sp + ) + ) + } + Button( + onClick = { /*TODO*/ }, + colors = ButtonDefaults.buttonColors(Color.White), + elevation = ButtonDefaults.elevation(0.dp) + ) { + Text( + text = "У меня нет аккаунта!", + textDecoration = TextDecoration.Underline, + style = TextStyle( + fontFamily = JejuFamily, + fontSize = 12.sp + ) + ) + } + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/shawarma/screens/registration/RegistrationScreen.kt b/app/src/main/java/com/example/shawarma/screens/registration/RegistrationScreen.kt index f71df22..8787308 100644 --- a/app/src/main/java/com/example/shawarma/screens/registration/RegistrationScreen.kt +++ b/app/src/main/java/com/example/shawarma/screens/registration/RegistrationScreen.kt @@ -1,9 +1,16 @@ package com.example.shawarma.screens.registration +import androidx.compose.foundation.background +import androidx.compose.foundation.gestures.FlingBehavior +import androidx.compose.foundation.gestures.ScrollScope import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.verticalScroll import androidx.compose.material.Button import androidx.compose.material.ButtonDefaults import androidx.compose.material.Card @@ -41,12 +48,14 @@ fun RegistrationCard(){ Column( horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier - .padding(top = 72.dp) .zIndex(2f) + .verticalScroll(rememberScrollState()) + .imePadding().padding(10.dp) + .fillMaxHeight() ) { Card( shape = RoundedCornerShape(20.dp), - modifier = Modifier.size(275.dp, 380.dp) + modifier = Modifier.size(275.dp, 380.dp + 72.dp).padding(top = 72.dp) ) { Column( horizontalAlignment = Alignment.CenterHorizontally diff --git a/app/src/main/java/com/example/shawarma/widgets/ShawarmaLogo1.kt b/app/src/main/java/com/example/shawarma/widgets/ShawarmaLogo1.kt index 12f49bc..b2d5a30 100644 --- a/app/src/main/java/com/example/shawarma/widgets/ShawarmaLogo1.kt +++ b/app/src/main/java/com/example/shawarma/widgets/ShawarmaLogo1.kt @@ -1,6 +1,7 @@ package com.example.shawarma.widgets import androidx.compose.foundation.Image +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.offset @@ -8,6 +9,7 @@ import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.rotate +import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import androidx.compose.ui.zIndex @@ -16,8 +18,9 @@ import com.example.shawarma.R @Composable fun ShawarmaLogo1(){ Column(modifier = Modifier - .zIndex(1f) - .fillMaxSize()) { + .zIndex(-1f) + .fillMaxSize() + ) { Image( painterResource( id = R.drawable.shawarma1