diff --git a/app/src/main/java/org/listenbrainz/android/ui/components/SeekBar.kt b/app/src/main/java/org/listenbrainz/android/ui/components/SeekBar.kt index 4eda2546..e261dbda 100644 --- a/app/src/main/java/org/listenbrainz/android/ui/components/SeekBar.kt +++ b/app/src/main/java/org/listenbrainz/android/ui/components/SeekBar.kt @@ -7,11 +7,15 @@ import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.Slider import androidx.compose.material.SliderDefaults import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.RectangleShape +import androidx.compose.ui.graphics.Shape import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.res.colorResource @@ -20,6 +24,7 @@ import androidx.compose.ui.semantics.progressBarRangeInfo import androidx.compose.ui.semantics.semantics import androidx.compose.ui.unit.dp import org.listenbrainz.android.R +import org.listenbrainz.android.ui.theme.ListenBrainzTheme @Composable fun SeekBar( @@ -47,7 +52,9 @@ fun CustomSeekBar( @FloatRange(from = 0.0, to = 1.0) progress: Float, onValueChange: (Float) -> Unit, - remainingProgressColor: Color = Color.Transparent + shape: Shape = RectangleShape, + progressColor: Color = ListenBrainzTheme.colorScheme.lbSignature, + remainingProgressColor: Color = ListenBrainzTheme.colorScheme.hint ) { val range = 0f..1f @@ -82,17 +89,17 @@ fun CustomSeekBar( Box( modifier = Modifier .fillMaxWidth() - .height(4.dp) + .height(5.dp) .graphicsLayer { alpha = 0.2f } - .background(remainingProgressColor) + .background(remainingProgressColor, shape) ) Box( modifier = Modifier .fillMaxWidth(progress) - .height(4.dp) - .background(colorResource(id = R.color.bp_color_primary)) + .height(5.dp) + .background(progressColor, shape) ) } } diff --git a/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/BrainzPlayerBackDropScreen.kt b/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/BrainzPlayerBackDropScreen.kt index b607e335..afb5ee36 100644 --- a/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/BrainzPlayerBackDropScreen.kt +++ b/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/BrainzPlayerBackDropScreen.kt @@ -25,6 +25,7 @@ import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.pager.rememberPagerState +import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.BackdropScaffold import androidx.compose.material.BackdropScaffoldState @@ -56,6 +57,7 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableStateListOf +import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue @@ -69,7 +71,6 @@ import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign @@ -98,6 +99,7 @@ import org.listenbrainz.android.util.BrainzPlayerExtensions.toSong import org.listenbrainz.android.util.SongViewPager import org.listenbrainz.android.viewmodel.BrainzPlayerViewModel import org.listenbrainz.android.viewmodel.PlaylistViewModel +import java.util.Locale import kotlin.math.absoluteValue import kotlin.math.max @@ -293,11 +295,11 @@ fun PlayerScreen( .fillMaxWidth(0.98F) .padding(horizontal = 20.dp), progress = progress, + shape = CircleShape, onValueChange = { newProgress -> brainzPlayerViewModel.onSeek(newProgress) brainzPlayerViewModel.onSeeked() - }, - remainingProgressColor = colorResource(id = R.color.bp_color_primary) + } ) } Row( @@ -308,32 +310,44 @@ fun PlayerScreen( .padding(start = 22.dp, top = 10.dp, end = 22.dp) ) { val songCurrentPosition by brainzPlayerViewModel.songCurrentPosition.collectAsState() - val duration: String - val currentPosition: String - if (currentlyPlayingSong.duration / (1000 * 60 * 60) > 0 && songCurrentPosition / (1000 * 60 * 60) > 0) { - duration = String.format( - "%02d:%02d:%02d", - currentlyPlayingSong.duration / (1000 * 60 * 60), - currentlyPlayingSong.duration / (1000 * 60) % 60, - currentlyPlayingSong.duration / 1000 % 60 - ) - currentPosition = String.format( - "%02d:%02d:%02d", - songCurrentPosition / (1000 * 60 * 60), - songCurrentPosition / (1000 * 60) % 60, - songCurrentPosition / 1000 % 60 - ) - } else { - duration = String.format( - "%02d:%02d", - currentlyPlayingSong.duration / (1000 * 60) % 60, - currentlyPlayingSong.duration / 1000 % 60 - ) - currentPosition = String.format( - "%02d:%02d", - songCurrentPosition / (1000 * 60) % 60, - songCurrentPosition / 1000 % 60 - ) + + val (duration, currentPosition) = remember( + currentlyPlayingSong.duration, + songCurrentPosition + ) { + val duration: String + val currentPosition: String + if (currentlyPlayingSong.duration / (1000 * 60 * 60) > 0 && songCurrentPosition / (1000 * 60 * 60) > 0) { + duration = String.format( + Locale.getDefault(), + "%02d:%02d:%02d", + currentlyPlayingSong.duration / (1000 * 60 * 60), + currentlyPlayingSong.duration / (1000 * 60) % 60, + currentlyPlayingSong.duration / 1000 % 60 + ) + currentPosition = String.format( + Locale.getDefault(), + "%02d:%02d:%02d", + songCurrentPosition / (1000 * 60 * 60), + songCurrentPosition / (1000 * 60) % 60, + songCurrentPosition / 1000 % 60 + ) + } else { + duration = String.format( + Locale.getDefault(), + "%02d:%02d", + currentlyPlayingSong.duration / (1000 * 60) % 60, + currentlyPlayingSong.duration / 1000 % 60 + ) + currentPosition = String.format( + Locale.getDefault(), + "%02d:%02d", + songCurrentPosition / (1000 * 60) % 60, + songCurrentPosition / 1000 % 60 + ) + } + + return@remember duration to currentPosition } diff --git a/app/src/main/java/org/listenbrainz/android/util/SongViewPager.kt b/app/src/main/java/org/listenbrainz/android/util/SongViewPager.kt index 25d11467..b9c69633 100644 --- a/app/src/main/java/org/listenbrainz/android/util/SongViewPager.kt +++ b/app/src/main/java/org/listenbrainz/android/util/SongViewPager.kt @@ -137,7 +137,8 @@ fun SongViewPager( onValueChange = { newProgress -> viewModel.onSeek(newProgress) viewModel.onSeeked() - } + }, + remainingProgressColor = ListenBrainzTheme.colorScheme.hint ) } Spacer(modifier = Modifier.height(4.dp))