Skip to content

Commit

Permalink
refac
Browse files Browse the repository at this point in the history
  • Loading branch information
kotlitecture committed Jun 29, 2024
1 parent 759df18 commit a5df0fe
Show file tree
Hide file tree
Showing 85 changed files with 194 additions and 192 deletions.
4 changes: 2 additions & 2 deletions docs/Dataflow/Basic In-Memory Cache API/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
## Overview

The API can be accessed through:
- `shared.data.datasource.cache.CacheSource` - facade interface at the core module level.
- `app.datasource.cache.AppCacheSource` - decorator class at the app level.
- `shared.data.source.cache.CacheSource` - facade interface at the core module level.
- `app.data.source.cache.AppCacheSource` - decorator class at the app level.

The difference is that the class serves as a **decorator** and can provide extra methods without impacting facade implementations.

Expand Down
4 changes: 2 additions & 2 deletions docs/Dataflow/Cash App Paging Library/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
## Overview

- DI integration: `app.di.datasource.ProvidesPagingSource`
- Data source: `app.datasource.paging.AppPagingSource`
- Data source: `app.data.source.paging.AppPagingSource`
- UI component: `shared.design.component.AppPagingList`

The integration includes an `AppPagingSource` class located in `app.datasource.paging` to facilitate working with the Paging Library.
The integration includes an `AppPagingSource` class located in `app.data.source.paging` to facilitate working with the Paging Library.

## Example

Expand Down
4 changes: 2 additions & 2 deletions docs/Dataflow/Facade Analytics API/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
## Overview

The API can be accessed through:
- `shared.data.datasource.analytics.AnalyticsSource` - facade interface at the core module level.
- `app.datasource.analytics.AppAnalyticsSource` - decorator class at the app level.
- `shared.data.source.analytics.AnalyticsSource` - facade interface at the core module level.
- `app.data.source.analytics.AppAnalyticsSource` - decorator class at the app level.

The difference is that the class serves as a **decorator** and can provide extra methods without impacting facade implementations.

Expand Down
4 changes: 2 additions & 2 deletions docs/Dataflow/Facade Config API/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
## Overview

The API can be accessed through:
- `shared.data.datasource.config.ConfigSource` - facade interface at the core module level.
- `app.datasource.config.AppConfigSource` - decorator class at the app level.
- `shared.data.source.config.ConfigSource` - facade interface at the core module level.
- `app.data.source.config.AppConfigSource` - decorator class at the app level.

The difference is that the class serves as a **decorator** and can provide extra methods without impacting facade implementations.

Expand Down
2 changes: 1 addition & 1 deletion docs/Dataflow/Ktor Client/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

The data source is available within the class `shared.data.datasource.http.HttpSource`. An instance of this class can be obtained through dependency injection (DI) as a singleton in `app.di.datasource.ProvidesHttpSource`.
The data source is available within the class `shared.data.source.http.HttpSource`. An instance of this class can be obtained through dependency injection (DI) as a singleton in `app.di.datasource.ProvidesHttpSource`.

The class provides the next functionality:

Expand Down
4 changes: 2 additions & 2 deletions docs/Dataflow/Multiplatform Settings/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
## Overview

The API can be accessed through:
- `shared.data.datasource.keyvalue.KeyValueSource` - facade interface at the core module level.
- `app.datasource.keyvalue.AppKeyValueSource` - decorator class at the app level.
- `shared.data.source.keyvalue.KeyValueSource` - facade interface at the core module level.
- `app.data.source.keyvalue.AppKeyValueSource` - decorator class at the app level.

The difference is that the class serves as a **decorator** and can provide extra methods without impacting facade implementations.

Expand Down
2 changes: 1 addition & 1 deletion docs/Dataflow/SQLDelight/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

- Component package: `app.datasource.database.sqldelight`
- Component package: `app.data.source.database.sqldelight`
- DI integration: `app.di.datasource.ProvidesSqlDelightSource`

The integration includes the following components:
Expand Down
6 changes: 3 additions & 3 deletions docs/Essentials/Material 3/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
## Overview

- Component package: `app.ui.theme`
- State management: `shared.presentation.theme.ThemeState`
- DI integration: `app.di.state.ProvidesThemeState`
- State management: `shared.presentation.theme.ThemeStore`
- DI integration: `app.di.state.ProvidesThemeStore`

This state instance is utilized by `app.ui.theme.AppThemeProvider`, which is pre-defined at the app level to furnish themes for the entire application.

Expand All @@ -19,7 +19,7 @@ fun App() = ViewModelProvider(remember { AppViewModelFactory }) {

## Change Themes

By default, `ThemeState` is initialized with pre-defined dark and light themes in the `design` module. To edit these themes:
By default, `ThemeStore` is initialized with pre-defined dark and light themes in the `design` module. To edit these themes:

1. Visit the [Material 3 Theme Builder](https://m3.material.io/theme-builder#/custom).
2. Customize the desired color theme.
Expand Down
10 changes: 5 additions & 5 deletions docs/Userflow/Save Theme API/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Component package: `app.ui.theme`

The current theme state is managed by an instance of `shared.presentation.theme.ThemeState`. This class provides a `configStore` property representing the currently selected theme configuration.
The current theme state is managed by an instance of `shared.presentation.theme.ThemeStore`. This class provides a `configStore` property representing the currently selected theme configuration.

The feature utilizes `AppThemeProvider` to control the value of this property:
- Persist its state whenever it changes.
Expand All @@ -16,19 +16,19 @@ Thus, whenever you update the current active application theme, it is automatica

```kotlin
class ToggleThemeViewModel(
private val themeState: ThemeState = get()
private val themeStore: ThemeStore = get()
) : BaseViewModel() {

fun onSetLightTheme() {
themeState.setLight()
themeStore.setLight()
}

fun onSetDarkTheme() {
themeState.setDark()
themeStore.setDark()
}

fun onSetCustomTheme() {
themeState.configStore.set(
themeStore.configStore.set(
ThemeConfig(
...
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ object Rules {
const val ShowcasesLoaderDir = "${ShowcasesDir}/feature/loader"
const val ShowcasesPasscodeDir = "${ShowcasesDir}/feature/passcode"
const val ShowcasesKt = "${ShowcasesDir}/Showcases.kt"
const val ThemeStateKt = "${SharedPresentationDir}/src/commonMain/kotlin/shared/presentation/theme/ThemeState.kt"
const val ThemeStoreKt = "${SharedPresentationDir}/src/commonMain/kotlin/shared/presentation/theme/ThemeStore.kt"
// dataflow
const val AppConfigSource = "${CommonAppMainDir}/kotlin/kotli/app/datasource/config/AppConfigSource.kt"
const val AnalyticsSource = "*/*AnalyticsSource.kt"
const val AnalyticsSource = "*/*AnalyticsSource*.kt"
const val CacheSource = "*/*CacheSource*.kt"
const val SqlDelightSource = "*/*SqlDelightSource.kt"
const val ConfigSource = "*/*ConfigSource.kt"
const val SqlDelightSource = "*/*SqlDelightSource*.kt"
const val ConfigSource = "*/*ConfigSource*.kt"
const val PagingSource = "*/*Paging*.kt"
const val HttpSource = "*/*HttpSource.kt"
const val KeyValueSource = "*/*KeyValueSource.kt"
const val SettingsKeyValueSource = "*/*SettingsKeyValueSource.kt"
const val HttpSource = "*/*HttpSource*.kt"
const val KeyValueSource = "*/*KeyValueSource*.kt"
const val SettingsKeyValueSource = "*/*SettingsKeyValueSource*.kt"
const val AppSqlDelightDir = "*/sqldelight/*"

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object SaveThemeProcessor : BaseFeatureProcessor() {

override fun doRemove(state: TemplateState) {
state.onApplyRules(
Rules.ThemeStateKt,
Rules.ThemeStoreKt,
RemoveMarkedLine(
marker = "theme_config",
singleLine = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Overview

The API can be accessed through:
- `shared.data.datasource.analytics.AnalyticsSource` - facade interface at the core module level.
- `app.datasource.analytics.AppAnalyticsSource` - decorator class at the app level.
- `shared.data.source.analytics.AnalyticsSource` - facade interface at the core module level.
- `app.data.source.analytics.AppAnalyticsSource` - decorator class at the app level.

The difference is that the class serves as a **decorator** and can provide extra methods without impacting facade implementations.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Overview

The API can be accessed through:
- `shared.data.datasource.cache.CacheSource` - facade interface at the core module level.
- `app.datasource.cache.AppCacheSource` - decorator class at the app level.
- `shared.data.source.cache.CacheSource` - facade interface at the core module level.
- `app.data.source.cache.AppCacheSource` - decorator class at the app level.

The difference is that the class serves as a **decorator** and can provide extra methods without impacting facade implementations.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Overview

The API can be accessed through:
- `shared.data.datasource.config.ConfigSource` - facade interface at the core module level.
- `app.datasource.config.AppConfigSource` - decorator class at the app level.
- `shared.data.source.config.ConfigSource` - facade interface at the core module level.
- `app.data.source.config.AppConfigSource` - decorator class at the app level.

The difference is that the class serves as a **decorator** and can provide extra methods without impacting facade implementations.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Overview

- Component package: `app.datasource.database.sqldelight`
- Component package: `app.data.source.database.sqldelight`
- DI integration: `app.di.datasource.ProvidesSqlDelightSource`

The integration includes the following components:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Overview

The data source is available within the class `shared.data.datasource.http.HttpSource`. An instance of this class can be obtained through dependency injection (DI) as a singleton in `app.di.datasource.ProvidesHttpSource`.
The data source is available within the class `shared.data.source.http.HttpSource`. An instance of this class can be obtained through dependency injection (DI) as a singleton in `app.di.datasource.ProvidesHttpSource`.

The class provides the next functionality:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Overview

The API can be accessed through:
- `shared.data.datasource.keyvalue.KeyValueSource` - facade interface at the core module level.
- `app.datasource.keyvalue.AppKeyValueSource` - decorator class at the app level.
- `shared.data.source.keyvalue.KeyValueSource` - facade interface at the core module level.
- `app.data.source.keyvalue.AppKeyValueSource` - decorator class at the app level.

The difference is that the class serves as a **decorator** and can provide extra methods without impacting facade implementations.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## Overview

- DI integration: `app.di.datasource.ProvidesPagingSource`
- Data source: `app.datasource.paging.AppPagingSource`
- Data source: `app.data.source.paging.AppPagingSource`
- UI component: `shared.design.component.AppPagingList`

The integration includes an `AppPagingSource` class located in `app.datasource.paging` to facilitate working with the Paging Library.
The integration includes an `AppPagingSource` class located in `app.data.source.paging` to facilitate working with the Paging Library.

## Example

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Overview

- Component package: `app.ui.theme`
- State management: `shared.presentation.theme.ThemeState`
- DI integration: `app.di.state.ProvidesThemeState`
- State management: `shared.presentation.theme.ThemeStore`
- DI integration: `app.di.state.ProvidesThemeStore`

This state instance is utilized by `app.ui.theme.AppThemeProvider`, which is pre-defined at the app level to furnish themes for the entire application.

Expand All @@ -17,7 +17,7 @@ fun App() = ViewModelProvider(remember { AppViewModelFactory }) {

## Change Themes

By default, `ThemeState` is initialized with pre-defined dark and light themes in the `design` module. To edit these themes:
By default, `ThemeStore` is initialized with pre-defined dark and light themes in the `design` module. To edit these themes:

1. Visit the [Material 3 Theme Builder](https://m3.material.io/theme-builder#/custom).
2. Customize the desired color theme.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Component package: `app.ui.theme`

The current theme state is managed by an instance of `shared.presentation.theme.ThemeState`. This class provides a `configStore` property representing the currently selected theme configuration.
The current theme state is managed by an instance of `shared.presentation.theme.ThemeStore`. This class provides a `configStore` property representing the currently selected theme configuration.

The feature utilizes `AppThemeProvider` to control the value of this property:
- Persist its state whenever it changes.
Expand All @@ -14,19 +14,19 @@ Thus, whenever you update the current active application theme, it is automatica

```kotlin
class ToggleThemeViewModel(
private val themeState: ThemeState = get()
private val themeStore: ThemeStore = get()
) : BaseViewModel() {

fun onSetLightTheme() {
themeState.setLight()
themeStore.setLight()
}

fun onSetDarkTheme() {
themeState.setDark()
themeStore.setDark()
}

fun onSetCustomTheme() {
themeState.configStore.set(
themeStore.configStore.set(
ThemeConfig(
...
)
Expand Down
2 changes: 1 addition & 1 deletion template/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ kotlin {
sqldelight {
databases {
create("AppDatabase") {
packageName.set("kotli.app.datasource.database.sqldelight")
packageName.set("kotli.app.data.source.database.sqldelight")
generateAsync.set(true)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package kotli.app.datasource.database.sqldelight
package kotli.app.data.source.database.sqldelight

import android.content.Context
import app.cash.sqldelight.async.coroutines.synchronous
import app.cash.sqldelight.db.SqlDriver
import app.cash.sqldelight.driver.android.AndroidSqliteDriver
import kotli.app.Application
import kotli.app.data.source.database.sqldelight.AppDatabase

actual fun createSqlDriver(name: String): SqlDriver {
val context: Context = Application.instance
Expand Down
6 changes: 3 additions & 3 deletions template/app/src/commonMain/kotlin/kotli/app/AppScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import shared.presentation.viewmodel.provideViewModel
@Composable
fun AppScreen() {
val viewModel: AppViewModel = provideViewModel()
val navigationState = viewModel.navigationState
val navigationState = viewModel.navigationStore
val navigationContext = rememberNavigationContext(navigationState)
NavigationBarProvider { // {userflow.navigation}
AppScaffold(
snackbarState = viewModel.snackbarState,
snackbarState = viewModel.snackbarStore,
navigationContext = navigationContext,
bottomBar = { BottomProvider() }
)
} // {userflow.navigation}
LoaderProvider(viewModel.appState)
LoaderProvider(viewModel.appStore)
}
10 changes: 5 additions & 5 deletions template/app/src/commonMain/kotlin/kotli/app/AppViewModel.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kotli.app

import shared.design.component.AppSnackbarState
import shared.design.component.AppSnackbarStore
import shared.presentation.viewmodel.BaseViewModel
import shared.presentation.navigation.NavigationStore

Expand All @@ -9,15 +9,15 @@ import shared.presentation.navigation.NavigationStore
*/
class AppViewModel(
private val navigationRouter: AppNavigationRouter,
val navigationState: NavigationStore,
val snackbarState: AppSnackbarState,
val appState: AppStore
val navigationStore: NavigationStore,
val snackbarStore: AppSnackbarStore,
val appStore: AppStore
) : BaseViewModel() {

override fun doBind() {
launchAsync("doBind") {
val startDestination = navigationRouter.getStartDestination()
navigationState.setStartDestination(startDestination)
navigationStore.setStartDestination(startDestination)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kotli.app.datasource.analytics
package kotli.app.data.source.analytics

import shared.data.source.analytics.CompositeAnalyticsSource

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kotli.app.datasource.cache
package kotli.app.data.source.cache

import shared.data.source.cache.InMemoryCacheSource

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kotli.app.datasource.config
package kotli.app.data.source.config

import shared.data.source.config.DelegateConfigSource

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package kotli.app.datasource.database.sqldelight
package kotli.app.data.source.database.sqldelight

import app.cash.sqldelight.db.SqlDriver
import kotli.app.data.source.database.sqldelight.AppDatabase
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.first
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kotli.app.datasource.keyvalue
package kotli.app.data.source.keyvalue

import shared.data.source.keyvalue.SettingsKeyValueSource
import shared.data.serialization.SerializationStrategy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kotli.app.datasource.paging
package kotli.app.data.source.paging

import app.cash.paging.Pager
import app.cash.paging.PagingSource
Expand Down
Loading

0 comments on commit a5df0fe

Please sign in to comment.