Skip to content

Commit dcf79ec

Browse files
authored
Merge pull request #7 from shinhyo/feature/multi-module
Feature/multiModule
2 parents d270b31 + c6b96ee commit dcf79ec

File tree

121 files changed

+1913
-1383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+1913
-1383
lines changed

.github/workflows/Build.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ jobs:
3939
- name: Check lint
4040
run: ./gradlew lintDebug --stacktrace
4141

42-
- name: Build all build type and flavor permutations
43-
run: ./gradlew assemble --stacktrace
42+
# - name: Build all build type and flavor permutations
43+
# run: ./gradlew assemble --stacktrace
4444

4545
# - name: Run local tests
4646
# run: ./gradlew testDebug testProdDebug --stacktrace
4747

48-
- name: Upload build outputs (APKs)
49-
uses: actions/upload-artifact@v3
50-
with:
51-
name: build-outputs
52-
path: app/build/outputs
48+
# - name: Upload build outputs (APKs)
49+
# uses: actions/upload-artifact@v3
50+
# with:
51+
# name: build-outputs
52+
# path: app/build/outputs
5353

5454
- name: Upload build reports
5555
if: always()

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Breaking Bad - Jetpack Compose
22
<a href='https://developer.android.com'><img src='http://img.shields.io/badge/platform-android-green.svg'/></a>
3-
<a href = "https://developer.android.com/jetpack/androidx/versions/all-channel#march_24_2021"> <img src = "https://img.shields.io/badge/Jetpack%20Compose-1.2.1-brightgreen" /> </a>
4-
<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"/></a>
3+
<a href="https://kotlinlang.org/docs/whatsnew1720.html"><img src = "https://shields.io/badge/kotlin-1.7.20-blue" /></a>
4+
<a href="https://developer.android.com/jetpack/androidx/releases/compose#versions"><img src = "https://img.shields.io/badge/jetpack%20compose-1.2.1-brightgreen" /></a>
5+
<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg"/></a>
56
[![ktlint](https://img.shields.io/badge/code%20style-%E2%9D%A4-FF4081.svg)](https://ktlint.github.io/)
67

78
<p >
@@ -20,7 +21,7 @@
2021
- Room - Create, store, and manage persistent data backed by a SQLite database.
2122
- ViewModel - Store and manage UI-related data in a lifecycle conscious.
2223
- App Startup - initialize components at app startup.
23-
- Clean Architecture
24+
- Clean Architecture (nowinandroid)
2425
- MVVM pattern
2526
- Kotlin Coroutines & Flows
2627
- Material Design
@@ -32,7 +33,7 @@
3233
- [Coil-Compose](https://coil-kt.github.io/coil/compose)
3334
- [Timber](https://github.com/JakeWharton/timber)
3435

35-
## Multi Module (Clean Architecture)
36+
## Multi Module ([nowinandroid](https://github.com/android/nowinandroid))
3637
![](project.dot.png)
3738

3839
### If you think this reposittory is useful, please press the star button at the top. ⭐️

app/build.gradle.kts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,15 @@ android {
2626

2727
dependencies {
2828

29-
implementation(project(":presentation"))
30-
implementation(project(":domain"))
31-
implementation(project(":data"))
29+
implementation(project(":core:designsystem"))
3230

33-
implementation(libs.material)
31+
implementation(project(":feature:main"))
32+
implementation(project(":feature:detail"))
3433

34+
implementation(libs.material)
3535
implementation(libs.androidx.startup)
36-
37-
implementation(libs.androidx.core.ktx)
38-
implementation(libs.androidx.appcompat)
3936
implementation(libs.androidx.activity.compose)
37+
implementation(libs.androidx.hilt.navigation.compose)
4038

4139
implementation(libs.timber)
42-
4340
}

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<uses-permission android:name="android.permission.INTERNET" />
66

77
<application
8-
android:name=".app.BrBaApp"
8+
android:name=".app.BrBaApplication"
99
android:allowBackup="true"
1010
android:hardwareAccelerated="true"
1111
android:icon="@mipmap/ic_launcher"
@@ -14,7 +14,7 @@
1414
android:supportsRtl="true"
1515
android:theme="@style/Theme.BrBaCompose">
1616
<activity
17-
android:name=".app.ui.MainActivity"
17+
android:name=".app.MainActivity"
1818
android:exported="true"
1919
android:theme="@style/Theme.BrBaCompose.NoActionBar">
2020
<intent-filter>

app/src/main/java/io/github/shinhyo/brba/app/BrBaApp.kt renamed to app/src/main/java/io/github/shinhyo/brba/app/BrBaApplication.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ import android.app.Application
1919
import dagger.hilt.android.HiltAndroidApp
2020

2121
@HiltAndroidApp
22-
class BrBaApp : Application()
22+
class BrBaApplication : Application()

app/src/main/java/io/github/shinhyo/brba/app/ui/MainActivity.kt renamed to app/src/main/java/io/github/shinhyo/brba/app/MainActivity.kt

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,27 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.github.shinhyo.brba.app.ui
16+
package io.github.shinhyo.brba.app
1717

1818
import android.os.Bundle
1919
import androidx.activity.compose.setContent
2020
import androidx.appcompat.app.AppCompatActivity
21-
import androidx.compose.runtime.Composable
2221
import androidx.core.view.WindowCompat
2322
import dagger.hilt.android.AndroidEntryPoint
24-
import io.github.shinhyo.brba.presentation.theme.BrBaComposeTheme
25-
import io.github.shinhyo.brba.presentation.ui.NavGraph
23+
import io.github.shinhyo.brba.app.ui.BrbaApp
24+
import io.github.shinhyo.brba.core.designsystem.theme.BrBaComposeTheme
2625

2726
@AndroidEntryPoint
2827
class MainActivity : AppCompatActivity() {
2928

3029
override fun onCreate(savedInstanceState: Bundle?) {
3130
super.onCreate(savedInstanceState)
3231
WindowCompat.setDecorFitsSystemWindows(window, false)
32+
3333
setContent {
34-
ComposeApp {
35-
NavGraph()
34+
BrBaComposeTheme {
35+
BrbaApp()
3636
}
3737
}
3838
}
3939
}
40-
41-
@Composable
42-
fun ComposeApp(content: @Composable () -> Unit) {
43-
BrBaComposeTheme {
44-
content()
45-
}
46-
}

app/src/main/java/io/github/shinhyo/brba/app/di/CoroutinesModule.kt

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,25 @@
1616
package io.github.shinhyo.brba.app.di
1717

1818
import dagger.Module
19-
import dagger.Provides
2019
import dagger.hilt.InstallIn
2120
import dagger.hilt.components.SingletonComponent
22-
import io.github.shinhyo.brba.domain.di.DefaultDispatcher
23-
import io.github.shinhyo.brba.domain.di.IoDispatcher
24-
import io.github.shinhyo.brba.domain.di.MainDispatcher
25-
import io.github.shinhyo.brba.domain.di.MainImmediateDispatcher
26-
import kotlinx.coroutines.CoroutineDispatcher
27-
import kotlinx.coroutines.Dispatchers
2821

2922
@InstallIn(SingletonComponent::class)
3023
@Module
3124
internal object CoroutinesModule {
32-
@DefaultDispatcher
33-
@Provides
34-
fun providesDefaultDispatcher(): CoroutineDispatcher = Dispatchers.Default
35-
36-
@IoDispatcher
37-
@Provides
38-
fun providesIoDispatcher(): CoroutineDispatcher = Dispatchers.IO
39-
40-
@MainDispatcher
41-
@Provides
42-
fun providesMainDispatcher(): CoroutineDispatcher = Dispatchers.Main
43-
44-
@MainImmediateDispatcher
45-
@Provides
46-
fun providesMainImmediateDispatcher(): CoroutineDispatcher = Dispatchers.Main.immediate
25+
// @DefaultDispatcher
26+
// @Provides
27+
// fun providesDefaultDispatcher(): CoroutineDispatcher = Dispatchers.Default
28+
//
29+
// @IoDispatcher
30+
// @Provides
31+
// fun providesIoDispatcher(): CoroutineDispatcher = Dispatchers.IO
32+
//
33+
// @MainDispatcher
34+
// @Provides
35+
// fun providesMainDispatcher(): CoroutineDispatcher = Dispatchers.Main
36+
//
37+
// @MainImmediateDispatcher
38+
// @Provides
39+
// fun providesMainImmediateDispatcher(): CoroutineDispatcher = Dispatchers.Main.immediate
4740
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2021 shinhyo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.github.shinhyo.brba.app.navigation
17+
18+
import androidx.compose.runtime.Composable
19+
import androidx.navigation.compose.NavHost
20+
import androidx.navigation.compose.rememberNavController
21+
import io.github.shinhyo.brba.feature.detail.navigaion.detailScreen
22+
import io.github.shinhyo.brba.feature.detail.navigaion.navigateToDetail
23+
import io.github.shinhyo.brba.feature.main.navigation.mainRoute
24+
import io.github.shinhyo.brba.feature.main.navigation.mainScreen
25+
26+
@Composable
27+
fun BrbaNavHost(startDestination: String = mainRoute) {
28+
val navController = rememberNavController()
29+
30+
NavHost(
31+
navController = navController,
32+
startDestination = startDestination
33+
) {
34+
mainScreen { id ->
35+
navController.navigateToDetail(id)
36+
}
37+
detailScreen()
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 shinhyo
2+
* Copyright 2022 shinhyo
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,12 +13,12 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.github.shinhyo.brba.presentation.utils
16+
package io.github.shinhyo.brba.app.ui
1717

18-
import kotlinx.coroutines.flow.Flow
19-
import kotlinx.coroutines.flow.flow
20-
import kotlinx.coroutines.flow.toList
18+
import androidx.compose.runtime.Composable
19+
import io.github.shinhyo.brba.app.navigation.BrbaNavHost
2120

22-
fun <T> Flow<T>.toListSingle(): Flow<List<T>> = flow {
23-
emit(toList(mutableListOf()))
21+
@Composable
22+
fun BrbaApp() {
23+
BrbaNavHost()
2424
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2022 shinhyo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.github.shinhyo.brba.app.ui
17+
18+
import androidx.compose.runtime.Composable
19+
import androidx.compose.runtime.Stable
20+
import androidx.compose.runtime.remember
21+
import androidx.compose.runtime.rememberCoroutineScope
22+
import androidx.navigation.NavHostController
23+
import androidx.navigation.compose.rememberNavController
24+
import kotlinx.coroutines.CoroutineScope
25+
26+
@Composable
27+
fun rememberAppState(
28+
coroutineScope: CoroutineScope = rememberCoroutineScope(),
29+
navController: NavHostController = rememberNavController()
30+
) = remember(navController, coroutineScope) {
31+
BrbaAppState(navController, coroutineScope)
32+
}
33+
34+
@Stable
35+
class BrbaAppState(
36+
val navController: NavHostController,
37+
val coroutineScope: CoroutineScope,
38+
) {
39+
40+
fun onBackClick() {
41+
navController.popBackStack()
42+
}
43+
}

0 commit comments

Comments
 (0)