├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── example
│ │ └── jetcomposenavmultimodule
│ │ ├── main
│ │ ├── navigation
│ │ │ └── AppNavGraph.kt
│ │ └── presentation
│ │ │ ├── AppContent.kt
│ │ │ ├── BottomTabs.kt
│ │ │ └── MainActivity.kt
│ │ └── ui
│ │ └── theme
│ │ ├── Color.kt
│ │ ├── Shape.kt
│ │ ├── Theme.kt
│ │ └── Type.kt
│ └── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ ├── ic_baseline_home.xml
│ ├── ic_baseline_settings.xml
│ └── ic_launcher_background.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-mdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── values-night
│ └── themes.xml
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── themes.xml
├── build.gradle
├── core
├── dependencyprovider
│ ├── build.gradle
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── core
│ │ └── dependencyprovider
│ │ └── DependencyProvider.kt
└── feature-api
│ ├── build.gradle
│ └── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── example
│ └── core
│ └── feature_api
│ ├── FeatureApi.kt
│ └── NavExt.kt
├── feature
├── home-api
│ ├── build.gradle
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── feature
│ │ └── api
│ │ └── home
│ │ └── HomeFeatureApi.kt
├── home-impl
│ ├── build.gradle
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── feature
│ │ └── home
│ │ └── impl
│ │ ├── navigation
│ │ └── HomeFeatureImpl.kt
│ │ └── presentation
│ │ ├── HomeScreen.kt
│ │ ├── ScreenA.kt
│ │ └── ScreenB.kt
├── onboarding-api
│ ├── build.gradle
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── api
│ │ └── onboarding
│ │ └── OnboardingFeatureApi.kt
├── onboarding-impl
│ ├── build.gradle
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── feature
│ │ └── onboarding
│ │ └── impl
│ │ ├── navigation
│ │ └── OnboardingFeatureImpl.kt
│ │ └── presentation
│ │ └── OnboardingScreen.kt
├── settings-api
│ ├── build.gradle
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── feature
│ │ └── api
│ │ └── settings
│ │ └── SettingsFeatureApi.kt
└── settings-impl
│ ├── build.gradle
│ └── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── example
│ └── feature
│ └── settings
│ └── impl
│ ├── navigation
│ └── SettingsFeatureImpl.kt
│ └── presentation
│ └── SettingsScreen.kt
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | .idea
5 | /.idea/caches
6 | /.idea/libraries
7 | /.idea/modules.xml
8 | /.idea/workspace.xml
9 | /.idea/navEditor.xml
10 | /.idea/assetWizardSettings.xml
11 | .DS_Store
12 | /build
13 | /captures
14 | .externalNativeBuild
15 | .cxx
16 | local.properties
17 | build
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | **Jetpack Compose Navigation in a multi-module project**
2 |
3 | - [Post text on medium.com EN](https://medium.com/@mmarashan/jetpack-compose-navigation-in-a-multi-module-project-8d3947e6e2a4)
4 | - [Post text on habr.com RU](https://habr.com/ru/post/586192/)
5 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'kotlin-android'
4 | }
5 |
6 | android {
7 | compileSdk 33
8 |
9 | defaultConfig {
10 | applicationId "com.example.jetcomposenavmultimodule"
11 | minSdk 26
12 | targetSdk 33
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | vectorDrawables {
18 | useSupportLibrary true
19 | }
20 | }
21 |
22 | buildTypes {
23 | release {
24 | minifyEnabled false
25 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
26 | }
27 | }
28 | compileOptions {
29 | sourceCompatibility JavaVersion.VERSION_1_8
30 | targetCompatibility JavaVersion.VERSION_1_8
31 | }
32 | kotlinOptions {
33 | jvmTarget = '1.8'
34 | useIR = true
35 | }
36 | buildFeatures {
37 | compose true
38 | }
39 | composeOptions {
40 | kotlinCompilerExtensionVersion compose_version
41 | kotlinCompilerVersion kotlin_compiler_version
42 | }
43 | packagingOptions {
44 | resources {
45 | excludes += '/META-INF/{AL2.0,LGPL2.1}'
46 | }
47 | }
48 | }
49 |
50 | dependencies {
51 |
52 | implementation 'androidx.core:core-ktx:1.6.0'
53 | implementation 'com.google.android.material:material:1.4.0'
54 | implementation "androidx.compose.ui:ui:$compose_version"
55 | implementation "androidx.compose.material:material:$compose_version"
56 | implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
57 | implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
58 | implementation 'androidx.activity:activity-compose:1.3.1'
59 | implementation "com.google.accompanist:accompanist-insets:0.18.0"
60 |
61 | implementation project(":core:feature-api")
62 | implementation project(":core:dependencyprovider")
63 |
64 | implementation project(':feature:home-api')
65 | implementation project(':feature:home-impl')
66 | implementation project(":feature:settings-api")
67 | implementation project(':feature:settings-impl')
68 | implementation project(":feature:onboarding-api")
69 | implementation project(':feature:onboarding-impl')
70 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/jetcomposenavmultimodule/main/navigation/AppNavGraph.kt:
--------------------------------------------------------------------------------
1 | package com.example.jetcomposenavmultimodule.main.navigation
2 |
3 | import androidx.compose.runtime.Composable
4 | import androidx.compose.ui.Modifier
5 | import androidx.navigation.NavHostController
6 | import androidx.navigation.compose.NavHost
7 | import com.example.core.dependencyprovider.DependencyProvider
8 | import com.example.core.feature_api.register
9 |
10 |
11 | @Composable
12 | fun AppNavGraph(
13 | modifier: Modifier = Modifier,
14 | navController: NavHostController
15 | ) {
16 | NavHost(
17 | navController = navController,
18 | startDestination = DependencyProvider.onboardingFeature().route
19 | ) {
20 | register(
21 | DependencyProvider.homeFeature(),
22 | navController = navController,
23 | modifier = modifier
24 | )
25 |
26 | register(
27 | DependencyProvider.settingsFeature(),
28 | navController = navController,
29 | modifier = modifier
30 | )
31 |
32 | register(
33 | DependencyProvider.onboardingFeature(),
34 | navController = navController,
35 | modifier = modifier
36 | )
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/jetcomposenavmultimodule/main/presentation/AppContent.kt:
--------------------------------------------------------------------------------
1 | package com.example.jetcomposenavmultimodule.main.presentation
2 |
3 | import androidx.compose.foundation.layout.padding
4 | import androidx.compose.material.BottomNavigation
5 | import androidx.compose.material.BottomNavigationItem
6 | import androidx.compose.material.Icon
7 | import androidx.compose.material.LocalContentColor
8 | import androidx.compose.material.MaterialTheme
9 | import androidx.compose.material.Scaffold
10 | import androidx.compose.material.Text
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.runtime.getValue
13 | import androidx.compose.runtime.remember
14 | import androidx.compose.ui.Modifier
15 | import androidx.compose.ui.res.painterResource
16 | import androidx.compose.ui.res.stringResource
17 | import androidx.compose.ui.unit.dp
18 | import androidx.navigation.NavController
19 | import androidx.navigation.compose.currentBackStackEntryAsState
20 | import androidx.navigation.compose.rememberNavController
21 | import com.example.jetcomposenavmultimodule.main.navigation.AppNavGraph
22 | import com.example.jetcomposenavmultimodule.ui.theme.JetComposeNavMultimoduleTheme
23 | import com.example.jetcomposenavmultimodule.ui.theme.backgroundWhite
24 | import com.google.accompanist.insets.ProvideWindowInsets
25 | import com.google.accompanist.insets.navigationBarsHeight
26 | import com.google.accompanist.insets.navigationBarsPadding
27 | import java.util.Locale
28 |
29 | @Composable
30 | fun AppContent() {
31 | ProvideWindowInsets {
32 | JetComposeNavMultimoduleTheme {
33 | val tabs = remember { BottomTabs.values() }
34 | val navController = rememberNavController()
35 | Scaffold(
36 | backgroundColor = backgroundWhite,
37 | bottomBar = { BottomBar(navController = navController, tabs) }
38 | ) { innerPaddingModifier ->
39 | AppNavGraph(
40 | navController = navController,
41 | modifier = Modifier.padding(innerPaddingModifier)
42 | )
43 | }
44 | }
45 | }
46 | }
47 |
48 | @Composable
49 | fun BottomBar(navController: NavController, tabs: Array) {
50 |
51 | val navBackStackEntry by navController.currentBackStackEntryAsState()
52 | val currentRoute = navBackStackEntry?.destination?.route ?: BottomTabs.HOME.route
53 |
54 | val routes = remember { BottomTabs.values().map { it.route } }
55 | if (currentRoute in routes) {
56 | BottomNavigation(
57 | Modifier.navigationBarsHeight(additional = 56.dp)
58 | ) {
59 | tabs.forEach { tab ->
60 | BottomNavigationItem(
61 | icon = { Icon(painterResource(tab.icon), contentDescription = null) },
62 | label = { Text(stringResource(tab.title).uppercase(Locale.getDefault())) },
63 | selected = currentRoute == tab.route,
64 | onClick = {
65 | if (tab.route != currentRoute) {
66 | navController.navigate(tab.route) {
67 | popUpTo(navController.graph.startDestinationId) {
68 | saveState = true
69 | }
70 | launchSingleTop = true
71 | restoreState = true
72 | }
73 | }
74 | },
75 | alwaysShowLabel = false,
76 | selectedContentColor = MaterialTheme.colors.secondary,
77 | unselectedContentColor = LocalContentColor.current,
78 | modifier = Modifier.navigationBarsPadding()
79 | )
80 | }
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/jetcomposenavmultimodule/main/presentation/BottomTabs.kt:
--------------------------------------------------------------------------------
1 | package com.example.jetcomposenavmultimodule.main.presentation
2 |
3 | import androidx.annotation.DrawableRes
4 | import androidx.annotation.StringRes
5 | import com.example.core.dependencyprovider.DependencyProvider
6 | import com.example.jetcomposenavmultimodule.R
7 |
8 | enum class BottomTabs(
9 | @StringRes
10 | val title: Int,
11 | @DrawableRes
12 | val icon: Int,
13 | val route: String
14 | ) {
15 |
16 | HOME(
17 | R.string.home,
18 | R.drawable.ic_baseline_home,
19 | DependencyProvider.homeFeature().homeRoute
20 | ),
21 | SETTINGS(
22 | R.string.settings,
23 | R.drawable.ic_baseline_settings,
24 | DependencyProvider.settingsFeature().settingsRoute
25 | )
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/jetcomposenavmultimodule/main/presentation/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.jetcomposenavmultimodule.main.presentation
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.core.view.WindowCompat
7 | import com.example.core.dependencyprovider.DependencyProvider
8 | import com.example.feature.home.impl.navigation.HomeFeatureImpl
9 | import com.example.feature.onboarding.impl.navigation.OnboardingFeatureImpl
10 | import com.example.feature.settings.impl.navigation.SettingsFeatureImpl
11 | import com.example.jetcomposenavmultimodule.ui.theme.JetComposeNavMultimoduleTheme
12 |
13 | class MainActivity : ComponentActivity() {
14 | override fun onCreate(savedInstanceState: Bundle?) {
15 | super.onCreate(savedInstanceState)
16 | WindowCompat.setDecorFitsSystemWindows(window, true)
17 |
18 | DependencyProvider.provideImpl(
19 | homeFeatureApi = HomeFeatureImpl(),
20 | settingsFeatureApi = SettingsFeatureImpl(),
21 | onboardingFeatureApi = OnboardingFeatureImpl()
22 | )
23 |
24 | setContent {
25 | JetComposeNavMultimoduleTheme {
26 | AppContent()
27 | }
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/jetcomposenavmultimodule/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.example.jetcomposenavmultimodule.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple200 = Color(0xFFBB86FC)
6 | val Purple500 = Color(0xFF6200EE)
7 | val Purple700 = Color(0xFF3700B3)
8 | val Teal200 = Color(0xFF03DAC5)
9 | val backgroundWhite = Color(0xFFFFFFFF)
--------------------------------------------------------------------------------
/app/src/main/java/com/example/jetcomposenavmultimodule/ui/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package com.example.jetcomposenavmultimodule.ui.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(4.dp),
10 | large = RoundedCornerShape(0.dp)
11 | )
--------------------------------------------------------------------------------
/app/src/main/java/com/example/jetcomposenavmultimodule/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.example.jetcomposenavmultimodule.ui.theme
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.material.MaterialTheme
5 | import androidx.compose.material.darkColors
6 | import androidx.compose.material.lightColors
7 | import androidx.compose.runtime.Composable
8 |
9 | private val DarkColorPalette = darkColors(
10 | primary = Purple200,
11 | primaryVariant = Purple700,
12 | secondary = Teal200
13 | )
14 |
15 | private val LightColorPalette = lightColors(
16 | primary = Purple500,
17 | primaryVariant = Purple700,
18 | secondary = Teal200
19 |
20 | /* Other default colors to override
21 | background = Color.White,
22 | surface = Color.White,
23 | onPrimary = Color.White,
24 | onSecondary = Color.Black,
25 | onBackground = Color.Black,
26 | onSurface = Color.Black,
27 | */
28 | )
29 |
30 | @Composable
31 | fun JetComposeNavMultimoduleTheme(
32 | darkTheme: Boolean = isSystemInDarkTheme(),
33 | content: @Composable() () -> Unit
34 | ) {
35 | val colors = if (darkTheme) {
36 | DarkColorPalette
37 | } else {
38 | LightColorPalette
39 | }
40 |
41 | MaterialTheme(
42 | colors = colors,
43 | typography = Typography,
44 | shapes = Shapes,
45 | content = content
46 | )
47 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/jetcomposenavmultimodule/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package com.example.jetcomposenavmultimodule.ui.theme
2 |
3 | import androidx.compose.material.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | body1 = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp
15 | )
16 | /* Other default text styles to override
17 | button = TextStyle(
18 | fontFamily = FontFamily.Default,
19 | fontWeight = FontWeight.W500,
20 | fontSize = 14.sp
21 | ),
22 | caption = TextStyle(
23 | fontFamily = FontFamily.Default,
24 | fontWeight = FontWeight.Normal,
25 | fontSize = 12.sp
26 | )
27 | */
28 | )
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_baseline_home.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_baseline_settings.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mmarashan/JetComposeNavMultimodule/fba6f0702029ae956ceb6a503755b6c4e6d30d39/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mmarashan/JetComposeNavMultimodule/fba6f0702029ae956ceb6a503755b6c4e6d30d39/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mmarashan/JetComposeNavMultimodule/fba6f0702029ae956ceb6a503755b6c4e6d30d39/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mmarashan/JetComposeNavMultimodule/fba6f0702029ae956ceb6a503755b6c4e6d30d39/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mmarashan/JetComposeNavMultimodule/fba6f0702029ae956ceb6a503755b6c4e6d30d39/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mmarashan/JetComposeNavMultimodule/fba6f0702029ae956ceb6a503755b6c4e6d30d39/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mmarashan/JetComposeNavMultimodule/fba6f0702029ae956ceb6a503755b6c4e6d30d39/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mmarashan/JetComposeNavMultimodule/fba6f0702029ae956ceb6a503755b6c4e6d30d39/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mmarashan/JetComposeNavMultimodule/fba6f0702029ae956ceb6a503755b6c4e6d30d39/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mmarashan/JetComposeNavMultimodule/fba6f0702029ae956ceb6a503755b6c4e6d30d39/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | JetComposeNavMultimodule
3 |
4 | Home
5 | Settings
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | ext {
4 | compose_version = '1.0.4'
5 | kotlin_compiler_version = '1.5.31'
6 | }
7 | repositories {
8 | google()
9 | mavenCentral()
10 | }
11 | dependencies {
12 | classpath "com.android.tools.build:gradle:7.0.3"
13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"
14 |
15 | // NOTE: Do not place your application dependencies here; they belong
16 | // in the individual module build.gradle files
17 | }
18 | }
19 |
20 | task clean(type: Delete) {
21 | delete rootProject.buildDir
22 | }
--------------------------------------------------------------------------------
/core/dependencyprovider/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'kotlin-android'
4 | }
5 |
6 | android {
7 | compileSdk 33
8 |
9 | defaultConfig {
10 | minSdk 26
11 | targetSdk 33
12 | versionCode 1
13 | versionName "1.0"
14 | }
15 | }
16 |
17 | dependencies {
18 | implementation project(':feature:home-api')
19 | implementation project(':feature:settings-api')
20 | implementation project(':feature:onboarding-api')
21 | }
--------------------------------------------------------------------------------
/core/dependencyprovider/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/core/dependencyprovider/src/main/java/com/example/core/dependencyprovider/DependencyProvider.kt:
--------------------------------------------------------------------------------
1 | package com.example.core.dependencyprovider
2 |
3 | import com.example.api.onboarding.OnboardingFeatureApi
4 | import com.example.feature.api.home.HomeFeatureApi
5 | import com.example.feature.api.settings.SettingsFeatureApi
6 |
7 | /**
8 | * WARNING!!! Don't use it in real project! Use real DI libraries: Dagger, Hilt, Koin..
9 | * We did this to simplify the example
10 | */
11 | object DependencyProvider {
12 |
13 | /* Don't use lateinit in real project :) */
14 | private lateinit var homeFeatureApi: HomeFeatureApi
15 | private lateinit var settingsFeatureApi: SettingsFeatureApi
16 | private lateinit var onboardingFeatureApi: OnboardingFeatureApi
17 |
18 | fun provideImpl(
19 | homeFeatureApi: HomeFeatureApi,
20 | settingsFeatureApi: SettingsFeatureApi,
21 | onboardingFeatureApi: OnboardingFeatureApi
22 | ) {
23 | this.homeFeatureApi = homeFeatureApi
24 | this.settingsFeatureApi = settingsFeatureApi
25 | this.onboardingFeatureApi = onboardingFeatureApi
26 | }
27 |
28 | fun homeFeature(): HomeFeatureApi = homeFeatureApi
29 |
30 | fun settingsFeature(): SettingsFeatureApi = settingsFeatureApi
31 |
32 | fun onboardingFeature(): OnboardingFeatureApi = onboardingFeatureApi
33 | }
--------------------------------------------------------------------------------
/core/feature-api/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'kotlin-android'
4 | }
5 |
6 | android {
7 | compileSdk 33
8 |
9 | defaultConfig {
10 | minSdk 26
11 | targetSdk 33
12 | versionCode 1
13 | versionName "1.0"
14 | }
15 |
16 | composeOptions {
17 | kotlinCompilerExtensionVersion compose_version
18 | kotlinCompilerVersion kotlin_compiler_version
19 | }
20 | buildFeatures {
21 | compose true
22 | }
23 | }
24 |
25 | dependencies {
26 | api "androidx.navigation:navigation-compose:2.4.0-alpha10"
27 | }
--------------------------------------------------------------------------------
/core/feature-api/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/core/feature-api/src/main/java/com/example/core/feature_api/FeatureApi.kt:
--------------------------------------------------------------------------------
1 | package com.example.core.feature_api
2 |
3 | import androidx.compose.ui.Modifier
4 | import androidx.navigation.NavGraphBuilder
5 | import androidx.navigation.NavHostController
6 |
7 | interface FeatureApi {
8 |
9 | fun registerGraph(
10 | navGraphBuilder: NavGraphBuilder,
11 | navController: NavHostController,
12 | modifier: Modifier = Modifier
13 | )
14 | }
--------------------------------------------------------------------------------
/core/feature-api/src/main/java/com/example/core/feature_api/NavExt.kt:
--------------------------------------------------------------------------------
1 | package com.example.core.feature_api
2 |
3 | import androidx.compose.ui.Modifier
4 | import androidx.navigation.NavGraphBuilder
5 | import androidx.navigation.NavHostController
6 |
7 | fun NavGraphBuilder.register(
8 | featureApi: FeatureApi,
9 | navController: NavHostController,
10 | modifier: Modifier = Modifier
11 | ) {
12 | featureApi.registerGraph(
13 | navGraphBuilder = this,
14 | navController = navController,
15 | modifier = modifier
16 | )
17 | }
--------------------------------------------------------------------------------
/feature/home-api/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'kotlin-android'
4 | }
5 |
6 | android {
7 | compileSdk 33
8 |
9 | defaultConfig {
10 | minSdk 26
11 | targetSdk 33
12 | versionCode 1
13 | versionName "1.0"
14 | }
15 |
16 | kotlinOptions {
17 | jvmTarget = '1.8'
18 | useIR = true
19 | }
20 | buildFeatures {
21 | compose true
22 | }
23 | composeOptions {
24 | kotlinCompilerExtensionVersion compose_version
25 | kotlinCompilerVersion kotlin_compiler_version
26 | }
27 | }
28 |
29 | dependencies {
30 | api project(":core:feature-api")
31 | }
--------------------------------------------------------------------------------
/feature/home-api/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/feature/home-api/src/main/java/com/example/feature/api/home/HomeFeatureApi.kt:
--------------------------------------------------------------------------------
1 | package com.example.feature.api.home
2 |
3 | import com.example.core.feature_api.FeatureApi
4 |
5 | interface HomeFeatureApi : FeatureApi {
6 |
7 | val homeRoute: String
8 | }
--------------------------------------------------------------------------------
/feature/home-impl/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'kotlin-android'
4 | }
5 |
6 | android {
7 | compileSdk 33
8 |
9 | defaultConfig {
10 | minSdk 26
11 | targetSdk 33
12 | versionCode 1
13 | versionName "1.0"
14 | }
15 |
16 | kotlinOptions {
17 | jvmTarget = '1.8'
18 | useIR = true
19 | }
20 | buildFeatures {
21 | compose true
22 | }
23 | composeOptions {
24 | kotlinCompilerExtensionVersion compose_version
25 | kotlinCompilerVersion kotlin_compiler_version
26 | }
27 | }
28 |
29 | dependencies {
30 |
31 | implementation 'androidx.core:core-ktx:1.6.0'
32 | implementation "androidx.compose.ui:ui:$compose_version"
33 | implementation "androidx.compose.material:material:$compose_version"
34 | implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
35 |
36 | implementation project(":core:feature-api")
37 | implementation project(":feature:home-api")
38 | implementation project(":core:dependencyprovider")
39 | }
--------------------------------------------------------------------------------
/feature/home-impl/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/feature/home-impl/src/main/java/com/example/feature/home/impl/navigation/HomeFeatureImpl.kt:
--------------------------------------------------------------------------------
1 | package com.example.feature.home.impl.navigation
2 |
3 | import android.net.Uri
4 | import androidx.compose.ui.Modifier
5 | import androidx.navigation.NavGraphBuilder
6 | import androidx.navigation.NavHostController
7 | import androidx.navigation.NavType
8 | import androidx.navigation.compose.composable
9 | import androidx.navigation.navArgument
10 | import androidx.navigation.navigation
11 | import com.example.feature.api.home.HomeFeatureApi
12 | import com.example.feature.home.impl.HomeScreen
13 | import com.example.feature.home.impl.ScreenA
14 | import com.example.feature.home.impl.ScreenB
15 |
16 | private const val baseRoute = "home"
17 | private const val scenarioABRoute = "$baseRoute/scenario"
18 | private const val screenBRoute = "$scenarioABRoute/B"
19 | private const val screenARoute = "$scenarioABRoute/A"
20 | private const val argumentKey = "arg"
21 |
22 | class HomeFeatureImpl : HomeFeatureApi {
23 |
24 | override val homeRoute = baseRoute
25 |
26 | override fun registerGraph(
27 | navGraphBuilder: NavGraphBuilder,
28 | navController: NavHostController,
29 | modifier: Modifier
30 | ) {
31 |
32 | navGraphBuilder.composable(baseRoute) {
33 | HomeScreen(
34 | modifier = modifier,
35 | onNavigateToABFlow = {
36 | navController.navigate(scenarioABRoute)
37 | }
38 | )
39 | }
40 |
41 | /* Nested graph for internal scenario */
42 | navGraphBuilder.navigation(
43 | route = scenarioABRoute,
44 | startDestination = screenARoute
45 | ) {
46 |
47 | composable(route = screenARoute) {
48 | ScreenA(
49 | modifier = modifier,
50 | onNavigateNextWithArgument = { argument ->
51 | val encodedArgument = Uri.encode(argument)
52 | navController.navigate(route = "$screenBRoute/$encodedArgument")
53 | }
54 | )
55 | }
56 |
57 | composable(
58 | route = "$screenBRoute/{$argumentKey}",
59 | arguments = listOf(
60 | navArgument(argumentKey) {
61 | type = NavType.StringType
62 | }
63 | )
64 | ) { backStackEntry ->
65 | val arguments = requireNotNull(backStackEntry.arguments)
66 | val argument = Uri.decode(arguments.getString(argumentKey).orEmpty())
67 |
68 | ScreenB(
69 | modifier = modifier,
70 | argument = argument.orEmpty()
71 | )
72 | }
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/feature/home-impl/src/main/java/com/example/feature/home/impl/presentation/HomeScreen.kt:
--------------------------------------------------------------------------------
1 | package com.example.feature.home.impl
2 |
3 | import androidx.compose.foundation.layout.Arrangement
4 | import androidx.compose.foundation.layout.Column
5 | import androidx.compose.foundation.layout.fillMaxSize
6 | import androidx.compose.foundation.layout.padding
7 | import androidx.compose.material.Button
8 | import androidx.compose.material.Text
9 | import androidx.compose.runtime.Composable
10 | import androidx.compose.ui.Alignment
11 | import androidx.compose.ui.Modifier
12 | import androidx.compose.ui.unit.dp
13 | import androidx.compose.ui.unit.sp
14 |
15 | @Composable
16 | internal fun HomeScreen(
17 | modifier: Modifier,
18 | onNavigateToABFlow: () -> Unit
19 | ) {
20 | Column(
21 | modifier = modifier.fillMaxSize(),
22 | horizontalAlignment = Alignment.CenterHorizontally,
23 | verticalArrangement = Arrangement.Center,
24 | ) {
25 | Text(
26 | "Home",
27 | modifier = Modifier.padding(36.dp),
28 | fontSize = 24.sp
29 | )
30 |
31 | Button(
32 | modifier = Modifier.padding(16.dp),
33 | onClick = onNavigateToABFlow
34 | ) {
35 | Text("Navigate to A-B scenario")
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/feature/home-impl/src/main/java/com/example/feature/home/impl/presentation/ScreenA.kt:
--------------------------------------------------------------------------------
1 | package com.example.feature.home.impl
2 |
3 | import androidx.compose.foundation.layout.Arrangement
4 | import androidx.compose.foundation.layout.Column
5 | import androidx.compose.foundation.layout.fillMaxSize
6 | import androidx.compose.foundation.layout.padding
7 | import androidx.compose.material.Button
8 | import androidx.compose.material.OutlinedTextField
9 | import androidx.compose.material.Text
10 | import androidx.compose.runtime.Composable
11 | import androidx.compose.runtime.getValue
12 | import androidx.compose.runtime.mutableStateOf
13 | import androidx.compose.runtime.remember
14 | import androidx.compose.runtime.setValue
15 | import androidx.compose.ui.Alignment
16 | import androidx.compose.ui.Modifier
17 | import androidx.compose.ui.unit.dp
18 | import androidx.compose.ui.unit.sp
19 |
20 | @Composable
21 | internal fun ScreenA(
22 | modifier: Modifier,
23 | onNavigateNextWithArgument: (String) -> Unit
24 | ) {
25 | var text by remember { mutableStateOf("") }
26 |
27 | Column(
28 | modifier = modifier.fillMaxSize(),
29 | horizontalAlignment = Alignment.CenterHorizontally,
30 | verticalArrangement = Arrangement.Center,
31 | ) {
32 | Text(
33 | "Screen A. Input parameter value",
34 | modifier = Modifier.padding(36.dp),
35 | fontSize = 24.sp
36 | )
37 |
38 | OutlinedTextField(
39 | value = text,
40 | onValueChange = { value -> text = value },
41 | modifier = Modifier.padding(36.dp)
42 | )
43 |
44 | Button(
45 | modifier = Modifier.padding(16.dp),
46 | onClick = {
47 | onNavigateNextWithArgument(text)
48 | }
49 | ) {
50 | Text("To screen B")
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/feature/home-impl/src/main/java/com/example/feature/home/impl/presentation/ScreenB.kt:
--------------------------------------------------------------------------------
1 | package com.example.feature.home.impl
2 |
3 | import androidx.compose.foundation.layout.Arrangement
4 | import androidx.compose.foundation.layout.Column
5 | import androidx.compose.foundation.layout.fillMaxSize
6 | import androidx.compose.foundation.layout.padding
7 | import androidx.compose.material.Text
8 | import androidx.compose.runtime.Composable
9 | import androidx.compose.ui.Alignment
10 | import androidx.compose.ui.Modifier
11 | import androidx.compose.ui.unit.dp
12 | import androidx.compose.ui.unit.sp
13 |
14 | @Composable
15 | fun ScreenB(modifier: Modifier, argument: String) {
16 | Column(
17 | modifier = modifier.fillMaxSize(),
18 | horizontalAlignment = Alignment.CenterHorizontally,
19 | verticalArrangement = Arrangement.Center,
20 | ) {
21 | Text(
22 | "Screen B",
23 | modifier = Modifier.padding(36.dp),
24 | fontSize = 24.sp
25 | )
26 | Text(
27 | "Argument = $argument",
28 | modifier = Modifier.padding(16.dp),
29 | fontSize = 24.sp
30 | )
31 | }
32 | }
--------------------------------------------------------------------------------
/feature/onboarding-api/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'kotlin-android'
4 | }
5 |
6 | android {
7 | compileSdk 33
8 |
9 | defaultConfig {
10 | minSdk 26
11 | targetSdk 33
12 | versionCode 1
13 | versionName "1.0"
14 | }
15 |
16 | kotlinOptions {
17 | jvmTarget = '1.8'
18 | useIR = true
19 | }
20 | buildFeatures {
21 | compose true
22 | }
23 | composeOptions {
24 | kotlinCompilerExtensionVersion compose_version
25 | kotlinCompilerVersion kotlin_compiler_version
26 | }
27 | }
28 |
29 | dependencies {
30 | api project(":core:feature-api")
31 | }
--------------------------------------------------------------------------------
/feature/onboarding-api/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/feature/onboarding-api/src/main/java/com/example/api/onboarding/OnboardingFeatureApi.kt:
--------------------------------------------------------------------------------
1 | package com.example.api.onboarding
2 |
3 | import com.example.core.feature_api.FeatureApi
4 |
5 | interface OnboardingFeatureApi: FeatureApi {
6 |
7 | val route: String
8 | }
--------------------------------------------------------------------------------
/feature/onboarding-impl/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'kotlin-android'
4 | }
5 |
6 | android {
7 | compileSdk 33
8 |
9 | defaultConfig {
10 | minSdk 26
11 | targetSdk 33
12 | versionCode 1
13 | versionName "1.0"
14 | }
15 |
16 | kotlinOptions {
17 | jvmTarget = '1.8'
18 | useIR = true
19 | }
20 | buildFeatures {
21 | compose true
22 | }
23 | composeOptions {
24 | kotlinCompilerExtensionVersion compose_version
25 | kotlinCompilerVersion '1.5.21'
26 | }
27 | }
28 |
29 | dependencies {
30 |
31 | implementation 'androidx.core:core-ktx:1.6.0'
32 | implementation "androidx.compose.ui:ui:$compose_version"
33 | implementation "androidx.compose.material:material:$compose_version"
34 | implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
35 |
36 | implementation project(":core:feature-api")
37 | implementation project(":core:dependencyprovider")
38 |
39 | implementation project(":feature:onboarding-api")
40 | implementation project(":feature:home-api")
41 | implementation project(":feature:settings-api")
42 | }
--------------------------------------------------------------------------------
/feature/onboarding-impl/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/feature/onboarding-impl/src/main/java/com/example/feature/onboarding/impl/navigation/OnboardingFeatureImpl.kt:
--------------------------------------------------------------------------------
1 | package com.example.feature.onboarding.impl.navigation
2 |
3 | import androidx.compose.ui.Modifier
4 | import androidx.navigation.NavGraphBuilder
5 | import androidx.navigation.NavHostController
6 | import androidx.navigation.compose.composable
7 | import com.example.api.onboarding.OnboardingFeatureApi
8 | import com.example.core.dependencyprovider.DependencyProvider
9 | import com.example.feature.onboarding.impl.OnboardingScreen
10 |
11 | class OnboardingFeatureImpl : OnboardingFeatureApi {
12 |
13 | override val route = "onboarding"
14 |
15 | override fun registerGraph(
16 | navGraphBuilder: NavGraphBuilder,
17 | navController: NavHostController,
18 | modifier: Modifier
19 | ) {
20 | navGraphBuilder.composable(route) {
21 | OnboardingScreen(
22 | modifier = modifier,
23 | onNavigateToHome = {
24 | val homeFeature = DependencyProvider.homeFeature()
25 | navController.navigate(homeFeature.homeRoute) {
26 | popUpTo(route) { inclusive = true }
27 | }
28 | },
29 | onNavigateToSettings = {
30 | val settingsFeature = DependencyProvider.settingsFeature()
31 | navController.navigate(settingsFeature.settingsRoute) {
32 | popUpTo(route) { inclusive = true }
33 | }
34 | }
35 | )
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/feature/onboarding-impl/src/main/java/com/example/feature/onboarding/impl/presentation/OnboardingScreen.kt:
--------------------------------------------------------------------------------
1 | package com.example.feature.onboarding.impl
2 |
3 | import androidx.compose.foundation.layout.Arrangement
4 | import androidx.compose.foundation.layout.Column
5 | import androidx.compose.foundation.layout.padding
6 | import androidx.compose.material.Button
7 | import androidx.compose.material.Text
8 | import androidx.compose.runtime.Composable
9 | import androidx.compose.ui.Alignment
10 | import androidx.compose.ui.Modifier
11 | import androidx.compose.ui.text.style.TextAlign
12 | import androidx.compose.ui.unit.dp
13 | import androidx.compose.ui.unit.sp
14 |
15 | @Composable
16 | internal fun OnboardingScreen(
17 | modifier: Modifier,
18 | onNavigateToHome: () -> Unit,
19 | onNavigateToSettings: () -> Unit
20 | ) {
21 | Column(
22 | modifier = modifier,
23 | verticalArrangement = Arrangement.Center,
24 | horizontalAlignment = Alignment.CenterHorizontally
25 | ) {
26 | Text(
27 | text = "Hello world! You're in onboarding screen",
28 | textAlign = TextAlign.Center,
29 | modifier = Modifier.padding(36.dp),
30 | fontSize = 24.sp
31 | )
32 | SimpleButton(
33 | text = "To home",
34 | onClick = onNavigateToHome
35 | )
36 |
37 | SimpleButton(
38 | text = "To settings",
39 | onClick = onNavigateToSettings
40 | )
41 | }
42 | }
43 |
44 | @Composable
45 | private fun SimpleButton(
46 | modifier: Modifier = Modifier,
47 | text: String,
48 | onClick: () -> Unit
49 | ) {
50 | Button(
51 | modifier = modifier.padding(16.dp),
52 | onClick = onClick
53 | ) {
54 | Text(text)
55 | }
56 | }
--------------------------------------------------------------------------------
/feature/settings-api/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'kotlin-android'
4 | }
5 |
6 | android {
7 | compileSdk 33
8 |
9 | defaultConfig {
10 | minSdk 26
11 | targetSdk 33
12 | versionCode 1
13 | versionName "1.0"
14 | }
15 |
16 | kotlinOptions {
17 | jvmTarget = '1.8'
18 | useIR = true
19 | }
20 | buildFeatures {
21 | compose true
22 | }
23 | composeOptions {
24 | kotlinCompilerExtensionVersion compose_version
25 | kotlinCompilerVersion kotlin_compiler_version
26 | }
27 | }
28 |
29 | dependencies {
30 | api project(":core:feature-api")
31 | }
--------------------------------------------------------------------------------
/feature/settings-api/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/feature/settings-api/src/main/java/com/example/feature/api/settings/SettingsFeatureApi.kt:
--------------------------------------------------------------------------------
1 | package com.example.feature.api.settings
2 |
3 | import com.example.core.feature_api.FeatureApi
4 |
5 | interface SettingsFeatureApi: FeatureApi {
6 |
7 | val settingsRoute: String
8 | }
--------------------------------------------------------------------------------
/feature/settings-impl/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'kotlin-android'
4 | }
5 |
6 | android {
7 | compileSdk 33
8 |
9 | defaultConfig {
10 | minSdk 26
11 | targetSdk 33
12 | versionCode 1
13 | versionName "1.0"
14 | }
15 |
16 | kotlinOptions {
17 | jvmTarget = '1.8'
18 | useIR = true
19 | }
20 | buildFeatures {
21 | compose true
22 | }
23 | composeOptions {
24 | kotlinCompilerExtensionVersion compose_version
25 | kotlinCompilerVersion kotlin_compiler_version
26 | }
27 | }
28 |
29 | dependencies {
30 |
31 | implementation 'androidx.core:core-ktx:1.6.0'
32 | implementation "androidx.compose.ui:ui:$compose_version"
33 | implementation "androidx.compose.material:material:$compose_version"
34 | implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
35 |
36 | implementation project(":core:feature-api")
37 | implementation project(":feature:settings-api")
38 | }
--------------------------------------------------------------------------------
/feature/settings-impl/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/feature/settings-impl/src/main/java/com/example/feature/settings/impl/navigation/SettingsFeatureImpl.kt:
--------------------------------------------------------------------------------
1 | package com.example.feature.settings.impl.navigation
2 |
3 | import androidx.compose.ui.Modifier
4 | import androidx.navigation.NavGraphBuilder
5 | import androidx.navigation.NavHostController
6 | import androidx.navigation.compose.composable
7 | import com.example.feature.api.settings.SettingsFeatureApi
8 | import com.example.feature.settings.impl.SettingsScreen
9 |
10 | class SettingsFeatureImpl : SettingsFeatureApi {
11 |
12 | override val settingsRoute: String = "settings"
13 |
14 | override fun registerGraph(
15 | navGraphBuilder: NavGraphBuilder,
16 | navController: NavHostController,
17 | modifier: Modifier
18 | ) {
19 | navGraphBuilder.composable(settingsRoute) {
20 | SettingsScreen(modifier = modifier)
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/feature/settings-impl/src/main/java/com/example/feature/settings/impl/presentation/SettingsScreen.kt:
--------------------------------------------------------------------------------
1 | package com.example.feature.settings.impl
2 |
3 | import androidx.compose.foundation.layout.Arrangement
4 | import androidx.compose.foundation.layout.Column
5 | import androidx.compose.foundation.layout.fillMaxSize
6 | import androidx.compose.material.Text
7 | import androidx.compose.runtime.Composable
8 | import androidx.compose.ui.Alignment
9 | import androidx.compose.ui.Modifier
10 | import androidx.compose.ui.unit.sp
11 |
12 | @Composable
13 | fun SettingsScreen(modifier: Modifier) {
14 | Column(
15 | modifier = modifier.fillMaxSize(),
16 | verticalArrangement = Arrangement.Center,
17 | horizontalAlignment = Alignment.CenterHorizontally
18 | ) {
19 | Text(
20 | "Settings",
21 | fontSize = 24.sp
22 | )
23 | }
24 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mmarashan/JetComposeNavMultimodule/fba6f0702029ae956ceb6a503755b6c4e6d30d39/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84 |
85 | APP_NAME="Gradle"
86 | APP_BASE_NAME=${0##*/}
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | MAX_FD=$( ulimit -H -n ) ||
147 | warn "Could not query maximum file descriptor limit"
148 | esac
149 | case $MAX_FD in #(
150 | '' | soft) :;; #(
151 | *)
152 | ulimit -n "$MAX_FD" ||
153 | warn "Could not set maximum file descriptor limit to $MAX_FD"
154 | esac
155 | fi
156 |
157 | # Collect all arguments for the java command, stacking in reverse order:
158 | # * args from the command line
159 | # * the main class name
160 | # * -classpath
161 | # * -D...appname settings
162 | # * --module-path (only if needed)
163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164 |
165 | # For Cygwin or MSYS, switch paths to Windows format before running java
166 | if "$cygwin" || "$msys" ; then
167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169 |
170 | JAVACMD=$( cygpath --unix "$JAVACMD" )
171 |
172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
173 | for arg do
174 | if
175 | case $arg in #(
176 | -*) false ;; # don't mess with options #(
177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178 | [ -e "$t" ] ;; #(
179 | *) false ;;
180 | esac
181 | then
182 | arg=$( cygpath --path --ignore --mixed "$arg" )
183 | fi
184 | # Roll the args list around exactly as many times as the number of
185 | # args, so each arg winds up back in the position where it started, but
186 | # possibly modified.
187 | #
188 | # NB: a `for` loop captures its iteration list before it begins, so
189 | # changing the positional parameters here affects neither the number of
190 | # iterations, nor the values presented in `arg`.
191 | shift # remove old arg
192 | set -- "$@" "$arg" # push replacement arg
193 | done
194 | fi
195 |
196 | # Collect all arguments for the java command;
197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198 | # shell script including quotes and variable substitutions, so put them in
199 | # double quotes to make sure that they get re-expanded; and
200 | # * put everything else in single quotes, so that it's not re-expanded.
201 |
202 | set -- \
203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
204 | -classpath "$CLASSPATH" \
205 | org.gradle.wrapper.GradleWrapperMain \
206 | "$@"
207 |
208 | # Use "xargs" to parse quoted args.
209 | #
210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211 | #
212 | # In Bash we could simply go:
213 | #
214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215 | # set -- "${ARGS[@]}" "$@"
216 | #
217 | # but POSIX shell has neither arrays nor command substitution, so instead we
218 | # post-process each arg (as a line of input to sed) to backslash-escape any
219 | # character that might be a shell metacharacter, then use eval to reverse
220 | # that process (while maintaining the separation between arguments), and wrap
221 | # the whole thing up as a single "set" statement.
222 | #
223 | # This will of course break if any of these variables contains a newline or
224 | # an unmatched quote.
225 | #
226 |
227 | eval "set -- $(
228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229 | xargs -n1 |
230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231 | tr '\n' ' '
232 | )" '"$@"'
233 |
234 | exec "$JAVACMD" "$@"
235 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | dependencyResolutionManagement {
2 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
3 | repositories {
4 | google()
5 | mavenCentral()
6 | }
7 | }
8 | rootProject.name = "JetComposeNavMultimodule"
9 | include ':app',
10 | ':core',
11 | ':core:feature-api',
12 | ':core:dependencyprovider',
13 |
14 | ':feature',
15 | ':feature:home-api',
16 | ':feature:home-impl',
17 | ':feature:settings-api',
18 | ':feature:settings-impl',
19 | ':feature:onboarding-api',
20 | ':feature:onboarding-impl'
21 |
--------------------------------------------------------------------------------