Skip to content

Commit

Permalink
refactoring result states
Browse files Browse the repository at this point in the history
  • Loading branch information
softartdev committed Nov 3, 2024
1 parent 3629660 commit 45eadf2
Show file tree
Hide file tree
Showing 59 changed files with 1,564 additions and 1,023 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,10 @@ Check out [CONTRIBUTING.md](/CONTRIBUTING.md) if you want to develop missing fea

- [SQLDelight](https://github.com/cashapp/sqldelight)
- [SQLCipher](https://github.com/sqlcipher/sqlcipher)
- [kotlinx-coroutines](https://github.com/Kotlin/kotlinx.coroutines)
- [kotlinx-datetime](https://github.com/Kotlin/kotlinx-datetime)
- [Compose Multiplatform, by JetBrains](https://github.com/JetBrains/compose-jb)
- [MaterialThemePrefs](https://github.com/softartdev/MaterialThemePrefs)
- [moko-resources](https://github.com/icerockdev/moko-resources)
- [kotlinx-coroutines](https://github.com/Kotlin/kotlinx.coroutines)
- [kotlinx-datetime](https://github.com/Kotlin/kotlinx-datetime)
- [Koin](https://github.com/InsertKoinIO/koin)
- [CWAC-SafeRoom](https://github.com/commonsguy/cwac-saferoom)
- [Napier](https://github.com/AAkira/Napier)
Expand Down
1 change: 1 addition & 0 deletions android-compose-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ dependencies {
debugImplementation(compose.uiTooling)
debugImplementation(libs.androidx.compose.test.manifest)
implementation(libs.androidx.navigation.compose)
implementation(platform(libs.koin.bom))
implementation(libs.koin.android)
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.analytics)
Expand Down
3 changes: 2 additions & 1 deletion desktop-compose-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ kotlin {
implementation(libs.androidx.navigation.compose)
implementation(libs.coroutines.swing)
implementation(compose.desktop.currentOs)
implementation(libs.koin.core.jvm)
implementation(project.dependencies.platform(libs.koin.bom))
implementation(libs.koin.core)
}
jvmTest.dependencies {
implementation(project(":jvm-compose-test"))
Expand Down
27 changes: 14 additions & 13 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@ targetSdk = "34"
minSdk = "21"
jdk = "17"
kotlin = "2.0.21"
agp = "8.7.1"
agp = "8.7.2"
gms = "4.4.2"
crashlytics = "3.0.2"
compose = "1.7.0"
coroutines = "1.8.1"
coroutines = "1.9.0"
sqlDelight = "2.0.2"
androidxSqlite = "2.4.0"
saferoom = "1.3.0"
androidSqlCipher = "4.5.4"
iosSqlCipher = "4.5.4"
koin = "3.5.6"
koin-bom = "4.0.0"
kotlinx-serialization = "1.7.3"
kotlinx-datetime = "0.6.0"
kotlinx-datetime = "0.6.1"
napier = "2.7.1"
materialThemePrefs = "0.9.0"
androidxViewModel = "2.8.3"
androidxNavigation = "2.8.0-alpha10"
androidxActivityCompose = "1.9.3"
androidxComposeTest = "1.7.4"
androidxComposeTest = "1.7.5"
androidxCoreSplashscreen = "1.0.1"
androidxTracing = "1.2.0"
androidxLifecycle = "2.8.6"
androidxLifecycle = "2.8.7"
androidxArch = "2.2.0"
androidxTestExt = "1.2.1"
androidxTest = "1.6.2"
androidxTestOrchestrator = "1.5.1"
firebase = "33.5.0"
firebase = "33.5.1"
leakCanary = "2.14"
junit = "4.13.2"
mockito = "5.14.1"
Expand Down Expand Up @@ -60,12 +60,13 @@ commonsware-saferoom = { module = "com.commonsware.cwac:saferoom.x", version.ref

android-sqlcipher = { module = "net.zetetic:android-database-sqlcipher", version.ref = "androidSqlCipher" }

koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" }
koin-core-jvm = { module = "io.insert-koin:koin-core-jvm", version.ref = "koin" }
koin-android = { module = "io.insert-koin:koin-android", version.ref = "koin" }
koin-androidx-compose = { module = "io.insert-koin:koin-androidx-compose", version.ref = "koin" }
koin-test = { module = "io.insert-koin:koin-test", version.ref = "koin" }
koin-test-junit4 = { module = "io.insert-koin:koin-test-junit4", version.ref = "koin" }
koin-bom = { module = "io.insert-koin:koin-bom", version.ref = "koin-bom" }
koin-core = { module = "io.insert-koin:koin-core" }
koin-core-viewmodel = { module = "io.insert-koin:koin-core-viewmodel" }
koin-compose-viewmodel-navigation = { module = "io.insert-koin:koin-compose-viewmodel-navigation" }
koin-android = { module = "io.insert-koin:koin-android" }
koin-androidx-compose = { module = "io.insert-koin:koin-androidx-compose" }
koin-test = { module = "io.insert-koin:koin-test" }

kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" }
Expand Down
2 changes: 2 additions & 0 deletions ios-compose-kit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ kotlin {
baseName = "iosComposeKit"
isStatic = true
export(project(":shared"))
export(project.dependencies.platform(libs.koin.bom))
export(libs.koin.core)
}
if (!OperatingSystem.current().isMacOsX) noPodspec()
Expand All @@ -35,6 +36,7 @@ kotlin {
implementation(compose.foundation)
implementation(compose.material)
implementation(compose.runtime)
implementation(project.dependencies.platform(libs.koin.bom))
api(libs.koin.core)
}
}
Expand Down
2 changes: 1 addition & 1 deletion iosApp/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 0dc93a6f6109335ea8cd3f91d2c87cc8c99f04a3

COCOAPODS: 1.15.2
COCOAPODS: 1.12.1
2 changes: 1 addition & 1 deletion iosApp/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions iosApp/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion jvm-compose-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ dependencies {
implementation(project(":shared-compose-ui"))
implementation(libs.androidx.lifecycle.common)
implementation(libs.androidx.lifecycle.runtime)
implementation(libs.koin.core.jvm)
implementation(platform(libs.koin.bom))
implementation(libs.koin.core)
implementation(libs.turbine)
implementation(compose.desktop.uiTestJUnit4)
implementation(compose.desktop.currentOs)
Expand Down
6 changes: 5 additions & 1 deletion shared-compose-ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ kotlin {
implementation(compose.material3)
implementation(compose.materialIconsExtended)
implementation(compose.components.resources)
implementation(project.dependencies.platform(libs.koin.bom))
implementation(libs.koin.core)
implementation(libs.koin.compose.viewmodel.navigation)
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.lifecycle.runtime.compose)
}
androidMain.dependencies {
implementation(project.dependencies.platform(libs.koin.bom))
implementation(libs.koin.androidx.compose)
}
jvmMain.dependencies {
implementation(libs.koin.core.jvm)
implementation(project.dependencies.platform(libs.koin.bom))
implementation(libs.koin.core)
}
jvmTest.dependencies {
implementation(kotlin("test"))
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
@file:OptIn(KoinExperimentalAPI::class)

package com.softartdev.notedelight

import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.remember
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.dialog
import androidx.navigation.compose.rememberNavController
import androidx.navigation.toRoute
import com.softartdev.notedelight.di.getViewModel
import com.softartdev.notedelight.shared.navigation.AppNavGraph
import com.softartdev.notedelight.shared.navigation.Router
import com.softartdev.notedelight.ui.MainScreen
Expand All @@ -27,6 +30,10 @@ import com.softartdev.notedelight.ui.dialog.security.EnterPasswordDialog
import com.softartdev.theme.material3.PreferableMaterialTheme
import com.softartdev.theme.material3.ThemeDialog
import com.softartdev.theme.pref.PreferenceHelper
import org.koin.compose.viewmodel.koinNavViewModel
import org.koin.compose.viewmodel.koinViewModel
import org.koin.core.annotation.KoinExperimentalAPI
import org.koin.core.parameter.parametersOf

@Composable
fun App(
Expand All @@ -37,27 +44,36 @@ fun App(
router.setController(navController)
onDispose(router::releaseController)
}
val snackbarHostState: SnackbarHostState = remember { SnackbarHostState() }
NavHost(
navController = navController,
startDestination = AppNavGraph.Splash,
) {
composable<AppNavGraph.Splash> {
SplashScreen(splashViewModel = getViewModel())
SplashScreen(splashViewModel = koinViewModel())
}
composable<AppNavGraph.SignIn> {
SignInScreen(signInViewModel = getViewModel())
SignInScreen(signInViewModel = koinViewModel())
}
composable<AppNavGraph.Main> {
MainScreen(mainViewModel = getViewModel())
MainScreen(
mainViewModel = koinViewModel(),
snackbarHostState = snackbarHostState
)
}
composable<AppNavGraph.Details> { backStackEntry: NavBackStackEntry ->
NoteDetail(
noteViewModel = getViewModel(),
noteId = backStackEntry.toRoute<AppNavGraph.Details>().noteId,
noteViewModel = koinNavViewModel {
parametersOf(backStackEntry.toRoute<AppNavGraph.Details>().noteId)
},
snackbarHostState = snackbarHostState
)
}
composable<AppNavGraph.Settings> {
SettingsScreen(settingsViewModel = getViewModel())
SettingsScreen(
settingsViewModel = koinViewModel(),
snackbarHostState = snackbarHostState
)
}
dialog<AppNavGraph.ThemeDialog> {
val preferenceHelper: PreferenceHelper = themePrefs.preferenceHelper
Expand All @@ -68,25 +84,36 @@ fun App(
)
}
dialog<AppNavGraph.SaveChangesDialog> {
SaveDialog(saveViewModel = getViewModel())
SaveDialog(saveViewModel = koinViewModel())
}
dialog<AppNavGraph.EditTitleDialog> { backStackEntry: NavBackStackEntry ->
EditTitleDialog(
noteId = backStackEntry.toRoute<AppNavGraph.EditTitleDialog>().noteId,
editTitleViewModel = getViewModel()
editTitleViewModel = koinViewModel {
parametersOf(backStackEntry.toRoute<AppNavGraph.EditTitleDialog>().noteId)
},
snackbarHostState = snackbarHostState
)
}
dialog<AppNavGraph.DeleteNoteDialog> {
DeleteDialog(deleteViewModel = getViewModel())
DeleteDialog(deleteViewModel = koinViewModel())
}
dialog<AppNavGraph.EnterPasswordDialog> {
EnterPasswordDialog(enterViewModel = getViewModel())
EnterPasswordDialog(
enterViewModel = koinViewModel(),
snackbarHostState = snackbarHostState
)
}
dialog<AppNavGraph.ConfirmPasswordDialog> {
ConfirmPasswordDialog(confirmViewModel = getViewModel())
ConfirmPasswordDialog(
confirmViewModel = koinViewModel(),
snackbarHostState = snackbarHostState
)
}
dialog<AppNavGraph.ChangePasswordDialog> {
ChangePasswordDialog(changeViewModel = getViewModel())
ChangePasswordDialog(
changeViewModel = koinViewModel(),
snackbarHostState = snackbarHostState
)
}
dialog<AppNavGraph.ErrorDialog> { backStackEntry: NavBackStackEntry ->
ErrorDialog(
Expand All @@ -95,4 +122,4 @@ fun App(
)
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import org.jetbrains.compose.resources.stringResource
expect fun BackHandler(enabled: Boolean = true, onBack: () -> Unit)

@Composable
fun Loader() {
fun Loader(modifier: Modifier = Modifier) {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxWidth().padding(20.dp)
modifier = modifier.fillMaxSize().padding(all = 20.dp)
) {
CircularProgressIndicator()
}
Expand Down
Loading

0 comments on commit 45eadf2

Please sign in to comment.