Навигация между экранами регистрации и авторизации + обновление targetSdk до 34 версии
This commit is contained in:
parent
8f58d80118
commit
1a76a041f0
17
.idea/deploymentTargetDropDown.xml
Normal file
17
.idea/deploymentTargetDropDown.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<targetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="C:\Users\dxren\.android\avd\Pixel_3a_API_34_extension_level_7_x86_64.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</targetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2023-10-08T11:14:30.167187700Z" />
|
||||
</component>
|
||||
</project>
|
@ -5,12 +5,12 @@ plugins {
|
||||
|
||||
android {
|
||||
namespace 'com.example.shawarma'
|
||||
compileSdk 33
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.example.shawarma"
|
||||
minSdk 23
|
||||
targetSdk 33
|
||||
targetSdk 34
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
@ -47,7 +47,9 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.20"
|
||||
def nav_version = "2.7.0"
|
||||
implementation "androidx.navigation:navigation-compose:$nav_version"
|
||||
implementation 'androidx.core:core-ktx:1.7.0'
|
||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
|
||||
implementation 'androidx.activity:activity-compose:1.3.1'
|
||||
|
@ -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.MainNavBar
|
||||
import com.example.shawarma.screens.authorization.AuthorizationScreen
|
||||
import com.example.shawarma.screens.registration.RegistrationScreen
|
||||
import com.example.shawarma.ui.theme.MyLightYellow
|
||||
@ -23,7 +24,7 @@ class MainActivity : ComponentActivity() {
|
||||
modifier = Modifier.fillMaxSize()
|
||||
)
|
||||
{
|
||||
AuthorizationScreen()
|
||||
MainNavBar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
23
app/src/main/java/com/example/shawarma/screens/MainNavBar.kt
Normal file
23
app/src/main/java/com/example/shawarma/screens/MainNavBar.kt
Normal file
@ -0,0 +1,23 @@
|
||||
package com.example.shawarma.screens
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import com.example.shawarma.screens.authorization.AuthorizationScreen
|
||||
import com.example.shawarma.screens.registration.RegistrationScreen
|
||||
import com.example.shawarma.utils.ScreenPaths
|
||||
|
||||
@Composable
|
||||
fun MainNavBar() {
|
||||
val navController = rememberNavController()
|
||||
|
||||
NavHost(navController = navController, startDestination = ScreenPaths.authorization.name) {
|
||||
composable(ScreenPaths.authorization.name) {
|
||||
AuthorizationScreen(navController)
|
||||
}
|
||||
composable(ScreenPaths.registration.name) {
|
||||
RegistrationScreen(navController)
|
||||
}
|
||||
}
|
||||
}
|
@ -24,19 +24,21 @@ 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 androidx.navigation.NavHostController
|
||||
import com.example.shawarma.ui.theme.JejuFamily
|
||||
import com.example.shawarma.ui.theme.MyLightRed
|
||||
import com.example.shawarma.utils.ScreenPaths
|
||||
import com.example.shawarma.widgets.MyTextField
|
||||
import com.example.shawarma.widgets.ShawarmaLogo1
|
||||
|
||||
@Composable
|
||||
fun AuthorizationScreen() {
|
||||
fun AuthorizationScreen(navHostController: NavHostController) {
|
||||
ShawarmaLogo1()
|
||||
AuthorizationCard()
|
||||
AuthorizationCard(navHostController)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun AuthorizationCard() {
|
||||
fun AuthorizationCard(navHostController: NavHostController) {
|
||||
val login = remember { mutableStateOf(TextFieldValue("")) }
|
||||
val password = remember { mutableStateOf(TextFieldValue("")) }
|
||||
|
||||
@ -106,7 +108,13 @@ fun AuthorizationCard() {
|
||||
)
|
||||
}
|
||||
Button(
|
||||
onClick = { /*TODO*/ },
|
||||
onClick = {
|
||||
navHostController.navigate(ScreenPaths.registration.name) {
|
||||
popUpTo(ScreenPaths.registration.name) {
|
||||
inclusive = true
|
||||
}
|
||||
}
|
||||
},
|
||||
colors = ButtonDefaults.buttonColors(Color.White),
|
||||
elevation = ButtonDefaults.elevation(0.dp)
|
||||
) {
|
||||
|
@ -27,20 +27,22 @@ 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 androidx.navigation.NavHostController
|
||||
import com.example.shawarma.ui.theme.JejuFamily
|
||||
import com.example.shawarma.ui.theme.MyLightRed
|
||||
import com.example.shawarma.utils.ScreenPaths
|
||||
import com.example.shawarma.widgets.MyTextField
|
||||
import com.example.shawarma.widgets.ShawarmaLogo1
|
||||
|
||||
@Composable
|
||||
fun RegistrationScreen() {
|
||||
RegistrationCard()
|
||||
fun RegistrationScreen(navHostController: NavHostController) {
|
||||
RegistrationCard(navHostController)
|
||||
ShawarmaLogo1()
|
||||
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun RegistrationCard(){
|
||||
fun RegistrationCard(navHostController: NavHostController){
|
||||
val login = remember { mutableStateOf(TextFieldValue("")) }
|
||||
val password = remember { mutableStateOf(TextFieldValue("")) }
|
||||
val passwordRepeat = remember { mutableStateOf(TextFieldValue("")) }
|
||||
@ -104,7 +106,9 @@ fun RegistrationCard(){
|
||||
singleLine = true
|
||||
)
|
||||
Button(
|
||||
onClick = { /*TODO*/ },
|
||||
onClick = {
|
||||
// TODO
|
||||
},
|
||||
colors = ButtonDefaults.buttonColors(MyLightRed, Color.White),
|
||||
shape = RoundedCornerShape(20.dp),
|
||||
modifier = Modifier
|
||||
@ -122,7 +126,13 @@ fun RegistrationCard(){
|
||||
)
|
||||
}
|
||||
Button(
|
||||
onClick = { /*TODO*/ },
|
||||
onClick = {
|
||||
navHostController.navigate(ScreenPaths.authorization.name) {
|
||||
popUpTo(ScreenPaths.authorization.name) {
|
||||
inclusive = true
|
||||
}
|
||||
}
|
||||
},
|
||||
colors = ButtonDefaults.buttonColors(Color.White),
|
||||
elevation = ButtonDefaults.elevation(0.dp)
|
||||
) {
|
||||
|
@ -0,0 +1,5 @@
|
||||
package com.example.shawarma.utils
|
||||
|
||||
enum class ScreenPaths {
|
||||
authorization, registration
|
||||
}
|
Loading…
Reference in New Issue
Block a user