Skip to content

Commit

Permalink
refactor: add decompose library for architecture (#36)
Browse files Browse the repository at this point in the history
* refactor: introduce decompose

* refactor: better modularization
  • Loading branch information
diegoberaldin authored Jun 9, 2023
1 parent 0803954 commit 0ed2c90
Show file tree
Hide file tree
Showing 311 changed files with 4,943 additions and 3,006 deletions.
1 change: 1 addition & 0 deletions .idea/.name

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

2 changes: 1 addition & 1 deletion .idea/artifacts/main_jvm_1_0_1.xml

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

2 changes: 1 addition & 1 deletion .idea/artifacts/repo_jvm_1_0_1.xml

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

6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ kotlin {
dependencies {
implementation(compose.desktop.currentOs)
implementation(compose.materialIconsExtended)
implementation(libs.essenty.instancekeeper)

implementation(compose.foundation)
implementation(compose.animation)

implementation(libs.koin)
implementation(libs.decompose)
implementation(libs.decompose.extensions)

implementation(projects.coreCommon)
implementation(projects.coreData)
Expand All @@ -55,7 +55,7 @@ kotlin {

compose.desktop {
application {
mainClass = "MetaTermKt"
mainClass = "MainKt"
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "MetaTerm"
Expand Down
3 changes: 2 additions & 1 deletion core-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ kotlin {
implementation(compose.desktop.currentOs)

implementation(libs.koin)
implementation(libs.essenty.instancekeeper)
implementation(libs.decompose)
implementation(libs.kotlinx.coroutines)
implementation(libs.androidx.datastore)

api(libs.bundles.log4j)
Expand Down
2 changes: 1 addition & 1 deletion core-common/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kotlin.code.style=official
kotlin.version=1.8.0
agp.version=7.3.0
compose.version=1.3.1
compose.version=1.4.0
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package coroutines
package common.coroutines

import kotlinx.coroutines.CoroutineDispatcher

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package coroutines
package common.coroutines

import kotlinx.coroutines.Dispatchers

Expand Down
31 changes: 31 additions & 0 deletions core-common/src/jvmMain/kotlin/common/di/CommonModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package common.di

import common.files.DefaultFileManager
import common.files.FileManager
import common.keystore.DefaultTemporaryKeyStore
import common.keystore.TemporaryKeyStore
import common.log.DefaultLogManager
import common.log.LogManager
import common.notification.DefaultNotificationCenter
import common.notification.NotificationCenter
import org.koin.dsl.module
import common.coroutines.CoroutineDispatcherProvider
import common.coroutines.CoroutineDispatcherProviderImpl

val commonModule = module {
single<CoroutineDispatcherProvider> {
CoroutineDispatcherProviderImpl
}
single<NotificationCenter> {
DefaultNotificationCenter
}
single<TemporaryKeyStore> {
DefaultTemporaryKeyStore(fileManager = get())
}
single<FileManager> {
DefaultFileManager
}
single<LogManager> {
DefaultLogManager(fileManager = get())
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package files
package common.files

import java.io.File
import java.util.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package files
package common.files

interface FileManager {
fun getFilePath(vararg components: String): String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package keystore
package common.keystore

import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.PreferenceDataStoreFactory
Expand All @@ -9,7 +9,7 @@ import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.floatPreferencesKey
import androidx.datastore.preferences.core.intPreferencesKey
import androidx.datastore.preferences.core.stringPreferencesKey
import files.FileManager
import common.files.FileManager
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.first
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package keystore
package common.keystore

interface TemporaryKeyStore {
suspend fun save(key: String, value: Boolean)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package log
package common.log

import files.FileManager
import common.files.FileManager
import org.slf4j.Logger
import org.slf4j.LoggerFactory

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package log
package common.log

interface LogManager {
fun trace(message: String)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package notification
package common.notification

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package notification
package common.notification

import kotlinx.coroutines.flow.SharedFlow

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ui.components
package common.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
Expand All @@ -19,7 +19,7 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.rememberDialogState
import ui.theme.Spacing
import common.ui.theme.Spacing

@Composable
fun CustomDialog(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ui.components
package common.ui.components

import androidx.compose.runtime.Composable
import androidx.compose.ui.window.AwtWindow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ui.components
package common.ui.components

import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
Expand Down Expand Up @@ -27,8 +27,8 @@ import androidx.compose.ui.text.drawText
import androidx.compose.ui.text.rememberTextMeasurer
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp
import utils.toLocalPixel
import utils.toRadians
import common.utils.toLocalPixel
import common.utils.toRadians
import java.text.DecimalFormat
import kotlin.math.sin

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ui.components
package common.ui.components

import androidx.compose.runtime.Composable
import androidx.compose.ui.window.AwtWindow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ui.components
package common.ui.components

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
Expand Down Expand Up @@ -32,7 +32,7 @@ import androidx.compose.ui.input.pointer.PointerEventType
import androidx.compose.ui.input.pointer.onPointerEvent
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import ui.theme.Spacing
import common.ui.theme.Spacing

@OptIn(ExperimentalComposeUiApi::class, ExperimentalFoundationApi::class)
@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ui.components
package common.ui.components

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
Expand All @@ -22,8 +22,8 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import ui.theme.SelectedBackground
import ui.theme.Spacing
import common.ui.theme.SelectedBackground
import common.ui.theme.Spacing

@OptIn(ExperimentalFoundationApi::class)
@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ui.components
package common.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
Expand All @@ -15,7 +15,7 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import ui.theme.Spacing
import common.ui.theme.Spacing

@Composable
fun CustomTextField(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ui.components
package common.ui.components

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.TooltipArea
Expand All @@ -11,7 +11,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import ui.theme.Spacing
import common.ui.theme.Spacing

@OptIn(ExperimentalFoundationApi::class)
@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ui.components
package common.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.border
Expand All @@ -16,7 +16,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import ui.theme.Spacing
import common.ui.theme.Spacing

@Composable
fun StyledLabel(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ui.components
package common.ui.components

import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.Arrangement
Expand All @@ -13,7 +13,7 @@ import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathEffect
import androidx.compose.ui.unit.dp
import ui.theme.Spacing
import common.ui.theme.Spacing

@Composable
fun TreeItem(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ui.theme
package common.ui.theme

import androidx.compose.material.darkColors
import androidx.compose.ui.graphics.Color
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ui.theme
package common.ui.theme

import androidx.compose.ui.unit.dp

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ui.theme
package common.ui.theme

import androidx.compose.material.Typography
import androidx.compose.ui.text.TextStyle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ui.theme
package common.ui.theme

import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package utils
package common.utils

import com.arkivanov.essenty.instancekeeper.InstanceKeeper
import com.arkivanov.essenty.instancekeeper.InstanceKeeperDispatcher
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package utils
package common.utils

import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalDensity
Expand Down
Loading

0 comments on commit 0ed2c90

Please sign in to comment.