Skip to content

Commit

Permalink
refactor: categorize settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
zyrouge committed Nov 10, 2024
1 parent 370d86b commit a774976
Show file tree
Hide file tree
Showing 35 changed files with 2,038 additions and 994 deletions.
6 changes: 6 additions & 0 deletions .phrasey/schema.toml
Original file line number Diff line number Diff line change
Expand Up @@ -720,3 +720,9 @@ name = "Date"

[[keys]]
name = "TotalSamples"

[[keys]]
name = "HomePage"

[[keys]]
name = "NowPlayingPage"
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import io.github.zyrouge.symphony.services.groove.AlbumArtist
import io.github.zyrouge.symphony.ui.helpers.Routes
import io.github.zyrouge.symphony.ui.helpers.ViewContext
import io.github.zyrouge.symphony.ui.helpers.navigateTo
import io.github.zyrouge.symphony.ui.view.AlbumArtistViewRoute

@Composable
fun AlbumArtistTile(context: ViewContext, albumArtist: AlbumArtist) {
Expand All @@ -45,7 +44,7 @@ fun AlbumArtistTile(context: ViewContext, albumArtist: AlbumArtist) {
context.symphony.radio.shorty.playQueue(albumArtist.getSortedSongIds(context.symphony))
},
onClick = {
context.navController.navigateTo(Routes.AlbumArtist.build(albumArtist.name))
context.navController.navigate(AlbumArtistViewRoute(albumArtist.name))
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import io.github.zyrouge.symphony.services.groove.Album
import io.github.zyrouge.symphony.ui.helpers.Routes
import io.github.zyrouge.symphony.ui.helpers.ViewContext
import io.github.zyrouge.symphony.ui.helpers.navigateTo
import io.github.zyrouge.symphony.ui.view.AlbumViewRoute
import io.github.zyrouge.symphony.ui.view.ArtistViewRoute

@Composable
fun AlbumTile(context: ViewContext, album: Album) {
Expand Down Expand Up @@ -55,7 +55,7 @@ fun AlbumTile(context: ViewContext, album: Album) {
context.symphony.radio.shorty.playQueue(album.getSortedSongIds(context.symphony))
},
onClick = {
context.navController.navigateTo(Routes.Album.build(album.id))
context.navController.navigate(AlbumViewRoute(album.id))
}
)
}
Expand Down Expand Up @@ -137,7 +137,7 @@ fun AlbumDropdownMenu(
},
onClick = {
onDismissRequest()
context.navController.navigateTo(Routes.Artist.build(artistName))
context.navController.navigate(ArtistViewRoute(artistName))
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import io.github.zyrouge.symphony.services.groove.Artist
import io.github.zyrouge.symphony.ui.helpers.Routes
import io.github.zyrouge.symphony.ui.helpers.ViewContext
import io.github.zyrouge.symphony.ui.helpers.navigateTo
import io.github.zyrouge.symphony.ui.view.ArtistViewRoute

@Composable
fun ArtistTile(context: ViewContext, artist: Artist) {
Expand All @@ -45,7 +44,7 @@ fun ArtistTile(context: ViewContext, artist: Artist) {
context.symphony.radio.shorty.playQueue(artist.getSortedSongIds(context.symphony))
},
onClick = {
context.navController.navigateTo(Routes.Artist.build(artist.name))
context.navController.navigate(ArtistViewRoute(artist.name))
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import io.github.zyrouge.symphony.services.groove.Groove
import io.github.zyrouge.symphony.services.groove.repositories.GenreRepository
import io.github.zyrouge.symphony.ui.helpers.Routes
import io.github.zyrouge.symphony.ui.helpers.ViewContext
import io.github.zyrouge.symphony.ui.helpers.navigateTo
import io.github.zyrouge.symphony.ui.view.GenreViewRoute

private object GenreTile {
val colors = listOf(
Expand Down Expand Up @@ -131,7 +130,7 @@ fun GenreGrid(
),
colors = GenreTile.cardColors(i),
onClick = {
context.navController.navigateTo(Routes.Genre.build(genre.name))
context.navController.navigate(GenreViewRoute(genre.name))
}
) {
Box(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import io.github.zyrouge.symphony.services.groove.Song
import io.github.zyrouge.symphony.ui.helpers.FadeTransition
import io.github.zyrouge.symphony.ui.helpers.Routes
import io.github.zyrouge.symphony.ui.helpers.TransitionDurations
import io.github.zyrouge.symphony.ui.helpers.ViewContext
import io.github.zyrouge.symphony.ui.helpers.navigateTo
import io.github.zyrouge.symphony.ui.view.NowPlayingViewRoute
import io.github.zyrouge.symphony.utils.runIfOrThis
import kotlin.math.absoluteValue

Expand Down Expand Up @@ -145,15 +144,15 @@ fun NowPlayingBottomBar(context: ViewContext, insetPadding: Boolean = true) {
.wrapContentHeight()
.swipeable(
onSwipeUp = {
context.navController.navigateTo(Routes.NowPlaying)
context.navController.navigate(NowPlayingViewRoute)
},
onSwipeDown = {
context.symphony.radio.stop()
},
),
shape = RectangleShape,
onClick = {
context.navController.navigateTo(Routes.NowPlaying)
context.navController.navigate(NowPlayingViewRoute)
}
) {
Row(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import io.github.zyrouge.symphony.services.groove.MediaExposer
import io.github.zyrouge.symphony.services.groove.Playlist
import io.github.zyrouge.symphony.ui.helpers.Routes
import io.github.zyrouge.symphony.ui.helpers.ViewContext
import io.github.zyrouge.symphony.ui.helpers.navigateTo
import io.github.zyrouge.symphony.ui.theme.ThemeColors
import io.github.zyrouge.symphony.ui.view.PlaylistViewRoute
import io.github.zyrouge.symphony.utils.Logger
import kotlinx.coroutines.launch

Expand All @@ -62,7 +61,7 @@ fun PlaylistTile(context: ViewContext, playlist: Playlist) {
.wrapContentHeight(),
colors = CardDefaults.cardColors(containerColor = Color.Transparent),
onClick = {
context.navController.navigateTo(Routes.Playlist.build(playlist.id))
context.navController.navigate(PlaylistViewRoute(playlist.id))
}
) {
Box(modifier = Modifier.padding(12.dp)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import io.github.zyrouge.symphony.services.groove.Song
import io.github.zyrouge.symphony.ui.helpers.Routes
import io.github.zyrouge.symphony.ui.helpers.ViewContext
import io.github.zyrouge.symphony.ui.helpers.navigateTo
import io.github.zyrouge.symphony.ui.view.AlbumArtistViewRoute
import io.github.zyrouge.symphony.ui.view.AlbumViewRoute
import io.github.zyrouge.symphony.ui.view.ArtistViewRoute
import io.github.zyrouge.symphony.utils.Logger

@Composable
Expand Down Expand Up @@ -273,7 +274,7 @@ fun SongDropdownMenu(
},
onClick = {
onDismissRequest()
context.navController.navigateTo(Routes.Artist.build(artistName))
context.navController.navigate(ArtistViewRoute(artistName))
}
)
}
Expand All @@ -287,7 +288,7 @@ fun SongDropdownMenu(
},
onClick = {
onDismissRequest()
context.navController.navigateTo(Routes.AlbumArtist.build(albumArtist))
context.navController.navigate(AlbumArtistViewRoute(albumArtist))
}
)
}
Expand All @@ -301,7 +302,7 @@ fun SongDropdownMenu(
},
onClick = {
onDismissRequest()
context.navController.navigateTo(Routes.Album.build(albumId))
context.navController.navigate(AlbumViewRoute(albumId))
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.text.style.TextDecoration
import io.github.zyrouge.symphony.services.groove.Song
import io.github.zyrouge.symphony.ui.helpers.Routes
import io.github.zyrouge.symphony.ui.helpers.ViewContext
import io.github.zyrouge.symphony.ui.helpers.navigateTo
import io.github.zyrouge.symphony.ui.view.AlbumArtistViewRoute
import io.github.zyrouge.symphony.ui.view.AlbumViewRoute
import io.github.zyrouge.symphony.ui.view.ArtistViewRoute
import io.github.zyrouge.symphony.ui.view.GenreViewRoute
import io.github.zyrouge.symphony.utils.ActivityUtils
import io.github.zyrouge.symphony.utils.DurationUtils
import java.text.SimpleDateFormat
Expand All @@ -34,15 +36,15 @@ fun SongInformationDialog(context: ViewContext, song: Song, onDismissRequest: ()
InformationKeyValue(context.symphony.t.Artist) {
LongPressCopyableAndTappableText(context, song.artists) {
onDismissRequest()
context.navController.navigateTo(Routes.Artist.build(it))
context.navController.navigate(ArtistViewRoute(it))
}
}
}
if (song.albumArtists.isNotEmpty()) {
InformationKeyValue(context.symphony.t.AlbumArtist) {
LongPressCopyableAndTappableText(context, song.albumArtists) {
onDismissRequest()
context.navController.navigateTo(Routes.AlbumArtist.build(it))
context.navController.navigate(AlbumArtistViewRoute(it))
}
}
}
Expand All @@ -51,23 +53,23 @@ fun SongInformationDialog(context: ViewContext, song: Song, onDismissRequest: ()
// TODO composers page maybe?
LongPressCopyableAndTappableText(context, song.composers) {
onDismissRequest()
context.navController.navigateTo(Routes.Artist.build(it))
context.navController.navigate(ArtistViewRoute(it))
}
}
}
context.symphony.groove.album.getIdFromSong(song)?.let { albumId ->
InformationKeyValue(context.symphony.t.Album) {
LongPressCopyableAndTappableText(context, setOf(song.album!!)) {
onDismissRequest()
context.navController.navigateTo(Routes.Album.build(albumId))
context.navController.navigate(AlbumViewRoute(albumId))
}
}
}
if (song.genres.isNotEmpty()) {
InformationKeyValue(context.symphony.t.Genre) {
LongPressCopyableAndTappableText(context, song.genres) {
onDismissRequest()
context.navController.navigateTo(Routes.Genre.build(it))
context.navController.navigate(GenreViewRoute(it))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ import io.github.zyrouge.symphony.services.groove.Groove
import io.github.zyrouge.symphony.services.groove.Song
import io.github.zyrouge.symphony.services.groove.repositories.SongRepository
import io.github.zyrouge.symphony.services.radio.Radio
import io.github.zyrouge.symphony.ui.helpers.Routes
import io.github.zyrouge.symphony.ui.helpers.ViewContext
import io.github.zyrouge.symphony.ui.helpers.navigateTo
import io.github.zyrouge.symphony.ui.view.SettingsViewElements
import io.github.zyrouge.symphony.ui.view.SettingsViewRoute

enum class SongListType {
Default,
Expand Down Expand Up @@ -97,8 +96,8 @@ fun SongList(
textAlign = TextAlign.Center,
modifier = Modifier
.clickable {
context.navController.navigateTo(
Routes.Settings.build(SettingsViewElements.MediaFolders)
context.navController.navigate(
SettingsViewRoute(SettingsViewElements.MediaFolders)
)
}
.padding(2.dp),
Expand Down
79 changes: 0 additions & 79 deletions app/src/main/java/io/github/zyrouge/symphony/ui/helpers/Routes.kt

This file was deleted.

12 changes: 8 additions & 4 deletions app/src/main/java/io/github/zyrouge/symphony/ui/view/Album.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,24 @@ import io.github.zyrouge.symphony.ui.components.SongList
import io.github.zyrouge.symphony.ui.components.SongListType
import io.github.zyrouge.symphony.ui.components.TopAppBarMinimalTitle
import io.github.zyrouge.symphony.ui.helpers.ViewContext
import kotlinx.serialization.Serializable

@Serializable
data class AlbumViewRoute(val albumId: String)

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AlbumView(context: ViewContext, albumId: String) {
fun AlbumView(context: ViewContext, route: AlbumViewRoute) {
val allAlbumIds by context.symphony.groove.album.all.collectAsState()
val allSongIds by context.symphony.groove.song.all.collectAsState()
val album by remember(allAlbumIds) {
derivedStateOf { context.symphony.groove.album.get(albumId) }
derivedStateOf { context.symphony.groove.album.get(route.albumId) }
}
val songIds by remember(album, allSongIds) {
derivedStateOf { album?.getSongIds(context.symphony) ?: listOf() }
}
val isViable by remember(allAlbumIds) {
derivedStateOf { allAlbumIds.contains(albumId) }
derivedStateOf { allAlbumIds.contains(route.albumId) }
}

Scaffold(
Expand Down Expand Up @@ -100,7 +104,7 @@ fun AlbumView(context: ViewContext, albumId: String) {
},
cardThumbnailLabelStyle = SongCardThumbnailLabelStyle.Subtle,
)
} else UnknownAlbum(context, albumId)
} else UnknownAlbum(context, route.albumId)
}
},
bottomBar = {
Expand Down
Loading

0 comments on commit a774976

Please sign in to comment.