├── .gradle
├── 8.0
│ ├── checksums
│ │ ├── checksums.lock
│ │ ├── md5-checksums.bin
│ │ └── sha1-checksums.bin
│ ├── dependencies-accessors
│ │ ├── dependencies-accessors.lock
│ │ └── gc.properties
│ ├── executionHistory
│ │ ├── executionHistory.bin
│ │ └── executionHistory.lock
│ ├── fileChanges
│ │ └── last-build.bin
│ ├── fileHashes
│ │ ├── fileHashes.bin
│ │ ├── fileHashes.lock
│ │ └── resourceHashesCache.bin
│ └── gc.properties
├── buildOutputCleanup
│ ├── buildOutputCleanup.lock
│ ├── cache.properties
│ └── outputFiles.bin
├── file-system.probe
└── vcs-1
│ └── gc.properties
├── .idea
├── .gitignore
├── .name
├── compiler.xml
├── deploymentTargetDropDown.xml
├── gradle.xml
├── kotlinc.xml
├── misc.xml
├── modules.xml
├── modules
│ ├── app
│ │ └── JetpackComposeDrawerNavigation.app.iml
│ ├── feature_about
│ │ └── JetpackComposeDrawerNavigation.feature_about.iml
│ ├── feature_articles
│ │ ├── JetpackComposeDrawerNavigation.feature_articles.iml
│ │ └── JetpackComposeDrawerNavigation.feature_articles.main.iml
│ └── ui_common
│ │ └── JetpackComposeDrawerNavigation.ui_common.main.iml
├── vcs.xml
└── workspace.xml
├── final
├── .DS_Store
├── .gradle
│ ├── 8.0
│ │ ├── checksums
│ │ │ ├── checksums.lock
│ │ │ └── sha1-checksums.bin
│ │ ├── dependencies-accessors
│ │ │ ├── dependencies-accessors.lock
│ │ │ └── gc.properties
│ │ ├── executionHistory
│ │ │ ├── executionHistory.bin
│ │ │ └── executionHistory.lock
│ │ ├── fileChanges
│ │ │ └── last-build.bin
│ │ ├── fileHashes
│ │ │ ├── fileHashes.bin
│ │ │ ├── fileHashes.lock
│ │ │ └── resourceHashesCache.bin
│ │ └── gc.properties
│ ├── buildOutputCleanup
│ │ ├── buildOutputCleanup.lock
│ │ ├── cache.properties
│ │ └── outputFiles.bin
│ ├── file-system.probe
│ └── vcs-1
│ │ └── gc.properties
├── .idea
│ ├── .gitignore
│ ├── .name
│ ├── compiler.xml
│ ├── gradle.xml
│ ├── inspectionProfiles
│ │ └── Project_Default.xml
│ ├── kotlinc.xml
│ ├── misc.xml
│ ├── modules
│ │ ├── app
│ │ │ └── JetpackComposeDrawerNavigation.app.iml
│ │ └── feature_article
│ │ │ └── JetpackComposeDrawerNavigation.feature_article.iml
│ └── vcs.xml
├── README.md
├── app
│ ├── .DS_Store
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── proguard-rules.pro
│ └── src
│ │ ├── .DS_Store
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── jetpackcompose
│ │ │ └── navigation
│ │ │ └── ExampleInstrumentedTest.kt
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── jetpackcompose
│ │ │ │ └── navigation
│ │ │ │ ├── MainActivity.kt
│ │ │ │ ├── MainApplication.kt
│ │ │ │ └── MainNavigation.kt
│ │ └── res
│ │ │ ├── drawable
│ │ │ ├── ic_launcher_background.xml
│ │ │ └── ic_launcher_foreground.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
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── themes.xml
│ │ │ └── xml
│ │ │ ├── backup_rules.xml
│ │ │ └── data_extraction_rules.xml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── jetpackcompose
│ │ └── navigation
│ │ └── ExampleUnitTest.kt
├── build.gradle.kts
├── feature_about
│ ├── .DS_Store
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── consumer-rules.pro
│ ├── proguard-rules.pro
│ └── src
│ │ ├── .DS_Store
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── jetpackcompose
│ │ │ └── feature
│ │ │ └── about
│ │ │ └── ExampleInstrumentedTest.kt
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── jetpackcompose
│ │ │ └── feature
│ │ │ └── about
│ │ │ ├── AboutScreen.kt
│ │ │ ├── AboutViewModel.kt
│ │ │ └── nav
│ │ │ └── AboutNavigaiton.kt
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── jetpackcompose
│ │ └── feature
│ │ └── about
│ │ └── ExampleUnitTest.kt
├── feature_article
│ ├── .DS_Store
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── consumer-rules.pro
│ ├── proguard-rules.pro
│ └── src
│ │ ├── .DS_Store
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── jetpackcompose
│ │ │ └── feature
│ │ │ └── article
│ │ │ └── ExampleInstrumentedTest.kt
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── jetpackcompose
│ │ │ └── feature
│ │ │ └── article
│ │ │ ├── ArticleScreen.kt
│ │ │ ├── ArticleViewModel.kt
│ │ │ └── nav
│ │ │ └── ArticleNavigation.kt
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── jetpackcompose
│ │ └── feature
│ │ └── article
│ │ └── ExampleUnitTest.kt
├── feature_articles
│ ├── .DS_Store
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── consumer-rules.pro
│ ├── proguard-rules.pro
│ └── src
│ │ ├── .DS_Store
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── jetpackcompose
│ │ │ └── feature
│ │ │ └── articles
│ │ │ └── ExampleInstrumentedTest.kt
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── jetpackcompose
│ │ │ └── feature
│ │ │ └── articles
│ │ │ ├── ArticlesScreen.kt
│ │ │ ├── ArticlesViewModel.kt
│ │ │ └── nav
│ │ │ └── ArticlesNavigation.kt
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── jetpackcompose
│ │ └── feature
│ │ └── articles
│ │ └── ExampleUnitTest.kt
├── feature_home
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── consumer-rules.pro
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── jetpackcompose
│ │ │ └── feature
│ │ │ └── home
│ │ │ └── ExampleInstrumentedTest.kt
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── jetpackcompose
│ │ │ └── feature
│ │ │ └── home
│ │ │ ├── HomeScreen.kt
│ │ │ └── nav
│ │ │ └── HomeNavigation.kt
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── jetpackcompose
│ │ └── feature
│ │ └── home
│ │ └── ExampleUnitTest.kt
├── feature_settings
│ ├── .DS_Store
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── consumer-rules.pro
│ ├── proguard-rules.pro
│ └── src
│ │ ├── .DS_Store
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── jetpackcompose
│ │ │ └── feature
│ │ │ └── settings
│ │ │ └── ExampleInstrumentedTest.kt
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── jetpackcompose
│ │ │ └── feature
│ │ │ └── settings
│ │ │ ├── SettingsScreen.kt
│ │ │ ├── SettingsViewModel.kt
│ │ │ └── nav
│ │ │ └── SettingsNavigation.kt
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── jetpackcompose
│ │ └── feature
│ │ └── settings
│ │ └── ExampleUnitTest.kt
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── local.properties
├── settings.gradle.kts
└── ui_common
│ ├── .DS_Store
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── consumer-rules.pro
│ ├── proguard-rules.pro
│ └── src
│ ├── .DS_Store
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── jetpackcompose
│ │ └── ui
│ │ └── common
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── jetpackcompose
│ │ └── ui
│ │ └── common
│ │ ├── AppBar.kt
│ │ └── theme
│ │ ├── Color.kt
│ │ ├── Theme.kt
│ │ └── Typography.kt
│ └── test
│ └── java
│ └── com
│ └── jetpackcompose
│ └── ui
│ └── common
│ └── ExampleUnitTest.kt
└── starter
├── .DS_Store
├── .gradle
├── 8.0
│ ├── checksums
│ │ └── checksums.lock
│ ├── dependencies-accessors
│ │ ├── dependencies-accessors.lock
│ │ └── gc.properties
│ ├── executionHistory
│ │ ├── executionHistory.bin
│ │ └── executionHistory.lock
│ ├── fileChanges
│ │ └── last-build.bin
│ ├── fileHashes
│ │ ├── fileHashes.bin
│ │ ├── fileHashes.lock
│ │ └── resourceHashesCache.bin
│ └── gc.properties
├── buildOutputCleanup
│ ├── buildOutputCleanup.lock
│ ├── cache.properties
│ └── outputFiles.bin
├── file-system.probe
└── vcs-1
│ └── gc.properties
├── .idea
├── .gitignore
├── .name
├── compiler.xml
├── gradle.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── kotlinc.xml
├── misc.xml
└── vcs.xml
├── README.md
├── app
├── .DS_Store
├── .gitignore
├── build.gradle.kts
├── proguard-rules.pro
└── src
│ ├── .DS_Store
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── jetpackcompose
│ │ └── navigation
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── jetpackcompose
│ │ │ └── navigation
│ │ │ ├── MainActivity.kt
│ │ │ ├── MainApplication.kt
│ │ │ └── MainNavigation.kt
│ └── res
│ │ ├── drawable
│ │ ├── ic_launcher_background.xml
│ │ └── ic_launcher_foreground.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
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ │ └── xml
│ │ ├── backup_rules.xml
│ │ └── data_extraction_rules.xml
│ └── test
│ └── java
│ └── com
│ └── jetpackcompose
│ └── navigation
│ └── ExampleUnitTest.kt
├── build.gradle.kts
├── feature_about
├── .DS_Store
├── .gitignore
├── build.gradle.kts
├── consumer-rules.pro
├── proguard-rules.pro
└── src
│ ├── .DS_Store
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── jetpackcompose
│ │ └── feature
│ │ └── about
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── jetpackcompose
│ │ └── feature
│ │ └── about
│ │ ├── AboutScreen.kt
│ │ └── AboutViewModel.kt
│ └── test
│ └── java
│ └── com
│ └── jetpackcompose
│ └── feature
│ └── about
│ └── ExampleUnitTest.kt
├── feature_article
├── .DS_Store
├── .gitignore
├── build.gradle.kts
├── consumer-rules.pro
├── proguard-rules.pro
└── src
│ ├── .DS_Store
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── jetpackcompose
│ │ └── feature
│ │ └── article
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── jetpackcompose
│ │ └── feature
│ │ └── article
│ │ ├── ArticleScreen.kt
│ │ └── ArticleViewModel.kt
│ └── test
│ └── java
│ └── com
│ └── jetpackcompose
│ └── feature
│ └── article
│ └── ExampleUnitTest.kt
├── feature_articles
├── .DS_Store
├── .gitignore
├── build.gradle.kts
├── consumer-rules.pro
├── proguard-rules.pro
└── src
│ ├── .DS_Store
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── jetpackcompose
│ │ └── feature
│ │ └── articles
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── jetpackcompose
│ │ └── feature
│ │ └── articles
│ │ ├── ArticlesScreen.kt
│ │ └── ArticlesViewModel.kt
│ └── test
│ └── java
│ └── com
│ └── jetpackcompose
│ └── feature
│ └── articles
│ └── ExampleUnitTest.kt
├── feature_settings
├── .DS_Store
├── .gitignore
├── build.gradle.kts
├── consumer-rules.pro
├── proguard-rules.pro
└── src
│ ├── .DS_Store
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── jetpackcompose
│ │ └── feature
│ │ └── settings
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── jetpackcompose
│ │ └── feature
│ │ └── settings
│ │ ├── SettingsScreen.kt
│ │ └── SettingsViewModel.kt
│ └── test
│ └── java
│ └── com
│ └── jetpackcompose
│ └── feature
│ └── settings
│ └── ExampleUnitTest.kt
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── local.properties
├── settings.gradle.kts
└── ui_common
├── .DS_Store
├── .gitignore
├── build.gradle.kts
├── consumer-rules.pro
├── proguard-rules.pro
└── src
├── .DS_Store
├── androidTest
└── java
│ └── com
│ └── jetpackcompose
│ └── ui
│ └── common
│ └── ExampleInstrumentedTest.kt
├── main
├── AndroidManifest.xml
└── java
│ └── com
│ └── jetpackcompose
│ └── ui
│ └── common
│ ├── AppBar.kt
│ └── theme
│ ├── Color.kt
│ ├── Theme.kt
│ └── Typography.kt
└── test
└── java
└── com
└── jetpackcompose
└── ui
└── common
└── ExampleUnitTest.kt
/.gradle/8.0/checksums/checksums.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/.gradle/8.0/checksums/checksums.lock
--------------------------------------------------------------------------------
/.gradle/8.0/checksums/md5-checksums.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/.gradle/8.0/checksums/md5-checksums.bin
--------------------------------------------------------------------------------
/.gradle/8.0/checksums/sha1-checksums.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/.gradle/8.0/checksums/sha1-checksums.bin
--------------------------------------------------------------------------------
/.gradle/8.0/dependencies-accessors/dependencies-accessors.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/.gradle/8.0/dependencies-accessors/dependencies-accessors.lock
--------------------------------------------------------------------------------
/.gradle/8.0/dependencies-accessors/gc.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/.gradle/8.0/dependencies-accessors/gc.properties
--------------------------------------------------------------------------------
/.gradle/8.0/executionHistory/executionHistory.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/.gradle/8.0/executionHistory/executionHistory.bin
--------------------------------------------------------------------------------
/.gradle/8.0/executionHistory/executionHistory.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/.gradle/8.0/executionHistory/executionHistory.lock
--------------------------------------------------------------------------------
/.gradle/8.0/fileChanges/last-build.bin:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gradle/8.0/fileHashes/fileHashes.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/.gradle/8.0/fileHashes/fileHashes.bin
--------------------------------------------------------------------------------
/.gradle/8.0/fileHashes/fileHashes.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/.gradle/8.0/fileHashes/fileHashes.lock
--------------------------------------------------------------------------------
/.gradle/8.0/fileHashes/resourceHashesCache.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/.gradle/8.0/fileHashes/resourceHashesCache.bin
--------------------------------------------------------------------------------
/.gradle/8.0/gc.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/.gradle/8.0/gc.properties
--------------------------------------------------------------------------------
/.gradle/buildOutputCleanup/buildOutputCleanup.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/.gradle/buildOutputCleanup/buildOutputCleanup.lock
--------------------------------------------------------------------------------
/.gradle/buildOutputCleanup/cache.properties:
--------------------------------------------------------------------------------
1 | #Tue Sep 19 12:13:44 CEST 2023
2 | gradle.version=8.0
3 |
--------------------------------------------------------------------------------
/.gradle/buildOutputCleanup/outputFiles.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/.gradle/buildOutputCleanup/outputFiles.bin
--------------------------------------------------------------------------------
/.gradle/file-system.probe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/.gradle/file-system.probe
--------------------------------------------------------------------------------
/.gradle/vcs-1/gc.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/.gradle/vcs-1/gc.properties
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/.idea/.gitignore
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | JetpackComposeDrawerNavigation
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/deploymentTargetDropDown.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
23 |
24 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/modules/app/JetpackComposeDrawerNavigation.app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/modules/feature_about/JetpackComposeDrawerNavigation.feature_about.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/modules/feature_articles/JetpackComposeDrawerNavigation.feature_articles.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/modules/feature_articles/JetpackComposeDrawerNavigation.feature_articles.main.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/modules/ui_common/JetpackComposeDrawerNavigation.ui_common.main.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/final/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/.DS_Store
--------------------------------------------------------------------------------
/final/.gradle/8.0/checksums/checksums.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/.gradle/8.0/checksums/checksums.lock
--------------------------------------------------------------------------------
/final/.gradle/8.0/checksums/sha1-checksums.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/.gradle/8.0/checksums/sha1-checksums.bin
--------------------------------------------------------------------------------
/final/.gradle/8.0/dependencies-accessors/dependencies-accessors.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/.gradle/8.0/dependencies-accessors/dependencies-accessors.lock
--------------------------------------------------------------------------------
/final/.gradle/8.0/dependencies-accessors/gc.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/.gradle/8.0/dependencies-accessors/gc.properties
--------------------------------------------------------------------------------
/final/.gradle/8.0/executionHistory/executionHistory.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/.gradle/8.0/executionHistory/executionHistory.bin
--------------------------------------------------------------------------------
/final/.gradle/8.0/executionHistory/executionHistory.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/.gradle/8.0/executionHistory/executionHistory.lock
--------------------------------------------------------------------------------
/final/.gradle/8.0/fileChanges/last-build.bin:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/final/.gradle/8.0/fileHashes/fileHashes.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/.gradle/8.0/fileHashes/fileHashes.bin
--------------------------------------------------------------------------------
/final/.gradle/8.0/fileHashes/fileHashes.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/.gradle/8.0/fileHashes/fileHashes.lock
--------------------------------------------------------------------------------
/final/.gradle/8.0/fileHashes/resourceHashesCache.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/.gradle/8.0/fileHashes/resourceHashesCache.bin
--------------------------------------------------------------------------------
/final/.gradle/8.0/gc.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/.gradle/8.0/gc.properties
--------------------------------------------------------------------------------
/final/.gradle/buildOutputCleanup/buildOutputCleanup.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/.gradle/buildOutputCleanup/buildOutputCleanup.lock
--------------------------------------------------------------------------------
/final/.gradle/buildOutputCleanup/cache.properties:
--------------------------------------------------------------------------------
1 | #Tue Sep 19 22:46:29 CEST 2023
2 | gradle.version=8.0
3 |
--------------------------------------------------------------------------------
/final/.gradle/buildOutputCleanup/outputFiles.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/.gradle/buildOutputCleanup/outputFiles.bin
--------------------------------------------------------------------------------
/final/.gradle/file-system.probe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/.gradle/file-system.probe
--------------------------------------------------------------------------------
/final/.gradle/vcs-1/gc.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/.gradle/vcs-1/gc.properties
--------------------------------------------------------------------------------
/final/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/final/.idea/.name:
--------------------------------------------------------------------------------
1 | JetpackComposeDrawerNavigation
--------------------------------------------------------------------------------
/final/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/final/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/final/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/final/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/final/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/final/.idea/modules/app/JetpackComposeDrawerNavigation.app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/final/.idea/modules/feature_article/JetpackComposeDrawerNavigation.feature_article.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/final/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/final/README.md:
--------------------------------------------------------------------------------
1 | # ComposeNavigationNBestPractices
--------------------------------------------------------------------------------
/final/app/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/app/.DS_Store
--------------------------------------------------------------------------------
/final/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/final/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.application")
3 | id("org.jetbrains.kotlin.android")
4 | id("com.google.dagger.hilt.android")
5 | kotlin("kapt")
6 | }
7 |
8 | android {
9 | namespace = "com.jetpackcompose.navigation"
10 | compileSdk = 33
11 |
12 | defaultConfig {
13 | applicationId = "com.jetpackcompose.navigation"
14 | minSdk = 24
15 | targetSdk = 33
16 | versionCode = 1
17 | versionName = "1.0"
18 |
19 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
20 | vectorDrawables {
21 | useSupportLibrary = true
22 | }
23 | }
24 |
25 | buildTypes {
26 | release {
27 | isMinifyEnabled = false
28 | proguardFiles(
29 | getDefaultProguardFile("proguard-android-optimize.txt"),
30 | "proguard-rules.pro"
31 | )
32 | }
33 | }
34 | kotlin {
35 | jvmToolchain(17)
36 | }
37 | buildFeatures {
38 | compose = true
39 | }
40 | composeOptions {
41 | kotlinCompilerExtensionVersion = "1.4.3"
42 | }
43 | packaging {
44 | resources {
45 | excludes += "/META-INF/{AL2.0,LGPL2.1}"
46 | }
47 | }
48 | // Allow references to generated code
49 | kapt {
50 | correctErrorTypes = true
51 | }
52 | }
53 |
54 | dependencies {
55 | implementation(project(":ui_common"))
56 | implementation(project(":feature_home"))
57 | implementation(project(":feature_article"))
58 |
59 | implementation("androidx.core:core-ktx:1.9.0")
60 | implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
61 | implementation("androidx.activity:activity-compose:1.7.2")
62 |
63 | // hilt
64 | implementation("com.google.dagger:hilt-android:2.44")
65 | kapt("com.google.dagger:hilt-android-compiler:2.44")
66 |
67 | // jetpack compose bom
68 | implementation(platform("androidx.compose:compose-bom:2023.05.01"))
69 | implementation("androidx.compose.ui:ui")
70 | implementation("androidx.compose.ui:ui-graphics")
71 | implementation("androidx.compose.ui:ui-tooling-preview")
72 | implementation("androidx.compose.material3:material3")
73 |
74 | // jetpack compose navigation
75 | implementation("androidx.navigation:navigation-compose:2.5.3")
76 | // implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
77 |
78 | testImplementation("junit:junit:4.13.2")
79 | androidTestImplementation("androidx.test.ext:junit:1.1.5")
80 | androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
81 | androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
82 | androidTestImplementation("androidx.compose.ui:ui-test-junit4")
83 | debugImplementation("androidx.compose.ui:ui-tooling")
84 | debugImplementation("androidx.compose.ui:ui-test-manifest")
85 | }
--------------------------------------------------------------------------------
/final/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
--------------------------------------------------------------------------------
/final/app/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/app/src/.DS_Store
--------------------------------------------------------------------------------
/final/app/src/androidTest/java/com/jetpackcompose/navigation/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.navigation
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.jetpackcompose.navigation", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/final/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
16 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/final/app/src/main/java/com/jetpackcompose/navigation/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.navigation
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.compose.foundation.layout.fillMaxSize
7 | import androidx.compose.material3.MaterialTheme
8 | import androidx.compose.material3.Surface
9 | import androidx.compose.ui.Modifier
10 | import com.jetpackcompose.ui.common.theme.JetpackComposeDrawerNavigationTheme
11 | import dagger.hilt.android.AndroidEntryPoint
12 |
13 | @AndroidEntryPoint
14 | class MainActivity : ComponentActivity() {
15 | override fun onCreate(savedInstanceState: Bundle?) {
16 | super.onCreate(savedInstanceState)
17 | setContent {
18 | JetpackComposeDrawerNavigationTheme {
19 | // A surface container using the 'background' color from the theme
20 | Surface(
21 | modifier = Modifier.fillMaxSize(),
22 | color = MaterialTheme.colorScheme.background
23 | ) {
24 | MainNavigation()
25 | }
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/final/app/src/main/java/com/jetpackcompose/navigation/MainApplication.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.navigation
2 |
3 | import android.app.Application
4 | import dagger.hilt.android.HiltAndroidApp
5 |
6 | @HiltAndroidApp
7 | class MainApplication : Application()
--------------------------------------------------------------------------------
/final/app/src/main/java/com/jetpackcompose/navigation/MainNavigation.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.navigation
2 |
3 | import androidx.compose.runtime.Composable
4 | import androidx.navigation.NavHostController
5 | import androidx.navigation.compose.NavHost
6 | import androidx.navigation.compose.rememberNavController
7 | import com.jetpackcompose.feature.article.nav.articleScreen
8 | import com.jetpackcompose.feature.article.nav.navigateToArticle
9 | import com.jetpackcompose.feature.home.nav.homeRoute
10 | import com.jetpackcompose.feature.home.nav.homeScreen
11 |
12 | @Composable
13 | fun MainNavigation(
14 | navController: NavHostController = rememberNavController(),
15 | ) {
16 | NavHost(navController = navController, startDestination = homeRoute) {
17 |
18 | homeScreen {
19 | navController.navigateToArticle("fakeArticleId")
20 | }
21 |
22 | articleScreen {
23 | navController.navigateUp()
24 | }
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/final/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 |
--------------------------------------------------------------------------------
/final/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/final/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/final/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/final/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/final/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/final/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/final/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/final/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/final/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/final/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/final/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/final/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/final/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/final/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/final/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | JetpackComposeDrawerNavigation
3 |
--------------------------------------------------------------------------------
/final/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/final/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/final/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/final/app/src/test/java/com/jetpackcompose/navigation/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.navigation
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/final/build.gradle.kts:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | plugins {
3 | id("com.android.application") version "8.1.0" apply false
4 | id("org.jetbrains.kotlin.android") version "1.8.10" apply false
5 | id("com.android.library") version "8.1.0" apply false
6 | id("com.google.dagger.hilt.android") version "2.44" apply false
7 | }
--------------------------------------------------------------------------------
/final/feature_about/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/feature_about/.DS_Store
--------------------------------------------------------------------------------
/final/feature_about/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/final/feature_about/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.library")
3 | id("org.jetbrains.kotlin.android")
4 | id("com.google.dagger.hilt.android")
5 | kotlin("kapt")
6 | }
7 |
8 | android {
9 | namespace = "com.jetpackcompose.feature_about"
10 | compileSdk = 33
11 |
12 | defaultConfig {
13 | minSdk = 24
14 |
15 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
16 | consumerProguardFiles("consumer-rules.pro")
17 | }
18 |
19 | buildTypes {
20 | release {
21 | isMinifyEnabled = false
22 | proguardFiles(
23 | getDefaultProguardFile("proguard-android-optimize.txt"),
24 | "proguard-rules.pro"
25 | )
26 | }
27 | }
28 | kotlin {
29 | jvmToolchain(17)
30 | }
31 | buildFeatures {
32 | compose = true
33 | }
34 | composeOptions {
35 | kotlinCompilerExtensionVersion = "1.4.3"
36 | }
37 | // Allow references to generated code
38 | kapt {
39 | correctErrorTypes = true
40 | }
41 | }
42 |
43 | dependencies {
44 | implementation(project(":ui_common"))
45 |
46 | implementation("androidx.core:core-ktx:1.9.0")
47 |
48 | // hitl
49 | implementation("com.google.dagger:hilt-android:2.44")
50 | kapt("com.google.dagger:hilt-android-compiler:2.44")
51 |
52 | // jetpack compose bom
53 | implementation(platform("androidx.compose:compose-bom:2023.05.01"))
54 | implementation("androidx.compose.ui:ui")
55 | implementation("androidx.compose.ui:ui-graphics")
56 | implementation("androidx.compose.ui:ui-tooling-preview")
57 | implementation("androidx.compose.material3:material3")
58 |
59 | // jetpack compose navigation
60 | implementation("androidx.navigation:navigation-compose:2.5.3")
61 | implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
62 |
63 | testImplementation("junit:junit:4.13.2")
64 | androidTestImplementation("androidx.test.ext:junit:1.1.5")
65 | androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
66 | }
--------------------------------------------------------------------------------
/final/feature_about/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/feature_about/consumer-rules.pro
--------------------------------------------------------------------------------
/final/feature_about/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
--------------------------------------------------------------------------------
/final/feature_about/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/feature_about/src/.DS_Store
--------------------------------------------------------------------------------
/final/feature_about/src/androidTest/java/com/jetpackcompose/feature/about/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.about
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.jetpackcompose.feature_about.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/final/feature_about/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/final/feature_about/src/main/java/com/jetpackcompose/feature/about/AboutScreen.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.about
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.material3.DrawerState
8 | import androidx.compose.material3.Scaffold
9 | import androidx.compose.material3.Text
10 | import androidx.compose.runtime.Composable
11 | import androidx.compose.ui.Alignment
12 | import androidx.compose.ui.Modifier
13 | import com.jetpackcompose.ui.common.CustomAppBar
14 |
15 | @Composable
16 | fun AboutScreen(drawerState: DrawerState, viewModel: AboutViewModel) {
17 | Scaffold(
18 | topBar = { CustomAppBar(drawerState = drawerState, title = "About Us") }
19 | ) { paddingValues ->
20 | Column(
21 | modifier = Modifier.padding(paddingValues).fillMaxSize(),
22 | horizontalAlignment = Alignment.CenterHorizontally,
23 | verticalArrangement = Arrangement.Center
24 | ) {
25 | Text(text = "About Screen")
26 | }
27 | }
28 |
29 | }
--------------------------------------------------------------------------------
/final/feature_about/src/main/java/com/jetpackcompose/feature/about/AboutViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.about
2 |
3 | import androidx.lifecycle.ViewModel
4 | import dagger.hilt.android.lifecycle.HiltViewModel
5 | import javax.inject.Inject
6 |
7 | @HiltViewModel
8 | class AboutViewModel @Inject constructor(
9 |
10 | ): ViewModel()
--------------------------------------------------------------------------------
/final/feature_about/src/main/java/com/jetpackcompose/feature/about/nav/AboutNavigaiton.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.about.nav
2 |
3 | import androidx.compose.material3.DrawerState
4 | import androidx.hilt.navigation.compose.hiltViewModel
5 | import androidx.navigation.NavGraphBuilder
6 | import androidx.navigation.compose.composable
7 | import com.jetpackcompose.feature.about.AboutScreen
8 | import com.jetpackcompose.feature.about.AboutViewModel
9 |
10 | const val aboutRoute = "about"
11 |
12 | fun NavGraphBuilder.aboutScreen(drawerState: DrawerState) {
13 | composable(aboutRoute) {
14 | val viewModel: AboutViewModel = hiltViewModel()
15 | AboutScreen(
16 | drawerState = drawerState,
17 | viewModel = viewModel
18 | )
19 | }
20 | }
--------------------------------------------------------------------------------
/final/feature_about/src/test/java/com/jetpackcompose/feature/about/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.about
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/final/feature_article/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/feature_article/.DS_Store
--------------------------------------------------------------------------------
/final/feature_article/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/final/feature_article/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.library")
3 | id("org.jetbrains.kotlin.android")
4 | id("com.google.dagger.hilt.android")
5 | kotlin("kapt")
6 | }
7 |
8 | android {
9 | namespace = "com.jetpackcompose.feature.article"
10 | compileSdk = 33
11 |
12 | defaultConfig {
13 | minSdk = 24
14 |
15 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
16 | consumerProguardFiles("consumer-rules.pro")
17 | }
18 |
19 | buildTypes {
20 | release {
21 | isMinifyEnabled = false
22 | proguardFiles(
23 | getDefaultProguardFile("proguard-android-optimize.txt"),
24 | "proguard-rules.pro"
25 | )
26 | }
27 | }
28 | kotlin {
29 | jvmToolchain(17)
30 | }
31 | buildFeatures {
32 | compose = true
33 | }
34 | composeOptions {
35 | kotlinCompilerExtensionVersion = "1.4.3"
36 | }
37 | // Allow references to generated code
38 | kapt {
39 | correctErrorTypes = true
40 | }
41 | }
42 |
43 | dependencies {
44 | implementation(project(":ui_common"))
45 |
46 | implementation("androidx.core:core-ktx:1.9.0")
47 |
48 | // hitl
49 | implementation("com.google.dagger:hilt-android:2.44")
50 | kapt("com.google.dagger:hilt-android-compiler:2.44")
51 |
52 | // compose navigation
53 | implementation("androidx.navigation:navigation-compose:2.5.3")
54 | implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
55 |
56 | // jetpack compose bom
57 | implementation(platform("androidx.compose:compose-bom:2023.05.01"))
58 | implementation("androidx.compose.ui:ui")
59 | implementation("androidx.compose.ui:ui-graphics")
60 | implementation("androidx.compose.ui:ui-tooling-preview")
61 | implementation("androidx.compose.material3:material3")
62 |
63 | testImplementation("junit:junit:4.13.2")
64 | androidTestImplementation("androidx.test.ext:junit:1.1.5")
65 | androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
66 | }
--------------------------------------------------------------------------------
/final/feature_article/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/feature_article/consumer-rules.pro
--------------------------------------------------------------------------------
/final/feature_article/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
--------------------------------------------------------------------------------
/final/feature_article/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/feature_article/src/.DS_Store
--------------------------------------------------------------------------------
/final/feature_article/src/androidTest/java/com/jetpackcompose/feature/article/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.article
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.jetpackcompose.feature.article.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/final/feature_article/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/final/feature_article/src/main/java/com/jetpackcompose/feature/article/ArticleScreen.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.article
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.icons.Icons
8 | import androidx.compose.material.icons.filled.ArrowBack
9 | import androidx.compose.material3.CenterAlignedTopAppBar
10 | import androidx.compose.material3.ExperimentalMaterial3Api
11 | import androidx.compose.material3.Icon
12 | import androidx.compose.material3.IconButton
13 | import androidx.compose.material3.Scaffold
14 | import androidx.compose.material3.Text
15 | import androidx.compose.runtime.Composable
16 | import androidx.compose.ui.Alignment
17 | import androidx.compose.ui.Modifier
18 |
19 | @OptIn(ExperimentalMaterial3Api::class)
20 | @Composable
21 | internal fun ArticleScreen(
22 | viewModel: ArticleViewModel,
23 | onNavigateBack: () -> Unit,
24 | ) {
25 | Scaffold(
26 | topBar = {
27 | CenterAlignedTopAppBar(
28 | navigationIcon = {
29 | IconButton(onClick = onNavigateBack) {
30 | Icon(Icons.Filled.ArrowBack, "")
31 | }
32 | },
33 | title = {
34 | Text("Article")
35 | }
36 | )
37 | }
38 | ) { paddingValues ->
39 | Column(
40 | modifier = Modifier.fillMaxSize().padding(paddingValues),
41 | horizontalAlignment = Alignment.CenterHorizontally,
42 | verticalArrangement = Arrangement.Center
43 | ) {
44 | Text(text = " Article Screen")
45 | }
46 | }
47 |
48 | }
--------------------------------------------------------------------------------
/final/feature_article/src/main/java/com/jetpackcompose/feature/article/ArticleViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.article
2 |
3 | import androidx.lifecycle.SavedStateHandle
4 | import androidx.lifecycle.ViewModel
5 | import com.jetpackcompose.feature.article.nav.ArticleArgs
6 | import dagger.hilt.android.lifecycle.HiltViewModel
7 | import javax.inject.Inject
8 |
9 | @HiltViewModel
10 | internal class ArticleViewModel @Inject constructor(
11 | savedStateHandle: SavedStateHandle
12 | ): ViewModel() {
13 | val articleArgs = ArticleArgs(savedStateHandle)
14 | }
--------------------------------------------------------------------------------
/final/feature_article/src/main/java/com/jetpackcompose/feature/article/nav/ArticleNavigation.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.article.nav
2 |
3 | import androidx.hilt.navigation.compose.hiltViewModel
4 | import androidx.lifecycle.SavedStateHandle
5 | import androidx.navigation.NavController
6 | import androidx.navigation.NavGraphBuilder
7 | import androidx.navigation.compose.composable
8 | import com.jetpackcompose.feature.article.ArticleScreen
9 | import com.jetpackcompose.feature.article.ArticleViewModel
10 |
11 | private const val articleIdArg = "articleId"
12 |
13 | fun NavGraphBuilder.articleScreen(onNavigateBack: () -> Unit) {
14 | composable("article/{$articleIdArg}") {
15 | val viewModel: ArticleViewModel = hiltViewModel()
16 | ArticleScreen(
17 | viewModel = viewModel,
18 | onNavigateBack = onNavigateBack
19 | )
20 | }
21 | }
22 |
23 | fun NavController.navigateToArticle(articleId: String) {
24 | this.navigate("article/$articleId")
25 | }
26 |
27 | internal class ArticleArgs(articleId: String) {
28 | constructor(savedStateHandle: SavedStateHandle) :
29 | this(checkNotNull(savedStateHandle[articleIdArg]) as String)
30 | }
--------------------------------------------------------------------------------
/final/feature_article/src/test/java/com/jetpackcompose/feature/article/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.article
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/final/feature_articles/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/feature_articles/.DS_Store
--------------------------------------------------------------------------------
/final/feature_articles/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/final/feature_articles/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.library")
3 | id("org.jetbrains.kotlin.android")
4 | id("com.google.dagger.hilt.android")
5 | kotlin("kapt")
6 | }
7 |
8 | android {
9 | namespace = "com.jetpackcompose.feature.articles"
10 | compileSdk = 33
11 |
12 | defaultConfig {
13 | minSdk = 24
14 |
15 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
16 | consumerProguardFiles("consumer-rules.pro")
17 | }
18 |
19 | buildTypes {
20 | release {
21 | isMinifyEnabled = false
22 | proguardFiles(
23 | getDefaultProguardFile("proguard-android-optimize.txt"),
24 | "proguard-rules.pro"
25 | )
26 | }
27 | }
28 | kotlin {
29 | jvmToolchain(17)
30 | }
31 | buildFeatures {
32 | compose = true
33 | }
34 | composeOptions {
35 | kotlinCompilerExtensionVersion = "1.4.3"
36 | }
37 | // Allow references to generated code
38 | kapt {
39 | correctErrorTypes = true
40 | }
41 | }
42 |
43 | dependencies {
44 | implementation(project(":ui_common"))
45 |
46 | implementation("androidx.core:core-ktx:1.9.0")
47 |
48 | // hitl
49 | implementation("com.google.dagger:hilt-android:2.44")
50 | kapt("com.google.dagger:hilt-android-compiler:2.44")
51 |
52 | // jetpack compose navigation
53 | implementation("androidx.navigation:navigation-compose:2.5.3")
54 | implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
55 |
56 | // jetpack compose bom
57 | implementation(platform("androidx.compose:compose-bom:2023.05.01"))
58 | implementation("androidx.compose.ui:ui")
59 | implementation("androidx.compose.ui:ui-graphics")
60 | implementation("androidx.compose.ui:ui-tooling-preview")
61 | implementation("androidx.compose.material3:material3")
62 |
63 | testImplementation("junit:junit:4.13.2")
64 | androidTestImplementation("androidx.test.ext:junit:1.1.5")
65 | androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
66 | }
--------------------------------------------------------------------------------
/final/feature_articles/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/feature_articles/consumer-rules.pro
--------------------------------------------------------------------------------
/final/feature_articles/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
--------------------------------------------------------------------------------
/final/feature_articles/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/feature_articles/src/.DS_Store
--------------------------------------------------------------------------------
/final/feature_articles/src/androidTest/java/com/jetpackcompose/feature/articles/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.articles
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.jetpackcompose.feature.articles.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/final/feature_articles/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/final/feature_articles/src/main/java/com/jetpackcompose/feature/articles/ArticlesScreen.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.articles
2 |
3 | import androidx.compose.foundation.clickable
4 | import androidx.compose.foundation.layout.Arrangement
5 | import androidx.compose.foundation.layout.Column
6 | import androidx.compose.foundation.layout.Spacer
7 | import androidx.compose.foundation.layout.fillMaxSize
8 | import androidx.compose.foundation.layout.height
9 | import androidx.compose.foundation.layout.padding
10 | import androidx.compose.material3.Button
11 | import androidx.compose.material3.DrawerState
12 | import androidx.compose.material3.Scaffold
13 | import androidx.compose.material3.Text
14 | import androidx.compose.runtime.Composable
15 | import androidx.compose.ui.Alignment
16 | import androidx.compose.ui.Modifier
17 | import androidx.compose.ui.unit.dp
18 | import com.jetpackcompose.ui.common.CustomAppBar
19 |
20 | @Composable
21 | fun ArticlesScreen(
22 | drawerState: DrawerState,
23 | viewModel: ArticlesViewModel,
24 | onNavigateToArticle: () -> Unit,
25 | ) {
26 | Scaffold(
27 | topBar = { CustomAppBar(
28 | drawerState = drawerState,
29 | title = "Articles"
30 | ) }
31 | ) { paddingValues ->
32 | Column(
33 | modifier = Modifier
34 | .fillMaxSize()
35 | .padding(paddingValues),
36 | horizontalAlignment = Alignment.CenterHorizontally,
37 | verticalArrangement = Arrangement.Center
38 | ) {
39 | Text(text = " Articles Screen")
40 | Spacer(modifier = Modifier.height(8.dp))
41 | Button(
42 | onClick = onNavigateToArticle,
43 | ) {
44 | Text(text = "Go To Article")
45 | }
46 |
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/final/feature_articles/src/main/java/com/jetpackcompose/feature/articles/ArticlesViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.articles
2 |
3 | import androidx.lifecycle.ViewModel
4 | import javax.inject.Inject
5 |
6 |
7 | class ArticlesViewModel @Inject constructor(
8 |
9 | ): ViewModel()
--------------------------------------------------------------------------------
/final/feature_articles/src/main/java/com/jetpackcompose/feature/articles/nav/ArticlesNavigation.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.articles.nav
2 |
3 | import androidx.compose.material3.DrawerState
4 | import androidx.hilt.navigation.compose.hiltViewModel
5 | import androidx.navigation.NavGraphBuilder
6 | import androidx.navigation.compose.composable
7 | import com.jetpackcompose.feature.articles.ArticlesScreen
8 | import com.jetpackcompose.feature.articles.ArticlesViewModel
9 |
10 | const val articlesRoute = "articles"
11 |
12 | fun NavGraphBuilder.articlesScreen(
13 | drawerState: DrawerState,
14 | onNavigateToArticle: () -> Unit,
15 | ) {
16 | composable(articlesRoute) {
17 | val viewModel: ArticlesViewModel = hiltViewModel()
18 | ArticlesScreen(
19 | drawerState = drawerState,
20 | viewModel = viewModel,
21 | onNavigateToArticle = onNavigateToArticle
22 | )
23 | }
24 |
25 | }
--------------------------------------------------------------------------------
/final/feature_articles/src/test/java/com/jetpackcompose/feature/articles/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.articles
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/final/feature_home/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/final/feature_home/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.library")
3 | id("org.jetbrains.kotlin.android")
4 | kotlin("kapt")
5 | }
6 |
7 | android {
8 | namespace = "com.jetpackcompose.feature.home"
9 | compileSdk = 33
10 |
11 | defaultConfig {
12 | minSdk = 24
13 |
14 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
15 | consumerProguardFiles("consumer-rules.pro")
16 | }
17 |
18 | buildTypes {
19 | release {
20 | isMinifyEnabled = false
21 | proguardFiles(
22 | getDefaultProguardFile("proguard-android-optimize.txt"),
23 | "proguard-rules.pro"
24 | )
25 | }
26 | }
27 | kotlin {
28 | jvmToolchain(17)
29 | }
30 | buildFeatures {
31 | compose = true
32 | }
33 | composeOptions {
34 | kotlinCompilerExtensionVersion = "1.4.3"
35 | }
36 | // Allow references to generated code
37 | kapt {
38 | correctErrorTypes = true
39 | }
40 | }
41 |
42 | dependencies {
43 | implementation(project(":feature_articles"))
44 | implementation(project(":feature_settings"))
45 | implementation(project(":feature_about"))
46 |
47 | // jetpack compose bom
48 | implementation(platform("androidx.compose:compose-bom:2023.05.01"))
49 | implementation("androidx.compose.ui:ui")
50 | implementation("androidx.compose.ui:ui-graphics")
51 | implementation("androidx.compose.ui:ui-tooling-preview")
52 | implementation("androidx.compose.material3:material3")
53 |
54 | // jetpack compose navigation
55 | implementation("androidx.navigation:navigation-compose:2.5.3")
56 |
57 | implementation("androidx.core:core-ktx:1.9.0")
58 | implementation("androidx.appcompat:appcompat:1.6.1")
59 | implementation("com.google.android.material:material:1.9.0")
60 | testImplementation("junit:junit:4.13.2")
61 | androidTestImplementation("androidx.test.ext:junit:1.1.5")
62 | androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
63 | }
--------------------------------------------------------------------------------
/final/feature_home/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/feature_home/consumer-rules.pro
--------------------------------------------------------------------------------
/final/feature_home/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
--------------------------------------------------------------------------------
/final/feature_home/src/androidTest/java/com/jetpackcompose/feature/home/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.home
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.jetpackcompose.feature.home.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/final/feature_home/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/final/feature_home/src/main/java/com/jetpackcompose/feature/home/HomeScreen.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.home
2 |
3 | import androidx.compose.foundation.Image
4 | import androidx.compose.foundation.layout.Box
5 | import androidx.compose.foundation.layout.Column
6 | import androidx.compose.foundation.layout.Spacer
7 | import androidx.compose.foundation.layout.fillMaxSize
8 | import androidx.compose.foundation.layout.fillMaxWidth
9 | import androidx.compose.foundation.layout.height
10 | import androidx.compose.foundation.layout.size
11 | import androidx.compose.material.icons.Icons
12 | import androidx.compose.material.icons.filled.AccountCircle
13 | import androidx.compose.material.icons.filled.Face
14 | import androidx.compose.material.icons.filled.Info
15 | import androidx.compose.material.icons.filled.Settings
16 | import androidx.compose.material3.DrawerState
17 | import androidx.compose.material3.DrawerValue
18 | import androidx.compose.material3.Icon
19 | import androidx.compose.material3.ModalDrawerSheet
20 | import androidx.compose.material3.ModalNavigationDrawer
21 | import androidx.compose.material3.NavigationDrawerItem
22 | import androidx.compose.material3.Text
23 | import androidx.compose.material3.rememberDrawerState
24 | import androidx.compose.runtime.Composable
25 | import androidx.compose.runtime.rememberCoroutineScope
26 | import androidx.compose.ui.Alignment
27 | import androidx.compose.ui.Modifier
28 | import androidx.compose.ui.graphics.vector.ImageVector
29 | import androidx.compose.ui.layout.ContentScale
30 | import androidx.compose.ui.unit.dp
31 | import androidx.navigation.NavHostController
32 | import androidx.navigation.compose.NavHost
33 | import androidx.navigation.compose.rememberNavController
34 | import com.jetpackcompose.feature.about.nav.aboutRoute
35 | import com.jetpackcompose.feature.about.nav.aboutScreen
36 | import com.jetpackcompose.feature.articles.nav.articlesRoute
37 | import com.jetpackcompose.feature.articles.nav.articlesScreen
38 | import com.jetpackcompose.feature.settings.nav.settingsRoute
39 | import com.jetpackcompose.feature.settings.nav.settingsScreen
40 | import kotlinx.coroutines.CoroutineScope
41 | import kotlinx.coroutines.launch
42 |
43 | private data class DrawerMenu(val icon: ImageVector, val title: String, val route: String)
44 |
45 | private val menus = arrayOf(
46 | DrawerMenu(Icons.Filled.Face, "Articles", articlesRoute),
47 | DrawerMenu(Icons.Filled.Settings, "Settings", settingsRoute),
48 | DrawerMenu(Icons.Filled.Info, "About Us", aboutRoute)
49 | )
50 |
51 | @Composable
52 | private fun DrawerContent(
53 | menus: Array,
54 | onMenuClick: (String) -> Unit
55 | ) {
56 | Column(
57 | modifier = Modifier.fillMaxSize()
58 | ) {
59 | Box(
60 | modifier = Modifier
61 | .fillMaxWidth()
62 | .height(200.dp),
63 | contentAlignment = Alignment.Center
64 | ) {
65 | Image(
66 | modifier = Modifier.size(150.dp),
67 | imageVector = Icons.Filled.AccountCircle,
68 | contentScale = ContentScale.Crop,
69 | contentDescription = null
70 | )
71 | }
72 | Spacer(modifier = Modifier.height(12.dp))
73 | menus.forEach {
74 | NavigationDrawerItem(
75 | label = { Text(text = it.title) },
76 | icon = { Icon(imageVector = it.icon, contentDescription = null) },
77 | selected = false,
78 | onClick = {
79 | onMenuClick(it.route)
80 | }
81 | )
82 | }
83 | }
84 | }
85 |
86 | @Composable
87 | internal fun HomeScreen(
88 | navController: NavHostController = rememberNavController(),
89 | coroutineScope: CoroutineScope = rememberCoroutineScope(),
90 | drawerState: DrawerState = rememberDrawerState(initialValue = DrawerValue.Closed),
91 | onNavigateToArticle: () -> Unit
92 | ) {
93 | ModalNavigationDrawer(
94 | drawerState = drawerState,
95 | drawerContent = {
96 | ModalDrawerSheet {
97 | DrawerContent(menus) { route ->
98 | coroutineScope.launch {
99 | drawerState.close()
100 | }
101 |
102 | navController.navigate(route)
103 | }
104 | }
105 | }
106 | ) {
107 | NavHost(navController = navController, startDestination = articlesRoute) {
108 |
109 | articlesScreen(drawerState, onNavigateToArticle)
110 |
111 | settingsScreen(drawerState)
112 |
113 | aboutScreen(drawerState)
114 |
115 | }
116 | }
117 | }
118 |
119 |
120 |
--------------------------------------------------------------------------------
/final/feature_home/src/main/java/com/jetpackcompose/feature/home/nav/HomeNavigation.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.home.nav
2 |
3 | import androidx.navigation.NavGraphBuilder
4 | import androidx.navigation.compose.composable
5 | import com.jetpackcompose.feature.home.HomeScreen
6 |
7 | const val homeRoute = "home"
8 |
9 | fun NavGraphBuilder.homeScreen(
10 | onNavigateToArticle: () -> Unit
11 | ) {
12 | composable(homeRoute) {
13 | HomeScreen(
14 | onNavigateToArticle = onNavigateToArticle
15 | )
16 | }
17 | }
--------------------------------------------------------------------------------
/final/feature_home/src/test/java/com/jetpackcompose/feature/home/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.home
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/final/feature_settings/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/feature_settings/.DS_Store
--------------------------------------------------------------------------------
/final/feature_settings/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/final/feature_settings/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import kotlin.jvm.internal.Intrinsics.Kotlin
2 |
3 | plugins {
4 | id("com.android.library")
5 | id("org.jetbrains.kotlin.android")
6 | id("com.google.dagger.hilt.android")
7 | kotlin("kapt")
8 | }
9 |
10 | android {
11 | namespace = "com.jetpackcompose.feature.settings"
12 | compileSdk = 33
13 |
14 | defaultConfig {
15 | minSdk = 24
16 |
17 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
18 | consumerProguardFiles("consumer-rules.pro")
19 | }
20 |
21 | buildTypes {
22 | release {
23 | isMinifyEnabled = false
24 | proguardFiles(
25 | getDefaultProguardFile("proguard-android-optimize.txt"),
26 | "proguard-rules.pro"
27 | )
28 | }
29 | }
30 | kotlin {
31 | jvmToolchain(17)
32 | }
33 | buildFeatures {
34 | compose = true
35 | }
36 | composeOptions {
37 | kotlinCompilerExtensionVersion = "1.4.3"
38 | }
39 | // Allow references to generated code
40 | kapt {
41 | correctErrorTypes = true
42 | }
43 | }
44 |
45 | dependencies {
46 | implementation(project(":ui_common"))
47 |
48 | implementation("androidx.core:core-ktx:1.9.0")
49 |
50 | // hitl
51 | implementation("com.google.dagger:hilt-android:2.44")
52 | kapt("com.google.dagger:hilt-android-compiler:2.44")
53 |
54 | // jetpack compose bom
55 | implementation(platform("androidx.compose:compose-bom:2023.05.01"))
56 | implementation("androidx.compose.ui:ui")
57 | implementation("androidx.compose.ui:ui-graphics")
58 | implementation("androidx.compose.ui:ui-tooling-preview")
59 | implementation("androidx.compose.material3:material3")
60 |
61 | // jetpack compose navigation
62 | implementation("androidx.navigation:navigation-compose:2.5.3")
63 | implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
64 |
65 | testImplementation("junit:junit:4.13.2")
66 | androidTestImplementation("androidx.test.ext:junit:1.1.5")
67 | androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
68 | }
--------------------------------------------------------------------------------
/final/feature_settings/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/feature_settings/consumer-rules.pro
--------------------------------------------------------------------------------
/final/feature_settings/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
--------------------------------------------------------------------------------
/final/feature_settings/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/feature_settings/src/.DS_Store
--------------------------------------------------------------------------------
/final/feature_settings/src/androidTest/java/com/jetpackcompose/feature/settings/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.settings
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.jetpackcompose.feature.settings.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/final/feature_settings/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/final/feature_settings/src/main/java/com/jetpackcompose/feature/settings/SettingsScreen.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.settings
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.material3.DrawerState
8 | import androidx.compose.material3.Scaffold
9 | import androidx.compose.material3.Text
10 | import androidx.compose.runtime.Composable
11 | import androidx.compose.ui.Alignment
12 | import androidx.compose.ui.Modifier
13 | import com.jetpackcompose.ui.common.CustomAppBar
14 |
15 | @Composable
16 | fun SettingsScreen(drawerState: DrawerState, viewModel: SettingsViewModel) {
17 | Scaffold(
18 | topBar = { CustomAppBar(drawerState = drawerState, title = "Settings") }
19 | ) { paddingValues ->
20 | Column(
21 | modifier = Modifier.fillMaxSize().padding(paddingValues),
22 | horizontalAlignment = Alignment.CenterHorizontally,
23 | verticalArrangement = Arrangement.Center
24 | ) {
25 | Text(text = " Settings Screen")
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/final/feature_settings/src/main/java/com/jetpackcompose/feature/settings/SettingsViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.settings
2 |
3 | import androidx.lifecycle.ViewModel
4 | import dagger.hilt.android.lifecycle.HiltViewModel
5 | import javax.inject.Inject
6 |
7 | @HiltViewModel
8 | class SettingsViewModel @Inject constructor(
9 |
10 | ): ViewModel()
--------------------------------------------------------------------------------
/final/feature_settings/src/main/java/com/jetpackcompose/feature/settings/nav/SettingsNavigation.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.settings.nav
2 |
3 | import androidx.compose.material3.DrawerState
4 | import androidx.hilt.navigation.compose.hiltViewModel
5 | import androidx.navigation.NavGraphBuilder
6 | import androidx.navigation.compose.composable
7 | import com.jetpackcompose.feature.settings.SettingsScreen
8 | import com.jetpackcompose.feature.settings.SettingsViewModel
9 |
10 | const val settingsRoute = "settings"
11 |
12 | fun NavGraphBuilder.settingsScreen(drawerState: DrawerState) {
13 | composable(settingsRoute) {
14 | val viewModel: SettingsViewModel = hiltViewModel()
15 | SettingsScreen(
16 | drawerState = drawerState,
17 | viewModel = viewModel
18 | )
19 |
20 | }
21 | }
--------------------------------------------------------------------------------
/final/feature_settings/src/test/java/com/jetpackcompose/feature/settings/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.settings
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/final/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 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/final/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/final/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Aug 15 00:03:17 CEST 2023
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/final/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 | # Stop when "xargs" is not available.
209 | if ! command -v xargs >/dev/null 2>&1
210 | then
211 | die "xargs is not available"
212 | fi
213 |
214 | # Use "xargs" to parse quoted args.
215 | #
216 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
217 | #
218 | # In Bash we could simply go:
219 | #
220 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
221 | # set -- "${ARGS[@]}" "$@"
222 | #
223 | # but POSIX shell has neither arrays nor command substitution, so instead we
224 | # post-process each arg (as a line of input to sed) to backslash-escape any
225 | # character that might be a shell metacharacter, then use eval to reverse
226 | # that process (while maintaining the separation between arguments), and wrap
227 | # the whole thing up as a single "set" statement.
228 | #
229 | # This will of course break if any of these variables contains a newline or
230 | # an unmatched quote.
231 | #
232 |
233 | eval "set -- $(
234 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
235 | xargs -n1 |
236 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
237 | tr '\n' ' '
238 | )" '"$@"'
239 |
240 | exec "$JAVACMD" "$@"
241 |
--------------------------------------------------------------------------------
/final/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% equ 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% equ 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 | set EXIT_CODE=%ERRORLEVEL%
84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
86 | exit /b %EXIT_CODE%
87 |
88 | :mainEnd
89 | if "%OS%"=="Windows_NT" endlocal
90 |
91 | :omega
92 |
--------------------------------------------------------------------------------
/final/local.properties:
--------------------------------------------------------------------------------
1 | ## This file must *NOT* be checked into Version Control Systems,
2 | # as it contains information specific to your local configuration.
3 | #
4 | # Location of the SDK. This is only used by Gradle.
5 | # For customization when using a Version Control System, please read the
6 | # header note.
7 | #Tue Sep 19 16:49:47 CEST 2023
8 | sdk.dir=/Users/saqibusman/Library/Android/sdk
9 |
--------------------------------------------------------------------------------
/final/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | gradlePluginPortal()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | }
15 |
16 | rootProject.name = "JetpackComposeDrawerNavigation"
17 | include(":app")
18 | include(":feature_articles")
19 | include(":ui_common")
20 | include(":feature_about")
21 | include(":feature_settings")
22 | include(":feature_article")
23 | include(":feature_home")
24 |
--------------------------------------------------------------------------------
/final/ui_common/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/ui_common/.DS_Store
--------------------------------------------------------------------------------
/final/ui_common/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/final/ui_common/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.library")
3 | id("org.jetbrains.kotlin.android")
4 | }
5 |
6 | android {
7 | namespace = "com.jetpackcompose.ui.common"
8 | compileSdk = 33
9 |
10 | defaultConfig {
11 | minSdk = 24
12 |
13 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
14 | consumerProguardFiles("consumer-rules.pro")
15 | }
16 |
17 | buildTypes {
18 | release {
19 | isMinifyEnabled = false
20 | proguardFiles(
21 | getDefaultProguardFile("proguard-android-optimize.txt"),
22 | "proguard-rules.pro"
23 | )
24 | }
25 | }
26 | kotlin {
27 | jvmToolchain(17)
28 | }
29 | buildFeatures {
30 | compose = true
31 | }
32 | composeOptions {
33 | kotlinCompilerExtensionVersion = "1.4.3"
34 | }
35 | }
36 |
37 | dependencies {
38 | // jetpack compose bom
39 | implementation(platform("androidx.compose:compose-bom:2023.05.01"))
40 | implementation("androidx.compose.ui:ui")
41 | implementation("androidx.compose.ui:ui-graphics")
42 | implementation("androidx.compose.ui:ui-tooling-preview")
43 | implementation("androidx.compose.material3:material3")
44 |
45 | implementation("androidx.core:core-ktx:1.9.0")
46 |
47 | testImplementation("junit:junit:4.13.2")
48 | androidTestImplementation("androidx.test.ext:junit:1.1.5")
49 | androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
50 | }
--------------------------------------------------------------------------------
/final/ui_common/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/ui_common/consumer-rules.pro
--------------------------------------------------------------------------------
/final/ui_common/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
--------------------------------------------------------------------------------
/final/ui_common/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/final/ui_common/src/.DS_Store
--------------------------------------------------------------------------------
/final/ui_common/src/androidTest/java/com/jetpackcompose/ui/common/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.ui.common
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.jetpackcompose.ui.common.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/final/ui_common/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/final/ui_common/src/main/java/com/jetpackcompose/ui/common/AppBar.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.ui.common
2 |
3 | import androidx.compose.material.icons.Icons
4 | import androidx.compose.material.icons.filled.Menu
5 | import androidx.compose.material3.CenterAlignedTopAppBar
6 | import androidx.compose.material3.DrawerState
7 | import androidx.compose.material3.ExperimentalMaterial3Api
8 | import androidx.compose.material3.Icon
9 | import androidx.compose.material3.IconButton
10 | import androidx.compose.material3.Text
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.runtime.rememberCoroutineScope
13 | import androidx.compose.ui.tooling.preview.Preview
14 | import com.jetpackcompose.ui.common.theme.JetpackComposeDrawerNavigationTheme
15 | import kotlinx.coroutines.launch
16 |
17 | @OptIn(ExperimentalMaterial3Api::class)
18 | @Composable
19 | fun CustomAppBar(drawerState: DrawerState? = null, title: String) {
20 | val coroutineScope = rememberCoroutineScope()
21 |
22 | CenterAlignedTopAppBar(
23 | navigationIcon = {
24 | if (drawerState != null) {
25 | IconButton(onClick = {
26 | coroutineScope.launch {
27 | drawerState.open()
28 | }
29 | }) {
30 | Icon(Icons.Filled.Menu, contentDescription = "")
31 | }
32 | }
33 | },
34 | title = { Text(text = title) }
35 | )
36 | }
37 |
38 |
39 | @Preview(widthDp = 300)
40 | @Composable
41 | fun PreviewCustomAppBar() {
42 | JetpackComposeDrawerNavigationTheme {
43 | CustomAppBar(drawerState = null, title = "Title")
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/final/ui_common/src/main/java/com/jetpackcompose/ui/common/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.ui.common.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple80 = Color(0xFFD0BCFF)
6 | val PurpleGrey80 = Color(0xFFCCC2DC)
7 | val Pink80 = Color(0xFFEFB8C8)
8 |
9 | val Purple40 = Color(0xFF6650a4)
10 | val PurpleGrey40 = Color(0xFF625b71)
11 | val Pink40 = Color(0xFF7D5260)
--------------------------------------------------------------------------------
/final/ui_common/src/main/java/com/jetpackcompose/ui/common/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.ui.common.theme
2 |
3 | import android.app.Activity
4 | import android.os.Build
5 | import androidx.compose.foundation.isSystemInDarkTheme
6 | import androidx.compose.material3.MaterialTheme
7 | import androidx.compose.material3.darkColorScheme
8 | import androidx.compose.material3.dynamicDarkColorScheme
9 | import androidx.compose.material3.dynamicLightColorScheme
10 | import androidx.compose.material3.lightColorScheme
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.runtime.SideEffect
13 | import androidx.compose.ui.graphics.toArgb
14 | import androidx.compose.ui.platform.LocalContext
15 | import androidx.compose.ui.platform.LocalView
16 | import androidx.core.view.WindowCompat
17 |
18 | private val DarkColorScheme = darkColorScheme(
19 | primary = Purple80,
20 | secondary = PurpleGrey80,
21 | tertiary = Pink80
22 | )
23 |
24 | private val LightColorScheme = lightColorScheme(
25 | primary = Purple40,
26 | secondary = PurpleGrey40,
27 | tertiary = Pink40
28 |
29 | /* Other default colors to override
30 | background = Color(0xFFFFFBFE),
31 | surface = Color(0xFFFFFBFE),
32 | onPrimary = Color.White,
33 | onSecondary = Color.White,
34 | onTertiary = Color.White,
35 | onBackground = Color(0xFF1C1B1F),
36 | onSurface = Color(0xFF1C1B1F),
37 | */
38 | )
39 |
40 | @Composable
41 | fun JetpackComposeDrawerNavigationTheme(
42 | darkTheme: Boolean = isSystemInDarkTheme(),
43 | // Dynamic color is available on Android 12+
44 | dynamicColor: Boolean = true,
45 | content: @Composable () -> Unit
46 | ) {
47 | val colorScheme = when {
48 | dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
49 | val context = LocalContext.current
50 | if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
51 | }
52 |
53 | darkTheme -> DarkColorScheme
54 | else -> LightColorScheme
55 | }
56 | val view = LocalView.current
57 | if (!view.isInEditMode) {
58 | SideEffect {
59 | val window = (view.context as Activity).window
60 | window.statusBarColor = colorScheme.primary.toArgb()
61 | WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
62 | }
63 | }
64 |
65 | MaterialTheme(
66 | colorScheme = colorScheme,
67 | typography = Typography,
68 | content = content
69 | )
70 | }
--------------------------------------------------------------------------------
/final/ui_common/src/main/java/com/jetpackcompose/ui/common/theme/Typography.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.ui.common.theme
2 |
3 | import androidx.compose.material3.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 | bodyLarge = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp,
15 | lineHeight = 24.sp,
16 | letterSpacing = 0.5.sp
17 | )
18 | /* Other default text styles to override
19 | titleLarge = TextStyle(
20 | fontFamily = FontFamily.Default,
21 | fontWeight = FontWeight.Normal,
22 | fontSize = 22.sp,
23 | lineHeight = 28.sp,
24 | letterSpacing = 0.sp
25 | ),
26 | labelSmall = TextStyle(
27 | fontFamily = FontFamily.Default,
28 | fontWeight = FontWeight.Medium,
29 | fontSize = 11.sp,
30 | lineHeight = 16.sp,
31 | letterSpacing = 0.5.sp
32 | )
33 | */
34 | )
--------------------------------------------------------------------------------
/final/ui_common/src/test/java/com/jetpackcompose/ui/common/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.ui.common
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/starter/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/.DS_Store
--------------------------------------------------------------------------------
/starter/.gradle/8.0/checksums/checksums.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/.gradle/8.0/checksums/checksums.lock
--------------------------------------------------------------------------------
/starter/.gradle/8.0/dependencies-accessors/dependencies-accessors.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/.gradle/8.0/dependencies-accessors/dependencies-accessors.lock
--------------------------------------------------------------------------------
/starter/.gradle/8.0/dependencies-accessors/gc.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/.gradle/8.0/dependencies-accessors/gc.properties
--------------------------------------------------------------------------------
/starter/.gradle/8.0/executionHistory/executionHistory.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/.gradle/8.0/executionHistory/executionHistory.bin
--------------------------------------------------------------------------------
/starter/.gradle/8.0/executionHistory/executionHistory.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/.gradle/8.0/executionHistory/executionHistory.lock
--------------------------------------------------------------------------------
/starter/.gradle/8.0/fileChanges/last-build.bin:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/starter/.gradle/8.0/fileHashes/fileHashes.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/.gradle/8.0/fileHashes/fileHashes.bin
--------------------------------------------------------------------------------
/starter/.gradle/8.0/fileHashes/fileHashes.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/.gradle/8.0/fileHashes/fileHashes.lock
--------------------------------------------------------------------------------
/starter/.gradle/8.0/fileHashes/resourceHashesCache.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/.gradle/8.0/fileHashes/resourceHashesCache.bin
--------------------------------------------------------------------------------
/starter/.gradle/8.0/gc.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/.gradle/8.0/gc.properties
--------------------------------------------------------------------------------
/starter/.gradle/buildOutputCleanup/buildOutputCleanup.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/.gradle/buildOutputCleanup/buildOutputCleanup.lock
--------------------------------------------------------------------------------
/starter/.gradle/buildOutputCleanup/cache.properties:
--------------------------------------------------------------------------------
1 | #Tue Sep 19 21:29:03 CEST 2023
2 | gradle.version=8.0
3 |
--------------------------------------------------------------------------------
/starter/.gradle/buildOutputCleanup/outputFiles.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/.gradle/buildOutputCleanup/outputFiles.bin
--------------------------------------------------------------------------------
/starter/.gradle/file-system.probe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/.gradle/file-system.probe
--------------------------------------------------------------------------------
/starter/.gradle/vcs-1/gc.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/.gradle/vcs-1/gc.properties
--------------------------------------------------------------------------------
/starter/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/starter/.idea/.name:
--------------------------------------------------------------------------------
1 | JetpackComposeDrawerNavigation
--------------------------------------------------------------------------------
/starter/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/starter/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/starter/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/starter/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/starter/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/starter/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/starter/README.md:
--------------------------------------------------------------------------------
1 | # ComposeNavigationNBestPractices
--------------------------------------------------------------------------------
/starter/app/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/app/.DS_Store
--------------------------------------------------------------------------------
/starter/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/starter/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.application")
3 | id("org.jetbrains.kotlin.android")
4 | id("com.google.dagger.hilt.android")
5 | kotlin("kapt")
6 | }
7 |
8 | android {
9 | namespace = "com.jetpackcompose.navigation"
10 | compileSdk = 33
11 |
12 | defaultConfig {
13 | applicationId = "com.jetpackcompose.navigation"
14 | minSdk = 24
15 | targetSdk = 33
16 | versionCode = 1
17 | versionName = "1.0"
18 |
19 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
20 | vectorDrawables {
21 | useSupportLibrary = true
22 | }
23 | }
24 |
25 | buildTypes {
26 | release {
27 | isMinifyEnabled = false
28 | proguardFiles(
29 | getDefaultProguardFile("proguard-android-optimize.txt"),
30 | "proguard-rules.pro"
31 | )
32 | }
33 | }
34 | kotlin {
35 | jvmToolchain(17)
36 | }
37 | buildFeatures {
38 | compose = true
39 | }
40 | composeOptions {
41 | kotlinCompilerExtensionVersion = "1.4.3"
42 | }
43 | packaging {
44 | resources {
45 | excludes += "/META-INF/{AL2.0,LGPL2.1}"
46 | }
47 | }
48 | // Allow references to generated code
49 | kapt {
50 | correctErrorTypes = true
51 | }
52 | }
53 |
54 | dependencies {
55 | implementation(project(":ui_common"))
56 | implementation(project(":feature_articles"))
57 | implementation(project(":feature_settings"))
58 | implementation(project(":feature_about"))
59 | implementation(project(":feature_article"))
60 |
61 | implementation("androidx.core:core-ktx:1.9.0")
62 | implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
63 | implementation("androidx.activity:activity-compose:1.7.2")
64 |
65 | // hitl
66 | implementation("com.google.dagger:hilt-android:2.44")
67 | kapt("com.google.dagger:hilt-android-compiler:2.44")
68 |
69 | // jetpack compose bom
70 | implementation(platform("androidx.compose:compose-bom:2023.05.01"))
71 | implementation("androidx.compose.ui:ui")
72 | implementation("androidx.compose.ui:ui-graphics")
73 | implementation("androidx.compose.ui:ui-tooling-preview")
74 | implementation("androidx.compose.material3:material3")
75 |
76 | // jetpack compose navigation
77 | implementation("androidx.navigation:navigation-compose:2.5.3")
78 | implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
79 |
80 | testImplementation("junit:junit:4.13.2")
81 | androidTestImplementation("androidx.test.ext:junit:1.1.5")
82 | androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
83 | androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
84 | androidTestImplementation("androidx.compose.ui:ui-test-junit4")
85 | debugImplementation("androidx.compose.ui:ui-tooling")
86 | debugImplementation("androidx.compose.ui:ui-test-manifest")
87 | }
--------------------------------------------------------------------------------
/starter/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
--------------------------------------------------------------------------------
/starter/app/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/app/src/.DS_Store
--------------------------------------------------------------------------------
/starter/app/src/androidTest/java/com/jetpackcompose/navigation/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.navigation
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.jetpackcompose.navigation", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/starter/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
16 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/starter/app/src/main/java/com/jetpackcompose/navigation/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.navigation
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.compose.foundation.layout.fillMaxSize
7 | import androidx.compose.material3.MaterialTheme
8 | import androidx.compose.material3.Surface
9 | import androidx.compose.ui.Modifier
10 | import com.jetpackcompose.ui.common.theme.JetpackComposeDrawerNavigationTheme
11 | import dagger.hilt.android.AndroidEntryPoint
12 |
13 | @AndroidEntryPoint
14 | class MainActivity : ComponentActivity() {
15 | override fun onCreate(savedInstanceState: Bundle?) {
16 | super.onCreate(savedInstanceState)
17 | setContent {
18 | JetpackComposeDrawerNavigationTheme {
19 | // A surface container using the 'background' color from the theme
20 | Surface(
21 | modifier = Modifier.fillMaxSize(),
22 | color = MaterialTheme.colorScheme.background
23 | ) {
24 | MainNavigation()
25 | }
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/starter/app/src/main/java/com/jetpackcompose/navigation/MainApplication.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.navigation
2 |
3 | import android.app.Application
4 | import dagger.hilt.android.HiltAndroidApp
5 |
6 | @HiltAndroidApp
7 | class MainApplication : Application()
--------------------------------------------------------------------------------
/starter/app/src/main/java/com/jetpackcompose/navigation/MainNavigation.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.navigation
2 |
3 | import androidx.compose.foundation.Image
4 | import androidx.compose.foundation.layout.Box
5 | import androidx.compose.foundation.layout.Column
6 | import androidx.compose.foundation.layout.Spacer
7 | import androidx.compose.foundation.layout.fillMaxSize
8 | import androidx.compose.foundation.layout.fillMaxWidth
9 | import androidx.compose.foundation.layout.height
10 | import androidx.compose.foundation.layout.size
11 | import androidx.compose.material.icons.Icons
12 | import androidx.compose.material.icons.filled.AccountCircle
13 | import androidx.compose.material.icons.filled.Face
14 | import androidx.compose.material.icons.filled.Info
15 | import androidx.compose.material.icons.filled.Settings
16 | import androidx.compose.material3.DrawerState
17 | import androidx.compose.material3.DrawerValue
18 | import androidx.compose.material3.Icon
19 | import androidx.compose.material3.ModalDrawerSheet
20 | import androidx.compose.material3.ModalNavigationDrawer
21 | import androidx.compose.material3.NavigationDrawerItem
22 | import androidx.compose.material3.Text
23 | import androidx.compose.material3.rememberDrawerState
24 | import androidx.compose.runtime.Composable
25 | import androidx.compose.runtime.rememberCoroutineScope
26 | import androidx.compose.ui.Alignment
27 | import androidx.compose.ui.Modifier
28 | import androidx.compose.ui.graphics.vector.ImageVector
29 | import androidx.compose.ui.layout.ContentScale
30 | import androidx.compose.ui.unit.dp
31 | import androidx.hilt.navigation.compose.hiltViewModel
32 | import androidx.navigation.NavHostController
33 | import androidx.navigation.compose.NavHost
34 | import androidx.navigation.compose.composable
35 | import androidx.navigation.compose.rememberNavController
36 | import com.jetpackcompose.feature.about.AboutScreen
37 | import com.jetpackcompose.feature.about.AboutViewModel
38 | import com.jetpackcompose.feature.article.ArticleScreen
39 | import com.jetpackcompose.feature.article.ArticleViewModel
40 | import com.jetpackcompose.feature.articles.ArticlesScreen
41 | import com.jetpackcompose.feature.articles.ArticlesViewModel
42 | import com.jetpackcompose.feature.settings.SettingsScreen
43 | import com.jetpackcompose.feature.settings.SettingsViewModel
44 | import kotlinx.coroutines.CoroutineScope
45 | import kotlinx.coroutines.launch
46 |
47 | enum class MainRoute(value: String) {
48 | Articles("articles"),
49 | About("about"),
50 | Settings("settings")
51 | }
52 |
53 | private data class DrawerMenu(val icon: ImageVector, val title: String, val route: String)
54 |
55 | private val menus = arrayOf(
56 | DrawerMenu(Icons.Filled.Face, "Articles", MainRoute.Articles.name),
57 | DrawerMenu(Icons.Filled.Settings, "Settings", MainRoute.Settings.name),
58 | DrawerMenu(Icons.Filled.Info, "About Us", MainRoute.About.name)
59 | )
60 |
61 | @Composable
62 | private fun DrawerContent(
63 | menus: Array,
64 | onMenuClick: (String) -> Unit
65 | ) {
66 | Column(
67 | modifier = Modifier.fillMaxSize()
68 | ) {
69 | Box(
70 | modifier = Modifier
71 | .fillMaxWidth()
72 | .height(200.dp),
73 | contentAlignment = Alignment.Center
74 | ) {
75 | Image(
76 | modifier = Modifier.size(150.dp),
77 | imageVector = Icons.Filled.AccountCircle,
78 | contentScale = ContentScale.Crop,
79 | contentDescription = null
80 | )
81 | }
82 | Spacer(modifier = Modifier.height(12.dp))
83 | menus.forEach {
84 | NavigationDrawerItem(
85 | label = { Text(text = it.title) },
86 | icon = { Icon(imageVector = it.icon, contentDescription = null) },
87 | selected = false,
88 | onClick = {
89 | onMenuClick(it.route)
90 | }
91 | )
92 | }
93 | }
94 | }
95 |
96 | @Composable
97 | fun MainNavigation(
98 | navController: NavHostController = rememberNavController(),
99 | coroutineScope: CoroutineScope = rememberCoroutineScope(),
100 | drawerState: DrawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
101 | ) {
102 | ModalNavigationDrawer(
103 | drawerState = drawerState,
104 | drawerContent = {
105 | ModalDrawerSheet {
106 | DrawerContent(menus) { route ->
107 | coroutineScope.launch {
108 | drawerState.close()
109 | }
110 |
111 | navController.navigate(route)
112 | }
113 | }
114 | }
115 | ) {
116 | NavHost(navController = navController, startDestination = MainRoute.Articles.name) {
117 | composable(MainRoute.Articles.name) {
118 | val viewModel: ArticlesViewModel = hiltViewModel()
119 | ArticlesScreen(drawerState, viewModel) {
120 | navController.navigate("article")
121 | }
122 | }
123 | composable(MainRoute.About.name) {
124 | val viewModel: AboutViewModel = hiltViewModel()
125 | AboutScreen(drawerState, viewModel)
126 | }
127 | composable(MainRoute.Settings.name) {
128 | val viewModel: SettingsViewModel = hiltViewModel()
129 | SettingsScreen(drawerState, viewModel)
130 | }
131 | composable("article") {
132 | val viewModel: ArticleViewModel = hiltViewModel()
133 | ArticleScreen(
134 | viewModel = viewModel,
135 | onBackNavigation = {
136 | navController.navigateUp()
137 | }
138 | )
139 | }
140 | }
141 | }
142 | }
--------------------------------------------------------------------------------
/starter/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 |
--------------------------------------------------------------------------------
/starter/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/starter/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/starter/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/starter/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/starter/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/starter/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/starter/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/starter/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/starter/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/starter/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/starter/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/starter/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/starter/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/starter/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/starter/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | JetpackComposeDrawerNavigation
3 |
--------------------------------------------------------------------------------
/starter/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/starter/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/starter/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/starter/app/src/test/java/com/jetpackcompose/navigation/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.navigation
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/starter/build.gradle.kts:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | plugins {
3 | id("com.android.application") version "8.1.0" apply false
4 | id("org.jetbrains.kotlin.android") version "1.8.10" apply false
5 | id("com.android.library") version "8.1.0" apply false
6 | id("com.google.dagger.hilt.android") version "2.44" apply false
7 | }
--------------------------------------------------------------------------------
/starter/feature_about/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/feature_about/.DS_Store
--------------------------------------------------------------------------------
/starter/feature_about/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/starter/feature_about/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.library")
3 | id("org.jetbrains.kotlin.android")
4 | id("com.google.dagger.hilt.android")
5 | kotlin("kapt")
6 | }
7 |
8 | android {
9 | namespace = "com.jetpackcompose.feature_about"
10 | compileSdk = 33
11 |
12 | defaultConfig {
13 | minSdk = 24
14 |
15 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
16 | consumerProguardFiles("consumer-rules.pro")
17 | }
18 |
19 | buildTypes {
20 | release {
21 | isMinifyEnabled = false
22 | proguardFiles(
23 | getDefaultProguardFile("proguard-android-optimize.txt"),
24 | "proguard-rules.pro"
25 | )
26 | }
27 | }
28 | kotlin {
29 | jvmToolchain(17)
30 | }
31 | buildFeatures {
32 | compose = true
33 | }
34 | composeOptions {
35 | kotlinCompilerExtensionVersion = "1.4.3"
36 | }
37 | // Allow references to generated code
38 | kapt {
39 | correctErrorTypes = true
40 | }
41 | }
42 |
43 | dependencies {
44 | implementation(project(":ui_common"))
45 |
46 | implementation("androidx.core:core-ktx:1.9.0")
47 |
48 | // hitl
49 | implementation("com.google.dagger:hilt-android:2.44")
50 | kapt("com.google.dagger:hilt-android-compiler:2.44")
51 |
52 | // jetpack compose bom
53 | implementation(platform("androidx.compose:compose-bom:2023.05.01"))
54 | implementation("androidx.compose.ui:ui")
55 | implementation("androidx.compose.ui:ui-graphics")
56 | implementation("androidx.compose.ui:ui-tooling-preview")
57 | implementation("androidx.compose.material3:material3")
58 |
59 | // jetpack compose navigation
60 | implementation("androidx.navigation:navigation-compose:2.5.3")
61 |
62 | testImplementation("junit:junit:4.13.2")
63 | androidTestImplementation("androidx.test.ext:junit:1.1.5")
64 | androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
65 | }
--------------------------------------------------------------------------------
/starter/feature_about/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/feature_about/consumer-rules.pro
--------------------------------------------------------------------------------
/starter/feature_about/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
--------------------------------------------------------------------------------
/starter/feature_about/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/feature_about/src/.DS_Store
--------------------------------------------------------------------------------
/starter/feature_about/src/androidTest/java/com/jetpackcompose/feature/about/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.about
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.jetpackcompose.feature_about.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/starter/feature_about/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/starter/feature_about/src/main/java/com/jetpackcompose/feature/about/AboutScreen.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.about
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.material3.DrawerState
8 | import androidx.compose.material3.Scaffold
9 | import androidx.compose.material3.Text
10 | import androidx.compose.runtime.Composable
11 | import androidx.compose.ui.Alignment
12 | import androidx.compose.ui.Modifier
13 | import com.jetpackcompose.ui.common.CustomAppBar
14 |
15 | @Composable
16 | fun AboutScreen(drawerState: DrawerState, viewModel: AboutViewModel) {
17 | Scaffold(
18 | topBar = { CustomAppBar(drawerState = drawerState, title = "About Us") }
19 | ) { paddingValues ->
20 | Column(
21 | modifier = Modifier.padding(paddingValues).fillMaxSize(),
22 | horizontalAlignment = Alignment.CenterHorizontally,
23 | verticalArrangement = Arrangement.Center
24 | ) {
25 | Text(text = "About Screen")
26 | }
27 | }
28 |
29 | }
--------------------------------------------------------------------------------
/starter/feature_about/src/main/java/com/jetpackcompose/feature/about/AboutViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.about
2 |
3 | import androidx.lifecycle.ViewModel
4 | import dagger.hilt.android.lifecycle.HiltViewModel
5 | import javax.inject.Inject
6 |
7 | @HiltViewModel
8 | class AboutViewModel @Inject constructor(
9 |
10 | ): ViewModel()
--------------------------------------------------------------------------------
/starter/feature_about/src/test/java/com/jetpackcompose/feature/about/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.about
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/starter/feature_article/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/feature_article/.DS_Store
--------------------------------------------------------------------------------
/starter/feature_article/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/starter/feature_article/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.library")
3 | id("org.jetbrains.kotlin.android")
4 | id("com.google.dagger.hilt.android")
5 | kotlin("kapt")
6 | }
7 |
8 | android {
9 | namespace = "com.jetpackcompose.feature.article"
10 | compileSdk = 33
11 |
12 | defaultConfig {
13 | minSdk = 24
14 |
15 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
16 | consumerProguardFiles("consumer-rules.pro")
17 | }
18 |
19 | buildTypes {
20 | release {
21 | isMinifyEnabled = false
22 | proguardFiles(
23 | getDefaultProguardFile("proguard-android-optimize.txt"),
24 | "proguard-rules.pro"
25 | )
26 | }
27 | }
28 | kotlin {
29 | jvmToolchain(17)
30 | }
31 | buildFeatures {
32 | compose = true
33 | }
34 | composeOptions {
35 | kotlinCompilerExtensionVersion = "1.4.3"
36 | }
37 | // Allow references to generated code
38 | kapt {
39 | correctErrorTypes = true
40 | }
41 | }
42 |
43 | dependencies {
44 | implementation(project(":ui_common"))
45 |
46 | implementation("androidx.core:core-ktx:1.9.0")
47 |
48 | // hitl
49 | implementation("com.google.dagger:hilt-android:2.44")
50 | kapt("com.google.dagger:hilt-android-compiler:2.44")
51 |
52 | // jetpack compose bom
53 | implementation(platform("androidx.compose:compose-bom:2023.05.01"))
54 | implementation("androidx.compose.ui:ui")
55 | implementation("androidx.compose.ui:ui-graphics")
56 | implementation("androidx.compose.ui:ui-tooling-preview")
57 | implementation("androidx.compose.material3:material3")
58 |
59 | // jetpack compose navigation
60 | implementation("androidx.navigation:navigation-compose:2.5.3")
61 |
62 | testImplementation("junit:junit:4.13.2")
63 | androidTestImplementation("androidx.test.ext:junit:1.1.5")
64 | androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
65 | }
--------------------------------------------------------------------------------
/starter/feature_article/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/feature_article/consumer-rules.pro
--------------------------------------------------------------------------------
/starter/feature_article/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
--------------------------------------------------------------------------------
/starter/feature_article/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/feature_article/src/.DS_Store
--------------------------------------------------------------------------------
/starter/feature_article/src/androidTest/java/com/jetpackcompose/feature/article/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.article
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.jetpackcompose.feature.article.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/starter/feature_article/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/starter/feature_article/src/main/java/com/jetpackcompose/feature/article/ArticleScreen.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.article
2 |
3 | import android.net.ipsec.ike.IkeSessionParams.IkeAuthDigitalSignRemoteConfig
4 | import androidx.compose.foundation.layout.Arrangement
5 | import androidx.compose.foundation.layout.Column
6 | import androidx.compose.foundation.layout.fillMaxSize
7 | import androidx.compose.foundation.layout.padding
8 | import androidx.compose.material.icons.Icons
9 | import androidx.compose.material.icons.filled.ArrowBack
10 | import androidx.compose.material3.CenterAlignedTopAppBar
11 | import androidx.compose.material3.ExperimentalMaterial3Api
12 | import androidx.compose.material3.Icon
13 | import androidx.compose.material3.IconButton
14 | import androidx.compose.material3.Scaffold
15 | import androidx.compose.material3.Text
16 | import androidx.compose.runtime.Composable
17 | import androidx.compose.ui.Alignment
18 | import androidx.compose.ui.Modifier
19 | import com.jetpackcompose.ui.common.CustomAppBar
20 |
21 | @OptIn(ExperimentalMaterial3Api::class)
22 | @Composable
23 | fun ArticleScreen(
24 | viewModel: ArticleViewModel,
25 | onBackNavigation: () -> Unit,
26 | ) {
27 | Scaffold(
28 | topBar = {
29 | CenterAlignedTopAppBar(
30 | navigationIcon = {
31 | IconButton(onClick = onBackNavigation) {
32 | Icon(Icons.Filled.ArrowBack, "")
33 | }
34 | },
35 | title = {
36 | Text("Article")
37 | }
38 | )
39 | }
40 | ) { paddingValues ->
41 | Column(
42 | modifier = Modifier.fillMaxSize().padding(paddingValues),
43 | horizontalAlignment = Alignment.CenterHorizontally,
44 | verticalArrangement = Arrangement.Center
45 | ) {
46 | Text(text = " Article Screen")
47 | }
48 | }
49 |
50 | }
--------------------------------------------------------------------------------
/starter/feature_article/src/main/java/com/jetpackcompose/feature/article/ArticleViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.article
2 |
3 | import androidx.lifecycle.ViewModel
4 | import dagger.hilt.android.lifecycle.HiltViewModel
5 | import javax.inject.Inject
6 |
7 | @HiltViewModel
8 | class ArticleViewModel @Inject constructor(): ViewModel()
--------------------------------------------------------------------------------
/starter/feature_article/src/test/java/com/jetpackcompose/feature/article/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.article
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/starter/feature_articles/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/feature_articles/.DS_Store
--------------------------------------------------------------------------------
/starter/feature_articles/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/starter/feature_articles/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.library")
3 | id("org.jetbrains.kotlin.android")
4 | id("com.google.dagger.hilt.android")
5 | kotlin("kapt")
6 | }
7 |
8 | android {
9 | namespace = "com.jetpackcompose.feature.articles"
10 | compileSdk = 33
11 |
12 | defaultConfig {
13 | minSdk = 24
14 |
15 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
16 | consumerProguardFiles("consumer-rules.pro")
17 | }
18 |
19 | buildTypes {
20 | release {
21 | isMinifyEnabled = false
22 | proguardFiles(
23 | getDefaultProguardFile("proguard-android-optimize.txt"),
24 | "proguard-rules.pro"
25 | )
26 | }
27 | }
28 | kotlin {
29 | jvmToolchain(17)
30 | }
31 | buildFeatures {
32 | compose = true
33 | }
34 | composeOptions {
35 | kotlinCompilerExtensionVersion = "1.4.3"
36 | }
37 | // Allow references to generated code
38 | kapt {
39 | correctErrorTypes = true
40 | }
41 | }
42 |
43 | dependencies {
44 | implementation(project(":ui_common"))
45 |
46 | implementation("androidx.core:core-ktx:1.9.0")
47 |
48 | // hitl
49 | implementation("com.google.dagger:hilt-android:2.44")
50 | kapt("com.google.dagger:hilt-android-compiler:2.44")
51 |
52 | // jetpack compose bom
53 | implementation(platform("androidx.compose:compose-bom:2023.05.01"))
54 | implementation("androidx.compose.ui:ui")
55 | implementation("androidx.compose.ui:ui-graphics")
56 | implementation("androidx.compose.ui:ui-tooling-preview")
57 | implementation("androidx.compose.material3:material3")
58 |
59 | // jetpack compose navigation
60 | implementation("androidx.navigation:navigation-compose:2.5.3")
61 |
62 | testImplementation("junit:junit:4.13.2")
63 | androidTestImplementation("androidx.test.ext:junit:1.1.5")
64 | androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
65 | }
--------------------------------------------------------------------------------
/starter/feature_articles/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/feature_articles/consumer-rules.pro
--------------------------------------------------------------------------------
/starter/feature_articles/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
--------------------------------------------------------------------------------
/starter/feature_articles/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/feature_articles/src/.DS_Store
--------------------------------------------------------------------------------
/starter/feature_articles/src/androidTest/java/com/jetpackcompose/feature/articles/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.articles
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.jetpackcompose.feature.articles.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/starter/feature_articles/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/starter/feature_articles/src/main/java/com/jetpackcompose/feature/articles/ArticlesScreen.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.articles
2 |
3 | import androidx.compose.foundation.layout.Arrangement
4 | import androidx.compose.foundation.layout.Column
5 | import androidx.compose.foundation.layout.Spacer
6 | import androidx.compose.foundation.layout.fillMaxSize
7 | import androidx.compose.foundation.layout.height
8 | import androidx.compose.foundation.layout.padding
9 | import androidx.compose.material3.Button
10 | import androidx.compose.material3.DrawerState
11 | import androidx.compose.material3.Scaffold
12 | import androidx.compose.material3.Text
13 | import androidx.compose.runtime.Composable
14 | import androidx.compose.ui.Alignment
15 | import androidx.compose.ui.Modifier
16 | import androidx.compose.ui.unit.dp
17 | import com.jetpackcompose.ui.common.CustomAppBar
18 |
19 | @Composable
20 | fun ArticlesScreen(
21 | drawerState: DrawerState,
22 | viewModel: ArticlesViewModel,
23 | onNavigateToArticle: () -> Unit,
24 | ) {
25 | Scaffold(
26 | topBar = { CustomAppBar(
27 | drawerState = drawerState,
28 | title = "Articles"
29 | ) }
30 | ) { paddingValues ->
31 | Column(
32 | modifier = Modifier
33 | .fillMaxSize()
34 | .padding(paddingValues),
35 | horizontalAlignment = Alignment.CenterHorizontally,
36 | verticalArrangement = Arrangement.Center
37 | ) {
38 | Text(text = " Articles Screen")
39 | Spacer(modifier = Modifier.height(8.dp))
40 | Button(onClick = onNavigateToArticle) {
41 | Text(text = "Go To Article")
42 | }
43 |
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/starter/feature_articles/src/main/java/com/jetpackcompose/feature/articles/ArticlesViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.articles
2 |
3 | import androidx.lifecycle.ViewModel
4 | import javax.inject.Inject
5 |
6 |
7 | class ArticlesViewModel @Inject constructor(
8 |
9 | ): ViewModel()
--------------------------------------------------------------------------------
/starter/feature_articles/src/test/java/com/jetpackcompose/feature/articles/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.articles
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/starter/feature_settings/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/feature_settings/.DS_Store
--------------------------------------------------------------------------------
/starter/feature_settings/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/starter/feature_settings/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import kotlin.jvm.internal.Intrinsics.Kotlin
2 |
3 | plugins {
4 | id("com.android.library")
5 | id("org.jetbrains.kotlin.android")
6 | id("com.google.dagger.hilt.android")
7 | kotlin("kapt")
8 | }
9 |
10 | android {
11 | namespace = "com.jetpackcompose.feature.settings"
12 | compileSdk = 33
13 |
14 | defaultConfig {
15 | minSdk = 24
16 |
17 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
18 | consumerProguardFiles("consumer-rules.pro")
19 | }
20 |
21 | buildTypes {
22 | release {
23 | isMinifyEnabled = false
24 | proguardFiles(
25 | getDefaultProguardFile("proguard-android-optimize.txt"),
26 | "proguard-rules.pro"
27 | )
28 | }
29 | }
30 | kotlin {
31 | jvmToolchain(17)
32 | }
33 | buildFeatures {
34 | compose = true
35 | }
36 | composeOptions {
37 | kotlinCompilerExtensionVersion = "1.4.3"
38 | }
39 | // Allow references to generated code
40 | kapt {
41 | correctErrorTypes = true
42 | }
43 | }
44 |
45 | dependencies {
46 | implementation(project(":ui_common"))
47 |
48 | implementation("androidx.core:core-ktx:1.9.0")
49 |
50 | // hitl
51 | implementation("com.google.dagger:hilt-android:2.44")
52 | kapt("com.google.dagger:hilt-android-compiler:2.44")
53 |
54 | // jetpack compose bom
55 | implementation(platform("androidx.compose:compose-bom:2023.05.01"))
56 | implementation("androidx.compose.ui:ui")
57 | implementation("androidx.compose.ui:ui-graphics")
58 | implementation("androidx.compose.ui:ui-tooling-preview")
59 | implementation("androidx.compose.material3:material3")
60 |
61 | // jetpack compose navigation
62 | implementation("androidx.navigation:navigation-compose:2.5.3")
63 |
64 | testImplementation("junit:junit:4.13.2")
65 | androidTestImplementation("androidx.test.ext:junit:1.1.5")
66 | androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
67 | }
--------------------------------------------------------------------------------
/starter/feature_settings/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/feature_settings/consumer-rules.pro
--------------------------------------------------------------------------------
/starter/feature_settings/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
--------------------------------------------------------------------------------
/starter/feature_settings/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/feature_settings/src/.DS_Store
--------------------------------------------------------------------------------
/starter/feature_settings/src/androidTest/java/com/jetpackcompose/feature/settings/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.settings
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.jetpackcompose.feature.settings.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/starter/feature_settings/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/starter/feature_settings/src/main/java/com/jetpackcompose/feature/settings/SettingsScreen.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.settings
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.material3.DrawerState
8 | import androidx.compose.material3.Scaffold
9 | import androidx.compose.material3.Text
10 | import androidx.compose.runtime.Composable
11 | import androidx.compose.ui.Alignment
12 | import androidx.compose.ui.Modifier
13 | import com.jetpackcompose.ui.common.CustomAppBar
14 |
15 | @Composable
16 | fun SettingsScreen(drawerState: DrawerState, viewModel: SettingsViewModel) {
17 | Scaffold(
18 | topBar = { CustomAppBar(drawerState = drawerState, title = "Settings") }
19 | ) { paddingValues ->
20 | Column(
21 | modifier = Modifier.fillMaxSize().padding(paddingValues),
22 | horizontalAlignment = Alignment.CenterHorizontally,
23 | verticalArrangement = Arrangement.Center
24 | ) {
25 | Text(text = " Settings Screen")
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/starter/feature_settings/src/main/java/com/jetpackcompose/feature/settings/SettingsViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.settings
2 |
3 | import androidx.lifecycle.ViewModel
4 | import dagger.hilt.android.lifecycle.HiltViewModel
5 | import javax.inject.Inject
6 |
7 | @HiltViewModel
8 | class SettingsViewModel @Inject constructor(
9 |
10 | ): ViewModel()
--------------------------------------------------------------------------------
/starter/feature_settings/src/test/java/com/jetpackcompose/feature/settings/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.feature.settings
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/starter/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 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/starter/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/starter/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Aug 15 00:03:17 CEST 2023
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/starter/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% equ 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% equ 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 | set EXIT_CODE=%ERRORLEVEL%
84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
86 | exit /b %EXIT_CODE%
87 |
88 | :mainEnd
89 | if "%OS%"=="Windows_NT" endlocal
90 |
91 | :omega
92 |
--------------------------------------------------------------------------------
/starter/local.properties:
--------------------------------------------------------------------------------
1 | ## This file must *NOT* be checked into Version Control Systems,
2 | # as it contains information specific to your local configuration.
3 | #
4 | # Location of the SDK. This is only used by Gradle.
5 | # For customization when using a Version Control System, please read the
6 | # header note.
7 | #Tue Sep 19 16:49:47 CEST 2023
8 | sdk.dir=/Users/saqibusman/Library/Android/sdk
9 |
--------------------------------------------------------------------------------
/starter/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | gradlePluginPortal()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | }
15 |
16 | rootProject.name = "JetpackComposeDrawerNavigation"
17 | include(":app")
18 | include(":feature_articles")
19 | include(":ui_common")
20 | include(":feature_about")
21 | include(":feature_settings")
22 | include(":feature_article")
23 |
--------------------------------------------------------------------------------
/starter/ui_common/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/ui_common/.DS_Store
--------------------------------------------------------------------------------
/starter/ui_common/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/starter/ui_common/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.library")
3 | id("org.jetbrains.kotlin.android")
4 | }
5 |
6 | android {
7 | namespace = "com.jetpackcompose.ui.common"
8 | compileSdk = 33
9 |
10 | defaultConfig {
11 | minSdk = 24
12 |
13 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
14 | consumerProguardFiles("consumer-rules.pro")
15 | }
16 |
17 | buildTypes {
18 | release {
19 | isMinifyEnabled = false
20 | proguardFiles(
21 | getDefaultProguardFile("proguard-android-optimize.txt"),
22 | "proguard-rules.pro"
23 | )
24 | }
25 | }
26 | kotlin {
27 | jvmToolchain(17)
28 | }
29 | buildFeatures {
30 | compose = true
31 | }
32 | composeOptions {
33 | kotlinCompilerExtensionVersion = "1.4.3"
34 | }
35 | }
36 |
37 | dependencies {
38 | // jetpack compose bom
39 | implementation(platform("androidx.compose:compose-bom:2023.05.01"))
40 | implementation("androidx.compose.ui:ui")
41 | implementation("androidx.compose.ui:ui-graphics")
42 | implementation("androidx.compose.ui:ui-tooling-preview")
43 | implementation("androidx.compose.material3:material3")
44 |
45 | implementation("androidx.core:core-ktx:1.9.0")
46 |
47 | testImplementation("junit:junit:4.13.2")
48 | androidTestImplementation("androidx.test.ext:junit:1.1.5")
49 | androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
50 | }
--------------------------------------------------------------------------------
/starter/ui_common/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/ui_common/consumer-rules.pro
--------------------------------------------------------------------------------
/starter/ui_common/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
--------------------------------------------------------------------------------
/starter/ui_common/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saqib-github-commits/ComposeNavigationBestPractices/0193904b4ec8d2018fa6d81b6f9a98186b721d2d/starter/ui_common/src/.DS_Store
--------------------------------------------------------------------------------
/starter/ui_common/src/androidTest/java/com/jetpackcompose/ui/common/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.ui.common
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.jetpackcompose.ui.common.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/starter/ui_common/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/starter/ui_common/src/main/java/com/jetpackcompose/ui/common/AppBar.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.ui.common
2 |
3 | import androidx.compose.material.icons.Icons
4 | import androidx.compose.material.icons.filled.Menu
5 | import androidx.compose.material3.CenterAlignedTopAppBar
6 | import androidx.compose.material3.DrawerState
7 | import androidx.compose.material3.ExperimentalMaterial3Api
8 | import androidx.compose.material3.Icon
9 | import androidx.compose.material3.IconButton
10 | import androidx.compose.material3.Text
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.runtime.rememberCoroutineScope
13 | import androidx.compose.ui.tooling.preview.Preview
14 | import com.jetpackcompose.ui.common.theme.JetpackComposeDrawerNavigationTheme
15 | import kotlinx.coroutines.launch
16 |
17 | @OptIn(ExperimentalMaterial3Api::class)
18 | @Composable
19 | fun CustomAppBar(drawerState: DrawerState? = null, title: String) {
20 | val coroutineScope = rememberCoroutineScope()
21 |
22 | CenterAlignedTopAppBar(
23 | navigationIcon = {
24 | if (drawerState != null) {
25 | IconButton(onClick = {
26 | coroutineScope.launch {
27 | drawerState.open()
28 | }
29 | }) {
30 | Icon(Icons.Filled.Menu, contentDescription = "")
31 | }
32 | }
33 | },
34 | title = { Text(text = title) }
35 | )
36 | }
37 |
38 |
39 | @Preview(widthDp = 300)
40 | @Composable
41 | fun PreviewCustomAppBar() {
42 | JetpackComposeDrawerNavigationTheme {
43 | CustomAppBar(drawerState = null, title = "Title")
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/starter/ui_common/src/main/java/com/jetpackcompose/ui/common/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.ui.common.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple80 = Color(0xFFD0BCFF)
6 | val PurpleGrey80 = Color(0xFFCCC2DC)
7 | val Pink80 = Color(0xFFEFB8C8)
8 |
9 | val Purple40 = Color(0xFF6650a4)
10 | val PurpleGrey40 = Color(0xFF625b71)
11 | val Pink40 = Color(0xFF7D5260)
--------------------------------------------------------------------------------
/starter/ui_common/src/main/java/com/jetpackcompose/ui/common/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.ui.common.theme
2 |
3 | import android.app.Activity
4 | import android.os.Build
5 | import androidx.compose.foundation.isSystemInDarkTheme
6 | import androidx.compose.material3.MaterialTheme
7 | import androidx.compose.material3.darkColorScheme
8 | import androidx.compose.material3.dynamicDarkColorScheme
9 | import androidx.compose.material3.dynamicLightColorScheme
10 | import androidx.compose.material3.lightColorScheme
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.runtime.SideEffect
13 | import androidx.compose.ui.graphics.toArgb
14 | import androidx.compose.ui.platform.LocalContext
15 | import androidx.compose.ui.platform.LocalView
16 | import androidx.core.view.WindowCompat
17 |
18 | private val DarkColorScheme = darkColorScheme(
19 | primary = Purple80,
20 | secondary = PurpleGrey80,
21 | tertiary = Pink80
22 | )
23 |
24 | private val LightColorScheme = lightColorScheme(
25 | primary = Purple40,
26 | secondary = PurpleGrey40,
27 | tertiary = Pink40
28 |
29 | /* Other default colors to override
30 | background = Color(0xFFFFFBFE),
31 | surface = Color(0xFFFFFBFE),
32 | onPrimary = Color.White,
33 | onSecondary = Color.White,
34 | onTertiary = Color.White,
35 | onBackground = Color(0xFF1C1B1F),
36 | onSurface = Color(0xFF1C1B1F),
37 | */
38 | )
39 |
40 | @Composable
41 | fun JetpackComposeDrawerNavigationTheme(
42 | darkTheme: Boolean = isSystemInDarkTheme(),
43 | // Dynamic color is available on Android 12+
44 | dynamicColor: Boolean = true,
45 | content: @Composable () -> Unit
46 | ) {
47 | val colorScheme = when {
48 | dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
49 | val context = LocalContext.current
50 | if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
51 | }
52 |
53 | darkTheme -> DarkColorScheme
54 | else -> LightColorScheme
55 | }
56 | val view = LocalView.current
57 | if (!view.isInEditMode) {
58 | SideEffect {
59 | val window = (view.context as Activity).window
60 | window.statusBarColor = colorScheme.primary.toArgb()
61 | WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
62 | }
63 | }
64 |
65 | MaterialTheme(
66 | colorScheme = colorScheme,
67 | typography = Typography,
68 | content = content
69 | )
70 | }
--------------------------------------------------------------------------------
/starter/ui_common/src/main/java/com/jetpackcompose/ui/common/theme/Typography.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.ui.common.theme
2 |
3 | import androidx.compose.material3.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 | bodyLarge = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp,
15 | lineHeight = 24.sp,
16 | letterSpacing = 0.5.sp
17 | )
18 | /* Other default text styles to override
19 | titleLarge = TextStyle(
20 | fontFamily = FontFamily.Default,
21 | fontWeight = FontWeight.Normal,
22 | fontSize = 22.sp,
23 | lineHeight = 28.sp,
24 | letterSpacing = 0.sp
25 | ),
26 | labelSmall = TextStyle(
27 | fontFamily = FontFamily.Default,
28 | fontWeight = FontWeight.Medium,
29 | fontSize = 11.sp,
30 | lineHeight = 16.sp,
31 | letterSpacing = 0.5.sp
32 | )
33 | */
34 | )
--------------------------------------------------------------------------------
/starter/ui_common/src/test/java/com/jetpackcompose/ui/common/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.jetpackcompose.ui.common
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------