-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStackKnowledgeNavHost.kt
102 lines (99 loc) · 4.62 KB
/
StackKnowledgeNavHost.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package com.kdn.stack_knowledge.navigation
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.compose.NavHost
import com.minstone.ui.navigation.NavigateType
import com.stackknowledge.login.navigation.loginScreen
import com.stackknowledge.login.navigation.navigateToLogin
import com.stackknowledge.login.navigation.roleCheckRoute
import com.stackknowledge.login.navigation.roleCheckScreen
import com.stackknowledge.main.navigation.mainScreen
import com.stackknowledge.main.navigation.navigateToMain
import com.kdn.stack_knowledge.navigation.util.bottomNavigationNavigate
import com.stackknowledge.ranking.navigation.navigateToRanking
import com.stackknowledge.ranking.navigation.navigateToTeacherRanking
import com.stackknowledge.ranking.navigation.rankingScreen
import com.stackknowledge.ranking.navigation.teacherRankingScreen
import com.stackknowledge.score_mission.navigation.gradingAnswerScreen
import com.stackknowledge.score_mission.navigation.navigateToGradingAnswer
import com.stackknowledge.score_mission.navigation.navigateToSolvedMission
import com.stackknowledge.score_mission.navigation.solvedMissionScreen
import com.stackknowledge.shop.navigation.shopRoute
import com.stackknowledge.shop.navigation.shopScreen
import com.stackknowledge.shop.navigation.teacherShopRoute
import com.stackknowledge.shop.navigation.teacherShopScreen
import com.kdn.stack_knowledge.ui.StackKnowledgeAppState
import com.stackkowledge.mission.navigation.createMissionScreen
import com.stackkowledge.mission.navigation.entireMissionScreen
import com.stackkowledge.mission.navigation.navigateToEntireMission
import com.stackkowledge.mission.navigation.navigateToResolveMission
import com.stackkowledge.mission.navigation.resolveMissionScreen
import enumdata.Authority
@Composable
fun StackKnowledgeNavHost(
appState: StackKnowledgeAppState,
startDestination: String = roleCheckRoute,
modifier: Modifier = Modifier,
onLoginButtonClick: () -> Unit = {},
) {
val navController = appState.navController
NavHost(
navController = navController,
startDestination = startDestination,
modifier = modifier
) {
loginScreen(
onSuccess = navController::navigateToMain,
onLoginButtonClick = onLoginButtonClick
)
roleCheckScreen(
onRoleButtonClick = navController::navigateToLogin
)
mainScreen(
onNavigate = { role, navType, index ->
if (index != null) {
if (navType == NavigateType.MISSION.value) {
if (role == Authority.ROLE_STUDENT) navController.navigateToEntireMission()
else navController.navigateToSolvedMission()
} else {
if (role == Authority.ROLE_STUDENT) navController.navigateToRanking()
else navController.navigateToTeacherRanking()
}
} else bottomNavigationNavigate(role, navController, navType)
},
)
createMissionScreen(
onNavigate = { role, navType -> bottomNavigationNavigate(role, navController, navType) },
createMissionSuccess = navController::navigateToMain
)
entireMissionScreen(
onNavigate = { role, navType -> bottomNavigationNavigate(role, navController, navType) },
onItemClick = navController::navigateToResolveMission
)
rankingScreen(
onNavigate = { role, navType -> bottomNavigationNavigate(role, navController, navType) }
)
teacherRankingScreen(
onNavigate = { role, navType -> bottomNavigationNavigate(role, navController, navType) }
)
resolveMissionScreen(
onNavigate = { role, navType -> bottomNavigationNavigate(role, navController, navType) },
onBackClick = navController::popBackStack,
solveMissionSuccess = navController::navigateToMain,
)
gradingAnswerScreen(
onNavigate = { role, navType -> bottomNavigationNavigate(role, navController, navType) },
scoreMissionSuccess = navController::navigateToMain,
)
solvedMissionScreen(
onNavigate = { role, navType -> bottomNavigationNavigate(role, navController, navType) },
onItemClick = navController::navigateToGradingAnswer
)
shopScreen(
onNavigate = { role, navType -> bottomNavigationNavigate(role, navController, navType) }
)
teacherShopScreen(
onNavigate = { role, navType -> bottomNavigationNavigate(role, navController, navType) }
)
}
}