Skip to content

Commit 24a474f

Browse files
committed
fix: expand space between stars in rating slider
Also add haptic feedback
1 parent 828d767 commit 24a474f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

app/src/main/kotlin/day/vitayuzu/neodb/ui/component/Star.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ fun StarsWithScores(
2727
modifier: Modifier = Modifier,
2828
showScores: Boolean = true,
2929
size: Int = 16,
30+
starSpace: Int = 2,
3031
) {
3132
val ratingInFive = rating.div(2)
3233
Row(
@@ -38,6 +39,7 @@ fun StarsWithScores(
3839
full = ratingInFive.toInt(),
3940
half = ratingInFive > ratingInFive.toInt(),
4041
size = size,
42+
space = starSpace,
4143
)
4244
if (showScores) {
4345
Text(
@@ -56,9 +58,10 @@ fun RatingStars(
5658
modifier: Modifier = Modifier,
5759
empty: Int = 5 - full - if (half) 1 else 0,
5860
size: Int = 16,
61+
space: Int = 2,
5962
) {
6063
Row(
61-
horizontalArrangement = Arrangement.spacedBy(2.dp, Alignment.Start),
64+
horizontalArrangement = Arrangement.spacedBy(space.dp, Alignment.Start),
6265
verticalAlignment = Alignment.CenterVertically,
6366
modifier = modifier,
6467
) {

app/src/main/kotlin/day/vitayuzu/neodb/ui/page/detail/PostComposeModal.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ import androidx.compose.runtime.saveable.rememberSaveable
5252
import androidx.compose.runtime.setValue
5353
import androidx.compose.ui.Alignment
5454
import androidx.compose.ui.Modifier
55+
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
56+
import androidx.compose.ui.platform.LocalHapticFeedback
5557
import androidx.compose.ui.res.painterResource
5658
import androidx.compose.ui.res.stringResource
5759
import androidx.compose.ui.tooling.preview.Preview
@@ -177,17 +179,22 @@ private fun ComposeModalContent(
177179
modifier = Modifier.fillMaxWidth(),
178180
verticalAlignment = Alignment.CenterVertically,
179181
) {
182+
val haptic = LocalHapticFeedback.current
180183
AnimatedVisibility(visible = selectedShelfTypeIndex != 0) {
181184
Slider(
182185
value = ratingSliderValue,
183186
valueRange = 0f..10f,
184187
steps = 9,
185-
onValueChange = { ratingSliderValue = it },
188+
onValueChange = {
189+
haptic.performHapticFeedback(HapticFeedbackType.SegmentTick)
190+
ratingSliderValue = it
191+
},
186192
track = {
187193
StarsWithScores(
188194
size = 36,
189195
rating = ratingSliderValue,
190196
showScores = false,
197+
starSpace = 4,
191198
)
192199
},
193200
thumb = {}, // clear thumb on the bottom

0 commit comments

Comments
 (0)