mirror of
https://github.com/florisboard/florisboard.git
synced 2024-09-19 19:42:20 +02:00
Fix usage of deprecated compose API
This commit is contained in:
parent
11d4ea206d
commit
777bf48b50
@ -35,6 +35,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableLongStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.Saver
|
||||
@ -124,7 +125,7 @@ private class SubtypeEditorState(init: Subtype?) {
|
||||
)
|
||||
}
|
||||
|
||||
val id: MutableState<Long> = mutableStateOf(init?.id ?: -1)
|
||||
val id: MutableState<Long> = mutableLongStateOf(init?.id ?: -1)
|
||||
val primaryLocale: MutableState<FlorisLocale> = mutableStateOf(init?.primaryLocale ?: SelectLocale)
|
||||
val secondaryLocales: MutableState<List<FlorisLocale>> = mutableStateOf(init?.secondaryLocales ?: listOf())
|
||||
val nlpProviders: MutableState<SubtypeNlpProviderMap> = mutableStateOf(init?.nlpProviders ?: Subtype.DEFAULT.nlpProviders)
|
||||
|
@ -37,6 +37,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
@ -365,7 +366,7 @@ private fun PropertyValueEditor(
|
||||
listOf("") + definedVariables.keys.toList()
|
||||
}
|
||||
val selectedIndex by remember(variableKeys, value.key) {
|
||||
mutableStateOf(variableKeys.indexOf(value.key).coerceIn(variableKeys.indices))
|
||||
mutableIntStateOf(variableKeys.indexOf(value.key).coerceIn(variableKeys.indices))
|
||||
}
|
||||
var expanded by remember { mutableStateOf(false) }
|
||||
Row(
|
||||
@ -528,7 +529,7 @@ private fun PropertyValueEditor(
|
||||
}
|
||||
|
||||
val selectedIndex by remember(value.colorName) {
|
||||
mutableStateOf(
|
||||
mutableIntStateOf(
|
||||
MaterialYouColor.colorNames.indexOf(value.colorName).coerceIn(MaterialYouColor.colorNames.indices)
|
||||
)
|
||||
}
|
||||
@ -756,13 +757,13 @@ private fun PropertyValueEditor(
|
||||
|
||||
is SnyggPercentShapeValue -> {
|
||||
var showDialogInitPercentage by rememberSaveable {
|
||||
mutableStateOf(0)
|
||||
mutableIntStateOf(0)
|
||||
}
|
||||
var showDialogForCorner by rememberSaveable {
|
||||
mutableStateOf<ShapeCorner?>(null)
|
||||
}
|
||||
var topStart by rememberSaveable {
|
||||
mutableStateOf(
|
||||
mutableIntStateOf(
|
||||
when (value) {
|
||||
is SnyggCutCornerPercentShapeValue -> value.topStart
|
||||
is SnyggRoundedCornerPercentShapeValue -> value.topStart
|
||||
@ -770,7 +771,7 @@ private fun PropertyValueEditor(
|
||||
)
|
||||
}
|
||||
var topEnd by rememberSaveable {
|
||||
mutableStateOf(
|
||||
mutableIntStateOf(
|
||||
when (value) {
|
||||
is SnyggCutCornerPercentShapeValue -> value.topEnd
|
||||
is SnyggRoundedCornerPercentShapeValue -> value.topEnd
|
||||
@ -778,7 +779,7 @@ private fun PropertyValueEditor(
|
||||
)
|
||||
}
|
||||
var bottomEnd by rememberSaveable {
|
||||
mutableStateOf(
|
||||
mutableIntStateOf(
|
||||
when (value) {
|
||||
is SnyggCutCornerPercentShapeValue -> value.bottomEnd
|
||||
is SnyggRoundedCornerPercentShapeValue -> value.bottomEnd
|
||||
@ -786,7 +787,7 @@ private fun PropertyValueEditor(
|
||||
)
|
||||
}
|
||||
var bottomStart by rememberSaveable {
|
||||
mutableStateOf(
|
||||
mutableIntStateOf(
|
||||
when (value) {
|
||||
is SnyggCutCornerPercentShapeValue -> value.bottomStart
|
||||
is SnyggRoundedCornerPercentShapeValue -> value.bottomStart
|
||||
|
@ -25,8 +25,11 @@ import androidx.compose.animation.core.infiniteRepeatable
|
||||
import androidx.compose.animation.core.rememberInfiniteTransition
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
@ -46,6 +49,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
@ -61,7 +65,6 @@ import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.font.FontStyle
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.google.accompanist.flowlayout.FlowRow
|
||||
import dev.patrickgold.florisboard.R
|
||||
import dev.patrickgold.florisboard.ime.input.InputKeyEventReceiver
|
||||
import dev.patrickgold.florisboard.ime.keyboard.ComputingEvaluator
|
||||
@ -100,6 +103,7 @@ private val TransparentTextSelectionColors = TextSelectionColors(
|
||||
)
|
||||
internal val SnyggEmptyRuleForAdding = SnyggRule(element = "- select -")
|
||||
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
internal fun EditRuleDialog(
|
||||
initRule: SnyggRule,
|
||||
@ -119,7 +123,7 @@ internal fun EditRuleDialog(
|
||||
var elementsExpanded by remember { mutableStateOf(false) }
|
||||
var elementsSelectedIndex by rememberSaveable {
|
||||
val index = possibleElementNames.indexOf(initRule.element).coerceIn(possibleElementNames.indices)
|
||||
mutableStateOf(index)
|
||||
mutableIntStateOf(index)
|
||||
}
|
||||
|
||||
val codes = rememberSaveable(saver = IntListSaver) { initRule.codes.toMutableStateList() }
|
||||
@ -269,7 +273,7 @@ internal fun EditRuleDialog(
|
||||
}
|
||||
|
||||
DialogProperty(text = stringRes(R.string.settings__theme_editor__rule_shift_states)) {
|
||||
FlowRow(mainAxisSpacing = 4.dp) {
|
||||
FlowRow(horizontalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||
FlorisChip(
|
||||
onClick = { shiftStateUnshifted = !shiftStateUnshifted },
|
||||
text = when (level) {
|
||||
@ -349,7 +353,7 @@ private fun EditCodeValueDialog(
|
||||
}
|
||||
var showKeyCodesHelp by rememberSaveable(codeValue) { mutableStateOf(false) }
|
||||
var showError by rememberSaveable(codeValue) { mutableStateOf(false) }
|
||||
var errorId by rememberSaveable(codeValue) { mutableStateOf(NATIVE_NULLPTR.toInt()) }
|
||||
var errorId by rememberSaveable(codeValue) { mutableIntStateOf(NATIVE_NULLPTR.toInt()) }
|
||||
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
val isFlorisBoardEnabled by InputMethodUtils.observeIsFlorisboardEnabled(foregroundOnly = true)
|
||||
|
@ -21,6 +21,7 @@ import android.icu.lang.UCharacter
|
||||
import android.view.KeyEvent
|
||||
import android.widget.Toast
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
@ -96,7 +97,7 @@ class KeyboardManager(context: Context) : InputKeyEventReceiver {
|
||||
|
||||
val resources = KeyboardManagerResources()
|
||||
val activeState = ObservableKeyboardState.new()
|
||||
var smartbarVisibleDynamicActionsCount by mutableStateOf(0)
|
||||
var smartbarVisibleDynamicActionsCount by mutableIntStateOf(0)
|
||||
private var lastToastReference = WeakReference<Toast>(null)
|
||||
|
||||
private val activeEvaluatorGuard = Mutex(locked = false)
|
||||
|
@ -17,8 +17,8 @@
|
||||
package dev.patrickgold.florisboard.ime.media
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.compose.foundation.gestures.awaitEachGesture
|
||||
import androidx.compose.foundation.gestures.awaitFirstDown
|
||||
import androidx.compose.foundation.gestures.forEachGesture
|
||||
import androidx.compose.foundation.gestures.waitForUpOrCancellation
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
@ -59,7 +59,6 @@ import dev.patrickgold.florisboard.ime.theme.FlorisImeTheme
|
||||
import dev.patrickgold.florisboard.ime.theme.FlorisImeUi
|
||||
import dev.patrickgold.florisboard.keyboardManager
|
||||
import dev.patrickgold.florisboard.lib.snygg.ui.SnyggSurface
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
|
||||
@SuppressLint("MutableCollectionMutableState")
|
||||
@Composable
|
||||
@ -126,23 +125,19 @@ internal fun KeyboardLikeButton(
|
||||
)
|
||||
SnyggSurface(
|
||||
modifier = modifier.pointerInput(Unit) {
|
||||
forEachGesture {
|
||||
coroutineScope {
|
||||
awaitPointerEventScope {
|
||||
awaitFirstDown(requireUnconsumed = false).also {
|
||||
if (it.pressed != it.previousPressed) it.consume()
|
||||
}
|
||||
isPressed = true
|
||||
inputEventDispatcher.sendDown(keyData)
|
||||
inputFeedbackController.keyPress(keyData)
|
||||
val up = waitForUpOrCancellation()
|
||||
isPressed = false
|
||||
if (up != null) {
|
||||
inputEventDispatcher.sendUp(keyData)
|
||||
} else {
|
||||
inputEventDispatcher.sendCancel(keyData)
|
||||
}
|
||||
}
|
||||
awaitEachGesture {
|
||||
awaitFirstDown(requireUnconsumed = false).also {
|
||||
if (it.pressed != it.previousPressed) it.consume()
|
||||
}
|
||||
isPressed = true
|
||||
inputEventDispatcher.sendDown(keyData)
|
||||
inputFeedbackController.keyPress(keyData)
|
||||
val up = waitForUpOrCancellation()
|
||||
isPressed = false
|
||||
if (up != null) {
|
||||
inputEventDispatcher.sendUp(keyData)
|
||||
} else {
|
||||
inputEventDispatcher.sendCancel(keyData)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -24,6 +24,8 @@ import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.gestures.detectTapGestures
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
@ -52,6 +54,7 @@ import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.key
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
@ -75,7 +78,6 @@ import androidx.compose.ui.viewinterop.AndroidView
|
||||
import androidx.compose.ui.window.Popup
|
||||
import androidx.emoji2.text.EmojiCompat
|
||||
import androidx.emoji2.widget.EmojiTextView
|
||||
import com.google.accompanist.flowlayout.FlowRow
|
||||
import dev.patrickgold.florisboard.R
|
||||
import dev.patrickgold.florisboard.app.florisPreferenceModel
|
||||
import dev.patrickgold.florisboard.editorInstance
|
||||
@ -86,7 +88,6 @@ import dev.patrickgold.florisboard.ime.theme.FlorisImeTheme
|
||||
import dev.patrickgold.florisboard.ime.theme.FlorisImeUi
|
||||
import dev.patrickgold.florisboard.keyboardManager
|
||||
import dev.patrickgold.florisboard.lib.android.showShortToast
|
||||
import dev.patrickgold.florisboard.lib.compose.florisScrollbar
|
||||
import dev.patrickgold.florisboard.lib.compose.safeTimes
|
||||
import dev.patrickgold.florisboard.lib.compose.stringRes
|
||||
import dev.patrickgold.florisboard.lib.snygg.ui.snyggBackground
|
||||
@ -170,7 +171,7 @@ fun EmojiPaletteView(
|
||||
.fillMaxWidth()
|
||||
.weight(1f),
|
||||
) {
|
||||
var recentlyUsedVersion by remember { mutableStateOf(0) }
|
||||
var recentlyUsedVersion by remember { mutableIntStateOf(0) }
|
||||
val emojiMapping = if (activeCategory == EmojiCategory.RECENTLY_USED) {
|
||||
// Purposely using remember here to prevent recomposition, as this would cause rapid
|
||||
// emoji changes for the user when in recently used category.
|
||||
@ -367,6 +368,7 @@ private fun EmojiKey(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
private fun EmojiVariationsPopup(
|
||||
variations: List<Emoji>,
|
||||
|
@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.absoluteOffset
|
||||
import androidx.compose.foundation.layout.requiredSize
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
@ -76,7 +77,7 @@ class PopupUiController(
|
||||
private var baseRenderInfo by mutableStateOf<BaseRenderInfo?>(null)
|
||||
private var extRenderInfo by mutableStateOf<ExtRenderInfo?>(null)
|
||||
|
||||
private var activeElementIndex by mutableStateOf(-1)
|
||||
private var activeElementIndex by mutableIntStateOf(-1)
|
||||
var evaluator: ComputingEvaluator = DefaultComputingEvaluator
|
||||
var fontSizeMultiplier: Float = 1.0f
|
||||
var keyHintConfiguration: KeyHintConfiguration = KeyHintConfiguration.HINTS_DISABLED
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
package dev.patrickgold.florisboard.ime.smartbar
|
||||
|
||||
import androidx.compose.foundation.gestures.awaitEachGesture
|
||||
import androidx.compose.foundation.gestures.awaitFirstDown
|
||||
import androidx.compose.foundation.gestures.forEachGesture
|
||||
import androidx.compose.foundation.gestures.waitForUpOrCancellation
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@ -195,29 +195,27 @@ private fun CandidateItem(
|
||||
modifier = modifier
|
||||
.snyggBackground(context, style)
|
||||
.pointerInput(Unit) {
|
||||
forEachGesture {
|
||||
awaitPointerEventScope {
|
||||
val down = awaitFirstDown()
|
||||
isPressed = true
|
||||
if (down.pressed != down.previousPressed) down.consume()
|
||||
var upOrCancel: PointerInputChange? = null
|
||||
try {
|
||||
upOrCancel = withTimeout(longPressDelay) {
|
||||
waitForUpOrCancellation()
|
||||
}
|
||||
upOrCancel?.let { if (it.pressed != it.previousPressed) it.consume() }
|
||||
} catch (_: PointerEventTimeoutCancellationException) {
|
||||
if (onLongPress()) {
|
||||
upOrCancel = null
|
||||
isPressed = false
|
||||
}
|
||||
waitForUpOrCancellation()?.let { if (it.pressed != it.previousPressed) it.consume() }
|
||||
awaitEachGesture {
|
||||
val down = awaitFirstDown()
|
||||
isPressed = true
|
||||
if (down.pressed != down.previousPressed) down.consume()
|
||||
var upOrCancel: PointerInputChange? = null
|
||||
try {
|
||||
upOrCancel = withTimeout(longPressDelay) {
|
||||
waitForUpOrCancellation()
|
||||
}
|
||||
if (upOrCancel != null) {
|
||||
onClick()
|
||||
upOrCancel?.let { if (it.pressed != it.previousPressed) it.consume() }
|
||||
} catch (_: PointerEventTimeoutCancellationException) {
|
||||
if (onLongPress()) {
|
||||
upOrCancel = null
|
||||
isPressed = false
|
||||
}
|
||||
isPressed = false
|
||||
waitForUpOrCancellation()?.let { if (it.pressed != it.previousPressed) it.consume() }
|
||||
}
|
||||
if (upOrCancel != null) {
|
||||
onClick()
|
||||
}
|
||||
isPressed = false
|
||||
}
|
||||
}
|
||||
.padding(horizontal = 12.dp),
|
||||
|
@ -21,8 +21,8 @@ import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.LocalIndication
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.gestures.awaitEachGesture
|
||||
import androidx.compose.foundation.gestures.awaitFirstDown
|
||||
import androidx.compose.foundation.gestures.forEachGesture
|
||||
import androidx.compose.foundation.gestures.waitForUpOrCancellation
|
||||
import androidx.compose.foundation.indication
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
@ -153,23 +153,21 @@ fun QuickActionButton(
|
||||
.snyggClip(actionStyle)
|
||||
.indication(interactionSource, LocalIndication.current)
|
||||
.pointerInput(action, isEnabled) {
|
||||
forEachGesture {
|
||||
awaitPointerEventScope {
|
||||
val down = awaitFirstDown()
|
||||
down.consume()
|
||||
if (isEnabled && type != QabType.STATIC_TILE) {
|
||||
val press = PressInteraction.Press(down.position)
|
||||
interactionSource.tryEmit(press)
|
||||
action.onPointerDown(context)
|
||||
val up = waitForUpOrCancellation()
|
||||
if (up != null) {
|
||||
up.consume()
|
||||
interactionSource.tryEmit(PressInteraction.Release(press))
|
||||
action.onPointerUp(context)
|
||||
} else {
|
||||
interactionSource.tryEmit(PressInteraction.Cancel(press))
|
||||
action.onPointerCancel(context)
|
||||
}
|
||||
awaitEachGesture {
|
||||
val down = awaitFirstDown()
|
||||
down.consume()
|
||||
if (isEnabled && type != QabType.STATIC_TILE) {
|
||||
val press = PressInteraction.Press(down.position)
|
||||
interactionSource.tryEmit(press)
|
||||
action.onPointerDown(context)
|
||||
val up = waitForUpOrCancellation()
|
||||
if (up != null) {
|
||||
up.consume()
|
||||
interactionSource.tryEmit(PressInteraction.Release(press))
|
||||
action.onPointerUp(context)
|
||||
} else {
|
||||
interactionSource.tryEmit(PressInteraction.Cancel(press))
|
||||
action.onPointerCancel(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableFloatStateOf
|
||||
import androidx.compose.runtime.mutableStateListOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
@ -464,7 +465,7 @@ private class TextKeyboardLayoutController(
|
||||
val glideTypingDetector = GlideTypingGesture.Detector(context)
|
||||
val glideDataForDrawing = mutableStateListOf<Pair<GlideTypingGesture.Detector.Position, Long>>()
|
||||
val fadingGlide = mutableStateListOf<Pair<GlideTypingGesture.Detector.Position, Long>>()
|
||||
var fadingGlideRadius by mutableStateOf(0.0f)
|
||||
var fadingGlideRadius by mutableFloatStateOf(0.0f)
|
||||
private val swipeGestureDetector = SwipeGesture.Detector(this)
|
||||
|
||||
lateinit var keyboard: TextKeyboard
|
||||
|
@ -20,6 +20,7 @@ import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.provider.OpenableColumns
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.neverEqualPolicy
|
||||
import androidx.compose.runtime.setValue
|
||||
@ -188,7 +189,7 @@ class CacheManager(context: Context) {
|
||||
var currentAction by mutableStateOf<EditorAction?>(null)
|
||||
var ext: Extension? = null
|
||||
var editor by mutableStateOf<T?>(null, neverEqualPolicy())
|
||||
var version by mutableStateOf(0)
|
||||
var version by mutableIntStateOf(0)
|
||||
|
||||
val isModified get() = version > 0
|
||||
|
||||
|
@ -46,6 +46,7 @@ import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.key
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.Saver
|
||||
import androidx.compose.ui.Alignment
|
||||
@ -116,17 +117,17 @@ class FlorisStepLayoutScope(
|
||||
@Suppress("unused")
|
||||
class FlorisStepState private constructor(
|
||||
private val currentAuto: MutableState<Int>,
|
||||
private val currentManual: MutableState<Int> = mutableStateOf(-1),
|
||||
private val currentManual: MutableState<Int> = mutableIntStateOf(-1),
|
||||
) {
|
||||
companion object {
|
||||
fun new(init: Int) = FlorisStepState(mutableStateOf(init))
|
||||
fun new(init: Int) = FlorisStepState(mutableIntStateOf(init))
|
||||
|
||||
val Saver = Saver<FlorisStepState, ArrayList<Int>>(
|
||||
save = {
|
||||
arrayListOf(it.currentAuto.value, it.currentManual.value)
|
||||
},
|
||||
restore = {
|
||||
FlorisStepState(mutableStateOf(it[0]), mutableStateOf(it[1]))
|
||||
FlorisStepState(mutableIntStateOf(it[0]), mutableIntStateOf(it[1]))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user