Răsfoiți Sursa

add: routeviewmodel; update: the items in the routescreens folder have been changed, navigation, bottombar

Maksutka 1 săptămână în urmă
părinte
comite
b387bea1b6

+ 36 - 11
TripHelper/app/src/main/java/com/example/triphelper/view/AppBar/bottombar/BottomBar.kt

@@ -123,17 +123,42 @@ fun BottomBar(controller: NavController,
                 modifier = Modifier.fillMaxHeight(),
                 contentAlignment = Alignment.Center
             ) {
-                IconButton(
-                    onClick = {},
-                    modifier = Modifier
-                        .size(111.dp)
-                        .background(color = Color(0xFFDC5B6E), RoundedCornerShape(100.dp))
-                ) {
-                    Icon(
-                        painter = painterResource(id = R.drawable.route_not_active),
-                        contentDescription = "Маршруты и туры",
-                        tint = Color.White,
-                    )
+                if(iconsRoutsIsActivity.value){
+                    IconButton(
+                        onClick = {
+                            controller.navigate((NavigationRoutes.CH_LOC))
+                        },
+                        modifier = Modifier
+                            .size(111.dp)
+                            .background(color = Color(0xFFDC5B6E), RoundedCornerShape(100.dp))
+                            .border(
+                                width = 5.dp,
+                                color = Color(0xFF510B3C),
+                                RoundedCornerShape(100.dp)
+                            )
+                    ) {
+                        Icon(
+                            painter = painterResource(id = R.drawable.route_not_active),
+                            contentDescription = "Маршруты и туры",
+                            tint = Color(0xFF510B3C),
+                        )
+                    }
+                }
+                else{
+                    IconButton(
+                        onClick = {
+                            controller.navigate((NavigationRoutes.CH_LOC))
+                        },
+                        modifier = Modifier
+                            .size(111.dp)
+                            .background(color = Color(0xFFDC5B6E), RoundedCornerShape(100.dp))
+                    ) {
+                        Icon(
+                            painter = painterResource(id = R.drawable.route_not_active),
+                            contentDescription = "Маршруты и туры",
+                            tint = Color.White,
+                        )
+                    }
                 }
             }
         }

+ 1 - 1
TripHelper/app/src/main/java/com/example/triphelper/view/Auth/Auth.kt

@@ -108,7 +108,7 @@ fun Auth(navController: NavController, viewModel: AuthViewModel = hiltViewModel(
                         navController.navigate(NavigationRoutes.REG)
                     }
                     Spacer(modifier = Modifier.width(20.dp))
-                    ButtonStyleBackSquare("Вход",45) {
+                    ButtonStyleBackSquare("Вход",45.sp) {
                         viewModel.onSignInEmailPassword(
                             email.value,
                             password.value,

+ 1 - 18
TripHelper/app/src/main/java/com/example/triphelper/view/LawScreen/LawScreen.kt

@@ -1,8 +1,6 @@
 package com.example.triphelper.view.MainScreen
 
 
-import androidx.compose.foundation.Image
-import androidx.compose.foundation.background
 import androidx.compose.foundation.border
 import com.example.triphelper.view.style.ButtonStyleBackSquare
 import androidx.compose.foundation.layout.Arrangement
@@ -14,14 +12,9 @@ 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.size
-import androidx.compose.foundation.layout.wrapContentSize
-import androidx.compose.foundation.lazy.LazyColumn
-import androidx.compose.foundation.lazy.items
 import androidx.compose.foundation.shape.RoundedCornerShape
 import androidx.compose.material3.Button
 import androidx.compose.material3.ButtonDefaults.buttonColors
-import androidx.compose.material3.CircularProgressIndicator
 import androidx.compose.material3.DropdownMenu
 import androidx.compose.material3.DropdownMenuItem
 import androidx.compose.material3.Icon
@@ -36,11 +29,7 @@ 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.Color
-import androidx.compose.ui.input.pointer.motionEventSpy
-import androidx.compose.ui.layout.ContentScale
-import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.res.painterResource
 import androidx.compose.ui.text.font.FontWeight
 import androidx.compose.ui.text.style.TextAlign
@@ -48,18 +37,12 @@ import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
 import androidx.hilt.navigation.compose.hiltViewModel
 import androidx.navigation.NavController
-import coil.compose.AsyncImagePainter
-import coil.compose.rememberAsyncImagePainter
-import coil.request.ImageRequest
 import com.example.testirovanye_supabase.R
 import com.example.triphelper.view.navigation.NavigationRoutes
-import com.example.triphelper.view.style.ButtonStyleBackSquare
 import com.example.triphelper.view.style.StyleMainFone
-import com.example.triphelper.view.theme.Casagrand
 import com.example.triphelper.view.theme.Roboto
 import com.example.triphelper.view.theme.RobotoB
 import com.example.triphelper.view.theme.SeoulBold
-import com.example.triphelper.view.theme.SeoulLight
 
 @Composable
 fun LawScreen(navController: NavController, iconsLawIsActivity: MutableState<Boolean>,viewModel: LawScreenViewModel = hiltViewModel()) {
@@ -178,7 +161,7 @@ fun LawScreen(navController: NavController, iconsLawIsActivity: MutableState<Boo
             }
         }
         Row(modifier = Modifier.fillMaxWidth(0.6f)) {
-            ButtonStyleBackSquare("Далее",33) {
+            ButtonStyleBackSquare("Далее",33.sp) {
                 viewModel.GetRules(coutryTitle.value)
                 if(viewModel.wrong.value){
                     navController.navigate("${NavigationRoutes.DESCLAW}/${coutryTitle.value}")

+ 1 - 1
TripHelper/app/src/main/java/com/example/triphelper/view/Registration/Registration.kt

@@ -227,7 +227,7 @@ fun Registration(
                     navController.navigate(NavigationRoutes.AUTH)
                 }
                 Spacer(modifier = Modifier.width(20.dp))
-                ButtonStyleBackSquare("Регистрация",33) {
+                ButtonStyleBackSquare("Регистрация",33.sp) {
                     viewModel.createNewUser(
                         emailUser = email.value,
                         passwordUser = password.value,

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

@@ -1,2 +1,304 @@
 package com.example.triphelper.view.RouteScreens
 
+import androidx.compose.foundation.background
+import androidx.compose.foundation.border
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxHeight
+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.shape.RoundedCornerShape
+import androidx.compose.material3.Button
+import androidx.compose.material3.ButtonDefaults.buttonColors
+import androidx.compose.material3.DropdownMenu
+import androidx.compose.material3.DropdownMenuItem
+import androidx.compose.material3.Icon
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.MutableState
+import androidx.compose.runtime.collectAsState
+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.Color
+import androidx.compose.ui.res.painterResource
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.style.TextAlign
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import androidx.hilt.navigation.compose.hiltViewModel
+import androidx.navigation.NavController
+import com.example.testirovanye_supabase.R
+import com.example.triphelper.view.navigation.NavigationRoutes
+import com.example.triphelper.view.style.ButtonStyleBackSquare
+import com.example.triphelper.view.style.StyleMainFone
+import com.example.triphelper.view.theme.Roboto
+import com.example.triphelper.view.theme.RobotoB
+import com.example.triphelper.view.theme.SeoulBold
+
+@Composable
+fun ChoiceLocation(navController: NavController, iconsRouteIsActivity: MutableState<Boolean>, viewModel: RouteViewModel = hiltViewModel()) {
+    iconsRouteIsActivity.value = true
+    var selectedItemCountry by remember { mutableStateOf("") } //Переменная для всплывающего списка
+    var selectedItemCity by remember { mutableStateOf("") }
+    val coutryTitle = remember { mutableStateOf("") } //Переменная для сохранения названия страны
+    val country by viewModel.country.collectAsState(initial = emptyList())
+    val city by viewModel.city.collectAsState(initial = emptyList())
+    val cityTitle = remember { mutableStateOf("") }
+    var expandedCountry by remember { mutableStateOf(false) }  //Переменная для всплывающего списка
+    var expandedCity by remember { mutableStateOf(false) }
+
+    LaunchedEffect(key1 = viewModel.navigationTo) {
+        viewModel.navigationTo.collect { destination ->
+            destination?.let {
+                navController.navigate(destination)
+            }
+        }
+    }
+    StyleMainFone()
+    Column(
+        modifier = Modifier.fillMaxWidth().fillMaxHeight(0.9f),
+        verticalArrangement = Arrangement.Center,
+        horizontalAlignment = Alignment.CenterHorizontally
+    ) {
+        Column(
+            modifier = Modifier.fillMaxWidth(),
+            verticalArrangement = Arrangement.Center,
+            horizontalAlignment = Alignment.CenterHorizontally
+        ){
+            Text(
+                text = "Страна",
+                fontFamily = SeoulBold,
+                fontWeight = FontWeight.Bold,
+                fontSize = 40.sp,
+                color = Color(0xFF510B3C),
+                modifier = Modifier.padding(20.dp)
+            )
+            Box(modifier = Modifier.padding(20.dp)) {
+                Button(
+                    onClick = {
+                        expandedCountry = true
+                        viewModel.getCountry()
+                    },
+                    shape = RoundedCornerShape(15.dp),
+                    modifier = Modifier
+                        .fillMaxWidth(0.9f)
+                        .height(70.dp)
+                        .border(
+                            width = 4.dp,
+                            color = Color(0xFF510B3C),
+                            shape = RoundedCornerShape(15.dp)
+                        ),
+                    colors = buttonColors(
+                        containerColor = Color.White
+                    )
+                ) {
+                    Row(
+                        modifier = Modifier.fillMaxSize(),
+                        horizontalArrangement = Arrangement.Start,
+                        verticalAlignment = Alignment.CenterVertically
+                    )
+                    {
+                        if (selectedItemCountry.isEmpty()) {
+                            Row(
+                                horizontalArrangement = Arrangement.SpaceBetween,
+                                verticalAlignment = Alignment.CenterVertically,
+                                modifier = Modifier.fillMaxWidth()
+                            )
+                            {
+                                Text(
+                                    "Выберите страну",
+                                    fontFamily = RobotoB,
+                                    fontSize = 22.sp,
+                                    color = Color(0xFF510B3C).copy(alpha = 0.7f),
+                                    textAlign = TextAlign.Start
+                                )
+                                Icon(
+                                    painter = painterResource(id = R.drawable.galka_down),
+                                    contentDescription = null,
+                                    tint = Color(0xFFDC5B6E).copy(alpha = 0.7f),
+
+                                    )
+                            }
+                        } else {
+                            Text(
+                                "$selectedItemCountry",
+                                fontFamily = RobotoB,
+                                fontWeight = FontWeight.W600,
+                                fontSize = 23.sp,
+                                color = Color(0xFF510B3C),
+                                textAlign = TextAlign.Start
+                            )
+                        }
+                    }
+                }
+                DropdownMenu(
+                    expanded = expandedCountry,
+                    onDismissRequest = { expandedCountry = false },
+                    containerColor = Color.White,
+                    modifier = Modifier
+                        .fillMaxWidth(0.8f)
+                        .height(200.dp)
+                ) {
+                    country.forEach { item ->
+                        DropdownMenuItem(
+                            onClick = {
+                                selectedItemCountry = item.title
+                                coutryTitle.value = item.title
+                                expandedCountry = false
+                            },
+                            text = {
+                                Text(
+                                    text = item.title,
+                                    fontSize = 18.sp,
+                                    fontFamily = Roboto,
+                                    color = Color(0xFF510B3C),
+                                    fontWeight = FontWeight.Bold,
+                                    textAlign = TextAlign.Start
+                                )
+                            }
+                        )
+                    }
+                }
+            }
+        }
+        Column(
+            modifier = Modifier.fillMaxWidth(),
+            verticalArrangement = Arrangement.Center,
+            horizontalAlignment = Alignment.CenterHorizontally
+        ){
+            Text(
+                text = "Город",
+                fontFamily = SeoulBold,
+                fontWeight = FontWeight.Bold,
+                fontSize = 40.sp,
+                color = Color(0xFF510B3C),
+                modifier = Modifier.padding(20.dp)
+            )
+            Box(modifier = Modifier.padding(20.dp)) {
+                Button(
+                    onClick = {
+                        expandedCity = true
+                        viewModel.getCity(coutryTitle.value)
+                    },
+                    shape = RoundedCornerShape(15.dp),
+                    modifier = Modifier
+                        .fillMaxWidth(0.9f)
+                        .height(70.dp)
+                        .border(
+                            width = 4.dp,
+                            color = Color(0xFF510B3C),
+                            shape = RoundedCornerShape(15.dp)
+                        ),
+                    colors = buttonColors(
+                        containerColor = Color.White
+                    )
+                ) {
+                    Row(
+                        modifier = Modifier.fillMaxSize(),
+                        horizontalArrangement = Arrangement.Start,
+                        verticalAlignment = Alignment.CenterVertically
+                    )
+                    {
+                        if (selectedItemCity.isEmpty()) {
+                            Row(
+                                horizontalArrangement = Arrangement.SpaceBetween,
+                                verticalAlignment = Alignment.CenterVertically,
+                                modifier = Modifier.fillMaxWidth()
+                            )
+                            {
+                                Text(
+                                    "Выберите город",
+                                    fontFamily = RobotoB,
+                                    fontSize = 22.sp,
+                                    color = Color(0xFF510B3C).copy(alpha = 0.7f),
+                                    textAlign = TextAlign.Start
+                                )
+                                Icon(
+                                    painter = painterResource(id = R.drawable.galka_down),
+                                    contentDescription = null,
+                                    tint = Color(0xFFDC5B6E).copy(alpha = 0.7f),
+
+                                    )
+                            }
+                        } else {
+                            Text(
+                                "$selectedItemCity",
+                                fontFamily = RobotoB,
+                                fontWeight = FontWeight.W600,
+                                fontSize = 23.sp,
+                                color = Color(0xFF510B3C),
+                                textAlign = TextAlign.Start
+                            )
+                        }
+                    }
+                }
+                DropdownMenu(
+                    expanded = expandedCity,
+                    onDismissRequest = { expandedCity = false },
+                    containerColor = Color.White,
+                    modifier = Modifier
+                        .fillMaxWidth(0.8f)
+                        .height(200.dp)
+                ) {
+                    city.forEach { item ->
+                        DropdownMenuItem(
+                            onClick = {
+                                selectedItemCity = item.title
+                                cityTitle.value = item.title
+                                expandedCity = false
+                            },
+                            text = {
+                                Text(
+                                    text = item.title,
+                                    fontSize = 18.sp,
+                                    fontFamily = Roboto,
+                                    color = Color(0xFF510B3C),
+                                    fontWeight = FontWeight.Bold,
+                                    textAlign = TextAlign.Start
+                                )
+                            }
+                        )
+                    }
+                }
+            }
+            if(viewModel.wrong.value){
+                Box(
+                    modifier = Modifier
+                        .fillMaxWidth(0.8f)
+                        .clip(RoundedCornerShape(10.dp))
+                        .background(color = Color.White)
+                        .border(
+                            width = 2.dp,
+                            color = Color.White,
+                            shape = RoundedCornerShape(10.dp)
+                        ),
+                ){
+                    Text(
+                        text = "Не выбран город",
+                        fontFamily = Roboto,
+                        fontWeight = FontWeight.W600,
+                        fontSize = 22.sp,
+                        color = Color.Red,
+                        modifier = Modifier.align(Alignment.Center)
+                    )
+                }
+
+            }
+            Row(modifier = Modifier.fillMaxWidth(0.6f).padding(top = 20.dp)) {
+                ButtonStyleBackSquare("Далее",33.sp) {
+                        navController.navigate("${NavigationRoutes.CH_TOUR}/${cityTitle.value}")
+                }
+            }
+        }
+    }
+}

+ 81 - 0
TripHelper/app/src/main/java/com/example/triphelper/view/RouteScreens/ChoiceTour.kt

@@ -1,2 +1,83 @@
 package com.example.triphelper.view.RouteScreens
 
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxHeight
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.MutableState
+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.unit.dp
+import androidx.compose.ui.unit.sp
+import androidx.hilt.navigation.compose.hiltViewModel
+import androidx.navigation.NavController
+import com.example.triphelper.view.navigation.NavigationRoutes
+import com.example.triphelper.view.style.ButtonStyleBackSquare
+import com.example.triphelper.view.style.StyleMainFone
+
+@Composable
+fun ChoiceTour(navController: NavController, iconsRouteIsActivity: MutableState<Boolean>,titleCity:String, viewModel: RouteViewModel = hiltViewModel()) {
+    iconsRouteIsActivity.value = true
+    val numberTour = remember { mutableStateOf("") }
+
+
+    LaunchedEffect(key1 = viewModel.navigationTo) {
+        viewModel.navigationTo.collect { destination ->
+            destination?.let {
+                navController.navigate(destination)
+            }
+        }
+    }
+    StyleMainFone()
+    Column(
+        modifier = Modifier.fillMaxWidth().fillMaxHeight(0.95f),
+        verticalArrangement = Arrangement.Center,
+        horizontalAlignment = Alignment.CenterHorizontally
+    ) {
+        Column(
+            verticalArrangement = Arrangement.spacedBy(50.dp)
+        ) {
+            Row(
+                Modifier.fillMaxWidth(0.9f)
+            ){
+                ButtonStyleBackSquare(
+                    title = "Базовый тур",
+                    sizeT = 35.sp
+                ) {
+                    numberTour.value = "1"
+                    navController.navigate("${NavigationRoutes.TOURS}/${titleCity}/${numberTour.value}")
+                }
+            }
+            Row(
+                Modifier.fillMaxWidth(0.9f)
+            ){
+                ButtonStyleBackSquare(
+                    title = "Стандартный тур",
+                    sizeT = 35.sp
+                ) {
+                    numberTour.value = "2"
+                    navController.navigate("${NavigationRoutes.TOURS}/${titleCity}/${numberTour.value}")
+                }
+            }
+            Row(
+                Modifier.fillMaxWidth(0.9f)
+            ){
+                ButtonStyleBackSquare(
+                    title = "Профи тур",
+                    sizeT = 35.sp
+                ) {
+                    numberTour.value = "3"
+                    navController.navigate("${NavigationRoutes.TOURS}/${titleCity}/${numberTour.value}")
+                }
+            }
+        }
+    }
+}

+ 145 - 0
TripHelper/app/src/main/java/com/example/triphelper/view/RouteScreens/RouteViewModel.kt

@@ -0,0 +1,145 @@
+package com.example.triphelper.view.RouteScreens
+
+import android.util.Log
+import androidx.compose.runtime.mutableStateOf
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
+import com.example.triphelper.domain.Constants
+import com.example.triphelper.model.City
+import com.example.triphelper.model.Country
+import com.example.triphelper.model.Rules
+import dagger.hilt.android.lifecycle.HiltViewModel
+import io.github.jan.supabase.postgrest.from
+import io.github.jan.supabase.postgrest.query.Columns
+import io.github.jan.supabase.postgrest.query.Order
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.asStateFlow
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
+import javax.inject.Inject
+
+
+@HiltViewModel
+class RouteViewModel@Inject constructor(): ViewModel(){
+    private var _navigationTo = MutableStateFlow<String?>(null)
+    val navigationTo = _navigationTo.asStateFlow()
+
+    private val _ruleses: MutableStateFlow<List<Rules>> = MutableStateFlow(listOf())
+    val ruleses: StateFlow<List<Rules>> = _ruleses.asStateFlow()
+
+    private val _titleCountry: MutableStateFlow<String> = MutableStateFlow("")
+    val titleCountry: Flow<String> = _titleCountry.asStateFlow()
+
+    private var _country: MutableStateFlow<List<Country>> = MutableStateFlow(listOf())
+    val country: StateFlow<List<Country>> = _country.asStateFlow()
+
+    private var _city: MutableStateFlow<List<City>> = MutableStateFlow(listOf())
+    val city: StateFlow<List<City>> = _city.asStateFlow()
+
+    private val _idCountry = MutableStateFlow<Int?>(null)
+    val idCountry: StateFlow<Int?> = _idCountry.asStateFlow()
+
+    var wrong = mutableStateOf(false)
+
+    fun getCountry(){
+        viewModelScope.launch {
+            try {
+                withContext(Dispatchers.IO) {
+                    val response = Constants.supabase
+                        .from("country")
+                        .select(){
+                            order(column = "title", order = Order.ASCENDING)
+                        }
+                        .decodeList<Country>()
+                    _country.value = response
+                }
+            } catch (e: Exception) {
+                Log.e("getCountry", "Error retrieving country data", e)
+            }
+        }
+    }
+    suspend fun getIdCountry(titleCountry: String) {
+        try {
+            val response = Constants.supabase
+                .from("country")
+                .select {
+                    filter {
+                        eq("title", titleCountry)
+                    }
+                }
+                .decodeSingleOrNull<Country>()
+            _idCountry.value = response?.id
+            _titleCountry.value = response?.title.toString()
+            Log.i("id", "${_idCountry.value}")
+        } catch (e: Exception) {
+            Log.e("getCountry", "Error retrieving country data", e)
+        }
+    }
+    fun getCity(countryTitle :String){
+        viewModelScope.launch {
+            try {
+                withContext(Dispatchers.IO) {
+                    getIdCountry(countryTitle)
+                    if(_idCountry.value == null){
+                        wrong.value = true
+                    }
+                    else{
+                        val response = Constants.supabase
+                            .from("city")
+                            .select(
+                                Columns.raw(
+                                    "id, "+
+                                            "country(id,title,flag), "+
+                                            "title"
+                                )
+                            ){
+                                order(column = "title", order = Order.ASCENDING)
+                                filter {
+                                    _idCountry.value?.let { eq("country", it) }
+                                }
+                            }
+                            .decodeList<City>()
+                        if(response.isEmpty()) wrong.value = true
+                        else{
+                            _city.value = response
+                            wrong.value = false
+                        }
+                        Log.i("City", "Done")
+                    }
+                }
+            } catch (e: Exception) {
+                Log.e("getCountry", "Error retrieving country data", e)
+            }
+        }
+    }
+    fun GetRules(title:String){
+        viewModelScope.launch {
+            try{
+                getIdCountry(title)
+                val responce = Constants.supabase.from("rules").select(
+                    Columns.raw(
+                        "id, "+
+                                "country(id,title,flag), "+
+                                "laws, "+
+                                "rules_of_culture, "+
+                                "gestures"
+                    )
+                ){
+                    filter {
+                        _idCountry.value?.let { eq("country", it) }
+                    }
+                }.decodeList<Rules>()
+                _ruleses.value = responce
+                wrong.value = true
+                Log.i("Rules","${_idCountry.value}")
+            }
+            catch (e: Exception){
+                Log.e("Error","error")
+                wrong.value = false
+            }
+        }
+    }
+}

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

@@ -1,2 +1,31 @@
 package com.example.triphelper.view.RouteScreens
 
+import androidx.compose.foundation.content.MediaType.Companion.Text
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.MutableState
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.hilt.navigation.compose.hiltViewModel
+import androidx.navigation.NavController
+
+@Composable
+fun Tours(navController: NavController, iconsRouteIsActivity: MutableState<Boolean>, titleCity : String, numberTour: String, viewModel: RouteViewModel = hiltViewModel()){
+    iconsRouteIsActivity.value = true
+    numberTour.toInt()
+    Column(
+        modifier = Modifier.fillMaxSize(),
+        verticalArrangement = Arrangement.Center,
+        horizontalAlignment = Alignment.CenterHorizontally
+    ){
+        Text(
+            text = titleCity
+        )
+        Text(
+            text = numberTour
+        )
+    }
+}

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

@@ -13,6 +13,7 @@ import androidx.navigation.compose.rememberNavController
 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 dagger.hilt.android.AndroidEntryPoint
 
 @AndroidEntryPoint

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

@@ -13,6 +13,9 @@ import com.example.triphelper.view.LawScreen.DescriptionLaws
 import com.example.triphelper.view.MainScreen.LawScreen
 import com.example.triphelper.view.MainScreen.MainScreen
 import com.example.triphelper.view.Registration.Registration
+import com.example.triphelper.view.RouteScreens.ChoiceLocation
+import com.example.triphelper.view.RouteScreens.ChoiceTour
+import com.example.triphelper.view.RouteScreens.Tours
 
 @RequiresApi(Build.VERSION_CODES.O)
 @Composable
@@ -20,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.LAW)
+        startDestination = NavigationRoutes.CH_LOC)
     {
         composable( NavigationRoutes.AUTH){
             barsIsVisible.value = false
@@ -36,6 +39,7 @@ fun Navigation(controller: NavHostController, barsIsVisible: MutableState<Boolea
             iconsAdviceIsActivity.value = false
             iconsProfileIsActivity.value = false
             iconsMainIsActivity.value = false
+            iconsRoutsIsActivity.value = false
             MainScreen(controller, iconsMainIsActivity)
         }
         composable(NavigationRoutes.LAW){
@@ -44,6 +48,7 @@ fun Navigation(controller: NavHostController, barsIsVisible: MutableState<Boolea
             iconsAdviceIsActivity.value = false
             iconsProfileIsActivity.value = false
             iconsMainIsActivity.value = false
+            iconsRoutsIsActivity.value = false
             LawScreen(controller, iconsLawIsActivity)
         }
         composable(route =  "${NavigationRoutes.DESCLAW}/{title}"){
@@ -54,9 +59,46 @@ fun Navigation(controller: NavHostController, barsIsVisible: MutableState<Boolea
             iconsAdviceIsActivity.value = false
             iconsProfileIsActivity.value = false
             iconsMainIsActivity.value = false
+            iconsRoutsIsActivity.value = false
             if (title != null) {
                 DescriptionLaws(controller, iconsLawIsActivity, title)
             }
         }
+        composable(NavigationRoutes.CH_LOC){
+            barsIsVisible.value = true
+            iconsLawIsActivity.value = false
+            iconsAdviceIsActivity.value = false
+            iconsProfileIsActivity.value = false
+            iconsMainIsActivity.value = false
+            iconsRoutsIsActivity.value = false
+            ChoiceLocation(controller, iconsRoutsIsActivity)
+        }
+        composable(route =  "${NavigationRoutes.CH_TOUR}/{titleCity}"){
+            backStackEntry ->
+            val titleCity = backStackEntry.arguments?.getString("titleCity")
+            barsIsVisible.value = true
+            iconsLawIsActivity.value = false
+            iconsAdviceIsActivity.value = false
+            iconsProfileIsActivity.value = false
+            iconsMainIsActivity.value = false
+            iconsRoutsIsActivity.value = false
+            if (titleCity != null) {
+                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)
+            }
+        }
     }
 }

+ 3 - 7
TripHelper/app/src/main/java/com/example/triphelper/view/style/StyleButton.kt

@@ -2,16 +2,13 @@ package com.example.triphelper.view.style
 
 import androidx.compose.foundation.background
 import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.Column
 import androidx.compose.foundation.layout.RowScope
-import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.foundation.layout.fillMaxWidth
 import androidx.compose.foundation.layout.height
 import androidx.compose.foundation.layout.size
 import androidx.compose.foundation.shape.RoundedCornerShape
 import androidx.compose.material3.Button
 import androidx.compose.material3.ButtonDefaults.buttonColors
-import androidx.compose.material3.Icon
 import androidx.compose.material3.IconButton
 import androidx.compose.material3.IconButtonDefaults
 import androidx.compose.material3.Text
@@ -20,16 +17,15 @@ import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.draw.clip
 import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.res.painterResource
 import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.TextUnit
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
-import com.example.testirovanye_supabase.R
 import com.example.triphelper.view.theme.Roboto
 
 
 @Composable
-fun RowScope.ButtonStyleBackSquare(title: String, sizeT:Int, onClick: () -> Unit) {
+fun RowScope.ButtonStyleBackSquare(title: String, sizeT: TextUnit, onClick: () -> Unit) {
     Box(
         modifier = Modifier
             .height(93.dp)
@@ -62,7 +58,7 @@ fun RowScope.ButtonStyleBackSquare(title: String, sizeT:Int, onClick: () -> Unit
                 text = title,
                 fontFamily = Roboto,
                 fontWeight = FontWeight.Bold,
-                fontSize = sizeT.sp
+                fontSize = sizeT
             )
         }