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.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
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.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.style.AttractionsLazy
import com.example.triphelper.view.style.FoodAdviceLazy
import com.example.triphelper.view.style.HotelsLazy
import com.example.triphelper.view.style.MetroLazy
import com.example.triphelper.view.style.RestaurantsLazy
import com.example.triphelper.view.style.StyleMainFone
import com.example.triphelper.view.theme.RobotoB
import com.example.triphelper.view.theme.SeoulBold

@Composable
fun AdviceScreen(navController: NavController, iconsAdviceIsActivity: MutableState<Boolean>,  viewModel: AdviceViewModel = hiltViewModel()) {
    iconsAdviceIsActivity.value = true
    var foodColumn by remember { mutableStateOf(true) }
    var tripColumn by remember { mutableStateOf(false) }
    var helthColumn by remember { mutableStateOf(false) }
    val advice by viewModel.advice.collectAsState(initial = emptyList())


    LaunchedEffect(key1 = viewModel.navigationTo) {
        viewModel.navigationTo.collect { destination ->
            destination?.let {
                navController.navigate(destination)
            }
        }
    }
    StyleMainFone()
    Column(
        modifier = Modifier
            .fillMaxSize()
            .padding(top = 65.dp),
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        Row(
            modifier = Modifier
                .fillMaxWidth()
                .padding(top = 10.dp)
                .fillMaxHeight(0.08f)
                .background(Color.White)
                .border(
                    width = 5.dp,
                    color = Color(0xFF510B3C)
                ),
            verticalAlignment = Alignment.CenterVertically,
            horizontalArrangement = Arrangement.SpaceEvenly
        ) {
            Box(
                modifier = Modifier
                    .fillMaxHeight(0.9f)
                    .background(if (foodColumn) Color(0xFFDC5B6E).copy(alpha = 0.4f) else Color.Transparent)
            ) {
                IconButton(
                    onClick = {
                        foodColumn = true
                        tripColumn = false
                        helthColumn = false
                    },
                    modifier = Modifier
                        .size(60.dp)
                ) {
                    Icon(
                        painter = painterResource(id = R.drawable.food_advice),
                        contentDescription = "Советы по еде",
                        tint = Color.Unspecified,
                        modifier = Modifier.size(50.dp)
                    )
                }
            }
            Box(
                modifier = Modifier
                    .fillMaxHeight(0.9f)
                    .background(if (tripColumn) Color(0xFFDC5B6E).copy(alpha = 0.4f) else Color.Transparent)
            ) {
                IconButton(
                    onClick = {
                        foodColumn = false
                        tripColumn = true
                        helthColumn = false
                    },
                    modifier = Modifier
                        .size(60.dp)
                ) {
                    Icon(
                        painter = painterResource(id = R.drawable.trip_advice),
                        contentDescription = "Советы по путешествию",
                        tint = Color.Unspecified,
                        modifier = Modifier.size(50.dp)
                    )
                }
            }
            Box(
                modifier = Modifier
                    .fillMaxHeight(0.9f)
                    .background(if (helthColumn) Color(0xFFDC5B6E).copy(alpha = 0.4f) else Color.Transparent)
            ) {
                IconButton(
                    onClick = {
                        foodColumn = false
                        tripColumn = false
                        helthColumn = true
                    },
                    modifier = Modifier
                        .size(60.dp)
                ) {
                    Icon(
                        painter = painterResource(id = R.drawable.helth_advice),
                        contentDescription = "Советы по здоровью",
                        tint = Color.Unspecified,
                        modifier = Modifier.size(45.dp)
                    )
                }
            }
        }
        if (foodColumn) {
            FoodAdviceLazy(navController,advice)
        }
        if (tripColumn) {
            FoodAdviceLazy(navController,advice)
        }
        if(helthColumn){
            FoodAdviceLazy(navController,advice)
        }
    }
}