-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
626 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,50 @@ | ||
[versions] | ||
kotlin = "1.9.22" | ||
ksp = "1.9.23-1.0.19" | ||
appcompat = "1.6.1" | ||
koin = "3.5.3" | ||
koin-annotations = "1.3.1" | ||
koin-android = "3.5.3" | ||
koin-compose = "3.5.3" | ||
kotlin = "1.9.23" | ||
coroutines = "1.8.0" | ||
kotest = "5.8.1" | ||
ktlint-lib = "1.2.1" | ||
material = "1.6.5" | ||
mvi = "1.7.0" | ||
mvi-compose = "0.0.3" | ||
mvi-kotest = "0.0.2" | ||
activity = "1.8.2" | ||
lifecycle = "2.7.0" | ||
ktlint-gradle = "12.1.0" | ||
android-library = "8.3.0" | ||
android-library = "8.3.1" | ||
maven-publish = "0.25.2" | ||
ui = "1.6.5" | ||
|
||
# its beeing used outside this file | ||
ktlint-lib = "1.2.1" | ||
|
||
[libraries] | ||
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } | ||
coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } | ||
kotest-runner = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" } | ||
kotlin-bom = { group = "org.jetbrains.kotlin", name = "kotlin-bom", version.ref = "kotlin" } | ||
adidas-mvi = { group = "com.adidas.mvi", name = "mvi", version.ref = "mvi" } | ||
appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" } | ||
coroutinesCore = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } | ||
coroutinesTest = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } | ||
kotestRunner = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" } | ||
kotlinBom = { group = "org.jetbrains.kotlin", name = "kotlin-bom", version.ref = "kotlin" } | ||
mvi = { group = "com.adidas.mvi", name = "mvi", version.ref = "mvi" } | ||
mviCompose = { group = "com.adidas.mvi", name = "mvi-compose", version.ref = "mvi-compose" } | ||
mviKotest = { group = "com.adidas.mvi", name = "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" } | ||
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" } | ||
koinAndroid = { module = "io.insert-koin:koin-android", version.ref = "koin-android" } | ||
koinAnnotations = { module = "io.insert-koin:koin-annotations", version.ref = "koin-annotations" } | ||
koinKspCompiler = { module = "io.insert-koin:koin-ksp-compiler", version.ref = "koin-annotations" } | ||
koinCompose = { module = "io.insert-koin:koin-androidx-compose", version.ref = "koin-compose" } | ||
|
||
[plugins] | ||
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } | ||
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint-gradle" } | ||
mavenPublish = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish" } | ||
android-library = { id = "com.android.library", version.ref = "android-library" } | ||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } | ||
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import com.android.build.gradle.AppExtension | ||
import com.android.build.gradle.TestedExtension | ||
import com.android.build.gradle.api.BaseVariant | ||
|
||
plugins { | ||
id("com.android.application") | ||
id("kotlin-android") | ||
id("kotlin-kapt") | ||
alias(libs.plugins.ksp) | ||
} | ||
|
||
android { | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
minSdk = 24 | ||
targetSdk = 34 | ||
|
||
versionCode = 1 | ||
versionName = "1.0" | ||
} | ||
|
||
namespace = "com.adidas.mvi.sample" | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_17.toString() | ||
} | ||
|
||
composeOptions { | ||
kotlinCompilerExtensionVersion = "1.5.11" | ||
} | ||
|
||
buildFeatures { | ||
compose = true | ||
} | ||
|
||
extensions.findByType<AppExtension>()?.let { | ||
project.extensions.configure(AppExtension::class.java) { | ||
applyKSP(this@configure, applicationVariants) | ||
} | ||
} | ||
} | ||
|
||
private fun <T : BaseVariant> applyKSP( | ||
extension: TestedExtension, | ||
variants: DomainObjectSet<T>, | ||
) { | ||
variants.all { | ||
extension.sourceSets { | ||
getByName(this@all.name) { | ||
kotlin.srcDir("build/generated/ksp/$name/kotlin") | ||
} | ||
} | ||
} | ||
} | ||
|
||
kotlin { | ||
explicitApi() | ||
} | ||
|
||
dependencies { | ||
implementation(libs.appcompat) | ||
implementation(libs.activityCompose) | ||
implementation(libs.ui) | ||
implementation(libs.material) | ||
|
||
implementation(libs.mvi) | ||
implementation(libs.mviCompose) | ||
|
||
implementation(libs.koinCore) | ||
implementation(libs.koinAndroid) | ||
implementation(libs.koinAnnotations) | ||
implementation(libs.koinCompose) | ||
ksp(libs.koinKspCompiler) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application | ||
android:name="com.adidas.mvi.sample.app.MviSampleApplication" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
|
||
<activity | ||
android:name="com.adidas.mvi.sample.MviSampleActivity" | ||
android:exported="true" | ||
android:launchMode="singleTask"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
17 changes: 17 additions & 0 deletions
17
mvi-sample/src/main/kotlin/com/adidas/mvi/sample/MviSampleActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.adidas.mvi.sample | ||
|
||
import android.os.Bundle | ||
import androidx.activity.compose.setContent | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.adidas.mvi.sample.login.ui.LoginScreen | ||
|
||
public class MviSampleActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
setContent { | ||
LoginScreen() | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
mvi-sample/src/main/kotlin/com/adidas/mvi/sample/app/MviSampleApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.adidas.mvi.sample.app | ||
|
||
import android.app.Application | ||
import com.adidas.mvi.sample.app.di.AppModule | ||
import com.adidas.mvi.sample.login.di.LoginModule | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.android.ext.koin.androidLogger | ||
import org.koin.core.context.startKoin | ||
import org.koin.core.logger.Level | ||
import org.koin.ksp.generated.module | ||
|
||
public class MviSampleApplication : Application() { | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
initializeKoin() | ||
} | ||
|
||
private fun initializeKoin() { | ||
startKoin { | ||
androidLogger(Level.ERROR) | ||
androidContext(this@MviSampleApplication) | ||
modules( | ||
AppModule().module, | ||
LoginModule().module | ||
) | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
mvi-sample/src/main/kotlin/com/adidas/mvi/sample/app/di/AppModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.adidas.mvi.sample.app.di | ||
|
||
import com.adidas.mvi.Logger | ||
import com.adidas.mvi.sample.app.logger.AppReduceLogger | ||
import org.koin.core.annotation.Module | ||
import org.koin.core.annotation.Single | ||
|
||
@Module | ||
public class AppModule { | ||
|
||
@Single | ||
internal fun provideLogger(): Logger { | ||
return AppReduceLogger() | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
mvi-sample/src/main/kotlin/com/adidas/mvi/sample/app/logger/AppReduceLogger.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.adidas.mvi.sample.app.logger | ||
|
||
import com.adidas.mvi.Loggable | ||
import com.adidas.mvi.Logger | ||
|
||
internal class AppReduceLogger : Logger { | ||
|
||
override fun logIntent(intent: Loggable) { | ||
println("Intent: ${getLoggableName(intent)}") | ||
} | ||
|
||
override fun logFailedIntent( | ||
intent: Loggable, | ||
throwable: Throwable, | ||
) { | ||
println("[Error]Intent: ${getLoggableName(intent)} Exception: ${throwable::class.qualifiedName}") | ||
throwable.printStackTrace() | ||
} | ||
|
||
override fun logTransformedNewState( | ||
transform: Loggable, | ||
previousState: Loggable, | ||
newState: Loggable, | ||
) { | ||
println( | ||
"Reduce: Using: ${getLoggableName(transform)}, On: ${ | ||
getLoggableName( | ||
previousState | ||
) | ||
}, To: ${getLoggableName(newState)}" | ||
) | ||
} | ||
|
||
override fun logFailedTransformNewState( | ||
transform: Loggable, | ||
state: Loggable, | ||
throwable: Throwable, | ||
) { | ||
println( | ||
"[Error]Reduce: Using: ${getLoggableName(transform)} On:${ | ||
getLoggableName( | ||
state | ||
) | ||
} Exception: ${throwable::class.qualifiedName}" | ||
) | ||
throwable.printStackTrace() | ||
} | ||
|
||
private fun getLoggableName(loggable: Loggable): String? { | ||
val qualifiedName = loggable::class.qualifiedName | ||
val packageName = loggable.javaClass.`package`?.name | ||
|
||
return qualifiedName?.substringAfter("$packageName.") ?: "N/D" | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
mvi-sample/src/main/kotlin/com/adidas/mvi/sample/login/di/LoginModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.adidas.mvi.sample.login.di | ||
|
||
import com.adidas.mvi.Logger | ||
import com.adidas.mvi.sample.login.viewmodel.LoginViewModel | ||
import org.koin.android.annotation.KoinViewModel | ||
import org.koin.core.annotation.Module | ||
|
||
@Module | ||
public class LoginModule { | ||
|
||
@KoinViewModel | ||
internal fun provideLoginViewModel( | ||
logger: Logger, | ||
): LoginViewModel { | ||
return LoginViewModel( | ||
logger = logger | ||
) | ||
} | ||
} |
Oops, something went wrong.