├── .idea └── .gitignore ├── kviewmodel ├── gradle.properties ├── src │ └── commonMain │ │ └── kotlin │ │ └── com │ │ └── adeo │ │ └── kviewmodel │ │ ├── Closeable.kt │ │ ├── Flow+Wrappers.kt │ │ ├── BaseSharedViewModel.kt │ │ └── KViewModel.kt └── build.gradle.kts ├── kviewmodel-compose ├── gradle.properties ├── build.gradle.kts └── src │ └── commonMain │ └── kotlin │ └── com │ └── adeo │ └── kviewmodel │ └── compose │ ├── ViewModel.kt │ └── Flow+State.kt ├── kviewmodel-odyssey ├── gradle.properties ├── src │ ├── commonMain │ │ └── kotlin │ │ │ └── com │ │ │ └── adeo │ │ │ └── kviewmodel │ │ │ └── odyssey │ │ │ ├── ConcurrentHashMap.kt │ │ │ ├── KClass+Name.kt │ │ │ ├── RootController+Setup.kt │ │ │ ├── StoredViewModel.kt │ │ │ └── ViewModelStore.kt │ ├── jsMain │ │ └── kotlin │ │ │ └── com │ │ │ └── adeo │ │ │ └── kviewmodel │ │ │ └── odyssey │ │ │ ├── KClass+Name.kt │ │ │ └── ConcurrentHashMap.kt │ ├── androidMain │ │ └── kotlin │ │ │ └── com │ │ │ └── adeo │ │ │ └── kviewmodel │ │ │ └── odyssey │ │ │ ├── ConcurrentHashMap.kt │ │ │ └── KClass+Name.kt │ ├── darwinMain │ │ └── kotlin │ │ │ └── com │ │ │ └── adeo │ │ │ └── kviewmodel │ │ │ └── odyssey │ │ │ ├── KClass+Name.kt │ │ │ └── ConcurrentHashMap.kt │ └── desktopMain │ │ └── kotlin │ │ └── com │ │ └── adeo │ │ └── kviewmodel │ │ └── odyssey │ │ ├── ConcurrentHashMap.kt │ │ └── KClass+Name.kt └── build.gradle.kts ├── android ├── src │ └── main │ │ ├── res │ │ ├── values-ru │ │ │ └── strings.xml │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── themes.xml │ │ │ └── colors.xml │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ └── drawable │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ └── com │ │ │ └── adeo │ │ │ └── kviewmodel │ │ │ └── example │ │ │ └── MainActivity.kt │ │ └── AndroidManifest.xml └── build.gradle.kts ├── gradle ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties └── libs.versions.toml ├── ios └── kviewmodel │ ├── kviewmodel │ ├── Assets.xcassets │ │ ├── Contents.json │ │ ├── AccentColor.colorset │ │ │ └── Contents.json │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── DetailViewController.swift │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ ├── SceneDelegate.swift │ └── ViewController.swift │ ├── kviewmodel.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── project.pbxproj │ ├── kviewmodel.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── Podfile ├── common-example ├── src │ └── commonMain │ │ └── kotlin │ │ └── com │ │ └── adeo │ │ └── kviewmodel │ │ └── example │ │ └── common │ │ ├── detail │ │ ├── models │ │ │ ├── DetailEvent.kt │ │ │ ├── DetailAction.kt │ │ │ └── DetailViewState.kt │ │ └── DetailViewModel.kt │ │ └── test │ │ ├── models │ │ ├── TestAction.kt │ │ ├── TestViewState.kt │ │ └── TestEvent.kt │ │ └── TestViewModel.kt └── build.gradle.kts ├── desktop ├── src │ └── main │ │ └── kotlin │ │ └── com │ │ └── adeo │ │ └── kviewmodel │ │ └── demo │ │ └── main.kt └── build.gradle.kts ├── .gitignore ├── common-example-compose ├── src │ └── commonMain │ │ └── kotlin │ │ └── com │ │ └── adeo │ │ └── kviewmodel │ │ └── example │ │ └── compose │ │ ├── detail │ │ └── DetailScreen.kt │ │ └── test │ │ └── TestScreen.kt └── build.gradle.kts ├── settings.gradle.kts ├── gradle.properties ├── gradlew.bat ├── README.md ├── gradlew └── LICENSE /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /kviewmodel/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=KViewModel 2 | POM_ARTIFACT_ID=kviewmodel -------------------------------------------------------------------------------- /kviewmodel-compose/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=KViewModel Compose 2 | POM_ARTIFACT_ID=kviewmodel-compose -------------------------------------------------------------------------------- /kviewmodel-odyssey/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=KViewModel Odyssey 2 | POM_ARTIFACT_ID=kviewmodel-odyssey -------------------------------------------------------------------------------- /android/src/main/res/values-ru/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adeo-opensource/kviewmodel--mpp/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /ios/kviewmodel/kviewmodel/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /android/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | KViewModelDemo 3 | -------------------------------------------------------------------------------- /kviewmodel/src/commonMain/kotlin/com/adeo/kviewmodel/Closeable.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel 2 | 3 | public interface Closeable { 4 | public fun close() 5 | } -------------------------------------------------------------------------------- /common-example/src/commonMain/kotlin/com/adeo/kviewmodel/example/common/detail/models/DetailEvent.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.example.common.detail.models 2 | 3 | sealed class DetailEvent -------------------------------------------------------------------------------- /common-example/src/commonMain/kotlin/com/adeo/kviewmodel/example/common/detail/models/DetailAction.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.example.common.detail.models 2 | 3 | sealed class DetailAction 4 | -------------------------------------------------------------------------------- /kviewmodel-odyssey/src/commonMain/kotlin/com/adeo/kviewmodel/odyssey/ConcurrentHashMap.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.odyssey 2 | 3 | public expect class ConcurrentHashMap() : MutableMap { 4 | } -------------------------------------------------------------------------------- /kviewmodel-odyssey/src/commonMain/kotlin/com/adeo/kviewmodel/odyssey/KClass+Name.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.odyssey 2 | 3 | import kotlin.reflect.KClass 4 | 5 | public expect val KClass<*>.name: String -------------------------------------------------------------------------------- /kviewmodel-odyssey/src/jsMain/kotlin/com/adeo/kviewmodel/odyssey/KClass+Name.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.odyssey 2 | 3 | import kotlin.reflect.KClass 4 | 5 | public actual val KClass<*>.name: String get() = js.name -------------------------------------------------------------------------------- /common-example/src/commonMain/kotlin/com/adeo/kviewmodel/example/common/detail/models/DetailViewState.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.example.common.detail.models 2 | 3 | data class DetailViewState( 4 | val text: String 5 | ) 6 | -------------------------------------------------------------------------------- /kviewmodel-odyssey/src/androidMain/kotlin/com/adeo/kviewmodel/odyssey/ConcurrentHashMap.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.odyssey 2 | 3 | public actual typealias ConcurrentHashMap = java.util.concurrent.ConcurrentHashMap -------------------------------------------------------------------------------- /kviewmodel-odyssey/src/androidMain/kotlin/com/adeo/kviewmodel/odyssey/KClass+Name.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.odyssey 2 | 3 | import kotlin.reflect.KClass 4 | 5 | public actual val KClass<*>.name: String get() = qualifiedName!! -------------------------------------------------------------------------------- /kviewmodel-odyssey/src/darwinMain/kotlin/com/adeo/kviewmodel/odyssey/KClass+Name.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.odyssey 2 | 3 | import kotlin.reflect.KClass 4 | 5 | public actual val KClass<*>.name: String get() = qualifiedName!! -------------------------------------------------------------------------------- /kviewmodel-odyssey/src/desktopMain/kotlin/com/adeo/kviewmodel/odyssey/ConcurrentHashMap.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.odyssey 2 | 3 | public actual typealias ConcurrentHashMap = java.util.concurrent.ConcurrentHashMap -------------------------------------------------------------------------------- /kviewmodel-odyssey/src/desktopMain/kotlin/com/adeo/kviewmodel/odyssey/KClass+Name.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.odyssey 2 | 3 | import kotlin.reflect.KClass 4 | 5 | public actual val KClass<*>.name: String get() = qualifiedName!! -------------------------------------------------------------------------------- /ios/kviewmodel/kviewmodel.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /common-example/src/commonMain/kotlin/com/adeo/kviewmodel/example/common/test/models/TestAction.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.example.common.test.models 2 | 3 | sealed class TestAction { 4 | data class OpenDetail(val param: Int) : TestAction() 5 | } -------------------------------------------------------------------------------- /ios/kviewmodel/kviewmodel/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /common-example/src/commonMain/kotlin/com/adeo/kviewmodel/example/common/test/models/TestViewState.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.example.common.test.models 2 | 3 | data class TestViewState( 4 | val titleText: String = "", 5 | val counter: Int = 0 6 | ) -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /common-example/src/commonMain/kotlin/com/adeo/kviewmodel/example/common/test/models/TestEvent.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.example.common.test.models 2 | 3 | sealed class TestEvent { 4 | object IncrementClick : TestEvent() 5 | object DecrementClick : TestEvent() 6 | object DetailClick : TestEvent() 7 | } -------------------------------------------------------------------------------- /desktop/src/main/kotlin/com/adeo/kviewmodel/demo/main.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.demo 2 | 3 | import javax.swing.JFrame 4 | import javax.swing.SwingUtilities 5 | 6 | fun main() = SwingUtilities.invokeLater { 7 | val window = JFrame() 8 | window.title = "KViewModel Demo" 9 | window.setSize(800, 600) 10 | } -------------------------------------------------------------------------------- /kviewmodel-odyssey/src/commonMain/kotlin/com/adeo/kviewmodel/odyssey/RootController+Setup.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.odyssey 2 | 3 | import ru.alexgladkov.odyssey.compose.RootController 4 | 5 | public fun RootController.setupWithViewModels() { 6 | onScreenRemove = { 7 | ViewModelStore.remove(it.key) 8 | } 9 | } -------------------------------------------------------------------------------- /ios/kviewmodel/kviewmodel.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /android/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /ios/kviewmodel/kviewmodel.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /kviewmodel-odyssey/src/jsMain/kotlin/com/adeo/kviewmodel/odyssey/ConcurrentHashMap.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.odyssey 2 | 3 | public actual class ConcurrentHashMap( 4 | private val delegate: HashMap = HashMap() 5 | ) : MutableMap by delegate { 6 | 7 | public actual constructor() : this(HashMap()) 8 | 9 | } 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .gradle 3 | .settings 4 | .project 5 | .classpath 6 | .vscode 7 | .idea 8 | !/.idea/codeStyles 9 | .run 10 | build 11 | *.iml 12 | Pods 13 | Podfile.lock 14 | *.podspec 15 | xcuserdata 16 | local.properties 17 | .externalNativeBuild 18 | .cxx 19 | *.xcuserstate 20 | *.xcbkptlist 21 | /gradle-plugin/generated 22 | kotlin-js-store -------------------------------------------------------------------------------- /ios/kviewmodel/kviewmodel.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/kviewmodel/Podfile: -------------------------------------------------------------------------------- 1 | source 'git@github.com:adeo/CocoaPods-Specs.git' # Production releases 2 | source 'git@github.com:adeo/CocoaPods-Specs-Snapshot.git' # Snapshot releases 3 | source 'https://cdn.cocoapods.org/' 4 | 5 | platform :ios, '14.0' 6 | use_frameworks! 7 | 8 | target 'kviewmodel' do 9 | pod 'common_example', :path => '../../common-example' 10 | end -------------------------------------------------------------------------------- /android/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /common-example-compose/src/commonMain/kotlin/com/adeo/kviewmodel/example/compose/detail/DetailScreen.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.example.compose.detail 2 | 3 | import androidx.compose.runtime.Composable 4 | import com.adeo.kviewmodel.compose.ViewModel 5 | import com.adeo.kviewmodel.example.common.detail.DetailViewModel 6 | 7 | @Composable 8 | fun DetailScreen(param: Int) { 9 | ViewModel(factory = { DetailViewModel(param) }) { _ -> 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnstableApiUsage") 2 | 3 | enableFeaturePreview("VERSION_CATALOGS") 4 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") 5 | 6 | dependencyResolutionManagement { 7 | repositories { 8 | google() 9 | mavenCentral() 10 | maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev") 11 | } 12 | } 13 | 14 | include(":kviewmodel", ":kviewmodel-compose", ":kviewmodel-odyssey") 15 | include(":common-example-compose", ":common-example") 16 | include(":android", ":desktop") -------------------------------------------------------------------------------- /android/src/main/java/com/adeo/kviewmodel/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.example 2 | 3 | import com.adeo.kviewmodel.example.compose.test.TestScreen 4 | import android.os.Bundle 5 | import androidx.activity.compose.setContent 6 | import androidx.appcompat.app.AppCompatActivity 7 | 8 | class MainActivity : AppCompatActivity() { 9 | 10 | override fun onCreate(savedInstanceState: Bundle?) { 11 | super.onCreate(savedInstanceState) 12 | 13 | setContent { 14 | TestScreen() 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /kviewmodel/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("multiplatform-setup") 3 | id("android-setup") 4 | id("com.vanniktech.maven.publish") 5 | } 6 | 7 | android { 8 | namespace = "com.adeo.kviewmodel" 9 | } 10 | 11 | kotlin { 12 | android { 13 | publishAllLibraryVariants() 14 | } 15 | 16 | sourceSets { 17 | commonMain { 18 | dependencies { 19 | api(libs.coroutines.core) 20 | } 21 | } 22 | } 23 | 24 | tasks.withType { 25 | kotlinOptions.freeCompilerArgs += "-Xexplicit-api=strict" 26 | } 27 | } -------------------------------------------------------------------------------- /kviewmodel-compose/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("multiplatform-compose-setup") 3 | id("android-setup") 4 | id("com.vanniktech.maven.publish") 5 | } 6 | 7 | android { 8 | namespace = "com.adeo.kviewmodel.compose" 9 | } 10 | 11 | kotlin { 12 | android { 13 | publishAllLibraryVariants() 14 | } 15 | 16 | sourceSets { 17 | commonMain { 18 | dependencies { 19 | api(projects.kviewmodel) 20 | } 21 | } 22 | } 23 | 24 | tasks.withType { 25 | kotlinOptions.freeCompilerArgs += "-Xexplicit-api=strict" 26 | } 27 | } -------------------------------------------------------------------------------- /common-example/src/commonMain/kotlin/com/adeo/kviewmodel/example/common/detail/DetailViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.example.common.detail 2 | 3 | import com.adeo.kviewmodel.BaseSharedViewModel 4 | import com.adeo.kviewmodel.example.common.detail.models.DetailAction 5 | import com.adeo.kviewmodel.example.common.detail.models.DetailEvent 6 | import com.adeo.kviewmodel.example.common.detail.models.DetailViewState 7 | 8 | class DetailViewModel(param: Int) : BaseSharedViewModel( 9 | DetailViewState(text = "Got $param") 10 | ) { 11 | 12 | override fun obtainEvent(viewEvent: DetailEvent) { 13 | 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /kviewmodel-compose/src/commonMain/kotlin/com/adeo/kviewmodel/compose/ViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.compose 2 | 3 | import androidx.compose.runtime.Composable 4 | import androidx.compose.runtime.DisallowComposableCalls 5 | import androidx.compose.runtime.DisposableEffect 6 | import androidx.compose.runtime.remember 7 | import com.adeo.kviewmodel.KViewModel 8 | 9 | @Composable 10 | public fun ViewModel( 11 | factory: @DisallowComposableCalls () -> T, 12 | content: @Composable (T) -> Unit 13 | ) { 14 | val viewModel = remember { factory() } 15 | content(viewModel) 16 | 17 | DisposableEffect(Unit) { 18 | onDispose(viewModel::clear) 19 | } 20 | } -------------------------------------------------------------------------------- /desktop/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") 3 | id("org.jetbrains.compose") 4 | } 5 | 6 | dependencies { 7 | implementation(compose.desktop.currentOs) 8 | } 9 | 10 | compose.desktop { 11 | application { 12 | mainClass = "com.adeo.kviewmodel.demo.MainKt" 13 | 14 | nativeDistributions { 15 | targetFormats( 16 | org.jetbrains.compose.desktop.application.dsl.TargetFormat.Msi 17 | ) 18 | packageName = "KViewModel Demo Desktop" 19 | packageVersion = "1.0.0" 20 | 21 | windows { 22 | menuGroup = "KViewModelDemo" 23 | upgradeUuid = "" // Provide to this unique UUID 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /kviewmodel-odyssey/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("multiplatform-compose-setup") 3 | id("android-setup") 4 | id("com.vanniktech.maven.publish") 5 | } 6 | 7 | android { 8 | namespace = "com.adeo.kviewmodel.odyssey" 9 | } 10 | 11 | kotlin { 12 | android { 13 | publishAllLibraryVariants() 14 | } 15 | 16 | sourceSets { 17 | commonMain { 18 | dependencies { 19 | api(projects.kviewmodel) 20 | implementation(libs.odyssey.core) 21 | implementation(libs.odyssey.compose) 22 | } 23 | } 24 | } 25 | 26 | tasks.withType { 27 | kotlinOptions.freeCompilerArgs += "-Xexplicit-api=strict" 28 | } 29 | } -------------------------------------------------------------------------------- /kviewmodel-odyssey/src/darwinMain/kotlin/com/adeo/kviewmodel/odyssey/ConcurrentHashMap.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.odyssey 2 | 3 | import kotlinx.atomicfu.locks.SynchronizedObject 4 | import kotlinx.atomicfu.locks.synchronized 5 | 6 | actual class ConcurrentHashMap( 7 | private val delegate: HashMap = HashMap() 8 | ) : MutableMap by delegate { 9 | 10 | actual constructor() : this(HashMap()) 11 | 12 | private val sync = SynchronizedObject() 13 | 14 | override val size: Int 15 | get() = synchronized(sync) { delegate.size } 16 | 17 | override fun get(key: K): V? = synchronized(sync) { delegate.get(key) } 18 | 19 | override fun put(key: K, value: V): V? = synchronized(sync) { delegate.put(key, value) } 20 | 21 | override fun remove(key: K): V? = synchronized(sync) { delegate.remove(key) } 22 | } -------------------------------------------------------------------------------- /common-example/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("multiplatform-setup") 3 | id("android-setup") 4 | kotlin("native.cocoapods") 5 | } 6 | 7 | android { 8 | namespace = "com.adeo.kviewmodel.example.common" 9 | } 10 | 11 | kotlin { 12 | cocoapods { 13 | summary = "KViewModel Apple Example" 14 | homepage = "https://github.com/adeo/kviewmodel--mpp" 15 | ios.deploymentTarget = "14.0" 16 | version = "1.0" 17 | 18 | framework { 19 | transitiveExport = false 20 | isStatic = true 21 | baseName = "KViewModelShared" 22 | } 23 | } 24 | 25 | sourceSets { 26 | commonMain { 27 | dependencies { 28 | implementation(projects.kviewmodel) 29 | implementation(libs.coroutines.core) 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /kviewmodel-odyssey/src/commonMain/kotlin/com/adeo/kviewmodel/odyssey/StoredViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.odyssey 2 | 3 | import androidx.compose.runtime.Composable 4 | import androidx.compose.runtime.DisallowComposableCalls 5 | import androidx.compose.runtime.remember 6 | import com.adeo.kviewmodel.KViewModel 7 | import ru.alexgladkov.odyssey.compose.local.LocalRootController 8 | 9 | @Composable 10 | public inline fun StoredViewModel( 11 | noinline factory: @DisallowComposableCalls () -> T, 12 | viewModelKey: String? = null, 13 | noinline content: @Composable (T) -> Unit, 14 | ) { 15 | val currentScreen = LocalRootController.current.currentScreen 16 | val screenKey = viewModelKey ?: currentScreen.value?.screen?.key ?: return 17 | val viewModel = remember { ViewModelStore.getOrPut(screenKey, factory) } 18 | content(viewModel) 19 | } -------------------------------------------------------------------------------- /kviewmodel-compose/src/commonMain/kotlin/com/adeo/kviewmodel/compose/Flow+State.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("NOTHING_TO_INLINE") 2 | 3 | package com.adeo.kviewmodel.compose 4 | 5 | import androidx.compose.runtime.Composable 6 | import androidx.compose.runtime.State 7 | import androidx.compose.runtime.collectAsState 8 | import kotlinx.coroutines.flow.SharedFlow 9 | import kotlinx.coroutines.flow.StateFlow 10 | import kotlin.coroutines.CoroutineContext 11 | import kotlin.coroutines.EmptyCoroutineContext 12 | 13 | @Composable 14 | public inline fun StateFlow.observeAsState(context: CoroutineContext = EmptyCoroutineContext): State { 15 | return collectAsState(context = context) 16 | } 17 | 18 | @Composable 19 | public inline fun SharedFlow.observeAsState(context: CoroutineContext = EmptyCoroutineContext): State { 20 | return collectAsState(initial = null, context = context) 21 | } -------------------------------------------------------------------------------- /ios/kviewmodel/kviewmodel/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIUserInterfaceStyle 6 | Light 7 | UIApplicationSceneManifest 8 | 9 | UIApplicationSupportsMultipleScenes 10 | 11 | UISceneConfigurations 12 | 13 | UIWindowSceneSessionRoleApplication 14 | 15 | 16 | UISceneConfigurationName 17 | Default Configuration 18 | UISceneDelegateClassName 19 | $(PRODUCT_MODULE_NAME).SceneDelegate 20 | UISceneStoryboardFile 21 | Main 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /kviewmodel-odyssey/src/commonMain/kotlin/com/adeo/kviewmodel/odyssey/ViewModelStore.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.odyssey 2 | 3 | import androidx.compose.runtime.DisallowComposableCalls 4 | import com.adeo.kviewmodel.KViewModel 5 | 6 | public object ViewModelStore { 7 | 8 | @PublishedApi 9 | internal val viewModelStore: ConcurrentHashMap = ConcurrentHashMap() 10 | 11 | @PublishedApi 12 | internal inline fun getOrPut( 13 | screenKey: String, 14 | factory: @DisallowComposableCalls () -> T 15 | ): T { 16 | val key = "${screenKey}_${T::class.name}" 17 | return viewModelStore.getOrPut(key, factory) as T 18 | } 19 | 20 | public fun remove(screenKey: String) { 21 | viewModelStore.forEach { 22 | if (it.key.startsWith(screenKey)) { 23 | it.value.clear() 24 | viewModelStore -= it.key 25 | } 26 | } 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /kviewmodel/src/commonMain/kotlin/com/adeo/kviewmodel/Flow+Wrappers.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel 2 | 3 | import kotlinx.coroutines.CoroutineScope 4 | import kotlinx.coroutines.Dispatchers 5 | import kotlinx.coroutines.SupervisorJob 6 | import kotlinx.coroutines.cancel 7 | import kotlinx.coroutines.flow.* 8 | 9 | public class WrappedStateFlow(private val origin: StateFlow) : StateFlow by origin { 10 | public fun watch(block: (T) -> Unit): Closeable = watchFlow(block) 11 | } 12 | 13 | public class WrappedSharedFlow(private val origin: SharedFlow) : SharedFlow by origin { 14 | public fun watch(block: (T) -> Unit): Closeable = watchFlow(block) 15 | } 16 | 17 | private fun Flow.watchFlow(block: (T) -> Unit): Closeable { 18 | val context = CoroutineScope(SupervisorJob() + Dispatchers.Main) 19 | onEach(block).launchIn(context) 20 | 21 | return object : Closeable { 22 | override fun close() { 23 | context.cancel() 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /android/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnstableApiUsage") 2 | 3 | plugins { 4 | id("com.android.application") 5 | kotlin("android") 6 | id("org.jetbrains.compose") 7 | } 8 | 9 | android { 10 | namespace = "com.adeo.kviewmodel.example" 11 | compileSdk = 33 12 | 13 | defaultConfig { 14 | minSdk = 21 15 | targetSdk = 33 16 | versionCode = 1 17 | versionName = "1.0" 18 | 19 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" 20 | } 21 | 22 | compileOptions { 23 | sourceCompatibility = JavaVersion.VERSION_1_8 24 | targetCompatibility = JavaVersion.VERSION_1_8 25 | } 26 | 27 | packagingOptions { 28 | resources.excludes.add("META-INF/*") 29 | } 30 | } 31 | 32 | dependencies { 33 | implementation(compose.material) 34 | 35 | implementation(projects.commonExample) 36 | implementation(projects.commonExampleCompose) 37 | implementation(libs.android.appcompat) 38 | implementation(libs.android.activity.compose) 39 | } -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 16 | 17 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ios/kviewmodel/kviewmodel/DetailViewController.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import KViewModelShared 3 | 4 | class DetailViewController: UIViewController { 5 | 6 | var param: Int32! 7 | 8 | private lazy var detailViewModel = DetailViewModel(param: param) 9 | 10 | private lazy var titleView: UILabel = { 11 | let titleView = UILabel() 12 | return titleView 13 | }() 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | renderUI() 18 | 19 | detailViewModel.viewStates().watch { [weak self] viewState in 20 | guard let self = self else { return } 21 | 22 | self.titleView.text = viewState.text 23 | } 24 | } 25 | 26 | deinit { 27 | print("Detail view controller deinited") 28 | } 29 | 30 | private func renderUI() { 31 | view.backgroundColor = .white 32 | view.addSubview(titleView) 33 | 34 | titleView.translatesAutoresizingMaskIntoConstraints = false 35 | titleView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true 36 | titleView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | plugin-android = "7.3.0" 3 | plugin-publish-maven = "0.22.0" 4 | plugin-multiplatform-compose = "1.2.1" 5 | 6 | kotlin = "1.7.20" 7 | coroutines = "1.6.4" 8 | odyssey = "1.3.1" 9 | android-appcompat = "1.5.1" 10 | android-activity-compose = "1.6.1" 11 | 12 | [libraries] 13 | plugin-android = { module = "com.android.tools.build:gradle", version.ref = "plugin-android" } 14 | plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } 15 | plugin-publish-maven = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "plugin-publish-maven" } 16 | plugin-multiplatform-compose = { module = "org.jetbrains.compose:compose-gradle-plugin", version.ref = "plugin-multiplatform-compose" } 17 | 18 | coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } 19 | android-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "android-appcompat" } 20 | android-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "android-activity-compose" } 21 | odyssey-core = { module = "io.github.alexgladkov:odyssey-core", version.ref = "odyssey" } 22 | odyssey-compose = { module = "io.github.alexgladkov:odyssey-compose", version.ref = "odyssey" } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8 2 | android.useAndroidX=true 3 | android.enableJetifier=false 4 | kotlin.code.style=official 5 | org.gradle.parallel=false 6 | org.gradle.caching=true 7 | kotlin.native.disableCompilerDaemon=true 8 | org.gradle.vfs.watch=true 9 | org.gradle.daemon=true 10 | org.jetbrains.compose.experimental.uikit.enabled=true 11 | org.jetbrains.compose.experimental.jscanvas.enabled=true 12 | org.jetbrains.compose.experimental.macos.enabled=true 13 | 14 | GROUP=com.adeo 15 | VERSION_NAME=0.14 16 | 17 | SONATYPE_HOST=S01 18 | 19 | POM_NAME=KViewModel library 20 | POM_DESCRIPTION=ViewModel for Multiplatform 21 | POM_URL=https://github.com/adeo-opensource/kviewmodel--mpp 22 | 23 | POM_LICENSE_NAME=The Apache Software License, Version 2.0 24 | POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt 25 | POM_LICENSE_DIST=repo 26 | 27 | POM_SCM_URL=https://github.com/adeo-opensource/kviewmodel--mpp 28 | POM_SCM_CONNECTION=scm:git:ssh://git@github.com/adeo-opensource/kviewmodel--mpp.git 29 | POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/adeo-opensource/kviewmodel--mpp.git 30 | 31 | POM_DEVELOPER_ID=Leroy Merlin 32 | POM_DEVELOPER_NAME=Leroy Merlin 33 | POM_DEVELOPER_EMAIL=aleksey.gladkov@leroymerlin.ru 34 | POM_DEVELOPER_URL=https://github.com/adeo-opensource/ -------------------------------------------------------------------------------- /common-example-compose/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("multiplatform-compose-setup") 3 | id("android-setup") 4 | kotlin("native.cocoapods") 5 | } 6 | 7 | android { 8 | namespace = "com.adeo.kviewmodel.example.compose" 9 | } 10 | 11 | kotlin { 12 | cocoapods { 13 | summary = "KViewModel Apple-Compose Example" 14 | homepage = "https://github.com/adeo/kviewmodel--mpp" 15 | ios.deploymentTarget = "14.0" 16 | version = "1.0" 17 | 18 | framework { 19 | transitiveExport = false 20 | isStatic = true 21 | baseName = "KViewModelCompose" 22 | 23 | freeCompilerArgs += listOf( 24 | "-linker-option", "-framework", "-linker-option", "Metal", 25 | "-linker-option", "-framework", "-linker-option", "CoreText", 26 | "-linker-option", "-framework", "-linker-option", "CoreGraphics", 27 | "-Xdisable-phases=VerifyBitcode" 28 | ) 29 | } 30 | } 31 | 32 | sourceSets { 33 | commonMain { 34 | dependencies { 35 | implementation(compose.foundation) 36 | implementation(compose.material) 37 | implementation(projects.commonExample) 38 | implementation(projects.kviewmodel) 39 | implementation(projects.kviewmodelCompose) 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /kviewmodel/src/commonMain/kotlin/com/adeo/kviewmodel/BaseSharedViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel 2 | 3 | import kotlinx.coroutines.CoroutineScope 4 | import kotlinx.coroutines.channels.BufferOverflow 5 | import kotlinx.coroutines.flow.* 6 | import kotlinx.coroutines.launch 7 | 8 | public abstract class BaseSharedViewModel(initialState: State) : KViewModel() { 9 | 10 | private val _viewStates = MutableStateFlow(initialState) 11 | 12 | private val _viewActions = MutableSharedFlow(replay = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST) 13 | 14 | public fun viewStates(): WrappedStateFlow = WrappedStateFlow(_viewStates.asStateFlow()) 15 | 16 | public fun viewActions(): WrappedSharedFlow = WrappedSharedFlow(_viewActions.asSharedFlow()) 17 | 18 | protected var viewState: State 19 | get() = _viewStates.value 20 | set(value) { 21 | _viewStates.value = value 22 | } 23 | 24 | protected var viewAction: Action? 25 | get() = _viewActions.replayCache.last() 26 | set(value) { 27 | _viewActions.tryEmit(value) 28 | } 29 | 30 | public abstract fun obtainEvent(viewEvent: Event) 31 | 32 | /** 33 | * Convenient method to perform work in [viewModelScope] scope. 34 | */ 35 | protected fun withViewModelScope(block: suspend CoroutineScope.() -> Unit) { 36 | viewModelScope.launch(block = block) 37 | } 38 | } -------------------------------------------------------------------------------- /ios/kviewmodel/kviewmodel/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // kviewmodel 4 | // 5 | // Created by Алексей Гладков on 14.02.2022. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /common-example/src/commonMain/kotlin/com/adeo/kviewmodel/example/common/test/TestViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.example.common.test 2 | 3 | import kotlinx.coroutines.Dispatchers 4 | import kotlinx.coroutines.delay 5 | import kotlinx.coroutines.launch 6 | import kotlinx.coroutines.withContext 7 | import com.adeo.kviewmodel.BaseSharedViewModel 8 | import com.adeo.kviewmodel.example.common.test.models.TestAction 9 | import com.adeo.kviewmodel.example.common.test.models.TestEvent 10 | import com.adeo.kviewmodel.example.common.test.models.TestViewState 11 | 12 | class TestViewModel: BaseSharedViewModel(initialState = TestViewState()) { 13 | 14 | init { 15 | // use if some data is not available at the initialization time 16 | // and need to perform some long operation 17 | // e.g: network request, database request 18 | fetchSomeInitialData() 19 | } 20 | 21 | override fun obtainEvent(viewEvent: TestEvent) = when (viewEvent) { 22 | is TestEvent.IncrementClick -> updateCounter(+1) 23 | is TestEvent.DecrementClick -> updateCounter(-1) 24 | is TestEvent.DetailClick -> viewAction = TestAction.OpenDetail(viewState.counter) 25 | } 26 | 27 | private fun fetchSomeInitialData() { 28 | viewState = viewState.copy(titleText = "Hello, World") 29 | } 30 | 31 | private fun updateCounter(byValue: Int) { 32 | viewModelScope.launch { 33 | val newValue = withContext(Dispatchers.Default) { 34 | delay(1000) 35 | return@withContext viewState.counter + byValue 36 | } 37 | viewState = viewState.copy(counter = newValue) 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /ios/kviewmodel/kviewmodel/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /ios/kviewmodel/kviewmodel/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /android/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /ios/kviewmodel/kviewmodel/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /kviewmodel/src/commonMain/kotlin/com/adeo/kviewmodel/KViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel 2 | 3 | import kotlinx.coroutines.CoroutineExceptionHandler 4 | import kotlinx.coroutines.CoroutineScope 5 | import kotlinx.coroutines.Dispatchers 6 | import kotlinx.coroutines.SupervisorJob 7 | import kotlinx.coroutines.cancel 8 | import kotlin.coroutines.CoroutineContext 9 | import kotlin.native.concurrent.ThreadLocal 10 | 11 | public abstract class KViewModel { 12 | 13 | private val mainCoroutineExceptionHandler: CoroutineExceptionHandler? by lazy(LazyThreadSafetyMode.NONE) { 14 | getCoroutineExceptionHandler() 15 | } 16 | private val coroutineTags = hashMapOf() 17 | private val mainCoroutineContext = (SupervisorJob() + Dispatchers.Main.immediate).run { 18 | val exceptionHandler = mainCoroutineExceptionHandler ?: return@run this 19 | this + exceptionHandler 20 | } 21 | 22 | public val viewModelScope: CoroutineScope 23 | get() = coroutineTags[MAIN_JOB_KEY] ?: launchNewScope() 24 | 25 | protected open fun getCoroutineExceptionHandler(): CoroutineExceptionHandler? = sharedExceptionHandler 26 | 27 | protected open fun onCleared() { 28 | 29 | } 30 | 31 | public fun clear() { 32 | coroutineTags.forEach { it.value.cancel() } 33 | onCleared() 34 | } 35 | 36 | // Launch view model scope except you provide a new key 37 | public fun launchNewScope( 38 | key: String = MAIN_JOB_KEY, 39 | coroutineContext: CoroutineContext = mainCoroutineContext 40 | ): CoroutineScope = 41 | coroutineTags.getOrPut(key) { 42 | CoroutineScope(coroutineContext) 43 | } 44 | 45 | @ThreadLocal 46 | public companion object { 47 | private var sharedExceptionHandler: CoroutineExceptionHandler? = null 48 | private const val MAIN_JOB_KEY = "main.viewmodel.shared.coroutine.job" 49 | 50 | public fun setupSharedExceptionHandler(exceptionHandler: CoroutineExceptionHandler) { 51 | sharedExceptionHandler = exceptionHandler 52 | } 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /ios/kviewmodel/kviewmodel/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // kviewmodel 4 | // 5 | // Created by Алексей Гладков on 14.02.2022. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /common-example-compose/src/commonMain/kotlin/com/adeo/kviewmodel/example/compose/test/TestScreen.kt: -------------------------------------------------------------------------------- 1 | package com.adeo.kviewmodel.example.compose.test 2 | 3 | import androidx.compose.foundation.layout.* 4 | import androidx.compose.material.Button 5 | import androidx.compose.material.OutlinedButton 6 | import androidx.compose.material.Text 7 | import androidx.compose.runtime.Composable 8 | import androidx.compose.ui.Alignment 9 | import androidx.compose.ui.Modifier 10 | import androidx.compose.ui.unit.dp 11 | import androidx.compose.ui.unit.sp 12 | import com.adeo.kviewmodel.compose.ViewModel 13 | import com.adeo.kviewmodel.compose.observeAsState 14 | import com.adeo.kviewmodel.example.common.test.TestViewModel 15 | import com.adeo.kviewmodel.example.common.test.models.TestAction 16 | import com.adeo.kviewmodel.example.common.test.models.TestEvent 17 | 18 | @Composable 19 | fun TestScreen() { 20 | ViewModel(factory = { TestViewModel() }) { viewModel -> 21 | val viewState = viewModel.viewStates().observeAsState() 22 | val viewAction = viewModel.viewActions().observeAsState() 23 | 24 | TestView( 25 | title = viewState.value.titleText, 26 | counter = viewState.value.counter, 27 | onIncrementClick = { viewModel.obtainEvent(TestEvent.IncrementClick) }, 28 | onDecrementClick = { viewModel.obtainEvent(TestEvent.DecrementClick) }, 29 | onDetailClick = { viewModel.obtainEvent(TestEvent.DetailClick) } 30 | ) 31 | 32 | when (val action = viewAction.value) { 33 | is TestAction.OpenDetail -> { 34 | // screen switching depends on the navigation library 35 | // DetailScreen(action.param) 36 | } 37 | else -> { 38 | 39 | } 40 | } 41 | } 42 | } 43 | 44 | @Composable 45 | private fun TestView( 46 | title: String, 47 | counter: Int, 48 | onIncrementClick: () -> Unit, 49 | onDecrementClick: () -> Unit, 50 | onDetailClick: () -> Unit 51 | ) { 52 | Column( 53 | modifier = Modifier.fillMaxSize().padding(16.dp), 54 | horizontalAlignment = Alignment.CenterHorizontally 55 | ) { 56 | Text(text = title) 57 | 58 | Spacer(modifier = Modifier.weight(1f)) 59 | 60 | Row(verticalAlignment = Alignment.CenterVertically) { 61 | OutlinedButton(onClick = onDecrementClick) { 62 | Text(text = "-") 63 | } 64 | Text( 65 | modifier = Modifier.padding(horizontal = 16.dp), 66 | text = counter.toString(), 67 | fontSize = 26.sp 68 | ) 69 | OutlinedButton(onClick = onIncrementClick) { 70 | Text(text = "+") 71 | } 72 | } 73 | 74 | Spacer(modifier = Modifier.weight(1f)) 75 | 76 | Button(onClick = onDetailClick) { 77 | Text(text = "Open detail") 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | 88 | @rem Execute Gradle 89 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 90 | 91 | :end 92 | @rem End local scope for the variables with windows NT shell 93 | if "%ERRORLEVEL%"=="0" goto mainEnd 94 | 95 | :fail 96 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 97 | rem the _cmd.exe /c_ return code! 98 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 99 | exit /b 1 100 | 101 | :mainEnd 102 | if "%OS%"=="Windows_NT" endlocal 103 | 104 | :omega 105 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # KViewModel 2 | 3 | KViewModel it's a lightweight library for MVVM or MVI pattern. Works with Jetpack Compose, XML, UIKit. 4 | 5 | Works with Kotlin Multiplatform and Compose Multiplatform! 6 | 7 | ### Implementation 8 | 9 | Kotlin DSL 10 | 11 | ```kotlin 12 | implementation("com.adeo:kviewmodel:0.14") // Core functions 13 | implementation("com.adeo:kviewmodel-compose:0.14") // Compose extensions 14 | implementation("com.adeo:kviewmodel-odyssey:0.14") // Odyssey extensions 15 | ``` 16 | 17 | ```groovy 18 | implementation "com.adeo:kviewmodel:0.14" // Core functions 19 | implementation "com.adeo:kviewmodel-compose:0.14" // Compose extensions 20 | implementation "com.adeo:kviewmodel-odyssey:0.14" // Odyssey extensions 21 | ``` 22 | 23 | ### How to use 24 | 25 | #### Common Code 26 | 27 | ```kotlin 28 | class TestViewModel : BaseSharedViewModel(initialState = TestViewState()) 29 | ``` 30 | 31 | Events - for user interaction 32 | 33 | ```kotlin 34 | sealed class TestEvent { 35 | object IncrementClick : TestEvent() 36 | object DecrementClick : TestEvent() 37 | object DetailClick : TestEvent() 38 | } 39 | ``` 40 | 41 | Actions - single action from view model like show snackbar or navigation 42 | 43 | ```kotlin 44 | sealed class TestAction { 45 | data class OpenDetail(val param: Int) : TestAction() 46 | } 47 | ``` 48 | 49 | ViewState - your current screen state (fields, loaders, etc) 50 | 51 | ```kotlin 52 | data class TestViewState( 53 | val titleText: String = "", 54 | val counter: Int = 0 55 | ) 56 | ``` 57 | 58 | #### Compose Multiplatform 59 | 60 | ```kotlin 61 | ViewModel(factory = { TestViewModel() }) { viewModel -> 62 | val viewState = viewModel.viewStates().observeAsState() 63 | val viewAction = viewModel.viewActions().observeAsState() 64 | 65 | Text(text = viewState.titleText) 66 | 67 | viewAction.value?.let { action -> 68 | when (action) { 69 | is TestAction.FirstCase -> TODO() 70 | is TestAction.SecondCase -> TODO() 71 | } 72 | } 73 | } 74 | ``` 75 | 76 | #### Custom ViewModel's exception handlers 77 | 78 | > **Note:** When using a custom exception handler you need to take care about crash reporting 79 | 80 | Shared exception handlers (for all ViewModels) 81 | 82 | ```kotlin 83 | class App: Application() { 84 | 85 | override fun onCreate() { 86 | super.onCreate() 87 | KViewModel.setupSharedExceptionHandler(CoroutineExceptionHandler { _, throwable -> 88 | // There is you can log common exceptions for all ViewModels 89 | }) 90 | } 91 | } 92 | ``` 93 | 94 | Single exception handlers (for only current ViewModel) 95 | 96 | ```kotlin 97 | class TestViewModel: BaseSharedViewModel(initialState = TestViewState()) { 98 | 99 | override fun getCoroutineExceptionHandler(): CoroutineExceptionHandler { 100 | return CoroutineExceptionHandler { _, throwable -> 101 | // There is you can log exceptions only for TestViewModel 102 | } 103 | } 104 | } 105 | ``` 106 | 107 | #### [Odyssey](https://github.com/AlexGladkov/Odyssey) integration 108 | Allows you to save the ViewModel 109 | ```kotlin 110 | setupNavigation( 111 | startScreen = "YourStartScreen", 112 | providers = yourCustomProviders 113 | ) { 114 | LocalRootController.current.setupWithViewModels() 115 | generateGraph() 116 | } 117 | ``` 118 | 119 | ```kotlin 120 | StoredViewModel(factory = { TestViewModel() }) { viewModel -> 121 | // usual code like above 122 | } 123 | ``` 124 | 125 | #### iOS 126 | 127 | ```swift 128 | // ViewState 129 | testViewModel.viewStates().watch { [weak self] viewState in 130 | guard let self = self else { return } 131 | 132 | self.titleView.text = viewState.someText 133 | } 134 | 135 | // Action 136 | testViewModel.viewActions().watch { [weak self] viewAction in 137 | guard let self = self, let viewAction = viewAction else { return } 138 | 139 | switch viewAction { 140 | case let args as TestAction.OpenDetail: 141 | self.presentDetail(param: args.param) 142 | 143 | default: break 144 | } 145 | } 146 | ``` 147 | 148 | ### Problems 149 | 150 | Feel free to make issues, we will try to fix it as fast as we can! For proposals, you can also use issue section 151 | -------------------------------------------------------------------------------- /ios/kviewmodel/kviewmodel/ViewController.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import KViewModelShared 3 | 4 | class ViewController: UIViewController { 5 | 6 | private let testViewModel = TestViewModel() 7 | 8 | private lazy var titleView: UILabel = { 9 | let titleView = UILabel() 10 | return titleView 11 | }() 12 | 13 | private lazy var counterView: UILabel = { 14 | let counterView = UILabel() 15 | counterView.font = .systemFont(ofSize: 26) 16 | return counterView 17 | }() 18 | 19 | private lazy var decrementButtonView: UIButton = { 20 | let buttonView = UIButton() 21 | buttonView.setTitle("-", for: .normal) 22 | buttonView.setTitleColor(.blue, for: .normal) 23 | buttonView.addTarget(self, action: #selector(decrementTap), for: .touchUpInside) 24 | return buttonView 25 | }() 26 | 27 | private lazy var incrementButtonView: UIButton = { 28 | let buttonView = UIButton() 29 | buttonView.setTitle("+", for: .normal) 30 | buttonView.setTitleColor(.blue, for: .normal) 31 | buttonView.addTarget(self, action: #selector(incrementTap), for: .touchUpInside) 32 | return buttonView 33 | }() 34 | 35 | private lazy var detailButtonView: UIButton = { 36 | let buttonView = UIButton() 37 | buttonView.setTitle("Open Detail", for: .normal) 38 | buttonView.setTitleColor(.blue, for: .normal) 39 | buttonView.addTarget(self, action: #selector(buttonTap), for: .touchUpInside) 40 | return buttonView 41 | }() 42 | 43 | override func viewDidLoad() { 44 | super.viewDidLoad() 45 | renderUI() 46 | 47 | testViewModel.viewStates().watch { [weak self] viewState in 48 | guard let self = self else { return } 49 | 50 | self.titleView.text = viewState.titleText 51 | self.counterView.text = String(viewState.counter) 52 | } 53 | 54 | testViewModel.viewActions().watch { [weak self] viewAction in 55 | guard let self = self, let viewAction = viewAction else { return } 56 | 57 | switch viewAction { 58 | case let args as TestAction.OpenDetail: self.presentDetail(param: args.param) 59 | default: break 60 | } 61 | } 62 | } 63 | 64 | private func renderUI() { 65 | view.addSubview(titleView) 66 | view.addSubview(counterView) 67 | view.addSubview(incrementButtonView) 68 | view.addSubview(decrementButtonView) 69 | view.addSubview(detailButtonView) 70 | 71 | titleView.translatesAutoresizingMaskIntoConstraints = false 72 | titleView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 16).isActive = true 73 | titleView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true 74 | 75 | counterView.translatesAutoresizingMaskIntoConstraints = false 76 | counterView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true 77 | counterView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true 78 | 79 | decrementButtonView.translatesAutoresizingMaskIntoConstraints = false 80 | decrementButtonView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true 81 | decrementButtonView.rightAnchor.constraint(equalTo: counterView.leftAnchor, constant: -16).isActive = true 82 | 83 | incrementButtonView.translatesAutoresizingMaskIntoConstraints = false 84 | incrementButtonView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true 85 | incrementButtonView.leftAnchor.constraint(equalTo: counterView.rightAnchor, constant: 16).isActive = true 86 | 87 | detailButtonView.translatesAutoresizingMaskIntoConstraints = false 88 | detailButtonView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true 89 | detailButtonView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -16).isActive = true 90 | } 91 | 92 | private func presentDetail(param: Int32) { 93 | let detailViewController = DetailViewController() 94 | detailViewController.param = param 95 | present(detailViewController, animated: true, completion: nil) 96 | } 97 | 98 | @objc private func decrementTap() { 99 | testViewModel.obtainEvent(viewEvent: TestEvent.DecrementClick()) 100 | } 101 | 102 | @objc private func incrementTap() { 103 | testViewModel.obtainEvent(viewEvent: TestEvent.IncrementClick()) 104 | } 105 | 106 | @objc private func buttonTap() { 107 | testViewModel.obtainEvent(viewEvent: TestEvent.DetailClick()) 108 | } 109 | 110 | } 111 | 112 | -------------------------------------------------------------------------------- /android/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 66 | 68 | 70 | 72 | 74 | 75 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | https://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | Copyright 2013-2018 Docker, Inc. 179 | 180 | Licensed under the Apache License, Version 2.0 (the "License"); 181 | you may not use this file except in compliance with the License. 182 | You may obtain a copy of the License at 183 | 184 | https://www.apache.org/licenses/LICENSE-2.0 185 | 186 | Unless required by applicable law or agreed to in writing, software 187 | distributed under the License is distributed on an "AS IS" BASIS, 188 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 189 | See the License for the specific language governing permissions and 190 | limitations under the License. -------------------------------------------------------------------------------- /ios/kviewmodel/kviewmodel.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 55; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9724F64C27BA853800C94351 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9724F64B27BA853800C94351 /* AppDelegate.swift */; }; 11 | 9724F64E27BA853800C94351 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9724F64D27BA853800C94351 /* SceneDelegate.swift */; }; 12 | 9724F65027BA853800C94351 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9724F64F27BA853800C94351 /* ViewController.swift */; }; 13 | 9724F65327BA853800C94351 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9724F65127BA853800C94351 /* Main.storyboard */; }; 14 | 9724F65527BA853900C94351 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9724F65427BA853900C94351 /* Assets.xcassets */; }; 15 | 9724F65827BA853900C94351 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9724F65627BA853900C94351 /* LaunchScreen.storyboard */; }; 16 | 9724F66027BAA3F200C94351 /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9724F65F27BAA3F200C94351 /* DetailViewController.swift */; }; 17 | AF6BDCCF919F3C7FC27717A4 /* Pods_kviewmodel.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2FE5D8D665CF4596A84B49F7 /* Pods_kviewmodel.framework */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | 2FE5D8D665CF4596A84B49F7 /* Pods_kviewmodel.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_kviewmodel.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | 6C6DBBB2C556E538CF47E652 /* Pods-kviewmodel.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-kviewmodel.release.xcconfig"; path = "Target Support Files/Pods-kviewmodel/Pods-kviewmodel.release.xcconfig"; sourceTree = ""; }; 23 | 9724F64827BA853800C94351 /* kviewmodel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = kviewmodel.app; sourceTree = BUILT_PRODUCTS_DIR; }; 24 | 9724F64B27BA853800C94351 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 25 | 9724F64D27BA853800C94351 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 26 | 9724F64F27BA853800C94351 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 27 | 9724F65227BA853800C94351 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 28 | 9724F65427BA853900C94351 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 29 | 9724F65727BA853900C94351 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 30 | 9724F65927BA853900C94351 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31 | 9724F65F27BAA3F200C94351 /* DetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = ""; }; 32 | C9DAAC793099CDD8DB161858 /* Pods-kviewmodel.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-kviewmodel.debug.xcconfig"; path = "Target Support Files/Pods-kviewmodel/Pods-kviewmodel.debug.xcconfig"; sourceTree = ""; }; 33 | /* End PBXFileReference section */ 34 | 35 | /* Begin PBXFrameworksBuildPhase section */ 36 | 9724F64527BA853800C94351 /* Frameworks */ = { 37 | isa = PBXFrameworksBuildPhase; 38 | buildActionMask = 2147483647; 39 | files = ( 40 | AF6BDCCF919F3C7FC27717A4 /* Pods_kviewmodel.framework in Frameworks */, 41 | ); 42 | runOnlyForDeploymentPostprocessing = 0; 43 | }; 44 | /* End PBXFrameworksBuildPhase section */ 45 | 46 | /* Begin PBXGroup section */ 47 | 6FCBD00CFAF5A8F1C361880E /* Frameworks */ = { 48 | isa = PBXGroup; 49 | children = ( 50 | 2FE5D8D665CF4596A84B49F7 /* Pods_kviewmodel.framework */, 51 | ); 52 | name = Frameworks; 53 | sourceTree = ""; 54 | }; 55 | 7BD94B369AD1A7F0550632FF /* Pods */ = { 56 | isa = PBXGroup; 57 | children = ( 58 | C9DAAC793099CDD8DB161858 /* Pods-kviewmodel.debug.xcconfig */, 59 | 6C6DBBB2C556E538CF47E652 /* Pods-kviewmodel.release.xcconfig */, 60 | ); 61 | path = Pods; 62 | sourceTree = ""; 63 | }; 64 | 9724F63F27BA853800C94351 = { 65 | isa = PBXGroup; 66 | children = ( 67 | 9724F64A27BA853800C94351 /* kviewmodel */, 68 | 9724F64927BA853800C94351 /* Products */, 69 | 7BD94B369AD1A7F0550632FF /* Pods */, 70 | 6FCBD00CFAF5A8F1C361880E /* Frameworks */, 71 | ); 72 | sourceTree = ""; 73 | }; 74 | 9724F64927BA853800C94351 /* Products */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 9724F64827BA853800C94351 /* kviewmodel.app */, 78 | ); 79 | name = Products; 80 | sourceTree = ""; 81 | }; 82 | 9724F64A27BA853800C94351 /* kviewmodel */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | 9724F64B27BA853800C94351 /* AppDelegate.swift */, 86 | 9724F64D27BA853800C94351 /* SceneDelegate.swift */, 87 | 9724F64F27BA853800C94351 /* ViewController.swift */, 88 | 9724F65127BA853800C94351 /* Main.storyboard */, 89 | 9724F65427BA853900C94351 /* Assets.xcassets */, 90 | 9724F65627BA853900C94351 /* LaunchScreen.storyboard */, 91 | 9724F65927BA853900C94351 /* Info.plist */, 92 | 9724F65F27BAA3F200C94351 /* DetailViewController.swift */, 93 | ); 94 | path = kviewmodel; 95 | sourceTree = ""; 96 | }; 97 | /* End PBXGroup section */ 98 | 99 | /* Begin PBXNativeTarget section */ 100 | 9724F64727BA853800C94351 /* kviewmodel */ = { 101 | isa = PBXNativeTarget; 102 | buildConfigurationList = 9724F65C27BA853900C94351 /* Build configuration list for PBXNativeTarget "kviewmodel" */; 103 | buildPhases = ( 104 | B5C62652FBD622CDAFCEE600 /* [CP] Check Pods Manifest.lock */, 105 | 9724F64427BA853800C94351 /* Sources */, 106 | 9724F64527BA853800C94351 /* Frameworks */, 107 | 9724F64627BA853800C94351 /* Resources */, 108 | ); 109 | buildRules = ( 110 | ); 111 | dependencies = ( 112 | ); 113 | name = kviewmodel; 114 | productName = kviewmodel; 115 | productReference = 9724F64827BA853800C94351 /* kviewmodel.app */; 116 | productType = "com.apple.product-type.application"; 117 | }; 118 | /* End PBXNativeTarget section */ 119 | 120 | /* Begin PBXProject section */ 121 | 9724F64027BA853800C94351 /* Project object */ = { 122 | isa = PBXProject; 123 | attributes = { 124 | BuildIndependentTargetsInParallel = 1; 125 | LastSwiftUpdateCheck = 1320; 126 | LastUpgradeCheck = 1320; 127 | TargetAttributes = { 128 | 9724F64727BA853800C94351 = { 129 | CreatedOnToolsVersion = 13.2.1; 130 | }; 131 | }; 132 | }; 133 | buildConfigurationList = 9724F64327BA853800C94351 /* Build configuration list for PBXProject "kviewmodel" */; 134 | compatibilityVersion = "Xcode 13.0"; 135 | developmentRegion = en; 136 | hasScannedForEncodings = 0; 137 | knownRegions = ( 138 | en, 139 | Base, 140 | ); 141 | mainGroup = 9724F63F27BA853800C94351; 142 | productRefGroup = 9724F64927BA853800C94351 /* Products */; 143 | projectDirPath = ""; 144 | projectRoot = ""; 145 | targets = ( 146 | 9724F64727BA853800C94351 /* kviewmodel */, 147 | ); 148 | }; 149 | /* End PBXProject section */ 150 | 151 | /* Begin PBXResourcesBuildPhase section */ 152 | 9724F64627BA853800C94351 /* Resources */ = { 153 | isa = PBXResourcesBuildPhase; 154 | buildActionMask = 2147483647; 155 | files = ( 156 | 9724F65827BA853900C94351 /* LaunchScreen.storyboard in Resources */, 157 | 9724F65527BA853900C94351 /* Assets.xcassets in Resources */, 158 | 9724F65327BA853800C94351 /* Main.storyboard in Resources */, 159 | ); 160 | runOnlyForDeploymentPostprocessing = 0; 161 | }; 162 | /* End PBXResourcesBuildPhase section */ 163 | 164 | /* Begin PBXShellScriptBuildPhase section */ 165 | B5C62652FBD622CDAFCEE600 /* [CP] Check Pods Manifest.lock */ = { 166 | isa = PBXShellScriptBuildPhase; 167 | buildActionMask = 2147483647; 168 | files = ( 169 | ); 170 | inputFileListPaths = ( 171 | ); 172 | inputPaths = ( 173 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 174 | "${PODS_ROOT}/Manifest.lock", 175 | ); 176 | name = "[CP] Check Pods Manifest.lock"; 177 | outputFileListPaths = ( 178 | ); 179 | outputPaths = ( 180 | "$(DERIVED_FILE_DIR)/Pods-kviewmodel-checkManifestLockResult.txt", 181 | ); 182 | runOnlyForDeploymentPostprocessing = 0; 183 | shellPath = /bin/sh; 184 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 185 | showEnvVarsInLog = 0; 186 | }; 187 | /* End PBXShellScriptBuildPhase section */ 188 | 189 | /* Begin PBXSourcesBuildPhase section */ 190 | 9724F64427BA853800C94351 /* Sources */ = { 191 | isa = PBXSourcesBuildPhase; 192 | buildActionMask = 2147483647; 193 | files = ( 194 | 9724F65027BA853800C94351 /* ViewController.swift in Sources */, 195 | 9724F64C27BA853800C94351 /* AppDelegate.swift in Sources */, 196 | 9724F64E27BA853800C94351 /* SceneDelegate.swift in Sources */, 197 | 9724F66027BAA3F200C94351 /* DetailViewController.swift in Sources */, 198 | ); 199 | runOnlyForDeploymentPostprocessing = 0; 200 | }; 201 | /* End PBXSourcesBuildPhase section */ 202 | 203 | /* Begin PBXVariantGroup section */ 204 | 9724F65127BA853800C94351 /* Main.storyboard */ = { 205 | isa = PBXVariantGroup; 206 | children = ( 207 | 9724F65227BA853800C94351 /* Base */, 208 | ); 209 | name = Main.storyboard; 210 | sourceTree = ""; 211 | }; 212 | 9724F65627BA853900C94351 /* LaunchScreen.storyboard */ = { 213 | isa = PBXVariantGroup; 214 | children = ( 215 | 9724F65727BA853900C94351 /* Base */, 216 | ); 217 | name = LaunchScreen.storyboard; 218 | sourceTree = ""; 219 | }; 220 | /* End PBXVariantGroup section */ 221 | 222 | /* Begin XCBuildConfiguration section */ 223 | 9724F65A27BA853900C94351 /* Debug */ = { 224 | isa = XCBuildConfiguration; 225 | buildSettings = { 226 | ALWAYS_SEARCH_USER_PATHS = NO; 227 | CLANG_ANALYZER_NONNULL = YES; 228 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 229 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 230 | CLANG_CXX_LIBRARY = "libc++"; 231 | CLANG_ENABLE_MODULES = YES; 232 | CLANG_ENABLE_OBJC_ARC = YES; 233 | CLANG_ENABLE_OBJC_WEAK = YES; 234 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 235 | CLANG_WARN_BOOL_CONVERSION = YES; 236 | CLANG_WARN_COMMA = YES; 237 | CLANG_WARN_CONSTANT_CONVERSION = YES; 238 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 239 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 240 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 241 | CLANG_WARN_EMPTY_BODY = YES; 242 | CLANG_WARN_ENUM_CONVERSION = YES; 243 | CLANG_WARN_INFINITE_RECURSION = YES; 244 | CLANG_WARN_INT_CONVERSION = YES; 245 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 246 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 247 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 248 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 249 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 250 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 251 | CLANG_WARN_STRICT_PROTOTYPES = YES; 252 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 253 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 254 | CLANG_WARN_UNREACHABLE_CODE = YES; 255 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 256 | COPY_PHASE_STRIP = NO; 257 | DEBUG_INFORMATION_FORMAT = dwarf; 258 | ENABLE_STRICT_OBJC_MSGSEND = YES; 259 | ENABLE_TESTABILITY = YES; 260 | GCC_C_LANGUAGE_STANDARD = gnu11; 261 | GCC_DYNAMIC_NO_PIC = NO; 262 | GCC_NO_COMMON_BLOCKS = YES; 263 | GCC_OPTIMIZATION_LEVEL = 0; 264 | GCC_PREPROCESSOR_DEFINITIONS = ( 265 | "DEBUG=1", 266 | "$(inherited)", 267 | ); 268 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 269 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 270 | GCC_WARN_UNDECLARED_SELECTOR = YES; 271 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 272 | GCC_WARN_UNUSED_FUNCTION = YES; 273 | GCC_WARN_UNUSED_VARIABLE = YES; 274 | IPHONEOS_DEPLOYMENT_TARGET = 15.2; 275 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 276 | MTL_FAST_MATH = YES; 277 | ONLY_ACTIVE_ARCH = YES; 278 | SDKROOT = iphoneos; 279 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 280 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 281 | }; 282 | name = Debug; 283 | }; 284 | 9724F65B27BA853900C94351 /* Release */ = { 285 | isa = XCBuildConfiguration; 286 | buildSettings = { 287 | ALWAYS_SEARCH_USER_PATHS = NO; 288 | CLANG_ANALYZER_NONNULL = YES; 289 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 290 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 291 | CLANG_CXX_LIBRARY = "libc++"; 292 | CLANG_ENABLE_MODULES = YES; 293 | CLANG_ENABLE_OBJC_ARC = YES; 294 | CLANG_ENABLE_OBJC_WEAK = YES; 295 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 296 | CLANG_WARN_BOOL_CONVERSION = YES; 297 | CLANG_WARN_COMMA = YES; 298 | CLANG_WARN_CONSTANT_CONVERSION = YES; 299 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 300 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 301 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 302 | CLANG_WARN_EMPTY_BODY = YES; 303 | CLANG_WARN_ENUM_CONVERSION = YES; 304 | CLANG_WARN_INFINITE_RECURSION = YES; 305 | CLANG_WARN_INT_CONVERSION = YES; 306 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 307 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 308 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 309 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 310 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 311 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 312 | CLANG_WARN_STRICT_PROTOTYPES = YES; 313 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 314 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 315 | CLANG_WARN_UNREACHABLE_CODE = YES; 316 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 317 | COPY_PHASE_STRIP = NO; 318 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 319 | ENABLE_NS_ASSERTIONS = NO; 320 | ENABLE_STRICT_OBJC_MSGSEND = YES; 321 | GCC_C_LANGUAGE_STANDARD = gnu11; 322 | GCC_NO_COMMON_BLOCKS = YES; 323 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 324 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 325 | GCC_WARN_UNDECLARED_SELECTOR = YES; 326 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 327 | GCC_WARN_UNUSED_FUNCTION = YES; 328 | GCC_WARN_UNUSED_VARIABLE = YES; 329 | IPHONEOS_DEPLOYMENT_TARGET = 15.2; 330 | MTL_ENABLE_DEBUG_INFO = NO; 331 | MTL_FAST_MATH = YES; 332 | SDKROOT = iphoneos; 333 | SWIFT_COMPILATION_MODE = wholemodule; 334 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 335 | VALIDATE_PRODUCT = YES; 336 | }; 337 | name = Release; 338 | }; 339 | 9724F65D27BA853900C94351 /* Debug */ = { 340 | isa = XCBuildConfiguration; 341 | baseConfigurationReference = C9DAAC793099CDD8DB161858 /* Pods-kviewmodel.debug.xcconfig */; 342 | buildSettings = { 343 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 344 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 345 | CODE_SIGN_STYLE = Automatic; 346 | CURRENT_PROJECT_VERSION = 1; 347 | GENERATE_INFOPLIST_FILE = YES; 348 | INFOPLIST_FILE = kviewmodel/Info.plist; 349 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 350 | INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; 351 | INFOPLIST_KEY_UIMainStoryboardFile = Main; 352 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 353 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 354 | LD_RUNPATH_SEARCH_PATHS = ( 355 | "$(inherited)", 356 | "@executable_path/Frameworks", 357 | ); 358 | MARKETING_VERSION = 1.0; 359 | PRODUCT_BUNDLE_IDENTIFIER = com.adeo.kviewmodel.example; 360 | PRODUCT_NAME = "$(TARGET_NAME)"; 361 | SWIFT_EMIT_LOC_STRINGS = YES; 362 | SWIFT_VERSION = 5.0; 363 | TARGETED_DEVICE_FAMILY = "1,2"; 364 | }; 365 | name = Debug; 366 | }; 367 | 9724F65E27BA853900C94351 /* Release */ = { 368 | isa = XCBuildConfiguration; 369 | baseConfigurationReference = 6C6DBBB2C556E538CF47E652 /* Pods-kviewmodel.release.xcconfig */; 370 | buildSettings = { 371 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 372 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 373 | CODE_SIGN_STYLE = Automatic; 374 | CURRENT_PROJECT_VERSION = 1; 375 | GENERATE_INFOPLIST_FILE = YES; 376 | INFOPLIST_FILE = kviewmodel/Info.plist; 377 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 378 | INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; 379 | INFOPLIST_KEY_UIMainStoryboardFile = Main; 380 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 381 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 382 | LD_RUNPATH_SEARCH_PATHS = ( 383 | "$(inherited)", 384 | "@executable_path/Frameworks", 385 | ); 386 | MARKETING_VERSION = 1.0; 387 | PRODUCT_BUNDLE_IDENTIFIER = com.adeo.kviewmodel.example; 388 | PRODUCT_NAME = "$(TARGET_NAME)"; 389 | SWIFT_EMIT_LOC_STRINGS = YES; 390 | SWIFT_VERSION = 5.0; 391 | TARGETED_DEVICE_FAMILY = "1,2"; 392 | }; 393 | name = Release; 394 | }; 395 | /* End XCBuildConfiguration section */ 396 | 397 | /* Begin XCConfigurationList section */ 398 | 9724F64327BA853800C94351 /* Build configuration list for PBXProject "kviewmodel" */ = { 399 | isa = XCConfigurationList; 400 | buildConfigurations = ( 401 | 9724F65A27BA853900C94351 /* Debug */, 402 | 9724F65B27BA853900C94351 /* Release */, 403 | ); 404 | defaultConfigurationIsVisible = 0; 405 | defaultConfigurationName = Release; 406 | }; 407 | 9724F65C27BA853900C94351 /* Build configuration list for PBXNativeTarget "kviewmodel" */ = { 408 | isa = XCConfigurationList; 409 | buildConfigurations = ( 410 | 9724F65D27BA853900C94351 /* Debug */, 411 | 9724F65E27BA853900C94351 /* Release */, 412 | ); 413 | defaultConfigurationIsVisible = 0; 414 | defaultConfigurationName = Release; 415 | }; 416 | /* End XCConfigurationList section */ 417 | }; 418 | rootObject = 9724F64027BA853800C94351 /* Project object */; 419 | } 420 | --------------------------------------------------------------------------------