Skip to content

Commit

Permalink
Remove unnecessary navController arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
alashow committed Jan 20, 2022
1 parent b9fa577 commit 3c4460a
Showing 1 changed file with 30 additions and 31 deletions.
61 changes: 30 additions & 31 deletions app/src/main/kotlin/tm/alashow/datmusic/ui/AppNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,117 +84,116 @@ internal fun AppNavigation(
popEnterTransition = { defaultPopEnterTransition() },
popExitTransition = { defaultPopExitTransition() },
) {
addSearchRoot(navController)
addDownloadsRoot(navController)
addLibraryRoot(navController)
addSettingsRoot(navController)

addPlaybackSheet(navController)
addSearchRoot()
addDownloadsRoot()
addLibraryRoot()
addSettingsRoot()
addPlaybackSheet()
}
}

@ExperimentalAnimationApi
private fun NavGraphBuilder.addSearchRoot(navController: NavController) {
private fun NavGraphBuilder.addSearchRoot() {
navigation(
route = RootScreen.Search.route,
startDestination = LeafScreen.Search().createRoute()
) {
addSearch(navController)
addArtistDetails(navController, RootScreen.Search)
addAlbumDetails(navController, RootScreen.Search)
addSearch()
addArtistDetails(RootScreen.Search)
addAlbumDetails(RootScreen.Search)
}
}

@ExperimentalAnimationApi
private fun NavGraphBuilder.addDownloadsRoot(navController: NavController) {
private fun NavGraphBuilder.addDownloadsRoot() {
navigation(
route = RootScreen.Downloads.route,
startDestination = LeafScreen.Downloads().createRoute()
) {
addDownloads(navController)
addDownloads()
}
}

@ExperimentalAnimationApi
private fun NavGraphBuilder.addLibraryRoot(navController: NavController) {
private fun NavGraphBuilder.addLibraryRoot() {
navigation(
route = RootScreen.Library.route,
startDestination = LeafScreen.Library().createRoute()
) {
addLibrary(navController)
addCreatePlaylist(navController)
addEditPlaylist(navController)
addPlaylistDetails(navController, RootScreen.Library)
addArtistDetails(navController, RootScreen.Library)
addAlbumDetails(navController, RootScreen.Library)
addLibrary()
addCreatePlaylist()
addEditPlaylist()
addPlaylistDetails(RootScreen.Library)
addArtistDetails(RootScreen.Library)
addAlbumDetails(RootScreen.Library)
}
}

@ExperimentalAnimationApi
private fun NavGraphBuilder.addSettingsRoot(navController: NavController) {
private fun NavGraphBuilder.addSettingsRoot() {
navigation(
route = RootScreen.Settings.route,
startDestination = LeafScreen.Settings().createRoute()
) {
addSettings(navController)
addSettings()
}
}

private fun NavGraphBuilder.addSearch(navController: NavController) {
private fun NavGraphBuilder.addSearch() {
composableScreen(LeafScreen.Search()) {
Search()
}
}

private fun NavGraphBuilder.addSettings(navController: NavController) {
private fun NavGraphBuilder.addSettings() {
composableScreen(LeafScreen.Settings()) {
Settings()
}
}

private fun NavGraphBuilder.addDownloads(navController: NavController) {
private fun NavGraphBuilder.addDownloads() {
composableScreen(LeafScreen.Downloads()) {
Downloads()
}
}

private fun NavGraphBuilder.addLibrary(navController: NavController) {
private fun NavGraphBuilder.addLibrary() {
composableScreen(LeafScreen.Library()) {
Library()
}
}

private fun NavGraphBuilder.addCreatePlaylist(navController: NavController) {
private fun NavGraphBuilder.addCreatePlaylist() {
bottomSheetScreen(LeafScreen.CreatePlaylist()) {
CreatePlaylist()
}
}

private fun NavGraphBuilder.addEditPlaylist(navController: NavController) {
private fun NavGraphBuilder.addEditPlaylist() {
bottomSheetScreen(EditPlaylistScreen()) {
EditPlaylist()
}
}

private fun NavGraphBuilder.addPlaylistDetails(navController: NavController, root: RootScreen) {
private fun NavGraphBuilder.addPlaylistDetails(root: RootScreen) {
composableScreen(LeafScreen.PlaylistDetail(rootRoute = root.route)) {
PlaylistDetail()
}
}

private fun NavGraphBuilder.addArtistDetails(navController: NavController, root: RootScreen) {
private fun NavGraphBuilder.addArtistDetails(root: RootScreen) {
composableScreen(LeafScreen.ArtistDetails(rootRoute = root.route)) {
ArtistDetail()
}
}

private fun NavGraphBuilder.addAlbumDetails(navController: NavController, root: RootScreen) {
private fun NavGraphBuilder.addAlbumDetails(root: RootScreen) {
composableScreen(LeafScreen.AlbumDetails(rootRoute = root.route)) {
AlbumDetail()
}
}

private fun NavGraphBuilder.addPlaybackSheet(navController: NavController) {
private fun NavGraphBuilder.addPlaybackSheet() {
bottomSheetScreen(LeafScreen.PlaybackSheet()) {
PlaybackSheet()
}
Expand Down

0 comments on commit 3c4460a

Please sign in to comment.