package com.diegocayo.organizame.presentation.navigation

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.CheckCircle
import androidx.compose.material.icons.filled.Event
import androidx.compose.material.icons.filled.Person
import androidx.compose.material.icons.filled.School
import androidx.compose.material.icons.outlined.CheckCircle
import androidx.compose.material.icons.outlined.Event
import androidx.compose.material.icons.outlined.Person
import androidx.compose.material.icons.outlined.School
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.navigation.NamedNavArgument
import androidx.navigation.NavType
import androidx.navigation.navArgument
import com.diegocayo.organizame.R

private object Routes {
    const val FIRST_STEP_NAV = "FIRST_STEP_NAV_GRAPH"
    const val FIRST_STEP = "first_step"
    const val GRETTING = "gretting/{name}"

    const val MAIN_NAV = "MAIN_NAV_GRAPH"
    const val TASKS = "tasks"
    const val CREATE_TASK = "tasks/create"
    const val EVENTS = "events"
    const val CREATE_EVENT = "events/create"
    const val SUBJECTS = "subjects"
    const val CREATE_SUBJECT = "subjects/create"
    const val PROFILE = "profile"
}

sealed class AppScreen(val route: String) {
    data object Welcome : AppScreen(Routes.FIRST_STEP_NAV) {
        data object FirstSteps : AppScreen(Routes.FIRST_STEP)
        data object Gretting : AppScreen(Routes.GRETTING) {
            fun createRoute(name: String) = "gretting/$name"
            val arguments = listOf(
                navArgument("name") { type = NavType.StringType }
            )
        }
    }

    data object Main : TopLevelDestination(Routes.MAIN_NAV) {
        data object Tasks : TopLevelDestination(
            route = Routes.TASKS,
            title = R.string.tasks,
            selectedIcon = Icons.Filled.CheckCircle,
            unselectedIcon = Icons.Outlined.CheckCircle
        ) {
            data object Create : TopLevelDestination(Routes.CREATE_TASK)
        }

        data object Events : TopLevelDestination(
            route = Routes.EVENTS,
            title = R.string.events,
            selectedIcon = Icons.Filled.Event,
            unselectedIcon = Icons.Outlined.Event
        ) {
            data object Create : TopLevelDestination(Routes.CREATE_EVENT)
        }

        data object Subjects : TopLevelDestination(
            route = Routes.SUBJECTS,
            title = R.string.subjects,
            selectedIcon = Icons.Filled.School,
            unselectedIcon = Icons.Outlined.School
        ) {
            data object Create : TopLevelDestination(Routes.CREATE_SUBJECT)
        }

        data object Profile : TopLevelDestination(
            route = Routes.PROFILE,
            title = R.string.profile,
            selectedIcon = Icons.Filled.Person,
            unselectedIcon = Icons.Outlined.Person
        )
    }
}

sealed class TopLevelDestination(
    val route: String,
    val title: Int? = null,
    val selectedIcon: ImageVector? = null,
    val unselectedIcon: ImageVector? = null,
    val navArguments: List<NamedNavArgument> = emptyList()
)