package de.sebse.fuplanner2

import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import androidx.navigation.NavType
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import de.sebse.fuplanner2.ui.courses.CoursesScreen
import de.sebse.fuplanner2.ui.details.CourseDetailsScreen

sealed class MenuItem {
    object Courses : NavLinks(R.string.menu_courses, R.drawable.ic_menu_courses, "courses")
    object Canteen : NavLinks(R.string.menu_canteen, R.drawable.ic_menu_canteen, "canteen")
    object Schedule : NavLinks(R.string.menu_schedule, R.drawable.ic_menu_event, "schedule")
    object Notifications :
        NavLinks(R.string.menu_notifications, R.drawable.ic_menu_notifications, "navigation")
}

val screens = listOf(
    MenuItem.Courses,
    MenuItem.Canteen,
    MenuItem.Schedule,
    MenuItem.Notifications
)

@Composable
fun MainActivityComposable() {
    DrawerLayout(
        appName = stringResource(R.string.app_name),
        menu = screens,
        startDestination = MenuItem.Courses.route
    ) { tools ->
        composable(route = MenuItem.Courses.route) {
            CoursesScreen(tools)
        }
        composable(
            arguments = listOf(
                navArgument("id") { type = NavType.LongType }
            ),
            route = "${MenuItem.Courses.route}/{id}"
        ) {
            val id = it.arguments!!.getLong("id")
            CourseDetailsScreen(tools, id)
        }
    }
}
