ソースを参照

add: try add maps in project

Maksutka 5 日 前
コミット
61ead7ad2a

+ 5 - 1
TripHelper/app/build.gradle.kts

@@ -22,7 +22,6 @@ android {
             useSupportLibrary = true
         }
     }
-
     buildTypes {
         release {
             isMinifyEnabled = false
@@ -67,6 +66,8 @@ dependencies {
     implementation(libs.androidx.benchmark.macro)
     implementation(libs.firebase.firestore.ktx)
     implementation(libs.androidx.runtime.saved.instance.state)
+    implementation(libs.androidx.appcompat)
+    implementation(libs.play.services.maps)
     testImplementation(libs.junit)
     androidTestImplementation(libs.androidx.junit)
     androidTestImplementation(libs.androidx.espresso.core)
@@ -90,4 +91,7 @@ dependencies {
 
     implementation (libs.ui)
 
+    implementation(libs.mapkit)
+    implementation(libs.mapkit.search)
+    implementation (libs.maps.mobile)
 }

+ 2 - 2
TripHelper/app/src/main/java/com/example/triphelper/view/RouteScreens/ChoiceLocation.kt

@@ -297,8 +297,8 @@ fun ChoiceLocation(navController: NavController, iconsRouteIsActivity: MutableSt
             Row(modifier = Modifier.fillMaxWidth(0.6f).padding(top = 20.dp)) {
                 ButtonStyleBackSquare("Далее",33.sp) {
                     viewModel.getCity(cityTitle.value)
-                    if(viewModel.routeWrong.value) navController.navigate(NavigationRoutes.TOURS)
-//                    "${NavigationRoutes.CH_TOUR}/${cityTitle.value}"
+                    if(viewModel.routeWrong.value)
+                        navController.navigate( "${NavigationRoutes.CH_TOUR}/${cityTitle.value}")
                 }
             }
         }

+ 5 - 7
TripHelper/app/src/main/java/com/example/triphelper/view/RouteScreens/Tours.kt

@@ -58,19 +58,17 @@ import com.example.triphelper.view.theme.RobotoB
 import com.example.triphelper.view.theme.SeoulBold
 import io.github.jan.supabase.realtime.Column
 
-//titleCity : String, numberTour: String,
+//
 @Composable
-fun Tours(navController: NavController, iconsRouteIsActivity: MutableState<Boolean>,  viewModel: RouteViewModel = hiltViewModel()) {
+fun Tours(navController: NavController, iconsRouteIsActivity: MutableState<Boolean>,titleCity : String, numberTour: String,  viewModel: RouteViewModel = hiltViewModel()) {
     iconsRouteIsActivity.value = true
     val titleToure by viewModel.titleToure.collectAsState("")
-    val number = 1
-    val titleCity = "Сеул"
     var attarctionsColumn by remember { mutableStateOf(true) }
     var hotelColumn by remember { mutableStateOf(false) }
     var restouranceColumn by remember { mutableStateOf(false) }
     var metroColumn by remember { mutableStateOf(false) }
     val orgTour by viewModel.orgTour.collectAsState(initial = emptyList())
-//    numberTour.toInt()
+
 
     LaunchedEffect(key1 = viewModel.navigationTo) {
         viewModel.navigationTo.collect { destination ->
@@ -80,7 +78,7 @@ fun Tours(navController: NavController, iconsRouteIsActivity: MutableState<Boole
         }
     }
     LaunchedEffect(Unit) {
-        viewModel.getNameToure(number)
+        viewModel.getNameToure(numberTour.toInt())
     }
     viewModel.getCountry()
     StyleMainFone()
@@ -223,7 +221,7 @@ fun Tours(navController: NavController, iconsRouteIsActivity: MutableState<Boole
             }
         }
         LaunchedEffect(Unit) {
-            viewModel.GetAttractions(number, titleCity)
+            viewModel.GetAttractions(numberTour.toInt(), titleCity)
         }
         if (attarctionsColumn) {
             AttractionsLazy(orgTour)

+ 2 - 0
TripHelper/app/src/main/java/com/example/triphelper/view/mainActivity/MainActivity.kt

@@ -14,6 +14,7 @@ import com.example.studybuddy.view.panels.bottombar.BottomBar
 import com.example.studybuddy.view.panels.topbar.TopBarApp
 import com.example.triphelper.view.navigation.Navigation
 import com.example.triphelper.view.style.StyleMainFone
+import com.yandex.mapkit.MapKitFactory
 import dagger.hilt.android.AndroidEntryPoint
 
 @AndroidEntryPoint
@@ -22,6 +23,7 @@ class MainActivity : ComponentActivity() {
     @RequiresApi(Build.VERSION_CODES.O)
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
+        MapKitFactory.setApiKey("9e42329a-2735-445f-ad60-32a56c59bce3")
         setContent {
             val controller = rememberNavController()
             val barsIsVisible = remember { mutableStateOf(false) }

+ 2 - 0
TripHelper/app/src/main/java/com/example/triphelper/view/maps/Maps.kt

@@ -0,0 +1,2 @@
+package com.example.triphelper.view.maps
+

+ 8 - 17
TripHelper/app/src/main/java/com/example/triphelper/view/navigation/Navigation.kt

@@ -23,7 +23,7 @@ fun Navigation(controller: NavHostController, barsIsVisible: MutableState<Boolea
                iconsLawIsActivity: MutableState<Boolean>, iconsProfileIsActivity: MutableState<Boolean>,
                iconsAdviceIsActivity: MutableState<Boolean>,iconsMainIsActivity: MutableState<Boolean>, iconsRoutsIsActivity: MutableState<Boolean>) {
     NavHost(navController = controller,
-        startDestination = NavigationRoutes.TOURS)
+        startDestination = NavigationRoutes.CH_LOC)
     {
         composable( NavigationRoutes.AUTH){
             barsIsVisible.value = false
@@ -86,28 +86,19 @@ fun Navigation(controller: NavHostController, barsIsVisible: MutableState<Boolea
                 ChoiceTour(controller, iconsRoutsIsActivity, titleCity)
             }
         }
-//        composable(route =  "${NavigationRoutes.TOURS}/{titleCity}/{numberToure}"){
-//                backStackEntry ->
-//            val titleCity = backStackEntry.arguments?.getString("titleCity")
-//            val numberToure = backStackEntry.arguments?.getString("numberToure")
-//            barsIsVisible.value = true
-//            iconsLawIsActivity.value = false
-//            iconsAdviceIsActivity.value = false
-//            iconsProfileIsActivity.value = false
-//            iconsMainIsActivity.value = false
-//            iconsRoutsIsActivity.value = false
-//            if (titleCity != null && numberToure != null) {
-//                Tours(controller, iconsRoutsIsActivity, titleCity, numberToure)
-//            }
-//        }
-        composable(NavigationRoutes.TOURS){
+        composable(route =  "${NavigationRoutes.TOURS}/{titleCity}/{numberToure}"){
+                backStackEntry ->
+            val titleCity = backStackEntry.arguments?.getString("titleCity")
+            val numberToure = backStackEntry.arguments?.getString("numberToure")
             barsIsVisible.value = true
             iconsLawIsActivity.value = false
             iconsAdviceIsActivity.value = false
             iconsProfileIsActivity.value = false
             iconsMainIsActivity.value = false
             iconsRoutsIsActivity.value = false
-            Tours(controller, iconsRoutsIsActivity)
+            if (titleCity != null && numberToure != null) {
+                Tours(controller, iconsRoutsIsActivity, titleCity, numberToure)
+            }
         }
     }
 }

+ 24 - 0
TripHelper/gradle/libs.versions.toml

@@ -1,5 +1,7 @@
 [versions]
+accompanistPermissions = "0.31.2-alpha"
 agp = "8.5.1"
+androidMapsUtils = "3.5.0"
 bom = "2.6.1"
 bomVersion = "VERSION"
 coilCompose = "2.4.0"
@@ -17,7 +19,12 @@ ktorClientEngine_z = "2.3.12"
 lifecycleRuntimeKtx = "2.8.7"
 activityCompose = "1.9.3"
 composeBom = "2024.10.01"
+mapkit = "4.0.0"
+mapkitSearch = "4.0.0"
+mapsMobile = "4.8.1-lite"
+mapsUtilsKtx = "3.5.0"
 navigationCompose = "2.8.3"
+playServicesMapsVersion = "18.1.0"
 storageKt = "2.6.0"
 ui = "1.7.5"
 xmodule_z = "2.6.0"
@@ -25,8 +32,16 @@ volley = "1.2.1"
 benchmarkMacro = "1.3.3"
 firebaseFirestoreKtx = "25.1.1"
 runtimeSavedInstanceState = "1.0.0-alpha11"
+appcompat = "1.7.0"
+playServicesMaps = "19.0.0"
+yandexMapkitKmp = "0.1.0"
+yandexMapkitKmpCompose = "0.1.0"
 
 [libraries]
+accompanist-navigation-material = { module = "com.github.chrisbanes.accompanist:accompanist-navigation-material", version.ref = "accompanistPermissions" }
+accompanist-permissions = { module = "com.github.chrisbanes.accompanist:accompanist-permissions", version.ref = "accompanistPermissions" }
+accompanist-systemuicontroller = { module = "com.github.chrisbanes.accompanist:accompanist-systemuicontroller", version.ref = "accompanistPermissions" }
+android-maps-utils = { module = "com.google.maps.android:android-maps-utils", version.ref = "androidMapsUtils" }
 androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
 androidx-core-ktx-v1150 = { module = "androidx.core:core-ktx", version.ref = "coreKtxVersion" }
 androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "hiltNavigationCompose" }
@@ -54,6 +69,11 @@ androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit
 androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
 ktor-client-android = { module = "io.ktor:ktor-client-android", version.ref = "ktorClientAndroid" }
 ktor-client-engine_z = { module = "io.ktor:ktor-client-[engine]", version.ref = "ktorClientEngine_z" }
+mapkit = { module = "com.yandex.mapkit:mapkit", version.ref = "mapkit" }
+mapkit-search = { module = "com.yandex.mapkit:mapkit-search", version.ref = "mapkitSearch" }
+maps-mobile = { module = "com.yandex.android:maps.mobile", version.ref = "mapsMobile" }
+maps-utils-ktx = { module = "com.google.maps.android:maps-utils-ktx", version.ref = "mapsUtilsKtx" }
+play-services-maps-v1810 = { module = "com.google.android.gms:play-services-maps", version.ref = "playServicesMapsVersion" }
 realtime-kt = { module = "io.github.jan-tennert.supabase:realtime-kt" }
 postgrest-kt = { module = "io.github.jan-tennert.supabase:postgrest-kt" }
 storage-kt = { module = "io.github.jan-tennert.supabase:storage-kt", version.ref = "storageKt" }
@@ -66,6 +86,10 @@ volley = { group = "com.android.volley", name = "volley", version.ref = "volley"
 androidx-benchmark-macro = { group = "androidx.benchmark", name = "benchmark-macro", version.ref = "benchmarkMacro" }
 firebase-firestore-ktx = { group = "com.google.firebase", name = "firebase-firestore-ktx", version.ref = "firebaseFirestoreKtx" }
 androidx-runtime-saved-instance-state = { group = "androidx.compose.runtime", name = "runtime-saved-instance-state", version.ref = "runtimeSavedInstanceState" }
+androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
+play-services-maps = { group = "com.google.android.gms", name = "play-services-maps", version.ref = "playServicesMaps" }
+yandex-mapkit-kmp = { module = "ru.sulgik.mapkit:yandex-mapkit-kmp", version.ref = "yandexMapkitKmp" }
+yandex-mapkit-kmp-compose = { module = "ru.sulgik.mapkit:yandex-mapkit-kmp-compose", version.ref = "yandexMapkitKmpCompose" }
 
 [plugins]
 android-application = { id = "com.android.application", version.ref = "agp" }

+ 1 - 0
TripHelper/settings.gradle.kts

@@ -16,6 +16,7 @@ dependencyResolutionManagement {
     repositories {
         google()
         mavenCentral()
+        maven { url = uri("https://maven.yandex.net/releases") } // Яндекс репозиторий
     }
 }