Cleanup destinations
This commit is contained in:
parent
6b7ec41f32
commit
0a409421a8
7 changed files with 93 additions and 66 deletions
|
@ -91,7 +91,7 @@ fun resources(): Resources {
|
||||||
@Composable
|
@Composable
|
||||||
fun StudeezNavGraph(
|
fun StudeezNavGraph(
|
||||||
appState: StudeezAppstate,
|
appState: StudeezAppstate,
|
||||||
modifier: Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
val drawerViewModel: DrawerViewModel = hiltViewModel()
|
val drawerViewModel: DrawerViewModel = hiltViewModel()
|
||||||
val navBarViewModel: NavigationBarViewModel = hiltViewModel()
|
val navBarViewModel: NavigationBarViewModel = hiltViewModel()
|
||||||
|
@ -113,8 +113,46 @@ fun StudeezNavGraph(
|
||||||
startDestination = StudeezDestinations.SPLASH_SCREEN,
|
startDestination = StudeezDestinations.SPLASH_SCREEN,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
) {
|
) {
|
||||||
|
// NavBar
|
||||||
|
composable(StudeezDestinations.HOME_SCREEN) {
|
||||||
|
HomeRoute(
|
||||||
|
open,
|
||||||
|
viewModel = hiltViewModel(),
|
||||||
|
drawerActions = drawerActions,
|
||||||
|
navigationBarActions = navigationBarActions,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
composable(StudeezDestinations.TASKS_SCREEN) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
composable(StudeezDestinations.SESSIONS_SCREEN) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
composable(StudeezDestinations.PROFILE_SCREEN) {
|
||||||
|
ProfileRoute(
|
||||||
|
open,
|
||||||
|
viewModel = hiltViewModel(),
|
||||||
|
drawerActions = drawerActions,
|
||||||
|
navigationBarActions = navigationBarActions,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Drawer
|
||||||
|
composable(StudeezDestinations.TIMER_SCREEN) {
|
||||||
|
TimerOverviewRoute(
|
||||||
|
viewModel = hiltViewModel(),
|
||||||
|
drawerActions = drawerActions,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
composable(StudeezDestinations.SETTINGS_SCREEN) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
// Login flow
|
||||||
composable(StudeezDestinations.SPLASH_SCREEN) {
|
composable(StudeezDestinations.SPLASH_SCREEN) {
|
||||||
SplashRoute(
|
SplashRoute(
|
||||||
openAndPopUp,
|
openAndPopUp,
|
||||||
|
@ -136,31 +174,12 @@ fun StudeezNavGraph(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
composable(StudeezDestinations.HOME_SCREEN) {
|
// Studying flow
|
||||||
HomeRoute(
|
composable(StudeezDestinations.TIMER_SELECTION_SCREEN) {
|
||||||
|
TimerSelectionRoute(
|
||||||
open,
|
open,
|
||||||
|
goBack,
|
||||||
viewModel = hiltViewModel(),
|
viewModel = hiltViewModel(),
|
||||||
drawerActions = drawerActions,
|
|
||||||
navigationBarActions = navigationBarActions,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO Tasks screen
|
|
||||||
// TODO Sessions screen
|
|
||||||
|
|
||||||
composable(StudeezDestinations.PROFILE_SCREEN) {
|
|
||||||
ProfileRoute(
|
|
||||||
open,
|
|
||||||
viewModel = hiltViewModel(),
|
|
||||||
drawerActions = drawerActions,
|
|
||||||
navigationBarActions = navigationBarActions,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
composable(StudeezDestinations.TIMER_OVERVIEW_SCREEN) {
|
|
||||||
TimerOverviewRoute(
|
|
||||||
viewModel = hiltViewModel(),
|
|
||||||
drawerActions = drawerActions,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,8 +191,12 @@ fun StudeezNavGraph(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Timers screen
|
composable(StudeezDestinations.SESSION_RECAP) {
|
||||||
// TODO Settings screen
|
SessionRecapRoute(
|
||||||
|
openAndPopUp = openAndPopUp,
|
||||||
|
viewModel = hiltViewModel()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Edit screens
|
// Edit screens
|
||||||
composable(StudeezDestinations.EDIT_PROFILE_SCREEN) {
|
composable(StudeezDestinations.EDIT_PROFILE_SCREEN) {
|
||||||
|
@ -183,20 +206,5 @@ fun StudeezNavGraph(
|
||||||
viewModel = hiltViewModel(),
|
viewModel = hiltViewModel(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
composable(StudeezDestinations.TIMER_SELECTION_SCREEN) {
|
|
||||||
TimerSelectionRoute(
|
|
||||||
open,
|
|
||||||
goBack,
|
|
||||||
viewModel = hiltViewModel(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
composable(StudeezDestinations.SESSION_RECAP) {
|
|
||||||
SessionRecapRoute(
|
|
||||||
openAndPopUp = openAndPopUp,
|
|
||||||
viewModel = hiltViewModel()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package be.ugent.sel.studeez.common.composable.drawer
|
package be.ugent.sel.studeez.common.composable.drawer
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
@ -16,6 +17,7 @@ import androidx.compose.material.icons.outlined.Info
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.vectorResource
|
import androidx.compose.ui.res.vectorResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
@ -28,7 +30,7 @@ data class DrawerActions(
|
||||||
val onTimersClick: () -> Unit,
|
val onTimersClick: () -> Unit,
|
||||||
val onSettingsClick: () -> Unit,
|
val onSettingsClick: () -> Unit,
|
||||||
val onLogoutClick: () -> Unit,
|
val onLogoutClick: () -> Unit,
|
||||||
val onAboutClick: () -> Unit,
|
val onAboutClick: (Context) -> Unit,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun getDrawerActions(
|
fun getDrawerActions(
|
||||||
|
@ -41,7 +43,9 @@ fun getDrawerActions(
|
||||||
onTimersClick = { drawerViewModel.onTimersClick(open) },
|
onTimersClick = { drawerViewModel.onTimersClick(open) },
|
||||||
onSettingsClick = { drawerViewModel.onSettingsClick(open) },
|
onSettingsClick = { drawerViewModel.onSettingsClick(open) },
|
||||||
onLogoutClick = { drawerViewModel.onLogoutClick(openAndPopUp) },
|
onLogoutClick = { drawerViewModel.onLogoutClick(openAndPopUp) },
|
||||||
onAboutClick = { drawerViewModel.onAboutClick(open) },
|
onAboutClick = { context ->
|
||||||
|
drawerViewModel.onAboutClick(open, context = context)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,10 +83,11 @@ fun Drawer(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val context = LocalContext.current
|
||||||
DrawerEntry(
|
DrawerEntry(
|
||||||
icon = Icons.Outlined.Info,
|
icon = Icons.Outlined.Info,
|
||||||
text = resources().getString(R.string.about),
|
text = resources().getString(R.string.about),
|
||||||
onClick = drawerActions.onAboutClick,
|
onClick = { drawerActions.onAboutClick(context) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
package be.ugent.sel.studeez.common.composable.drawer
|
package be.ugent.sel.studeez.common.composable.drawer
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import be.ugent.sel.studeez.domain.AccountDAO
|
import be.ugent.sel.studeez.domain.AccountDAO
|
||||||
import be.ugent.sel.studeez.domain.LogService
|
import be.ugent.sel.studeez.domain.LogService
|
||||||
import be.ugent.sel.studeez.navigation.StudeezDestinations
|
import be.ugent.sel.studeez.navigation.StudeezDestinations
|
||||||
|
@ -9,6 +14,8 @@ import be.ugent.sel.studeez.screens.StudeezViewModel
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
const val REPO_URL: String = "https://github.ugent.be/SELab1/project2023-groep14/"
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class DrawerViewModel @Inject constructor(
|
class DrawerViewModel @Inject constructor(
|
||||||
private val accountDAO: AccountDAO,
|
private val accountDAO: AccountDAO,
|
||||||
|
@ -20,11 +27,11 @@ class DrawerViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onTimersClick(openAndPopup: (String) -> Unit) {
|
fun onTimersClick(openAndPopup: (String) -> Unit) {
|
||||||
openAndPopup(StudeezDestinations.TIMER_OVERVIEW_SCREEN)
|
openAndPopup(StudeezDestinations.TIMER_SCREEN)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onSettingsClick(open: (String) -> Unit) {
|
fun onSettingsClick(open: (String) -> Unit) {
|
||||||
// TODO
|
open(StudeezDestinations.SETTINGS_SCREEN)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onLogoutClick(openAndPopUp: (String, String) -> Unit) {
|
fun onLogoutClick(openAndPopUp: (String, String) -> Unit) {
|
||||||
|
@ -34,7 +41,8 @@ class DrawerViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onAboutClick(open: (String) -> Unit) {
|
fun onAboutClick(open: (String) -> Unit, context: Context) {
|
||||||
// TODO
|
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(REPO_URL))
|
||||||
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@ import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import be.ugent.sel.studeez.navigation.StudeezDestinations.HOME_SCREEN
|
import be.ugent.sel.studeez.navigation.StudeezDestinations.HOME_SCREEN
|
||||||
import be.ugent.sel.studeez.navigation.StudeezDestinations.PROFILE_SCREEN
|
import be.ugent.sel.studeez.navigation.StudeezDestinations.PROFILE_SCREEN
|
||||||
|
import be.ugent.sel.studeez.navigation.StudeezDestinations.SESSIONS_SCREEN
|
||||||
|
import be.ugent.sel.studeez.navigation.StudeezDestinations.TASKS_SCREEN
|
||||||
import be.ugent.sel.studeez.resources
|
import be.ugent.sel.studeez.resources
|
||||||
import be.ugent.sel.studeez.ui.theme.StudeezTheme
|
import be.ugent.sel.studeez.ui.theme.StudeezTheme
|
||||||
import be.ugent.sel.studeez.R.string as AppText
|
import be.ugent.sel.studeez.R.string as AppText
|
||||||
|
@ -71,8 +73,7 @@ fun NavigationBar(
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
label = { Text(text = resources().getString(AppText.tasks)) },
|
label = { Text(text = resources().getString(AppText.tasks)) },
|
||||||
// TODO selected = navigationBarActions.isSelectedTab(TASKS_SCREEN),
|
selected = navigationBarActions.isSelectedTab(TASKS_SCREEN),
|
||||||
selected = false,
|
|
||||||
onClick = navigationBarActions.onTasksClick
|
onClick = navigationBarActions.onTasksClick
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -86,8 +87,7 @@ fun NavigationBar(
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
label = { Text(text = resources().getString(AppText.sessions)) },
|
label = { Text(text = resources().getString(AppText.sessions)) },
|
||||||
// TODO selected = navigationBarActions.isSelectedTab(SESSIONS_SCREEN),
|
selected = navigationBarActions.isSelectedTab(SESSIONS_SCREEN),
|
||||||
selected = false,
|
|
||||||
onClick = navigationBarActions.onSessionsClick
|
onClick = navigationBarActions.onSessionsClick
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import be.ugent.sel.studeez.domain.AccountDAO
|
||||||
import be.ugent.sel.studeez.domain.LogService
|
import be.ugent.sel.studeez.domain.LogService
|
||||||
import be.ugent.sel.studeez.navigation.StudeezDestinations.HOME_SCREEN
|
import be.ugent.sel.studeez.navigation.StudeezDestinations.HOME_SCREEN
|
||||||
import be.ugent.sel.studeez.navigation.StudeezDestinations.PROFILE_SCREEN
|
import be.ugent.sel.studeez.navigation.StudeezDestinations.PROFILE_SCREEN
|
||||||
|
import be.ugent.sel.studeez.navigation.StudeezDestinations.SESSIONS_SCREEN
|
||||||
|
import be.ugent.sel.studeez.navigation.StudeezDestinations.TASKS_SCREEN
|
||||||
import be.ugent.sel.studeez.screens.StudeezViewModel
|
import be.ugent.sel.studeez.screens.StudeezViewModel
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -19,11 +21,11 @@ class NavigationBarViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onTasksClick(open: (String) -> Unit) {
|
fun onTasksClick(open: (String) -> Unit) {
|
||||||
// TODO
|
open(TASKS_SCREEN)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onSessionsClick(open: (String) -> Unit) {
|
fun onSessionsClick(open: (String) -> Unit) {
|
||||||
// TODO
|
open(SESSIONS_SCREEN)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onProfileClick(open: (String) -> Unit) {
|
fun onProfileClick(open: (String) -> Unit) {
|
||||||
|
|
|
@ -1,21 +1,25 @@
|
||||||
package be.ugent.sel.studeez.navigation
|
package be.ugent.sel.studeez.navigation
|
||||||
|
|
||||||
object StudeezDestinations {
|
object StudeezDestinations {
|
||||||
const val SPLASH_SCREEN = "splash"
|
// NavBar
|
||||||
const val SIGN_UP_SCREEN = "signup"
|
|
||||||
const val LOGIN_SCREEN = "login"
|
|
||||||
|
|
||||||
const val HOME_SCREEN = "home"
|
const val HOME_SCREEN = "home"
|
||||||
const val TIMER_OVERVIEW_SCREEN = "timer_overview"
|
const val TASKS_SCREEN = "tasks"
|
||||||
|
const val SESSIONS_SCREEN = "sessions"
|
||||||
|
const val PROFILE_SCREEN = "profile"
|
||||||
|
|
||||||
|
// Drawer
|
||||||
|
const val TIMER_SCREEN = "timer_overview"
|
||||||
|
const val SETTINGS_SCREEN = "settings"
|
||||||
|
|
||||||
|
// Login flow
|
||||||
|
const val SPLASH_SCREEN = "splash"
|
||||||
|
const val LOGIN_SCREEN = "login"
|
||||||
|
const val SIGN_UP_SCREEN = "signup"
|
||||||
|
|
||||||
|
// Studying flow
|
||||||
const val TIMER_SELECTION_SCREEN = "timer_selection"
|
const val TIMER_SELECTION_SCREEN = "timer_selection"
|
||||||
const val SESSION_SCREEN = "session"
|
const val SESSION_SCREEN = "session"
|
||||||
const val SESSION_RECAP = "session_recap"
|
const val SESSION_RECAP = "session_recap"
|
||||||
// const val TASKS_SCREEN = "tasks"
|
|
||||||
// const val SESSIONS_SCREEN = "sessions"
|
|
||||||
const val PROFILE_SCREEN = "profile"
|
|
||||||
|
|
||||||
// const val TIMERS_SCREEN = "timers"
|
|
||||||
// const val SETTINGS_SCREEN = "settings"
|
|
||||||
|
|
||||||
// Edit screens
|
// Edit screens
|
||||||
const val EDIT_PROFILE_SCREEN = "edit_profile"
|
const val EDIT_PROFILE_SCREEN = "edit_profile"
|
||||||
|
|
|
@ -39,7 +39,7 @@ fun HomeScreen(
|
||||||
title = resources().getString(R.string.home),
|
title = resources().getString(R.string.home),
|
||||||
drawerActions = drawerActions,
|
drawerActions = drawerActions,
|
||||||
navigationBarActions = navigationBarActions,
|
navigationBarActions = navigationBarActions,
|
||||||
barAction = { FriendsAction() }
|
// TODO barAction = { FriendsAction() }
|
||||||
) {
|
) {
|
||||||
BasicButton(R.string.start_session, Modifier.basicButton()) {
|
BasicButton(R.string.start_session, Modifier.basicButton()) {
|
||||||
onStartSessionClick()
|
onStartSessionClick()
|
||||||
|
|
Reference in a new issue