From 354e2351b7d68f08ef29d54f9eacdfd4f54566f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9luchu?= Date: Wed, 30 Aug 2023 14:09:17 +0200 Subject: [PATCH] Separate numbers type for remembers --- gradle/libs.versions.toml | 6 +- jchucomponents-core/build.gradle | 2 +- jchucomponents-ktx/build.gradle | 2 +- jchucomponents-prefs/build.gradle | 2 +- jchucomponents-qr/build.gradle | 2 +- jchucomponents-ui/build.gradle | 2 +- .../remember/RememberCountdownTimer.kt | 2 - .../remember/RememberMutableDoubleStateOf.kt | 130 +++++++++++++++++ .../remember/RememberMutableFloatStateOf.kt | 131 ++++++++++++++++++ .../remember/RememberMutableIntStateOf.kt | 130 +++++++++++++++++ .../remember/RememberMutableLongStateOf.kt | 130 +++++++++++++++++ 11 files changed, 529 insertions(+), 10 deletions(-) create mode 100644 jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberMutableDoubleStateOf.kt create mode 100644 jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberMutableFloatStateOf.kt create mode 100644 jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberMutableIntStateOf.kt create mode 100644 jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberMutableLongStateOf.kt diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a5bba497..3600397f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,8 +6,8 @@ androidx-compose-material = "1.5.0" androidx-compose-runtime = "1.5.0" androidx-compose-ui = "1.5.0" androidx-lifecycle = "2.6.1" -androidx-navigation = "2.7.0" -com-google-accompanist = "0.31.6-rc" +androidx-navigation = "2.7.1" +com-google-accompanist = "0.32.0" com-squareup-okhttp3 = "4.11.0" com-squareup-retrofit2 = "2.9.0" io-coil-kt = "2.4.0" @@ -36,7 +36,7 @@ androidx-lifecycle-lifecycle-livedata-core-ktx = { module = "androidx.lifecycle: androidx-lifecycle-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle" } androidx-navigation-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "androidx-navigation" } androidx-preference = "androidx.preference:preference-ktx:1.2.1" -com-android-tools-build-gradle = "com.android.tools.build:gradle:8.1.0" +com-android-tools-build-gradle = "com.android.tools.build:gradle:8.1.1" com-google-accompanist-accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "com-google-accompanist" } com-google-android-gms-play-services-base = "com.google.android.gms:play-services-base:18.2.0" com-google-code-gson = "com.google.code.gson:gson:2.10.1" diff --git a/jchucomponents-core/build.gradle b/jchucomponents-core/build.gradle index d6e4f8d7..6979604e 100644 --- a/jchucomponents-core/build.gradle +++ b/jchucomponents-core/build.gradle @@ -50,7 +50,7 @@ afterEvaluate { from components.release groupId = "com.github.jeluchu" artifactId = "jchucomponents-core" - version = "1.8.3" + version = "1.8.5" } } } diff --git a/jchucomponents-ktx/build.gradle b/jchucomponents-ktx/build.gradle index 4c96f961..0adfa079 100644 --- a/jchucomponents-ktx/build.gradle +++ b/jchucomponents-ktx/build.gradle @@ -45,7 +45,7 @@ afterEvaluate { from components.release groupId = "com.github.jeluchu" artifactId = "jchucomponents-ktx" - version = "1.8.3" + version = "1.8.5" } } } diff --git a/jchucomponents-prefs/build.gradle b/jchucomponents-prefs/build.gradle index e82f5712..ea384d58 100644 --- a/jchucomponents-prefs/build.gradle +++ b/jchucomponents-prefs/build.gradle @@ -46,7 +46,7 @@ afterEvaluate { from components.release groupId = "com.github.jeluchu" artifactId = "jchucomponents-prefs" - version = "1.8.3" + version = "1.8.5" } } } diff --git a/jchucomponents-qr/build.gradle b/jchucomponents-qr/build.gradle index 7284569e..c349d798 100644 --- a/jchucomponents-qr/build.gradle +++ b/jchucomponents-qr/build.gradle @@ -42,7 +42,7 @@ afterEvaluate { from components.release groupId = "com.github.jeluchu" artifactId = "jchucomponents-qr" - version = "1.8.3" + version = "1.8.5" } } } diff --git a/jchucomponents-ui/build.gradle b/jchucomponents-ui/build.gradle index d7b0b9a2..f1e68347 100644 --- a/jchucomponents-ui/build.gradle +++ b/jchucomponents-ui/build.gradle @@ -48,7 +48,7 @@ afterEvaluate { from components.release groupId = "com.github.jeluchu" artifactId = "jchucomponents-ui" - version = "1.8.3" + version = "1.8.5" } } } diff --git a/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberCountdownTimer.kt b/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberCountdownTimer.kt index 434e5a45..70b56689 100644 --- a/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberCountdownTimer.kt +++ b/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberCountdownTimer.kt @@ -3,8 +3,6 @@ package com.jeluchu.jchucomponents.ui.runtime.remember import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember import androidx.compose.runtime.withFrameMillis import kotlinx.coroutines.delay import kotlinx.coroutines.isActive diff --git a/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberMutableDoubleStateOf.kt b/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberMutableDoubleStateOf.kt new file mode 100644 index 00000000..dea47508 --- /dev/null +++ b/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberMutableDoubleStateOf.kt @@ -0,0 +1,130 @@ +/* + * + * Copyright 2022 Jeluchu + * + */ + +@file:Suppress("unused") + +package com.jeluchu.jchucomponents.ui.runtime.remember + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.MutableDoubleState +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.State +import androidx.compose.runtime.mutableDoubleStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.snapshots.Snapshot + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableDoubleState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableDoubleState] + * + * @see State + * @see MutableDoubleState + */ +@Composable +fun rememberMutableDoubleStateOf( + value: Double, +): MutableDoubleState = remember { mutableDoubleStateOf(value) } + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableDoubleState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableDoubleState] + * + * @see State + * @see MutableDoubleState + */ +@Composable +fun rememberMutableDoubleStateOf( + key1: Any?, + value: Double +): MutableDoubleState = remember(key1) { mutableDoubleStateOf(value) } + + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableDoubleState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableDoubleState] + * + * @see State + * @see MutableDoubleState + */ +@Composable +fun rememberMutableDoubleStateOf( + key1: Any?, + key2: Any?, + value: Double +): MutableDoubleState = remember(key1, key2) { mutableDoubleStateOf(value) } + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableDoubleState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableDoubleState] + * + * @see State + * @see MutableState + */ +@Composable +fun rememberMutableDoubleStateOf( + key1: Any?, + key2: Any?, + key3: Any?, + value: Double +): MutableDoubleState = remember(key1, key2, key3) { mutableDoubleStateOf(value) } + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableDoubleState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableDoubleState] + * + * @see State + * @see MutableDoubleState + */ +@Composable +fun rememberMutableDoubleStateOf( + vararg keys: Any?, + value: Double +): MutableDoubleState = remember(keys) { mutableDoubleStateOf(value) } \ No newline at end of file diff --git a/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberMutableFloatStateOf.kt b/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberMutableFloatStateOf.kt new file mode 100644 index 00000000..84b9806a --- /dev/null +++ b/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberMutableFloatStateOf.kt @@ -0,0 +1,131 @@ +/* + * + * Copyright 2022 Jeluchu + * + */ + +@file:Suppress("unused") + +package com.jeluchu.jchucomponents.ui.runtime.remember + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.MutableFloatState +import androidx.compose.runtime.MutableLongState +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.State +import androidx.compose.runtime.mutableFloatStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.snapshots.Snapshot + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableLongState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableLongState] + * + * @see State + * @see MutableLongState + */ +@Composable +fun rememberMutableFloatStateOf( + value: Float +): MutableFloatState = remember { mutableFloatStateOf(value) } + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableLongState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableLongState] + * + * @see State + * @see MutableLongState + */ +@Composable +fun rememberMutableFloatStateOf( + key1: Any?, + value: Float +): MutableFloatState = remember(key1) { mutableFloatStateOf(value) } + + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableLongState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableLongState] + * + * @see State + * @see MutableLongState + */ +@Composable +fun rememberMutableFloatStateOf( + key1: Any?, + key2: Any?, + value: Float +): MutableFloatState = remember(key1, key2) { mutableFloatStateOf(value) } + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableLongState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableLongState] + * + * @see State + * @see MutableState + */ +@Composable +fun rememberMutableFloatStateOf( + key1: Any?, + key2: Any?, + key3: Any?, + value: Float +): MutableFloatState = remember(key1, key2, key3) { mutableFloatStateOf(value) } + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableLongState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableLongState] + * + * @see State + * @see MutableLongState + */ +@Composable +fun rememberMutableFloatStateOf( + vararg keys: Any?, + value: Float +): MutableFloatState = remember(keys) { mutableFloatStateOf(value) } \ No newline at end of file diff --git a/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberMutableIntStateOf.kt b/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberMutableIntStateOf.kt new file mode 100644 index 00000000..a6f85bc5 --- /dev/null +++ b/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberMutableIntStateOf.kt @@ -0,0 +1,130 @@ +/* + * + * Copyright 2022 Jeluchu + * + */ + +@file:Suppress("unused") + +package com.jeluchu.jchucomponents.ui.runtime.remember + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.MutableIntState +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.State +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.snapshots.Snapshot + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableIntState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableIntState] + * + * @see State + * @see MutableIntState + */ +@Composable +fun rememberMutableIntStateOf( + value: Int, +): MutableIntState = remember { mutableIntStateOf(value) } + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableIntState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableIntState] + * + * @see State + * @see MutableIntState + */ +@Composable +fun rememberMutableIntStateOf( + key1: Any?, + value: Int +): MutableIntState = remember(key1) { mutableIntStateOf(value) } + + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableIntState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableIntState] + * + * @see State + * @see MutableIntState + */ +@Composable +fun rememberMutableIntStateOf( + key1: Any?, + key2: Any?, + value: Int +): MutableIntState = remember(key1, key2) { mutableIntStateOf(value) } + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableIntState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableIntState] + * + * @see State + * @see MutableState + */ +@Composable +fun rememberMutableIntStateOf( + key1: Any?, + key2: Any?, + key3: Any?, + value: Int +): MutableIntState = remember(key1, key2, key3) { mutableIntStateOf(value) } + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableIntState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableIntState] + * + * @see State + * @see MutableIntState + */ +@Composable +fun rememberMutableIntStateOf( + vararg keys: Any?, + value: Int +): MutableIntState = remember(keys) { mutableIntStateOf(value) } \ No newline at end of file diff --git a/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberMutableLongStateOf.kt b/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberMutableLongStateOf.kt new file mode 100644 index 00000000..afb3afed --- /dev/null +++ b/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/runtime/remember/RememberMutableLongStateOf.kt @@ -0,0 +1,130 @@ +/* + * + * Copyright 2022 Jeluchu + * + */ + +@file:Suppress("unused") + +package com.jeluchu.jchucomponents.ui.runtime.remember + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.MutableLongState +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.State +import androidx.compose.runtime.mutableLongStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.snapshots.Snapshot + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableLongState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableLongState] + * + * @see State + * @see MutableLongState + */ +@Composable +fun rememberMutableLongStateOf( + value: Long +): MutableLongState = remember { mutableLongStateOf(value) } + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableLongState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableLongState] + * + * @see State + * @see MutableLongState + */ +@Composable +fun rememberMutableLongStateOf( + key1: Any?, + value: Long +): MutableLongState = remember(key1) { mutableLongStateOf(value) } + + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableLongState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableLongState] + * + * @see State + * @see MutableLongState + */ +@Composable +fun rememberMutableLongStateOf( + key1: Any?, + key2: Any?, + value: Long +): MutableLongState = remember(key1, key2) { mutableLongStateOf(value) } + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableLongState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableLongState] + * + * @see State + * @see MutableState + */ +@Composable +fun rememberMutableLongStateOf( + key1: Any?, + key2: Any?, + key3: Any?, + value: Long +): MutableLongState = remember(key1, key2, key3) { mutableLongStateOf(value) } + +/** + * + * This is an overload for the original method. + * If you have any questions, please see the documentation of the original method + * + * Remember a new [MutableLongState] initialized with the passed in [value] + * + * The MutableState class is a single value holder whose reads and writes are observed by + * Compose. + * Additionally, writes to it is transacted as part of the [Snapshot] system. + * + * @param value the initial value for the [MutableLongState] + * + * @see State + * @see MutableLongState + */ +@Composable +fun rememberMutableLongStateOf( + vararg keys: Any?, + value: Long +): MutableLongState = remember(keys) { mutableLongStateOf(value) } \ No newline at end of file