Skip to content

Commit

Permalink
Add an option to show path on song list, #81
Browse files Browse the repository at this point in the history
  • Loading branch information
Lambada10 committed Oct 17, 2024
1 parent 47b10b5 commit c7b813c
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 43 deletions.
13 changes: 13 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class UserSettingsController(private val dataStore: DataStore<Preferences>) {
var sdCardPath by mutableStateOf(dataStore.get(sdCardPathKey, null))
private set

var showPath by mutableStateOf(dataStore.get(showPathKey, false))
private set

fun updateEmbedLyrics(to: Boolean) {
dataStore.set(embedKey, to)
embedLyricsIntoFiles = to
Expand Down Expand Up @@ -88,6 +91,11 @@ class UserSettingsController(private val dataStore: DataStore<Preferences>) {
dataStore.set(sdCardPathKey, to)
sdCardPath = to
}

fun updateShowPath(to: Boolean) {
dataStore.set(showPathKey, to)
showPath = to
}
}

private val embedKey = booleanPreferencesKey("embed_lyrics")
Expand All @@ -98,4 +106,5 @@ private val includeTranslationKey = booleanPreferencesKey("include_translation")
private val multiPersonWordByWordKey = booleanPreferencesKey("multi_person_word_by_word")
private val disableMarqueeKey = booleanPreferencesKey("marquee_disable")
private val pureBlackKey = booleanPreferencesKey("pure_black")
private val sdCardPathKey = stringPreferencesKey("sd_card_path")
private val sdCardPathKey = stringPreferencesKey("sd_card_path")
private val showPathKey = booleanPreferencesKey("show_path")
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import pl.lambada.songsync.ui.screens.about.components.MarqueeSwitch
import pl.lambada.songsync.ui.screens.about.components.MultiPersonSwitch
import pl.lambada.songsync.ui.screens.about.components.PureBlackThemeSwitch
import pl.lambada.songsync.ui.screens.about.components.SdCardPathSetting
import pl.lambada.songsync.ui.screens.about.components.ShowPathSwitch
import pl.lambada.songsync.ui.screens.about.components.SupportSection
import pl.lambada.songsync.ui.screens.about.components.TranslationSwitch
import pl.lambada.songsync.ui.screens.about.components.UpdateAvailableDialog
Expand Down Expand Up @@ -75,6 +76,13 @@ fun AboutScreen(
)
}

item {
ShowPathSwitch(
selected = userSettingsController.showPath,
onToggle = { userSettingsController.updateShowPath(it) }
)
}

item {
TranslationSwitch(
selected = userSettingsController.includeTranslation,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package pl.lambada.songsync.ui.screens.about.components

import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import pl.lambada.songsync.R
import pl.lambada.songsync.ui.components.AboutItem
import pl.lambada.songsync.ui.components.SwitchItem

@Composable
fun ShowPathSwitch(selected: Boolean, onToggle: (Boolean) -> Unit) {
AboutItem(label = stringResource(R.string.song_path)) {
SwitchItem(
label = stringResource(R.string.song_path_description),
selected = selected,
onClick = { onToggle(!selected) }
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ fun HomeScreenLoaded(
song = song,
sharedTransitionScope = sharedTransitionScope,
animatedVisibilityScope = animatedVisibilityScope,
disableMarquee = viewModel.userSettingsController.disableMarquee
disableMarquee = viewModel.userSettingsController.disableMarquee,
showPath = viewModel.userSettingsController.showPath
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import coil.compose.rememberAsyncImagePainter
import coil.imageLoader
import coil.request.ImageRequest
import pl.lambada.songsync.R
import pl.lambada.songsync.data.remote.UserSettingsController
import pl.lambada.songsync.domain.model.Song
import pl.lambada.songsync.ui.components.AnimatedText

Expand All @@ -46,7 +47,8 @@ fun SongItem(
song: Song,
sharedTransitionScope: SharedTransitionScope,
animatedVisibilityScope: AnimatedVisibilityScope,
disableMarquee: Boolean = true
disableMarquee: Boolean = true,
showPath: Boolean,
) {
val painter = rememberAsyncImagePainter(
ImageRequest.Builder(LocalContext.current).data(data = song.imgUri).apply {
Expand All @@ -61,7 +63,7 @@ fun SongItem(
Row(
modifier = Modifier
.fillMaxWidth()
.height(76.dp)
.height(if (showPath) 100.dp else 80.dp)
.background(bgColor)
.combinedClickable(
onClick = {
Expand All @@ -75,46 +77,65 @@ fun SongItem(
.padding(vertical = 12.dp, horizontal = 24.dp)
) {
with(sharedTransitionScope) {
Image(
painter = painter,
contentDescription = stringResource(id = R.string.album_cover),
modifier = Modifier
.sharedBounds(
sharedContentState = rememberSharedContentState(key = "cover$filePath"),
animatedVisibilityScope = animatedVisibilityScope,
clipInOverlayDuringTransition = sharedTransitionScope.OverlayClip(
RoundedCornerShape(20f)
)
)
.fillMaxHeight()
.aspectRatio(1f)
.clip(RoundedCornerShape(20f))
)
Spacer(modifier = Modifier.width(12.dp))
Column(
modifier = Modifier.fillMaxHeight(),
verticalArrangement = Arrangement.SpaceAround
) {
AnimatedText(
animate = !disableMarquee,
text = songName,
fontSize = 16.sp,
color = MaterialTheme.colorScheme.contentColorFor(bgColor),
modifier = Modifier.sharedBounds(
sharedContentState = rememberSharedContentState(key = "title$filePath"),
animatedVisibilityScope = animatedVisibilityScope
Column {
Row(
modifier = Modifier.fillMaxHeight(if (showPath) 0.7f else 1f),
) {
Image(
painter = painter,
contentDescription = stringResource(id = R.string.album_cover),
modifier = Modifier
.sharedBounds(
sharedContentState = rememberSharedContentState(key = "cover$filePath"),
animatedVisibilityScope = animatedVisibilityScope,
clipInOverlayDuringTransition = sharedTransitionScope.OverlayClip(
RoundedCornerShape(20f)
)
)
.fillMaxHeight()
.aspectRatio(1f)
.clip(RoundedCornerShape(20f))
)
)
AnimatedText(
animate = !disableMarquee,
text = artists,
fontSize = 14.sp,
color = MaterialTheme.colorScheme.contentColorFor(bgColor),
modifier = Modifier.sharedBounds(
sharedContentState = rememberSharedContentState(key = "artist$filePath"),
animatedVisibilityScope = animatedVisibilityScope
Spacer(modifier = Modifier.width(12.dp))
Column(
modifier = Modifier.fillMaxHeight(),
verticalArrangement = Arrangement.SpaceAround
) {
AnimatedText(
animate = !disableMarquee,
text = songName,
fontSize = 16.sp,
color = MaterialTheme.colorScheme.contentColorFor(bgColor),
modifier = Modifier.sharedBounds(
sharedContentState = rememberSharedContentState(key = "title$filePath"),
animatedVisibilityScope = animatedVisibilityScope
)
)
AnimatedText(
animate = !disableMarquee,
text = artists,
fontSize = 14.sp,
color = MaterialTheme.colorScheme.contentColorFor(bgColor),
modifier = Modifier.sharedBounds(
sharedContentState = rememberSharedContentState(key = "artist$filePath"),
animatedVisibilityScope = animatedVisibilityScope
)
)
}
}
if (showPath) {
Spacer(modifier = Modifier.height(4.dp))
AnimatedText(
animate = !disableMarquee,
text = filePath,
fontSize = 12.sp,
color = MaterialTheme.colorScheme.contentColorFor(bgColor),
modifier = Modifier.sharedBounds(
sharedContentState = rememberSharedContentState(key = "path$filePath"),
animatedVisibilityScope = animatedVisibilityScope
)
)
)
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,6 @@
<string name="embed_non_local_song_error">You tried to embed the lyrics to a non-local file. Aborting operation.</string>
<string name="multi_person_word_by_word">Multi-person word by word lyrics</string>
<string name="multi_person_word_by_word_summary">Use multi-person lyrics format when getting lyrics from Apple Music</string>
</resources>
<string name="song_path">Show song path</string>
<string name="song_path_description">Show the path of a song file on song list</string>
</resources>

0 comments on commit c7b813c

Please sign in to comment.