Skip to content

Commit

Permalink
```
Browse files Browse the repository at this point in the history
feat(settings): Add blur player background setting

Adds a setting to blur the background of the now playing screen.  Includes UI updates and data storage.
```
  • Loading branch information
maxrave-dev committed Jan 31, 2025
1 parent 6c768df commit 45fcf74
Show file tree
Hide file tree
Showing 7 changed files with 1,186 additions and 1,061 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,25 @@ class DataStoreManager(
}
}

val blurPlayerBackground =
settingsDataStore.data.map { preferences ->
preferences[BLUR_PLAYER_BACKGROUND] ?: FALSE
}

suspend fun setBlurPlayerBackground(blur: Boolean) {
withContext(Dispatchers.IO) {
if (blur) {
settingsDataStore.edit { settings ->
settings[BLUR_PLAYER_BACKGROUND] = TRUE
}
} else {
settingsDataStore.edit { settings ->
settings[BLUR_PLAYER_BACKGROUND] = FALSE
}
}
}
}

val playbackSpeed =
settingsDataStore.data.map { preferences ->
preferences[PLAYBACK_SPEED] ?: 1.0f
Expand Down Expand Up @@ -798,6 +817,7 @@ class DataStoreManager(
val SHOULD_SHOW_LOG_IN_REQUIRED_ALERT = stringPreferencesKey("should_show_log_in_required_alert")
val AUTO_CHECK_FOR_UPDATES = stringPreferencesKey("auto_check_for_updates")
val BLUR_FULLSCREEN_LYRICS = stringPreferencesKey("blur_fullscreen_lyrics")
val BLUR_PLAYER_BACKGROUND = stringPreferencesKey("blur_player_background")
val PLAYBACK_SPEED = floatPreferencesKey("playback_speed")
val PITCH = intPreferencesKey("pitch")
const val REPEAT_MODE_OFF = "REPEAT_MODE_OFF"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ import com.moriatsushi.insetsx.systemBars
import dev.chrisbanes.haze.HazeState
import dev.chrisbanes.haze.hazeEffect
import dev.chrisbanes.haze.hazeSource
import dev.chrisbanes.haze.materials.CupertinoMaterials
import dev.chrisbanes.haze.materials.ExperimentalHazeMaterialsApi
import dev.chrisbanes.haze.materials.HazeMaterials
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch

Expand Down Expand Up @@ -354,7 +354,7 @@ fun FullscreenLyricsSheet(
if (shouldHaze) {
Modifier.hazeEffect(
hazeState,
style = HazeMaterials.thin(),
style = CupertinoMaterials.thin(),
)
} else {
Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ fun SettingScreen(
val proxyPort by viewModel.proxyPort.collectAsStateWithLifecycle()
val autoCheckUpdate by viewModel.autoCheckUpdate.collectAsStateWithLifecycle()
val blurFullscreenLyrics by viewModel.blurFullscreenLyrics.collectAsStateWithLifecycle()
val blurPlayerBackground by viewModel.blurPlayerBackground.collectAsStateWithLifecycle()
var checkForUpdateSubtitle by rememberSaveable {
mutableStateOf("")
}
Expand Down Expand Up @@ -276,6 +277,12 @@ fun SettingScreen(
smallSubtitle = true,
switch = (blurFullscreenLyrics to { viewModel.setBlurFullscreenLyrics(it) }),
)
SettingItem(
title = stringResource(R.string.blur_player_background),
subtitle = stringResource(R.string.blur_player_background_description),
smallSubtitle = true,
switch = (blurPlayerBackground to { viewModel.setBlurPlayerBackground(it) }),
)
}
}
item(key = "content") {
Expand Down
Loading

0 comments on commit 45fcf74

Please sign in to comment.