Skip to content

Commit

Permalink
[FEATURE]#75 : Notification 모듈 NavGraph 생성 및 전환 설정 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongjaino committed Aug 4, 2024
1 parent ffddd81 commit 58213a0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
13 changes: 13 additions & 0 deletions app/src/main/kotlin/com/bff/wespot/AppNavGraphs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.bff.wespot.message.screen.destinations.MessageWriteScreenDestination
import com.bff.wespot.message.screen.destinations.ReceiverSelectionScreenDestination
import com.bff.wespot.message.screen.destinations.ReservedMessageScreenDestination
import com.bff.wespot.message.viewmodel.SendViewModel
import com.bff.wespot.notification.screen.destinations.NotificationScreenDestination
import com.bff.wespot.vote.screen.destinations.IndividualVoteScreenDestination
import com.bff.wespot.vote.screen.destinations.VoteHomeScreenDestination
import com.bff.wespot.vote.screen.destinations.VoteResultScreenDestination
Expand Down Expand Up @@ -83,6 +84,17 @@ object AppNavGraphs {
.associateBy { it.route }
}

val notification = object : NavGraphSpec {
override val route = "notification"

override val startRoute = NotificationScreenDestination routedIn this

override val destinationsByRoute = listOf<DestinationSpec<*>>(
NotificationScreenDestination,
).routedIn(this)
.associateBy { it.route }
}

val root = object : NavGraphSpec {
override val route = "root"

Expand All @@ -94,6 +106,7 @@ object AppNavGraphs {
vote,
message,
entire,
notification,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import com.bff.wespot.message.screen.send.MessageWriteNavigator
import com.bff.wespot.message.screen.send.MessageWriteScreenArgs
import com.bff.wespot.message.screen.send.ReceiverSelectionNavigator
import com.bff.wespot.message.screen.send.ReceiverSelectionScreenArgs
import com.bff.wespot.notification.screen.NotificationNavigator
import com.bff.wespot.notification.screen.destinations.NotificationScreenDestination
import com.bff.wespot.vote.screen.IndividualVoteArgs
import com.bff.wespot.vote.screen.IndividualVoteNavigator
import com.bff.wespot.vote.screen.VoteNavigator
Expand Down Expand Up @@ -54,7 +56,8 @@ class CommonNavGraphNavigator(
VoteResultNavigator,
VoteStorageNavigator,
ReservedMessageNavigator,
IndividualVoteNavigator {
IndividualVoteNavigator,
NotificationNavigator {
override fun navigateUp() {
navController.navigateUp()
}
Expand Down Expand Up @@ -84,6 +87,7 @@ class CommonNavGraphNavigator(
}

override fun navigateNotificationScreen() {
navController.navigate(NotificationScreenDestination within navGraph)
}

override fun navigateToResultScreen(args: VoteResultScreenArgs) {
Expand Down
24 changes: 15 additions & 9 deletions app/src/main/kotlin/com/bff/wespot/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ private fun MainScreen() {
action = {
IconButton(
modifier = Modifier.padding(top = 10.dp, bottom = 10.dp, end = 4.dp),
onClick = {},
onClick = {
navController.navigateToNavGraph(AppNavGraphs.notification)
},
) {
Icon(
painter = painterResource(id = R.drawable.notification),
Expand All @@ -104,14 +106,7 @@ private fun MainScreen() {
BottomNavigationTab(
selectedNavigation = currentSelectedItem,
onNavigationSelected = { selected ->
navController.navigate(selected) {
launchSingleTop = true
restoreState = true

popUpTo(navController.graph.findStartDestination().id) {
saveState = true
}
}
navController.navigateToNavGraph(selected)
},
modifier = Modifier.fillMaxWidth(),
)
Expand Down Expand Up @@ -230,3 +225,14 @@ private fun TabItem(
}
}
}

private fun NavController.navigateToNavGraph(navGraph: NavGraphSpec) {
this.navigate(navGraph) {
launchSingleTop = true
restoreState = true

popUpTo(this@navigateToNavGraph.graph.findStartDestination().id) {
saveState = true
}
}
}

0 comments on commit 58213a0

Please sign in to comment.