8000 mvi-compose to KMP by extmkv · Pull Request #36 · adidas/mvi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

mvi-compose to KMP #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

# Disable ktlint on generated source code, see
# https://github.com/JLLeitschuh/ktlint-gradle/issues/746
[**/build/generated/**]
ktlint = disabled

[*.{kt,kts}]
insert_final_newline = true
max_line_length = 250
ij_kotlin_imports_layout = *, ^
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
ktlint_compose_preview-public-check = disabled
ktlint_function_naming_ignore_when_annotated_with = Composable
20 changes: 11 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
.idea/artifacts
.idea/compiler.xml
.idea/jarRepositories.xml
.idea/modules.xml
.idea/*.iml
.idea/modules
*.iml
*.ipr

# CMake
cmake-build-*/
Expand Down Expand Up @@ -187,4 +187,6 @@ gradle-app.setting

.DS_Store

local.properties
local.properties

.kotlin
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ koin-android = "3.5.6"
koin-compose = "3.5.6"
kotlin = "2.0.0"
coroutines = "1.8.1"
kotest = "5.9.0"
material = "1.7.0"
mvi = "1.7.0"
kotest = "5.9.1"
material = "1.7.1"
mvi = "1.8.2-alpha01"
mvi-compose = "0.0.3"
activity = "1.9.2"
lifecycle = "2.8.5"
androidx-lifecycle = "2.8.0"
ktlint-gradle = "12.1.0"
android-library = "8.3.2"
maven-publish = "0.29.0"
ui = "1.7.0"
ui = "1.7.1"
mockk = "1.13.11"
mvi-kotest = "0.0.2"

Expand All @@ -35,7 +35,7 @@ mvi = { module = "com.adidas.mvi:mvi", version.ref = "mvi" }
mviCompose = { module = "com.adidas.mvi:mvi-compose", version.ref = "mvi-compose" }
mviKotest = { module = "com.adidas.mvi:mvi-kotest", version.ref = "mvi-kotest" }
activityCompose = { module = "androidx.activity:activity-compose", version.ref = "activity" }
lifecycleRuntimeCompose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "lifecycle" }
androidx-lifecycle-runtime-compose = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidx-lifecycle" }
material = { module = "androidx.compose.material:material", version.ref = "material" }
ui = { module = "androidx.compose.ui:ui", version.ref = "ui" }
koinCore = { module = "io.insert-koin:koin-core", version.ref = "koin" }
Expand Down
65 changes: 51 additions & 14 deletions mvi-compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,56 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jlleitschuh.gradle.ktlint.KtlintExtension

plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.ktlint)
alias(libs.plugins.mavenPublish)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.android.library)
}

kotlin {
explicitApi()

jvm()
androidTarget {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64(),
macosX64(),
macosArm64(),
watchosArm32(),
watchosArm64(),
watchosSimulatorArm64(),
watchosX64(),
tvosArm64(),
tvosSimulatorArm64(),
tvosX64(),
).forEach {
it.binaries.framework {
baseName = "mvi-compose"
isStatic = true
}
}

sourceSets {
commonMain.dependencies {
implementation(libs.mvi)
implementation(libs.androidx.lifecycle.runtime.compose)
}

androidMain.dependencies {
implementation(libs.activityCompose)
}
}
}

android {
Expand All @@ -25,27 +69,20 @@ android {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
"proguard-rules.pro",
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

buildFeatures {
compose = true
}
}

dependencies {

implementation(platform(libs.kotlinBom))
implementation(libs.mvi)
implementation(libs.activityCompose)
implementation(libs.lifecycleRuntimeCompose)
configure<KtlintExtension> {
version.set(libs.versions.ktlint.lib.get())
}
2 changes: 1 addition & 1 deletion mvi-compose/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
POM_ARTIFACT_ID=mvi-compose
GROUP=com.adidas.mvi
VERSION_CODE=1
VERSION_NAME=0.0.3
VERSION_NAME=0.1.0
POM_NAME=Adidas MVI Compose
POM_DESCRIPTION=Adidas MVI Compose
POM_PACKAGING=aar
2 changes: 0 additions & 2 deletions mvi-compose/src/main/AndroidManifest.xml

This file was deleted.

4 changes: 2 additions & 2 deletions mvi-sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ dependencies {
implementation(libs.material)

implementation(libs.mvi)
implementation(libs.mviCompose)
implementation(project(":mvi-compose"))

implementation(libs.koinCore)
implementation(libs.koinAndroid)
Expand All @@ -90,4 +90,4 @@ dependencies {
testImplementation(libs.kotestRunner)
testImplementation(libs.mockk)
testImplementation(libs.mviKotest)
}
}
4 changes: 2 additions & 2 deletions mvi/src/commonMain/kotlin/com/adidas/mvi/Reducer.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.adidas.mvi

import com.adidas.mvi.transform.StateTransform
import kotlin.coroutines.coroutineContext
import kotlin.reflect.KClass
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand All @@ -13,8 +15,6 @@ import kotlinx.coroutines.flow.scan
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlin.coroutines.coroutineContext
import kotlin.reflect.KClass

public class Reducer<TIntent, TState>(
private val coroutineScope: CoroutineScope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ public inline fun <TState : LoggableState, reified TRequiredState : TState> requ
return StateReduceRequirement(TRequiredState::class, reduce).reduce(state)
}

public inline fun <TState : LoggableState, reified TRequiredState : TState> requireState(
noinline reduce: (TRequiredState) -> TState,
): ReduceRequirement<TState> {
public inline fun <TState : LoggableState, reified TRequiredState : TState> requireState(noinline reduce: (TRequiredState) -> TState): ReduceRequirement<TState> {
return StateReduceRequirement(TRequiredState::class, reduce)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,7 @@ internal class ReducerTests : BehaviorSpec({
}
})

private fun createIntentExecutorContainer(
executedIntents: MutableList<TestIntent> = mutableListOf(),
): (TestIntent) -> Flow<StateTransform<State<TestState, TestSideEffect>>> =
private fun createIntentExecutorContainer(executedIntents: MutableList<TestIntent> = mutableListOf()): (TestIntent) -> Flow<StateTransform<State<TestState, TestSideEffect>>> =
{
executedIntents.add(it)
flowOf(TestTransform.Transform1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import io.kotest.matchers.booleans.shouldBeFalse
import io.kotest.matchers.collections.shouldBeEmpty
import io.kotest.matchers.collections.shouldContain
import io.kotest.matchers.collections.shouldContainInOrder
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Semaphore
import kotlin.time.DurationUnit
import kotlin.time.ExperimentalTime
import kotlin.time.toDuration
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Semaphore

@ExperimentalTime
internal class SideEffectsTest : BehaviorSpec({
Expand Down
Loading
0