Skip to content

Commit

Permalink
Refactoring for navigation module
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriy-chernysh committed Dec 2, 2024
1 parent f214e48 commit 106a53f
Show file tree
Hide file tree
Showing 18 changed files with 464 additions and 302 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import com.mobiledevpro.navigation.Screen
import com.mobiledevpro.navigation.chatListScreen
import com.mobiledevpro.navigation.peopleNavGraph
import com.mobiledevpro.navigation.profileScreen
import com.mobiledevpro.navigation.screen.chatListScreen
import com.mobiledevpro.navigation.screen.peopleNavGraph
import com.mobiledevpro.navigation.screen.userProfileScreen

/**
* Nested navigation graph for Home screen
Expand All @@ -46,7 +46,7 @@ fun HomeNavGraph(

chatListScreen()
peopleNavGraph()
profileScreen(onNavigateTo = onNavigateToRoot)
userProfileScreen(onNavigateTo = onNavigateToRoot)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import com.mobiledevpro.navigation.Screen
import com.mobiledevpro.navigation.onBoardingFirstScreen
import com.mobiledevpro.navigation.onBoardingSecondScreen
import com.mobiledevpro.navigation.onBoardingThirdScreen
import com.mobiledevpro.navigation.screen.onBoardingFirstScreen
import com.mobiledevpro.navigation.screen.onBoardingSecondScreen
import com.mobiledevpro.navigation.screen.onBoardingThirdScreen

/**
* Nested navigation graph for OnBoarding screen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import com.mobiledevpro.navigation.Screen
import com.mobiledevpro.navigation.ext.navigateTo
import com.mobiledevpro.navigation.peopleListScreen
import com.mobiledevpro.navigation.peopleProfileScreen
import com.mobiledevpro.navigation.screen.peopleListScreen
import com.mobiledevpro.navigation.screen.peopleProfileScreen

/**
* Nested navigation graph for People screen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import com.mobiledevpro.navigation.Screen
import com.mobiledevpro.navigation.ext.navigateTo
import com.mobiledevpro.navigation.homeNavGraph
import com.mobiledevpro.navigation.onBoardingNavGraph
import com.mobiledevpro.navigation.subscriptionScreen
import com.mobiledevpro.navigation.screen.homeScreen
import com.mobiledevpro.navigation.screen.onBoardingScreen
import com.mobiledevpro.navigation.screen.subscriptionScreen

/**
* Top-level navigation host in the app
Expand All @@ -52,8 +52,8 @@ fun RootNavGraph(
}

//Nested Navigation Graphs
onBoardingNavGraph(onNavigateToRoot = navController::navigateTo)
homeNavGraph(onNavigateToRoot = navController::navigateTo)
onBoardingScreen(onNavigateToRoot = navController::navigateTo)
homeScreen(onNavigateToRoot = navController::navigateTo)

//Root screens
subscriptionScreen(onNavigateBack = navigateBack)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2024 | Dmitri Chernysh | http://mobile-dev.pro
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.mobiledevpro.navigation.screen

import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import com.mobiledevpro.chatlist.di.featureChatListModule
import com.mobiledevpro.chatlist.view.ChatListScreen
import com.mobiledevpro.chatlist.view.ChatListViewModel
import com.mobiledevpro.di.rememberNavViewModel
import com.mobiledevpro.navigation.Screen

fun NavGraphBuilder.chatListScreen() {
composable(
route = Screen.ChatList.route
) {

val viewModel = rememberNavViewModel<ChatListViewModel>(
modules = { listOf(featureChatListModule) }
)

ChatListScreen(
state = viewModel.uiState,
onClick = { chat ->
//TODO: open chat screen
}
)
}
}
Loading

0 comments on commit 106a53f

Please sign in to comment.