Skip to content

Commit

Permalink
inititate module structure
Browse files Browse the repository at this point in the history
  • Loading branch information
stslex committed Nov 23, 2023
1 parent 0f17900 commit d63b0e8
Show file tree
Hide file tree
Showing 17 changed files with 244 additions and 136 deletions.
4 changes: 3 additions & 1 deletion composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ kotlin {
implementation(compose.desktop.currentOs)
}
commonMain.dependencies {
implementation(libs.kermit)
implementation(project(":core:core"))
implementation(project(":core:ui"))
implementation(project(":feature:home"))

implementation(projects.shared)
implementation(compose.runtime)
Expand Down
2 changes: 1 addition & 1 deletion composeApp/src/commonMain/kotlin/App.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import androidx.compose.runtime.Composable
import org.jetbrains.compose.resources.ExperimentalResourceApi
import com.stslex.core.ui.theme.AppTheme

@Composable
fun App() {
Expand Down
58 changes: 2 additions & 56 deletions composeApp/src/commonMain/kotlin/InitialApp.kt
Original file line number Diff line number Diff line change
@@ -1,61 +1,7 @@
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material.Button
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.painterResource
import com.stslex.feature.home.HomeScreen

@OptIn(ExperimentalResourceApi::class)
@Composable
fun InitialApp() {
Box(
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colors.background)
) {
val defaultGreetState = "Hello World!"
val clickedGreetState = "Compose: ${Greeting().greet()}"
var isClicked by remember { mutableStateOf(false) }
val greetingText by remember {
derivedStateOf {
if (isClicked) {
clickedGreetState
} else {
defaultGreetState
}
}
}
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
) {
Button(
onClick = {
isClicked = !isClicked
}
) {
Text(greetingText)
}
AnimatedVisibility(isClicked) {
Image(
painterResource("compose-multiplatform.xml"),
null
)
}
}
}
HomeScreen()
}
24 changes: 0 additions & 24 deletions composeApp/src/commonMain/kotlin/main_screen/MainScreen.kt

This file was deleted.

36 changes: 0 additions & 36 deletions composeApp/src/commonMain/resources/compose-multiplatform.xml

This file was deleted.

46 changes: 46 additions & 0 deletions core/core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidLibrary)
alias(libs.plugins.jetbrainsCompose)
}

kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "core"
isStatic = true
}
}

sourceSets {
commonMain.dependencies {
implementation(libs.kermit)
implementation(projects.shared)
implementation(compose.runtime)
implementation(compose.foundation)
}
commonTest.dependencies {
implementation(libs.kotlin.test)
}
}
}

android {
namespace = "com.stslex.core.core"
compileSdk = libs.versions.android.compileSdk.get().toInt()
defaultConfig {
minSdk = libs.versions.android.minSdk.get().toInt()
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package core
package com.stslex.core.core

import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
import kotlinx.coroutines.MainCoroutineDispatcher

interface AppDispatcher {
Expand All @@ -12,7 +11,7 @@ interface AppDispatcher {
}

class AppDispatcherImpl : AppDispatcher {
override val io: CoroutineDispatcher = Dispatchers.IO
override val io: CoroutineDispatcher = Dispatchers.Default // TODO IO
override val main: MainCoroutineDispatcher = Dispatchers.Main
override val default: CoroutineDispatcher = Dispatchers.Default
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package core
package com.stslex.core.core

import kotlinx.coroutines.CoroutineExceptionHandler

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package core
package com.stslex.core.core

import co.touchlab.kermit.Logger as Log

Expand Down
52 changes: 52 additions & 0 deletions core/ui/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import org.jetbrains.compose.ExperimentalComposeLibrary

plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidLibrary)
alias(libs.plugins.jetbrainsCompose)
}

kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "ui"
isStatic = true
}
}

sourceSets {
commonMain.dependencies {
implementation(project(":core:core"))

implementation(projects.shared)
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
@OptIn(ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
}
commonTest.dependencies {
implementation(libs.kotlin.test)
}
}
}

android {
namespace = "com.stslex.core.ui"
compileSdk = libs.versions.android.compileSdk.get().toInt()
defaultConfig {
minSdk = libs.versions.android.minSdk.get().toInt()
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package store
package com.stslex.core.ui.mvi

import core.AppDispatcher
import core.Logger
import core.coroutineExceptionHandler
import com.stslex.core.core.AppDispatcher
import com.stslex.core.core.Logger
import com.stslex.core.core.coroutineExceptionHandler
import com.stslex.core.ui.navigation.Router
import com.stslex.core.ui.mvi.Store.Action
import com.stslex.core.ui.mvi.Store.Event
import com.stslex.core.ui.mvi.Store.Navigation
import com.stslex.core.ui.mvi.Store.State
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
Expand All @@ -16,11 +21,6 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import st.slex.csplashscreen.core.ui.mvi.Router
import st.slex.csplashscreen.core.ui.mvi.Store.Action
import st.slex.csplashscreen.core.ui.mvi.Store.Event
import st.slex.csplashscreen.core.ui.mvi.Store.Navigation
import st.slex.csplashscreen.core.ui.mvi.Store.State

abstract class BaseStore<S : State, E : Event, A : Action, N : Navigation>(
private val router: Router<N>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package st.slex.csplashscreen.core.ui.mvi
package com.stslex.core.ui.mvi

interface Store {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package st.slex.csplashscreen.core.ui.mvi
package com.stslex.core.ui.navigation

import com.stslex.core.ui.mvi.Store

fun interface Router<in E : Store.Navigation> {
operator fun invoke(event: E)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package com.stslex.core.ui.theme

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.MaterialTheme
import androidx.compose.material.darkColors
Expand Down
53 changes: 53 additions & 0 deletions feature/home/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import org.jetbrains.compose.ExperimentalComposeLibrary

plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidLibrary)
alias(libs.plugins.jetbrainsCompose)
}

kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "home"
isStatic = true
}
}

sourceSets {
commonMain.dependencies {
implementation(project(":core:core"))
implementation(project(":core:ui"))

implementation(projects.shared)
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
@OptIn(ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
}
commonTest.dependencies {
implementation(libs.kotlin.test)
}
}
}

android {
namespace = "com.stslex.feature.home"
compileSdk = libs.versions.android.compileSdk.get().toInt()
defaultConfig {
minSdk = libs.versions.android.minSdk.get().toInt()
}
}
Loading

0 comments on commit d63b0e8

Please sign in to comment.