Skip to content

Commit

Permalink
[FEATURE] #105 : Attendance -> AttendanceManagemenet 로직 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn committed Jan 19, 2024
1 parent da0f2bd commit 58e4551
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 11 deletions.
8 changes: 7 additions & 1 deletion app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -64,6 +65,7 @@ internal fun AttendanceRoute(
userRoleState = userRoleState,
eventsState = eventsState,
navigateToProfile = navigateToProfile,
navigateToAttendanceManagement = { navigateToAttendanceManagement(userId) },
)
}

Expand All @@ -73,6 +75,7 @@ internal fun AttendanceScreen(
userRoleState: UserRoleState,
eventsState: EventsState,
navigateToProfile: () -> Unit,
navigateToAttendanceManagement: () -> Unit,
) {
Scaffold(
containerColor = WappTheme.colors.backgroundBlack,
Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import kotlinx.coroutines.flow.collectLatest

@Composable
internal fun AttendanceManagementRoute(
userId: String,
viewModel: AttendanceManagementViewModel = hiltViewModel(),
navigateToManagement: (String) -> Unit,
) {
Expand All @@ -58,7 +59,7 @@ internal fun AttendanceManagementRoute(
AttendanceManagementScreen(
snackBarHostState = snackBarHostState,
eventsState = eventsState,
navigateToManagement = { navigateToManagement("") },
navigateToManagement = { navigateToManagement(userId) },
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
}

0 comments on commit 58e4551

Please sign in to comment.