Skip to content

Commit

Permalink
Updated compose and refactored shared modules names (#8)
Browse files Browse the repository at this point in the history
refac (*) core -> presentation
deps (*) compose multiplatform 1.6.11
  • Loading branch information
kotlitecture committed Jun 5, 2024
1 parent c6542b9 commit 719c34c
Show file tree
Hide file tree
Showing 136 changed files with 237 additions and 272 deletions.
44 changes: 4 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,7 @@ Run your project to check what is included and how it works, and once everything

# Architecture

```mermaid
---
title: Modules Structure
---
flowchart TB
subgraph core["Architectural Components (core)"]
a1["Jetpack ViewModel"]
a2["Jetpack Navigation"]
a3["Jetpack Lifecycle"]
a4["MVVM"]
end
subgraph data["Data Sources (data)"]
b1["HTTP API"]
b2["KeyValue API"]
b3["SQL / NoSQL API"]
b4["..."]
end
subgraph design["Design System (design)"]
c1["Themes"]
c2["Fonts"]
c3["UI Components"]
c4["UI Containers"]
end
subgraph app["Business Logic (app)"]
direction TB
d1["Dependency Injection"]
d2["Feature 1"]
d3["Feature 2"]
d4["Feature N"]
d1 -.- d2
d1 -.- d3
d1 -.- d4
end
core --> app
data --> app
design --> app
```
![Modules](images/concept/arch_modules.png)

The overall architecture is built on:
- [Compose Multiplatform UI Framework](https://www.jetbrains.com/lp/compose-multiplatform/)
Expand All @@ -77,13 +41,13 @@ Application logic is implemented in the app module and contains only app-specifi

All common logic is part of the shared group, which is split into three modules:

- **core** - architectural solutions to integrate app components with each other.
- **presentation** - architectural solutions to integrate app components with each other.
- **data** - data sources to use in the app.
- **design** - the design system of the app (fonts, themes, UI components, etc.).

These modules are used only at the app level. This approach lets you develop all three components independently and create a more complex app structure. For example, app-specific features can be implemented as separate modules, having the same shared dependencies.

## Module - core
## Module - presentation

Provides architectural solutions to implement user flows and integrate all components with each other in a lifecycle-aware manner.

Expand Down Expand Up @@ -143,7 +107,7 @@ When a project is configured and downloaded via [Kotli](https://kotlitecture.com

| Showcases :: Overview | Showcases :: Theme Dialog | Showcases :: Key-Value Storage |
|:---------------------------------------------------------:|:-------------------------------------------------------:|:-----------------------------------------------------------------:|
| ![Showcases Overview](screenshots/showcases_overview.jpg) | ![Theme Dialog](screenshots/showcases_theme_dialog.jpg) | ![Key-Value Storage](screenshots/showcases_key_value_objects.jpg) |
| ![Showcases Overview](images/screenshots/showcases_overview.jpg) | ![Theme Dialog](images/screenshots/showcases_theme_dialog.jpg) | ![Key-Value Storage](images/screenshots/showcases_key_value_objects.jpg) |

# Features

Expand Down
Binary file added images/concept/arch_modules.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion processor/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apply from: "${project.rootDir}/gradle/kotlin/processor.gradle"

group = 'com.kotlitecture.kotli'
version = '0.1.2'
version = '0.2.0'
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object Rules {
const val SrcIosMainDir = "*/src/iosMain"
const val SrcJsMainDir = "*/src/jsMain"
const val SrcJvmMainDir = "*/src/jvmMain"
const val SharedCoreDir = "shared/core"
const val SharedPresentationDir = "shared/presentation"
const val SharedDataDir = "shared/data"
const val SharedDesignDir = "shared/design"

Expand Down Expand Up @@ -65,7 +65,7 @@ object Rules {
const val ShowcasesLoaderDir = "${ShowcasesDir}/feature/loader"
const val ShowcasesPasscodeDir = "${ShowcasesDir}/feature/passcode"
const val ShowcasesKt = "${ShowcasesDir}/Showcases.kt"
const val ThemeStateKt = "${SharedCoreDir}/src/commonMain/kotlin/shared/core/theme/ThemeState.kt"
const val ThemeStateKt = "${SharedPresentationDir}/src/commonMain/kotlin/shared/presentation/theme/ThemeState.kt"
// dataflow
const val AppConfigSource = "${CommonAppMainDir}/kotlin/kotli/app/datasource/config/AppConfigSource.kt"
const val AnalyticsSource = "*/*AnalyticsSource.kt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Overview

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

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 Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Overview

The integration comes with a simple API for easier usage of Jetpack Navigation.
The API is available under the package `shared.core.navigation`.
The API is available under the package `shared.presentation.navigation`.

## Create Destination

Expand Down Expand Up @@ -31,7 +31,7 @@ object TemplateDestination : NavigationDestination<TemplateDestination.Data>() {

## Register Destination

All app destinations should be registered within an instance of the class `shared.core.navigation.NavigationState`.
All app destinations should be registered within an instance of the class `shared.presentation.navigation.NavigationState`.
This instance is already pre-configured in dependency injection (DI) through the `app.di.state.ProvidesNavigationState` class.
Simply place all your destinations within this instance.

Expand All @@ -56,7 +56,7 @@ val ProvidesNavigationState = module {

## Navigate to Destination

Once the navigation is aware of the destinations, you can initiate navigation to them using the `onBack` and `onNext` methods available in the `shared.core.navigation.NavigationState` class.
Once the navigation is aware of the destinations, you can initiate navigation to them using the `onBack` and `onNext` methods available in the `shared.presentation.navigation.NavigationState` class.
Simply inject `NavigationState` into your `ViewModel` or other dependency injection managed class, and navigate whenever necessary.

```kotlin
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.core.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.ThemeState`. 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 Down
2 changes: 1 addition & 1 deletion template/composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ kotlin {
implementation(libs.koin.core)
implementation(libs.napier)
implementation(libs.touchlab.kermit)
implementation(projects.shared.core)
implementation(projects.shared.data)
implementation(projects.shared.design)
implementation(projects.shared.presentation)
}
// {platform.android.dependencies}
androidMain.dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import androidx.compose.ui.platform.LocalContext
import androidx.core.splashscreen.SplashScreen
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import kotli.app.di.get
import shared.core.misc.extensions.findActivity
import shared.core.navigation.NavigationState
import shared.core.theme.ThemeState
import shared.presentation.misc.extensions.findActivity
import shared.presentation.navigation.NavigationState
import shared.presentation.theme.ThemeState

class AppActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
2 changes: 1 addition & 1 deletion template/composeApp/src/commonMain/kotlin/kotli/app/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import kotli.app.feature.navigation.samples.b.NavigationBViewModel
import kotli.app.feature.navigation.samples.c.NavigationCViewModel
import kotli.app.feature.theme.change.ChangeThemeViewModel
import kotli.app.feature.theme.toggle.ToggleThemeViewModel
import shared.core.ViewModelProvider
import shared.presentation.ViewModelProvider

/**
* Root of the application.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kotli.app

import kotli.app.showcases.ShowcasesDestination
import shared.core.navigation.NavigationDestination
import shared.presentation.navigation.NavigationDestination

/**
* Application navigation router.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import androidx.compose.runtime.Composable
import kotli.app.feature.loader.data.DataLoaderProvider
import kotli.app.feature.navigation.NavigationBarProvider
import kotli.app.feature.navigation.BottomProvider
import shared.core.navigation.rememberNavigationContext
import shared.core.provideViewModel
import shared.presentation.navigation.rememberNavigationContext
import shared.presentation.provideViewModel
import shared.design.container.AppScaffold

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kotli.app

import shared.core.state.StoreState
import shared.presentation.state.StoreState

/**
* Represents the state of the application. This class extends [StoreState], providing functionality
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kotli.app

import shared.core.BaseViewModel
import shared.core.navigation.NavigationState
import shared.presentation.BaseViewModel
import shared.presentation.navigation.NavigationState

/**
* ViewModel for the main screen of the application.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import shared.data.datasource.config.DelegateConfigSource

/**
* This class represents a configuration source for application settings.
* It delegates to a FirebaseRemoteConfigSource and provides methods to retrieve various configuration values.
* It delegates to an underlining source and provides methods to retrieve various configuration values
* without keys passed.
*/
class AppConfigSource : DelegateConfigSource(
// delegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import shared.data.serialization.SerializationStrategy
class AppKeyValueSource : SettingsKeyValueSource() {

/**
* Reads the value associated with the specified key from encrypted storage.
* Reads the value associated with the specified key from a storage.
*
* @param key The key to read.
* @return The value associated with the key, or `null` if the key does not exist or cannot be decrypted.
Expand All @@ -22,7 +22,7 @@ class AppKeyValueSource : SettingsKeyValueSource() {
}

/**
* Saves the specified key-value pair into encrypted storage.
* Saves the specified key-value pair into a storage.
*
* @param key The key to save.
* @param value The value to save.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import kotli.app.feature.navigation.samples.b.NavigationBDestination
import kotli.app.feature.navigation.samples.c.NavigationCDestination
import kotli.app.showcases.ShowcasesDestination
import org.koin.dsl.module
import shared.core.navigation.NavigationDestination
import shared.core.navigation.NavigationState
import shared.core.navigation.NavigationStrategy
import shared.presentation.navigation.NavigationDestination
import shared.presentation.navigation.NavigationState
import shared.presentation.navigation.NavigationStrategy
import shared.design.icon.AppIconModel
import shared.design.icon.AppIcons

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import kotli.app.feature.navigation.samples.c.NavigationCDestination
import kotli.app.feature.theme.change.ChangeThemeDestination
import kotli.app.feature.theme.change.ChangeThemeDialogDestination
import org.koin.dsl.module
import shared.core.navigation.NavigationState
import shared.presentation.navigation.NavigationState

val ProvidesNavigationState = module {
single {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kotli.app.di.state

import shared.core.theme.ThemeConfig
import shared.core.theme.ThemeState
import shared.presentation.theme.ThemeConfig
import shared.presentation.theme.ThemeState
import shared.design.theme.DarkThemeContext
import shared.design.theme.LightThemeContext
import org.koin.dsl.module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import shared.core.provideViewModel
import shared.core.state.StoreState
import shared.presentation.provideViewModel
import shared.presentation.state.StoreState
import shared.design.component.AppCard
import shared.design.component.AppCircularProgressIndicator
import shared.design.component.AppDialog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.map
import shared.core.BaseViewModel
import shared.core.state.DataState
import shared.core.state.StoreObject
import shared.core.state.StoreState
import shared.presentation.BaseViewModel
import shared.presentation.state.DataState
import shared.presentation.state.StoreObject
import shared.presentation.state.StoreState

class DataLoaderViewModel(
private val configSource: AppConfigSource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import shared.core.size.ViewSize
import shared.core.size.ViewSizeProvider
import shared.presentation.size.ViewSize
import shared.presentation.size.ViewSizeProvider

/**
* Composable function to display an adaptive navigation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package kotli.app.feature.navigation

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import shared.core.provideViewModel
import shared.presentation.provideViewModel
import shared.design.container.AppBottomNavigation

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kotli.app.feature.navigation

import androidx.compose.runtime.Composable
import shared.core.provideViewModel
import shared.presentation.provideViewModel
import shared.design.container.AppDismissibleNavigation

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kotli.app.feature.navigation

import androidx.compose.runtime.Composable
import shared.core.provideViewModel
import shared.presentation.provideViewModel
import shared.design.container.AppModalNavigation

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package kotli.app.feature.navigation

import shared.core.navigation.NavigationDestination
import shared.core.state.StoreObject
import shared.core.state.StoreState
import shared.presentation.navigation.NavigationDestination
import shared.presentation.state.StoreObject
import shared.presentation.state.StoreState

/**
* Represents the state of the navigation bar.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.map
import shared.core.BaseViewModel
import shared.core.navigation.NavigationState
import shared.core.state.StoreObject
import shared.presentation.BaseViewModel
import shared.presentation.navigation.NavigationState
import shared.presentation.state.StoreObject

class NavigationBarViewModel(
private val navigationBarState: NavigationBarState,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kotli.app.feature.navigation

import androidx.compose.runtime.Composable
import shared.core.provideViewModel
import shared.presentation.provideViewModel
import shared.design.container.AppPermanentNavigation

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kotli.app.feature.navigation

import androidx.compose.runtime.Composable
import shared.core.provideViewModel
import shared.presentation.provideViewModel
import shared.design.container.AppRailNavigation

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package kotli.app.feature.navigation.samples.a

import androidx.navigation.NavGraphBuilder
import shared.core.navigation.NavigationStrategy
import shared.core.navigation.NavigationDestinationNoArgs
import shared.presentation.navigation.NavigationStrategy
import shared.presentation.navigation.NavigationDestinationNoArgs

object NavigationADestination : NavigationDestinationNoArgs() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import shared.core.provideViewModel
import shared.presentation.provideViewModel
import shared.design.component.AppText

@Composable
Expand Down
Loading

0 comments on commit 719c34c

Please sign in to comment.