diff --git a/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt b/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt index 76e06dcb..6d8ac781 100644 --- a/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt +++ b/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt @@ -8,6 +8,8 @@ import androidx.navigation.compose.NavHost import androidx.navigation.navOptions import com.wap.designsystem.WappTheme import com.wap.wapp.core.domain.usecase.auth.SignInUseCase +import com.wap.wapp.feature.attendance.management.navigation.attendanceManagementScreen +import com.wap.wapp.feature.attendance.management.navigation.navigateToAttendanceManagemenet import com.wap.wapp.feature.attendance.navigation.attendanceScreen import com.wap.wapp.feature.attendance.navigation.navigateToAttendance import com.wap.wapp.feature.auth.signin.navigation.navigateToSignIn @@ -101,7 +103,11 @@ fun WappNavHost( navController.navigateToSignIn(navOptions { popUpTo(profileNavigationRoute) }) }, ) - attendanceScreen(navigateToProfile = navController::navigateToProfile) + attendanceScreen( + navigateToProfile = navController::navigateToProfile, + navigateToAttendanceManagement = navController::navigateToAttendanceManagemenet, + ) + attendanceManagementScreen(navigateToAttendance = navController::navigateToAttendance) profileSettingScreen( navigateToSignIn = { navController.navigateToSignIn( diff --git a/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/AttendanceScreen.kt b/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/AttendanceScreen.kt index 4fc9a486..35288fe7 100644 --- a/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/AttendanceScreen.kt +++ b/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/AttendanceScreen.kt @@ -46,6 +46,7 @@ internal fun AttendanceRoute( userId: String, viewModel: AttendanceViewModel = hiltViewModel(), navigateToProfile: () -> Unit, + navigateToAttendanceManagement: (String) -> Unit, ) { val snackBarHostState = remember { SnackbarHostState() } val userRoleState by viewModel.userRole.collectAsStateWithLifecycle() @@ -64,6 +65,7 @@ internal fun AttendanceRoute( userRoleState = userRoleState, eventsState = eventsState, navigateToProfile = navigateToProfile, + navigateToAttendanceManagement = { navigateToAttendanceManagement(userId) }, ) } @@ -73,6 +75,7 @@ internal fun AttendanceScreen( userRoleState: UserRoleState, eventsState: EventsState, navigateToProfile: () -> Unit, + navigateToAttendanceManagement: () -> Unit, ) { Scaffold( containerColor = WappTheme.colors.backgroundBlack, @@ -113,7 +116,7 @@ internal fun AttendanceScreen( if (userRoleState == UserRoleState.Success(UserRole.MANAGER)) { AttendanceCheckButton( - onAttendanceCheckButtonClicked = {}, + onAttendanceCheckButtonClicked = navigateToAttendanceManagement, modifier = Modifier .align(Alignment.BottomEnd) .padding(end = 16.dp, bottom = 16.dp), diff --git a/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/management/AttendanceManagementScreen.kt b/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/management/AttendanceManagementScreen.kt index 401174c5..027533c8 100644 --- a/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/management/AttendanceManagementScreen.kt +++ b/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/management/AttendanceManagementScreen.kt @@ -41,6 +41,7 @@ import kotlinx.coroutines.flow.collectLatest @Composable internal fun AttendanceManagementRoute( + userId: String, viewModel: AttendanceManagementViewModel = hiltViewModel(), navigateToManagement: (String) -> Unit, ) { @@ -58,7 +59,7 @@ internal fun AttendanceManagementRoute( AttendanceManagementScreen( snackBarHostState = snackBarHostState, eventsState = eventsState, - navigateToManagement = { navigateToManagement("") }, + navigateToManagement = { navigateToManagement(userId) }, ) } diff --git a/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/management/navigation/AttendanceManagementNavigation.kt b/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/management/navigation/AttendanceManagementNavigation.kt index 0bac3d65..9fe58367 100644 --- a/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/management/navigation/AttendanceManagementNavigation.kt +++ b/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/management/navigation/AttendanceManagementNavigation.kt @@ -3,18 +3,30 @@ package com.wap.wapp.feature.attendance.management.navigation import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder import androidx.navigation.NavOptions +import androidx.navigation.NavType import androidx.navigation.compose.composable +import androidx.navigation.navArgument import androidx.navigation.navOptions import com.wap.wapp.feature.attendance.management.AttendanceManagementRoute -const val attendanceManagementNavigationRoute = "attendance/management" +const val attendanceManagementNavigationRoute = "attendance/management/{userId}" -fun NavController.navigateToAttendanceManagement( +fun NavController.navigateToAttendanceManagemenet( + userId: String, navOptions: NavOptions? = navOptions {}, -) = this.navigate(attendanceManagementNavigationRoute, navOptions) +) { + this.navigate("attendance/management/$userId", navOptions) +} -fun NavGraphBuilder.attendanceManagementScreen(navigateToManagement: (String) -> Unit) { - composable(route = attendanceManagementNavigationRoute) { - AttendanceManagementRoute(navigateToManagement = navigateToManagement) +fun NavGraphBuilder.attendanceManagementScreen(navigateToAttendance: (String) -> Unit) { + composable( + route = attendanceManagementNavigationRoute, + arguments = listOf(navArgument("userId") { type = NavType.StringType }), + ) { navBackStackEntry -> + val userId = navBackStackEntry.arguments?.getString("userId") ?: "" + AttendanceManagementRoute( + userId = userId, + navigateToManagement = navigateToAttendance, + ) } } diff --git a/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/navigation/AttendanceNavigation.kt b/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/navigation/AttendanceNavigation.kt index b4fd1aad..05450ed0 100644 --- a/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/navigation/AttendanceNavigation.kt +++ b/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/navigation/AttendanceNavigation.kt @@ -18,12 +18,19 @@ fun NavController.navigateToAttendance( this.navigate("attendance/$userId", navOptions) } -fun NavGraphBuilder.attendanceScreen(navigateToProfile: () -> Unit) { +fun NavGraphBuilder.attendanceScreen( + navigateToProfile: () -> Unit, + navigateToAttendanceManagement: (String) -> Unit, +) { composable( route = attendanceNavigationRoute, arguments = listOf(navArgument("userId") { type = NavType.StringType }), ) { navBackStackEntry -> val userId = navBackStackEntry.arguments?.getString("userId") ?: "" - AttendanceRoute(userId = userId, navigateToProfile = navigateToProfile) + AttendanceRoute( + userId = userId, + navigateToProfile = navigateToProfile, + navigateToAttendanceManagement = navigateToAttendanceManagement, + ) } }