Skip to content

Commit

Permalink
feat: sort by recently #83
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyroid committed Jan 24, 2024
1 parent 7aae69b commit d8b64bc
Show file tree
Hide file tree
Showing 14 changed files with 241 additions and 50 deletions.
2 changes: 2 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ dependencies {
implementation(libs.androidx.media3.media3.session)
implementation(libs.com.google.dagger.hilt.android)
ksp(libs.com.google.dagger.hilt.compiler)

api(libs.kotlinx.datetime)
}
2 changes: 0 additions & 2 deletions data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ dependencies {
implementation(libs.kotlinx.serialization.yaml)
implementation(libs.kotlinx.serialization.coverter.retrofit)

implementation(libs.kotlinx.datetime)

implementation(libs.io.coil.kt.coil)

implementation(libs.com.google.dagger.hilt.android)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.m3u.ui.helper.Action
import com.m3u.ui.EventHandler
import com.m3u.ui.helper.LocalHelper
import com.m3u.ui.ResumeEvent
import com.m3u.ui.Sort
import com.m3u.ui.SortBottomSheet
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
Expand Down Expand Up @@ -83,6 +84,7 @@ fun FavouriteRoute(
zapping = zapping,
navigateToStream = navigateToStream,
onMenu = { dialogStatus = DialogStatus.Selections(it) },
sort = sort,
modifier = Modifier
.fillMaxSize()
.thenIf(!tv && pref.godMode) {
Expand Down Expand Up @@ -122,6 +124,7 @@ private fun FavoriteScreen(
streams: ImmutableList<Stream>,
zapping: Stream?,
navigateToStream: () -> Unit,
sort: Sort,
onMenu: (Stream) -> Unit,
modifier: Modifier = Modifier
) {
Expand All @@ -136,6 +139,7 @@ private fun FavoriteScreen(
streams = streams,
zapping = zapping,
rowCount = actualRowCount,
sort = sort,
navigateToStream = navigateToStream,
onMenu = onMenu,
modifier = modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class FavouriteViewModel @Inject constructor(
Sort.DESC -> all.sortedWith(
compareByDescending(String.CASE_INSENSITIVE_ORDER) { it.title }
)
Sort.RECENTLY -> all.sortedByDescending { it.seen }
}
.toPersistentList()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.m3u.data.database.model.Stream
import com.m3u.material.ktx.isTelevision
import com.m3u.material.ktx.plus
import com.m3u.material.model.LocalSpacing
import com.m3u.ui.Sort
import com.m3u.ui.helper.LocalHelper
import kotlinx.collections.immutable.ImmutableList

Expand All @@ -26,6 +27,7 @@ internal fun FavouriteGallery(
streams: ImmutableList<Stream>,
zapping: Stream?,
rowCount: Int,
sort: Sort,
navigateToStream: () -> Unit,
onMenu: (Stream) -> Unit,
modifier: Modifier = Modifier
Expand All @@ -39,6 +41,7 @@ internal fun FavouriteGallery(
streams = streams,
zapping = zapping,
rowCount = rowCount,
sort = sort,
navigateToStream = navigateToStream,
onMenu = onMenu,
modifier = modifier
Expand All @@ -49,6 +52,7 @@ internal fun FavouriteGallery(
streams = streams,
zapping = zapping,
rowCount = rowCount,
sort = sort,
navigateToStream = navigateToStream,
onMenu = onMenu,
modifier = modifier
Expand All @@ -62,6 +66,7 @@ private fun FavouriteGalleryImpl(
streams: ImmutableList<Stream>,
zapping: Stream?,
rowCount: Int,
sort: Sort,
navigateToStream: () -> Unit,
onMenu: (Stream) -> Unit,
modifier: Modifier = Modifier
Expand All @@ -87,6 +92,7 @@ private fun FavouriteGalleryImpl(
stream = stream,
noPictureMode = pref.noPictureMode,
zapping = zapping == stream,
sort = sort,
onClick = {
helper.play(stream.id)
navigateToStream()
Expand Down Expand Up @@ -118,6 +124,7 @@ private fun FavouriteGalleryImpl(
stream = stream,
noPictureMode = pref.noPictureMode,
zapping = zapping == stream,
sort = sort,
onClick = {
helper.play(stream.id)
navigateToStream()
Expand All @@ -138,6 +145,7 @@ private fun CompactFavouriteGalleryImpl(
streams: ImmutableList<Stream>,
zapping: Stream?,
rowCount: Int,
sort: Sort,
navigateToStream: () -> Unit,
onMenu: (Stream) -> Unit,
modifier: Modifier = Modifier
Expand All @@ -162,6 +170,7 @@ private fun CompactFavouriteGalleryImpl(
stream = stream,
noPictureMode = pref.noPictureMode,
zapping = zapping == stream,
sort = sort,
onClick = {
helper.play(stream.id)
navigateToStream()
Expand Down Expand Up @@ -189,6 +198,7 @@ private fun CompactFavouriteGalleryImpl(
stream = stream,
noPictureMode = pref.noPictureMode,
zapping = zapping == stream,
sort = sort,
onClick = {
helper.play(stream.id)
navigateToStream()
Expand Down
Loading

0 comments on commit d8b64bc

Please sign in to comment.