Jelajahi Sumber

second 2 commit

unknown 1 bulan lalu
induk
melakukan
0e99c9c5a5

+ 1 - 0
app/build.gradle.kts

@@ -61,6 +61,7 @@ dependencies {
     implementation(libs.androidx.ui.tooling.preview)
     implementation(libs.androidx.material3)
     implementation(libs.play.services.auth)
+    implementation(libs.androidx.navigation.compose)
     testImplementation(libs.junit)
     androidTestImplementation(libs.androidx.junit)
     androidTestImplementation(libs.androidx.espresso.core)

+ 2 - 1
app/src/main/java/com/example/firstprojectsh/main/components/CountriesList.kt

@@ -22,12 +22,13 @@ import androidx.compose.ui.layout.ContentScale
 import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
+import androidx.navigation.NavHostController
 
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.withContext
 
 @Composable
-fun CountriesList() {
+fun CountriesList(navController: NavHostController) {
     Text(text = "Новая страница", fontSize = 25.sp)
 
 

+ 7 - 5
app/src/main/java/com/example/firstprojectsh/main/components/auth.kt

@@ -1,8 +1,10 @@
 package com.example.firstprojectsh.main.components
+import android.annotation.SuppressLint
 import androidx.compose.foundation.layout.Arrangement
 import androidx.compose.foundation.layout.Column
 import androidx.compose.foundation.layout.padding
 import androidx.compose.material3.Button
+import androidx.compose.material3.ExperimentalMaterial3Api
 import androidx.compose.material3.Icon
 import androidx.compose.material3.IconButton
 import androidx.compose.material3.Text
@@ -21,12 +23,14 @@ 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.NavHostController
 import com.example.firstprojectsh.R
 import com.example.firstprojectsh.main.MainViewModel
 
-@Preview
+
+@SuppressLint("RememberReturnType")
 @Composable
-fun auth() {
+fun auth(navController: NavHostController) {
     val viewModel = MainViewModel()
     val email = remember { mutableStateOf("") }
     val password = remember { mutableStateOf("") }
@@ -73,9 +77,7 @@ fun auth() {
         }){
             Text("Регистрация", fontSize = 25.sp)
         }
-        Button(onClick = {
-
-        }){
+        Button(onClick = {navController.navigate("ConfirmationEmail ")}){
             Text("как гость", fontSize = 25.sp)
         }
     }

+ 27 - 0
app/src/main/java/com/example/firstprojectsh/main/components/navigation.kt

@@ -0,0 +1,27 @@
+package com.example.firstprojectsh.main.components
+
+import android.os.Build
+import androidx.annotation.RequiresApi
+import androidx.compose.runtime.Composable
+import androidx.navigation.compose.NavHost
+import androidx.navigation.compose.composable
+import androidx.navigation.compose.rememberNavController
+
+@RequiresApi(Build.VERSION_CODES.O)
+@Composable
+fun Navigation() {
+    val navController = rememberNavController()
+    NavHost(navController = navController,
+        startDestination = "auth")
+    {
+        composable("auth"){
+            auth(navController)
+        }
+        composable("CountriesList"){
+            CountriesList(navController)
+        }
+
+    }
+}
+
+

+ 2 - 0
gradle/libs.versions.toml

@@ -14,6 +14,7 @@ activityCompose = "1.8.0"
 composeBom = "2024.04.01"
 serializerMoshi = "VERSION"
 playServicesAuth = "21.1.0"
+navigationCompose = "2.8.1"
 
 [libraries]
 androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -46,6 +47,7 @@ supabase-postgrest-kt = { module = "io.github.jan-tennert.supabase:postgrest-kt"
 supabase-realtime-kt = { module = "io.github.jan-tennert.supabase:realtime-kt" }
 supabase-serializer-moshi = { module = "io.github.jan-tennert.supabase:serializer-moshi", version.ref = "serializerMoshi" }
 play-services-auth = { group = "com.google.android.gms", name = "play-services-auth", version.ref = "playServicesAuth" }
+androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigationCompose" }
 
 [plugins]
 android-application = { id = "com.android.application", version.ref = "agp" }