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
@Composable | |
internal fun CoordinatedScroll( | |
collapsingAreaHeightPx: MutableState<Float> = remember { mutableStateOf(0f) }, | |
content: @Composable (Float, NestedScrollConnection) -> Unit | |
) { | |
val toolbarOffsetHeightPx = remember { mutableStateOf(0f) } | |
val currentAbsoluteOffsetPx = remember { mutableStateOf(0f) } | |
val nestedScrollConnection = remember { | |
object : NestedScrollConnection { |
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
fun Modifier.clickableSingle( | |
enabled: Boolean = true, | |
onClickLabel: String? = null, | |
role: Role? = null, | |
onClick: () -> Unit | |
) = composed( | |
inspectorInfo = debugInspectorInfo { | |
name = "clickable" | |
properties["enabled"] = enabled | |
properties["onClickLabel"] = onClickLabel |
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
internal interface MultipleEventsCutter { | |
fun processEvent(event: () -> Unit) | |
companion object | |
} | |
internal fun MultipleEventsCutter.Companion.get(): MultipleEventsCutter = | |
MultipleEventsCutterImpl() | |
private class MultipleEventsCutterImpl : MultipleEventsCutter { |
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
multipleEventsCutter { manager -> | |
Card( | |
onClick = { manager.processEvent {...} } | |
) { | |
... | |
} | |
} |
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
Row( | |
modifier = modifier.clickableSingle(onClick = { ... }), | |
) { | |
... | |
} |
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
fun Modifier.clickableSingle( | |
enabled: Boolean = true, | |
onClickLabel: String? = null, | |
role: Role? = null, | |
onClick: () -> Unit | |
) = composed( | |
inspectorInfo = debugInspectorInfo { | |
name = "clickable" | |
properties["enabled"] = enabled | |
properties["onClickLabel"] = onClickLabel |
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
interface MultipleEventsCutterManager { | |
fun processEvent(event: () -> Unit) | |
} | |
@OptIn(FlowPreview::class) | |
@Composable | |
fun <T>multipleEventsCutter( | |
content: @Composable (MultipleEventsCutterManager) -> T | |
) : T { | |
val debounceState = remember { |
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
private var a: Int by LazyMutable { getAValue() } | |
private fun getAValue(): Int { | |
return 5 | |
} |
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
class LazyMutable<T>(val initializer: () -> T) { | |
private object UninitializedValue | |
@Volatile private var propValue: Any? = UninitializedValue | |
@Suppress("UNCHECKED_CAST") | |
operator fun getValue(thisRef: Any?, property: KProperty<*>): T { | |
val localValue = propValue | |
if(localValue != UninitializedValue) { | |
return localValue as T |
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
private var a: Int by lazy { getAValue() } | |
private fun getAValue(): Int { | |
return 5 | |
} |