Skip to content

Commit 188fc2c

Browse files
committed
Update version to 1.26.
Adjusted lyrics scroll offsets.
1 parent 98642e2 commit 188fc2c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ android {
1313
applicationId = "com.craftworks.music"
1414
minSdk = 23
1515
targetSdk = 35
16-
versionCode = 250
17-
versionName = "1.25"
16+
versionCode = 260
17+
versionName = "1.26"
1818

1919
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2020
vectorDrawables {

app/src/main/java/com/craftworks/music/ui/playing/NowPlayingLyrics.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fun LyricsView(
7575
val coroutineScope = rememberCoroutineScope()
7676
val visibleItemsInfo by remember { derivedStateOf { state.layoutInfo.visibleItemsInfo } }
7777

78-
val scrollOffset = dpToPx(64)
78+
val scrollOffset = dpToPx(128)
7979

8080
// Update the current playback position every second
8181
LaunchedEffect(mediaController, lyrics) {
@@ -107,9 +107,9 @@ fun LyricsView(
107107
coroutineScope.launch {
108108
// If the next item is visible, animate smoothly to it using FastOutSlowIn Easing
109109
// else use animateScrollToItem.
110-
if (visibleItemsInfo.any { it.index == targetIndex }) {
111-
val currentItem = visibleItemsInfo.firstOrNull { it.index == currentLyricIndex.intValue }
110+
val currentItem = visibleItemsInfo.firstOrNull { it.index == currentLyricIndex.intValue }
112111

112+
if (visibleItemsInfo.any { it.index == targetIndex }) {
113113
val scrollBy = (currentItem?.offset ?: 0) + (currentItem?.size ?: 0) - scrollOffset
114114

115115
state.animateScrollBy(
@@ -120,7 +120,7 @@ fun LyricsView(
120120
else
121121
state.animateScrollToItem(
122122
index = targetIndex,
123-
scrollOffset = -scrollOffset
123+
scrollOffset = -(currentItem?.size ?: 0)
124124
)
125125
}
126126
}
@@ -171,7 +171,7 @@ fun LyricsView(
171171
coroutineScope.launch {
172172
state.animateScrollToItem(
173173
index = index,
174-
scrollOffset = -scrollOffset
174+
scrollOffset = -scrollOffset + (visibleItemsInfo.firstOrNull { it.index == index }?.size ?: 0)
175175
)
176176
}
177177
}

0 commit comments

Comments
 (0)