-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from icerockdev/develop
Release 0.15.0
- Loading branch information
Showing
24 changed files
with
275 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...w-compose/src/commonMain/kotlin/dev/icerock/moko/mvvm/flow/compose/MutableStateAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package dev.icerock.moko.mvvm.flow.compose | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.MutableState | ||
import androidx.compose.runtime.State | ||
import androidx.compose.runtime.collectAsState | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlin.coroutines.CoroutineContext | ||
import kotlin.coroutines.EmptyCoroutineContext | ||
|
||
class MutableStateAdapter<T>( | ||
private val state: State<T>, | ||
private val mutate: (T) -> Unit | ||
) : MutableState<T> { | ||
|
||
override var value: T | ||
get() = state.value | ||
set(value) { | ||
mutate(value) | ||
} | ||
|
||
override fun component1(): T = value | ||
override fun component2(): (T) -> Unit = { value = it } | ||
} | ||
|
||
@Composable | ||
fun <T> MutableStateFlow<T>.collectAsMutableState( | ||
context: CoroutineContext = EmptyCoroutineContext | ||
): MutableState<T> = MutableStateAdapter( | ||
state = collectAsState(context), | ||
mutate = { value = it } | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
plugins { | ||
id("android-library-convention") | ||
id("detekt-convention") | ||
id("android-publication-convention") | ||
} | ||
|
||
dependencies { | ||
api(projects.mvvmFlowResources) | ||
|
||
api(libs.material) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="dev.icerock.moko.mvvm.flow.material" /> |
34 changes: 34 additions & 0 deletions
34
...w-material/src/main/kotlin/dev/icerock/moko/mvvm/flow/material/TextInputLayoutBindings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package dev.icerock.moko.mvvm.flow.material | ||
|
||
import androidx.lifecycle.LifecycleOwner | ||
import com.google.android.material.textfield.TextInputLayout | ||
import dev.icerock.moko.mvvm.flow.CStateFlow | ||
import dev.icerock.moko.mvvm.flow.binding.bind | ||
import dev.icerock.moko.resources.desc.StringDesc | ||
import kotlinx.coroutines.DisposableHandle | ||
|
||
@JvmName("bindErrorString") | ||
fun <T : String?> TextInputLayout.bindError( | ||
lifecycleOwner: LifecycleOwner, | ||
flow: CStateFlow<T?> | ||
): DisposableHandle { | ||
return flow.bind(lifecycleOwner) { | ||
error = it | ||
isErrorEnabled = it != null | ||
} | ||
} | ||
|
||
@JvmName("bindErrorStringDesc") | ||
fun <T : StringDesc?> TextInputLayout.bindError( | ||
lifecycleOwner: LifecycleOwner, | ||
flow: CStateFlow<T?> | ||
): DisposableHandle { | ||
return flow.bind(lifecycleOwner) { | ||
error = it?.toString(context) | ||
isErrorEnabled = it != null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.