Skip to content

Commit

Permalink
✨ feat(album): Add album like/unlike functionality (Fixed #660)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxrave-dev committed Dec 31, 2024
1 parent e0392fc commit f227eee
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import com.maxrave.simpmusic.extension.toSongEntity
import com.maxrave.simpmusic.ui.component.CenterLoadingBox
import com.maxrave.simpmusic.ui.component.DescriptionView
import com.maxrave.simpmusic.ui.component.EndOfPage
import com.maxrave.simpmusic.ui.component.HeartCheckBox
import com.maxrave.simpmusic.ui.component.NowPlayingBottomSheet
import com.maxrave.simpmusic.ui.component.RippleIconButton
import com.maxrave.simpmusic.ui.component.SongFullWidthItems
Expand Down Expand Up @@ -365,6 +366,14 @@ fun AlbumScreen(
}
}
}
Spacer(modifier = Modifier.size(5.dp))
HeartCheckBox(
size = 36,
checked = uiState.liked,
onStateChange = {
viewModel.setAlbumLike()
},
)
Spacer(Modifier.weight(1f))
Spacer(Modifier.size(5.dp))
RippleIconButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ class AlbumViewModel(
}
}

fun setAlbumLike() {
viewModelScope.launch {
mainRepository.updateAlbumLiked(uiState.value.browseId, if (!uiState.value.liked) 1 else 0 )
_uiState.update {
it.copy(
liked = !it.liked,
)
}
}
}

private fun getAlbumFlow(browseId: String) {
job?.cancel()
collectDownloadStateJob?.cancel()
Expand Down

0 comments on commit f227eee

Please sign in to comment.