Skip to content

Commit

Permalink
Merge pull request #10 from shinhyo/refactoring
Browse files Browse the repository at this point in the history
refactoring
  • Loading branch information
shinhyo authored Dec 29, 2023
2 parents 0d33862 + 3185142 commit 756ee2b
Show file tree
Hide file tree
Showing 119 changed files with 1,163 additions and 1,336 deletions.
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# https://pinterest.github.io/ktlint/latest/rules/standard

root = true

[*.{kt, kts}]
ktlint_code_style = ktlint_official
indent_size = 4
indent_style = space
ij_kotlin_allow_trailing_comma = false
ij_kotlin_allow_trailing_comma_on_call_site = false

# enabled, disabled
ktlint_standard = enabled
ktlint_experimental = disabled
ktlint_custom-rule-set = disabled

max_line_length = off
insert_final_newline = false

# ktlint_standard_multiline-expression-wrapping = disabled
# ktlint_standard_import-ordering = disabled
# ktlint_standard_trailing-comma-on-declaration-site = disabled
4 changes: 2 additions & 2 deletions .github/workflows/Build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
java-version: 17

- name: chmod cache key
run: chmod +x ./scripts/checksum.sh
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Breaking Bad - Jetpack Compose
<a href='https://developer.android.com'><img src='http://img.shields.io/badge/platform-android-green.svg'/></a>
<a href="https://kotlinlang.org/docs/whatsnew1720.html"><img src = "https://shields.io/badge/kotlin-1.7.20-blue" /></a>
<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>
<a href="https://kotlinlang.org/docs/whatsnew1920.html"><img src = "https://shields.io/badge/kotlin-1.9.20-blue" /></a>
<a href="https://developer.android.com/jetpack/compose/bom"><img src = "https://img.shields.io/badge/jetpack%20compose-2023.10.01-brightgreen" /></a>
<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg"/></a>
[![ktlint](https://img.shields.io/badge/code%20style-%E2%9D%A4-FF4081.svg)](https://ktlint.github.io/)

Expand All @@ -24,11 +24,10 @@
- Clean Architecture (nowinandroid)
- MVVM pattern
- Kotlin Coroutines & Flows
- Material Design
- Material Design3
- Single Activity
- StaggeredVerticalGrid
- [Gradle Version Catalog](https://docs.gradle.org/7.4/userguide/platforms.html)
- [Accompanist](https://google.github.io/accompanist)
- [Retrofit2](https://github.com/square/retrofit)
- [Coil-Compose](https://coil-kt.github.io/coil/compose)
- [Timber](https://github.com/JakeWharton/timber)
Expand Down
36 changes: 30 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
plugins {
id("brba.android.application")
id("brba.android.application.compose")
id("brba.android.hilt")
}

android {
Expand All @@ -13,28 +11,54 @@ android {
versionName = "1.0"
}

signingConfigs {
getByName("debug") {
storeFile = rootProject.file("debug.keystore")
storePassword = "android"
keyAlias = "androiddebugkey"
keyPassword = "android"
}
}

buildTypes {
getByName("debug") {
isDebuggable = false
}

getByName("release") {
isMinifyEnabled = false
isDebuggable = false
isShrinkResources = true
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("debug")
}
}

buildFeatures {
buildConfig = true
}
}

dependencies {

implementation(project(":core:data"))
implementation(project(":core:designsystem"))

implementation(project(":feature:main"))
implementation(project(":feature:list"))
implementation(project(":feature:favorite"))
implementation(project(":feature:detail"))

implementation(libs.material)
implementation(libs.androidx.startup)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.activity.compose)

implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.hilt.navigation.compose)

implementation(libs.androidx.compose.material3)

implementation(libs.timber)
}
}
6 changes: 5 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

-keep,allowobfuscation,allowshrinking interface retrofit2.Call
-keep,allowobfuscation,allowshrinking class retrofit2.Response
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:enableOnBackInvokedCallback="true"
android:theme="@style/Theme.BrBaCompose">
<activity
android:name=".app.MainActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class BrBaApplication : Application()
class BrBaApplication : Application()
3 changes: 2 additions & 1 deletion app/src/main/java/io/github/shinhyo/brba/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

WindowCompat.setDecorFitsSystemWindows(window, false)

setContent {
Expand All @@ -36,4 +37,4 @@ class MainActivity : AppCompatActivity() {
}
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ class TimberInitializer : Initializer<Unit> {
}

override fun dependencies(): MutableList<Class<out Initializer<*>>> = mutableListOf()
}
}

This file was deleted.

23 changes: 19 additions & 4 deletions app/src/main/java/io/github/shinhyo/brba/app/ui/BrbaApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,25 @@
*/
package io.github.shinhyo.brba.app.ui

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import io.github.shinhyo.brba.app.navigation.BrbaNavHost
import androidx.compose.ui.Modifier
import androidx.navigation.compose.NavHost
import io.github.shinhyo.brba.app.ui.main.navigation.ROUTE_MAIN
import io.github.shinhyo.brba.app.ui.main.navigation.mainScreen
import io.github.shinhyo.brba.feature.detail.navigaion.detailScreen

@Composable
fun BrbaApp() {
BrbaNavHost()
}
fun BrbaApp(
appState: BrbaAppState = rememberAppState()
) {
// root
NavHost(
navController = appState.navController,
startDestination = ROUTE_MAIN,
modifier = Modifier.fillMaxSize()
) {
mainScreen(appState = appState)
detailScreen()
}
}
34 changes: 27 additions & 7 deletions app/src/main/java/io/github/shinhyo/brba/app/ui/BrbaAppState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,45 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.navigation.NavDestination
import androidx.navigation.NavHostController
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import io.github.shinhyo.brba.app.ui.main.Tab
import io.github.shinhyo.brba.feature.favorate.navigation.navigateFavorite
import io.github.shinhyo.brba.feature.main.navigation.navigateList
import kotlinx.coroutines.CoroutineScope

@Composable
fun rememberAppState(
coroutineScope: CoroutineScope = rememberCoroutineScope(),
navController: NavHostController = rememberNavController()
) = remember(navController, coroutineScope) {
BrbaAppState(navController, coroutineScope)
navController: NavHostController = rememberNavController(),
navTabController: NavHostController = rememberNavController()
): BrbaAppState = remember(
navController,
navTabController,
coroutineScope
) {
BrbaAppState(coroutineScope, navController, navTabController)
}

@Stable
class BrbaAppState(
val navController: NavHostController,
val coroutineScope: CoroutineScope,
val navController: NavHostController,
val navTabController: NavHostController
) {

fun onBackClick() {
navController.popBackStack()
val currentDestination: NavDestination?
@Composable get() = navController.currentBackStackEntryAsState().value?.destination

val currentTabDestination: NavDestination?
@Composable get() = navTabController.currentBackStackEntryAsState().value?.destination

fun navigateTopDestination(destination: Tab) {
when (destination) {
Tab.LIST -> navTabController.navigateList()
Tab.FAVORITE -> navTabController.navigateFavorite()
}
}
}
}
Loading

0 comments on commit 756ee2b

Please sign in to comment.