diff --git a/app/release/app-release.apk b/app/release/app-release.apk index 163088f..a53e4f8 100644 Binary files a/app/release/app-release.apk and b/app/release/app-release.apk differ diff --git a/app/release/baselineProfiles/0/app-release.dm b/app/release/baselineProfiles/0/app-release.dm index 944caba..5cc01cf 100644 Binary files a/app/release/baselineProfiles/0/app-release.dm and b/app/release/baselineProfiles/0/app-release.dm differ diff --git a/app/release/baselineProfiles/1/app-release.dm b/app/release/baselineProfiles/1/app-release.dm index b9772ab..7a89a7b 100644 Binary files a/app/release/baselineProfiles/1/app-release.dm and b/app/release/baselineProfiles/1/app-release.dm differ diff --git a/app/src/main/java/com/kyant/glass/playground/ConfigurationBottomSheet.kt b/app/src/main/java/com/kyant/glass/playground/ConfigurationBottomSheet.kt index ce34dbe..affbc85 100644 --- a/app/src/main/java/com/kyant/glass/playground/ConfigurationBottomSheet.kt +++ b/app/src/main/java/com/kyant/glass/playground/ConfigurationBottomSheet.kt @@ -1,5 +1,6 @@ package com.kyant.glass.playground +import androidx.compose.animation.animateContentSize import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -16,7 +17,9 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import com.kyant.expressa.components.button.Button import com.kyant.expressa.components.iconbutton.IconButton +import com.kyant.expressa.m3.motion.MotionScheme import com.kyant.expressa.m3.shape.CornerShape import com.kyant.expressa.prelude.* import com.kyant.expressa.ui.Icon @@ -97,6 +100,13 @@ fun ConfigurationBottomSheet( } ConfigurationMode.Advanced -> { + Button({ state.unsafeMode = !state.unsafeMode }) { + Text( + if (state.unsafeMode) stringResource(R.string.disable_unsafe_mode) + else stringResource(R.string.enable_unsafe_mode), + Modifier.animateContentSize(MotionScheme.fastSpatial()) + ) + } SliderChip( state.bleedOpacity, stringResource(R.string.bleed_opacity), diff --git a/app/src/main/java/com/kyant/glass/playground/PreviewState.kt b/app/src/main/java/com/kyant/glass/playground/PreviewState.kt index 1248d34..6622fb0 100644 --- a/app/src/main/java/com/kyant/glass/playground/PreviewState.kt +++ b/app/src/main/java/com/kyant/glass/playground/PreviewState.kt @@ -34,6 +34,7 @@ class PreviewState { } var displayControls: Boolean by mutableStateOf(true) + var unsafeMode: Boolean by mutableStateOf(false) var imageBitmap: ImageBitmap? by mutableStateOf(null) @@ -168,15 +169,18 @@ class PreviewState { private var state: T by mutableStateOf(initialValue) + val range: ClosedRange + get() = if (unsafeMode) valueRange() else safeValueRange() + val value: T by derivedStateOf { - state.coerceIn(valueRange()) + state.coerceIn(range) } val unsafeValue: T get() = state val isValid: Boolean by derivedStateOf { - state in valueRange() + state in range } val isSafe: Boolean by derivedStateOf { @@ -184,7 +188,7 @@ class PreviewState { } val progress: Float by derivedStateOf { - val range = valueRange() + val range = range if (range.isEmpty()) { 0f } else { @@ -208,7 +212,7 @@ class PreviewState { } fun setValue(value: T) { - state = value.coerceIn(valueRange()) + state = value.coerceIn(range) } fun setFloatValue(value: Float) { @@ -216,7 +220,7 @@ class PreviewState { } fun setProgress(progress: Float) { - val range = valueRange() + val range = range val start = typeConverter.convertToVector(range.start).value val end = typeConverter.convertToVector(range.endInclusive).value setFloatValue(lerp(start, end, progress)) diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 65ff38b..aca84a4 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -9,8 +9,10 @@ 关闭 颜色 圆角半径 + 禁用不安全值 色散高度 离心系数 + 启用不安全值 高度 隐藏控件 不透明度 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3c75952..572dc58 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -9,8 +9,10 @@ Close Colors Corner radius + Disable unsafe values Dispersion height Eccentric factor + Enable unsafe values Height Hide controls Opacity