Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] 내가 등록한 코스 -> 코스 상세 페이지 이동 기능 구현 #231

Merged
merged 2 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class MyCourseContract {
) : UiState

sealed interface MyCourseSideEffect : UiSideEffect {
data class NavigateToEnroll(val courseId: Int) : MyCourseSideEffect
data class NavigateToCourseDetail(val courseId: Int) : MyCourseSideEffect
data object PopBackStack : MyCourseSideEffect
}
Comment on lines 17 to 21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

첨엔 아니었자나...ㅠㅠ


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ fun MyCourseRoute(
viewModel: MyCourseViewModel = hiltViewModel(),
popBackStack: () -> Unit,
navigateToEnroll: (EnrollType, Int?) -> Unit,
navigateToCourseDetail: (Int) -> Unit,
myCourseType: MyCourseType
) {
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
Expand All @@ -60,6 +61,8 @@ fun MyCourseRoute(
viewModel.sideEffect.flowWithLifecycle(lifecycle = lifecycleOwner.lifecycle)
.collect { myCourseSideEffect ->
when (myCourseSideEffect) {
is MyCourseContract.MyCourseSideEffect.NavigateToEnroll -> navigateToEnroll(EnrollType.TIMELINE, myCourseSideEffect.courseId)
is MyCourseContract.MyCourseSideEffect.NavigateToCourseDetail -> navigateToCourseDetail(myCourseSideEffect.courseId)
is MyCourseContract.MyCourseSideEffect.PopBackStack -> popBackStack()
}
}
Expand All @@ -75,7 +78,8 @@ fun MyCourseRoute(
padding = padding,
myCourseUiState = uiState,
onIconClick = popBackStack,
onCourseCardClick = navigateToEnroll
navigateToEnroll = { courseId -> viewModel.setSideEffect(MyCourseContract.MyCourseSideEffect.NavigateToEnroll(courseId = courseId)) },
navigateToCourseDetail = { courseId -> viewModel.setSideEffect(MyCourseContract.MyCourseSideEffect.NavigateToCourseDetail(courseId = courseId)) }
)
}

Expand All @@ -88,7 +92,8 @@ fun MyCourseScreen(
padding: PaddingValues,
myCourseUiState: MyCourseContract.MyCourseUiState = MyCourseContract.MyCourseUiState(),
onIconClick: () -> Unit,
onCourseCardClick: (EnrollType, Int?) -> Unit
navigateToEnroll: (Int) -> Unit,
navigateToCourseDetail: (Int) -> Unit
) {
Column(
modifier = Modifier
Expand Down Expand Up @@ -123,8 +128,8 @@ fun MyCourseScreen(
course = course,
onClick = {
when (myCourseUiState.myCourseType) {
MyCourseType.ENROLL -> {}
MyCourseType.READ -> onCourseCardClick(EnrollType.TIMELINE, course.courseId)
MyCourseType.ENROLL -> navigateToCourseDetail(course.courseId)
MyCourseType.READ -> navigateToEnroll(course.courseId)
}
}
)
Expand Down Expand Up @@ -182,7 +187,8 @@ fun MyCourseScreenPreview() {
)
),
onIconClick = {},
onCourseCardClick = { _, _ -> }
navigateToEnroll = {},
navigateToCourseDetail = {}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ fun NavController.navigateMyCourses(myCourseType: MyCourseType) {
fun NavGraphBuilder.myCoursesNavGraph(
padding: PaddingValues,
popBackStack: () -> Unit,
navigateToEnroll: (EnrollType, Int?) -> Unit
navigateToEnroll: (EnrollType, Int?) -> Unit,
navigateToCourseDetail: (Int) -> Unit
) {
composable(
route = ROUTE_WITH_ARGUMENT,
Expand All @@ -32,7 +33,7 @@ fun NavGraphBuilder.myCoursesNavGraph(
MyCourseType.valueOf(it)
} ?: MyCourseType.ENROLL

MyCourseRoute(padding = padding, popBackStack = popBackStack, myCourseType = myCourseType, navigateToEnroll = navigateToEnroll)
MyCourseRoute(padding = padding, popBackStack = popBackStack, myCourseType = myCourseType, navigateToEnroll = navigateToEnroll, navigateToCourseDetail = navigateToCourseDetail)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,6 @@ class MainNavigator(
navHostController.navigationSignIn()
}

fun navigateTimeline(navOptions: NavOptions? = null) {
navHostController.navigationTimeline(
navOptions ?: navOptions {
popUpTo(navHostController.graph.findStartDestination().id) {
inclusive = true
}
launchSingleTop = true
}
)
}

fun navigateToTimelineDetail(timelineType: TimelineType, dateId: Int) {
navHostController.navigateToTimelineDetail(timelineType, dateId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ fun MainNavHost(
myCoursesNavGraph(
padding = padding,
popBackStack = navigator::popBackStackIfNotHome,
navigateToEnroll = navigator::navigateToEnroll
navigateToEnroll = navigator::navigateToEnroll,
navigateToCourseDetail = navigator::navigateToCourseDetail
)

myPageNavGraph(
Expand Down
Loading