Convert FavDialogTheta to use rememberInDataStore
This commit is contained in:
1 parent
cdbe3cf728
commit
fe1249630b
2 files changed
+1
-6
No files matched your search
@@ -170,7 +170,6 @@ object Settings : DataStorePreferences(null) {
|
||||
var displayName by stringOrNullPref("display_name", null)
|
||||
var language by stringPref("app_language", "system").observed { updateWhenLocaleChanges() }
|
||||
var lastUpdateTime by longPref("last_update_time", 0)
|
||||
var favDialogTheta by floatPref("fav_select_dialog_delta", 0F)
|
||||
|
||||
// TODO: Remove this after swipe gestures are correctly handled in compose
|
||||
var touchSlopFactor = intPref("touch_slop", 3)
|
||||
|
||||
@@ -7,13 +7,11 @@ import androidx.compose.foundation.gestures.rememberDraggable2DState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableFloatStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.layout.Layout
|
||||
import com.hippo.ehviewer.Settings
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.atan2
|
||||
import kotlin.math.cos
|
||||
@@ -38,7 +36,7 @@ fun CircularLayout(
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
var delta by remember { mutableFloatStateOf(Settings.favDialogTheta) }
|
||||
var delta by rememberInDataStore("FavDialogTheta") { mutableFloatStateOf(0F) }
|
||||
val state = rememberDraggable2DState {
|
||||
val prevOfs = currentOfs
|
||||
val prevTheta = currentTheta
|
||||
@@ -72,12 +70,10 @@ fun CircularLayout(
|
||||
animateDecay(delta, omega, rotateDecay) { d, _ ->
|
||||
delta = d
|
||||
}
|
||||
Settings.favDialogTheta = delta
|
||||
}
|
||||
}
|
||||
currentOfs = null
|
||||
currentTheta = null
|
||||
Settings.favDialogTheta = delta
|
||||
},
|
||||
),
|
||||
content = content,
|
||||
|
||||
Reference in new issue
Block a user