Skip to content

Commit

Permalink
Fix some thing inside LocalPlaylistScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
maxrave-dev committed Nov 29, 2024
1 parent feff9d7 commit 573e01d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ class MainRepository(
localDataSource.insertSongInfo(songInfo)
}

suspend fun getSongInfoEntiy(videoId: String): Flow<SongInfoEntity?> =
suspend fun getSongInfoEntity(videoId: String): Flow<SongInfoEntity?> =
flow { emit(localDataSource.getSongInfo(videoId)) }.flowOn(Dispatchers.Main)

suspend fun recoverQueue(temp: List<Track>) {
Expand Down Expand Up @@ -2617,7 +2617,7 @@ class MainRepository(
)
}.onFailure {
it.printStackTrace()
emit(getSongInfoEntiy(videoId).firstOrNull())
emit(getSongInfoEntity(videoId).firstOrNull())
}
}
}.flowOn(Dispatchers.IO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.ColorMatrix
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
Expand Down Expand Up @@ -547,12 +546,9 @@ fun ActionButton(
Modifier
.fillMaxWidth()
.wrapContentHeight(Alignment.CenterVertically)
.clickable {
if (enable) onClick()
}
.apply {
if (!enable) greyScale()
},
.then(
if (enable) Modifier.clickable { onClick.invoke() } else Modifier.greyScale()
),
) {
Row(
verticalAlignment = Alignment.CenterVertically,
Expand All @@ -571,20 +567,14 @@ fun ActionButton(
if (enable) {
ColorFilter.tint(iconColor)
} else {
ColorFilter.colorMatrix(
ColorMatrix().apply {
setToSaturation(
0f,
)
},
)
ColorFilter.tint(Color.Gray)
},
)

Text(
text = if (text != null) stringResource(text) else textString ?: "",
style = typo.labelSmall,
color = textColor ?: Color.Unspecified,
color = if (enable) textColor ?: Color.Unspecified else Color.Gray,
modifier =
Modifier
.padding(start = 10.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ import com.maxrave.simpmusic.ui.component.EndOfPage
import com.maxrave.simpmusic.ui.component.LoadingDialog
import com.maxrave.simpmusic.ui.component.LocalPlaylistBottomSheet
import com.maxrave.simpmusic.ui.component.NowPlayingBottomSheet
import com.maxrave.simpmusic.ui.component.SongFullWidthItems
import com.maxrave.simpmusic.ui.component.RippleIconButton
import com.maxrave.simpmusic.ui.component.SongFullWidthItems
import com.maxrave.simpmusic.ui.component.SuggestItems
import com.maxrave.simpmusic.ui.theme.md_theme_dark_background
import com.maxrave.simpmusic.ui.theme.typo
Expand Down Expand Up @@ -188,7 +188,7 @@ fun PlaylistScreen(

val playingTrack by sharedViewModel.nowPlayingState
.mapLatest {
it?.mediaItem
it?.songEntity
}.collectAsState(initial = null)
val isPlaying by sharedViewModel.controllerState.map { it.isPlaying }.collectAsState(initial = false)
val suggestedTracks by viewModel.uiState.map { it.suggestions?.songs ?: emptyList() }.collectAsState(initial = emptyList())
Expand Down Expand Up @@ -630,7 +630,7 @@ fun PlaylistScreen(
suggestedTracks.forEachIndexed { index, track ->
SuggestItems(
track = track,
isPlaying = playingTrack?.mediaId == track.videoId,
isPlaying = playingTrack?.videoId == track.videoId,
onAddClickListener = {
viewModel.addSuggestTrackToListTrack(
track,
Expand Down Expand Up @@ -754,7 +754,7 @@ fun PlaylistScreen(
}) { index ->
val item = trackPagingItems[index]
if (item != null) {
if (playingTrack?.mediaId == item.videoId && isPlaying) {
if (playingTrack?.videoId == item.videoId && isPlaying) {
SongFullWidthItems(
isPlaying = true,
songEntity = item,
Expand Down

0 comments on commit 573e01d

Please sign in to comment.