Compare commits
2 Commits
feature/IS
...
6cba0674cf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cba0674cf | ||
|
|
b87d911cea |
@@ -334,7 +334,7 @@ fun DcdSettingPopup(
|
||||
modifier = Modifier
|
||||
.fillMaxHeight()
|
||||
.size(40.px.dp, 210.px.dp),
|
||||
chargeRate = gasChargeRate
|
||||
chargeRate = gasChargeRate.toInt()
|
||||
)
|
||||
|
||||
// Icon
|
||||
|
||||
@@ -28,26 +28,14 @@ import com.laseroptek.raman.ui.screens.main.MainViewModel
|
||||
import com.laseroptek.raman.utils.DefaultDispatcherProvider
|
||||
import com.laseroptek.raman.utils.ext.px
|
||||
import timber.log.Timber
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.ceil
|
||||
|
||||
|
||||
@Composable
|
||||
fun GradientSlider(
|
||||
modifier: Modifier = Modifier,
|
||||
chargeRate: Float = 0f,
|
||||
chargeRate: Int = 0, // Value from (0 .. 100)
|
||||
) {
|
||||
val normalizedRate = chargeRate.coerceIn(0f, 100f)
|
||||
val bucket = normalizedRate / 5f
|
||||
val remainder = normalizedRate % 5f
|
||||
val isExactMultiple = abs(remainder) < 0.0001f
|
||||
|
||||
val chargeIndex = when {
|
||||
normalizedRate == 0f -> -1
|
||||
isExactMultiple -> (bucket - 1f).toInt().coerceAtLeast(-1)
|
||||
else -> (ceil(bucket.toDouble()).toInt() - 1)
|
||||
}.coerceIn(-1, 19)
|
||||
|
||||
val chargeIndex = ((chargeRate.coerceIn(0, 100) + 4) / 5).toInt() // 0..19
|
||||
Timber.d("chargeRate: $chargeRate, chargeIndex: $chargeIndex")
|
||||
|
||||
Box(
|
||||
@@ -115,6 +103,6 @@ fun GradientSliderPreview(
|
||||
//mainViewModel = mainViewModel
|
||||
modifier = Modifier
|
||||
.size(40.px.dp, 210.px.dp),
|
||||
chargeRate = 20f
|
||||
chargeRate = 20
|
||||
)
|
||||
}
|
||||
|
||||
@@ -108,15 +108,15 @@ fun PresetIconButton(
|
||||
Image(
|
||||
painter = painterResource(id =
|
||||
if (type == PresetButtonType.SAVE) {
|
||||
R.drawable.ic_preset_save
|
||||
R.drawable.ic_preset_save2
|
||||
} else {
|
||||
R.drawable.ic_preset_load
|
||||
}
|
||||
),
|
||||
contentDescription = "",
|
||||
modifier = Modifier
|
||||
.size(20.px.dp),
|
||||
contentScale = ContentScale.Crop
|
||||
.size(30.px.dp),
|
||||
contentScale = ContentScale.Fit
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,12 +552,12 @@ fun PresetLoadPopup(
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Spacer(Modifier.weight(1f))
|
||||
|
||||
if (isEditMode) {
|
||||
////////////////////////////////////////////////////
|
||||
// Edit Mode
|
||||
|
||||
Spacer(modifier = Modifier.width(10.px.dp))
|
||||
|
||||
// Preset Delete (Delete confirm popup)
|
||||
Box(
|
||||
modifier = Modifier
|
||||
@@ -578,7 +578,7 @@ fun PresetLoadPopup(
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(Modifier.width(10.px.dp))
|
||||
Spacer(Modifier.weight(1f))
|
||||
|
||||
// Preset Cancel (Reload selected item from mainViewModel)
|
||||
Box(
|
||||
@@ -729,7 +729,11 @@ fun PresetLoadPopup(
|
||||
contentScale = ContentScale.Crop
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.width(10.px.dp))
|
||||
} else {
|
||||
Spacer(Modifier.weight(1f))
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// Select Mode - hide Keyboard
|
||||
focusManager.clearFocus(force = true) // Hide the keyboard
|
||||
@@ -790,6 +794,8 @@ fun PresetLoadPopup(
|
||||
contentScale = ContentScale.Crop
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.width(10.px.dp))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user