package com.mitchelbv.thuis_c

import android.annotation.SuppressLint
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.mitchelbv.thuis_c.ui.theme.ThuisTheme

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            ThuisTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colors.background
                ) {
                    ThuisApp()
                }
            }
        }
    }
}

@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
@Composable
fun ThuisApp() {
    var currentScreen: ThuisDestination by remember { mutableStateOf(Home) }
    return Scaffold(bottomBar = {
        BottomNavigation() {
            destinations.forEachIndexed { index, item ->
                BottomNavigationItem(
                    selected = currentScreen.route == destinations[index].route,
                    onClick = { currentScreen = destinations[index] },
                    icon = {
                        Icon(
                            destinations[index].icon,
                            contentDescription = null
                        )
                    })
            }
        }
    }) {
        currentScreen.screen()
    }
}