import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import coil.compose.rememberImagePainter
import com.example.deezermusicplayer.Category

@Composable
fun MusicCategoriesScreen(
    categories: List<Category>,
    onCategorySelected: (Category) -> Unit,
    modifier: Modifier = Modifier
) {
    LazyColumn(
        modifier = modifier,
        contentPadding = PaddingValues(16.dp)
    ) {
        items(categories) { category ->
            CategoryItem(category) {
                onCategorySelected(category)
            }
        }
    }
}

@Composable
private fun CategoryItem(category: Category, onClick: () -> Unit) {
    Column(
        modifier = Modifier
            .clickable(onClick = onClick)
            .fillMaxWidth(),
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        val painter = rememberImagePainter(
            data = category.picture_medium
        )

        Image(
            painter = painter,
            contentDescription = category.name,
            contentScale = ContentScale.Crop,
            modifier = Modifier
                .fillMaxWidth()
                .height(120.dp)
        )

        Text(
            text = category.name,
            modifier = Modifier
                .padding(top = 8.dp)
                .align(Alignment.CenterHorizontally),
            style = MaterialTheme.typography.body2,
            color = MaterialTheme.colors.onSurface
        )
    }
},package com.example.deezermusicplayer

import CategoriesViewModel
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.padding
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.lifecycle.ViewModelStore
import androidx.navigation.NavController
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import com.example.deezermusicplayer.ui.theme.DeezerMusicPlayerTheme


class MainActivity : ComponentActivity() {
    private val bottomNavigationItems = listOf(
        Screen.Home,
        Screen.Favorites
    )
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            DeezerMusicPlayerTheme {
                // Set up navigation
                val navController = rememberNavController()

                Scaffold(
                    bottomBar = {
                        BottomNavigation {
                            // BottomNavigation code
                        }
                    },
                    content = { paddingValues ->
                        NavigationHost(
                            navController = navController,
                            modifier = Modifier.padding(paddingValues)
                        )
                    }
                )
            }
        }
    }

    @Composable
    fun NavigationHost(
        navController: NavController,
        modifier: Modifier = Modifier,
    ) {
        val categoriesViewModel = remember { CategoriesViewModel() }
        val categories by categoriesViewModel.categories.collectAsState() // use collectAsState here to collect the latest state

        // Set the ViewModelStore before creating the NavHost:
        if (navController is NavHostController) {
            navController.setViewModelStore(ViewModelStore())
        }

        NavHost(navController = navController as NavHostController, startDestination = Screen.Home.route) {
            composable(Screen.Home.route) {
                HomeScreen(categories = categories, navController = navController, modifier = modifier)
            }
            composable(Screen.Favorites.route) {
                FavoritesScreen(categories = categories, navController = navController, modifier = modifier)
            }
        }
    }


    @Composable
    fun HomeScreen(
        categories: List<Category>,
        navController: NavController,
        modifier: Modifier = Modifier
    ) {
        // HomeScreen content goes here (not the Scaffold)
    }
        @Composable
    fun FavoritesScreen(categories: List<Category>, navController: NavController, modifier: Modifier = Modifier) {

    }
},package com.example.deezermusicplayer

data class Category(
    val id: Int,
    val name: String,
    val picture_medium: String
),import android.util.Log
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.deezermusicplayer.Category
import com.example.deezermusicplayer.DeezerRepository
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
class CategoriesViewModel : ViewModel() {
    private val deezerRepository = DeezerRepository()
    private val _categories = MutableStateFlow<List<Category>>(emptyList())
    val categories: StateFlow<List<Category>>
        get() = _categories

    init {
        fetchCategories()
    }

    private fun fetchCategories() {
        viewModelScope.launch {
            try {
                val categories = deezerRepository.getCategories()
                _categories.value = categories
            } catch (e: Exception) {
                Log.e("CategoriesViewModel", "Failed to fetch categories: ${e.message}")
            }
        }
    }

    // public function to fetch categories
    fun refreshCategories() {
        fetchCategories()
    }
}. These are some of my classes separated with ",". When i ran the app, ı see an empty bottom navigation with no content in the initial selected page. I want 2 icons on the bottom navigation, left icon will be homeScreen composable and 2nd icon will leads to favorites composable. At home screen composable, i want to observe, MusicCategoriesScreen composable as content but i see MusicCategoriesScreen composable is not used in the code yet. Can you make the necessary changes for my desirable code








