Add dot to make the user aware of battery restrictions
This commit is contained in:
@@ -22,11 +22,13 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.draw.drawBehind
|
||||||
import androidx.compose.ui.draw.shadow
|
import androidx.compose.ui.draw.shadow
|
||||||
|
import androidx.compose.ui.geometry.Offset
|
||||||
import androidx.compose.ui.graphics.Brush
|
import androidx.compose.ui.graphics.Brush
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.ColorFilter
|
import androidx.compose.ui.graphics.ColorFilter
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
import androidx.compose.ui.graphics.Shadow
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
@@ -196,6 +198,26 @@ fun HomeScreen() {
|
|||||||
settingsRoute()
|
settingsRoute()
|
||||||
}
|
}
|
||||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||||
|
.run {
|
||||||
|
if (preferences.isFirstLaunch) {
|
||||||
|
drawBehind {
|
||||||
|
drawCircle(
|
||||||
|
color = colorPalette.red,
|
||||||
|
center = Offset(
|
||||||
|
x = size.width,
|
||||||
|
y = 0.dp.toPx()
|
||||||
|
),
|
||||||
|
radius = 4.dp.toPx(),
|
||||||
|
shadow = Shadow(
|
||||||
|
color = colorPalette.red,
|
||||||
|
blurRadius = 4.dp.toPx()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this
|
||||||
|
}
|
||||||
|
}
|
||||||
.size(24.dp)
|
.size(24.dp)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import androidx.compose.runtime.*
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.alpha
|
import androidx.compose.ui.draw.alpha
|
||||||
|
import androidx.compose.ui.geometry.center
|
||||||
import androidx.compose.ui.graphics.*
|
import androidx.compose.ui.graphics.*
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.text.TextStyle
|
||||||
@@ -26,6 +27,7 @@ import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette
|
|||||||
import it.vfsfitvnm.vimusic.ui.styling.LocalTypography
|
import it.vfsfitvnm.vimusic.ui.styling.LocalTypography
|
||||||
import it.vfsfitvnm.vimusic.utils.*
|
import it.vfsfitvnm.vimusic.utils.*
|
||||||
|
|
||||||
|
|
||||||
@ExperimentalAnimationApi
|
@ExperimentalAnimationApi
|
||||||
@Composable
|
@Composable
|
||||||
fun SettingsScreen() {
|
fun SettingsScreen() {
|
||||||
@@ -92,6 +94,7 @@ fun SettingsScreen() {
|
|||||||
host {
|
host {
|
||||||
val colorPalette = LocalColorPalette.current
|
val colorPalette = LocalColorPalette.current
|
||||||
val typography = LocalTypography.current
|
val typography = LocalTypography.current
|
||||||
|
val preferences = LocalPreferences.current
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -132,7 +135,9 @@ fun SettingsScreen() {
|
|||||||
color: Color,
|
color: Color,
|
||||||
title: String,
|
title: String,
|
||||||
description: String,
|
description: String,
|
||||||
route: Route0
|
route: Route0,
|
||||||
|
withAlert: Boolean = false,
|
||||||
|
onClick: (() -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
@@ -143,6 +148,7 @@ fun SettingsScreen() {
|
|||||||
interactionSource = remember { MutableInteractionSource() },
|
interactionSource = remember { MutableInteractionSource() },
|
||||||
onClick = {
|
onClick = {
|
||||||
route()
|
route()
|
||||||
|
onClick?.invoke()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.padding(horizontal = 16.dp, vertical = 12.dp)
|
.padding(horizontal = 16.dp, vertical = 12.dp)
|
||||||
@@ -163,7 +169,10 @@ fun SettingsScreen() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.weight(1f)
|
||||||
|
) {
|
||||||
BasicText(
|
BasicText(
|
||||||
text = title,
|
text = title,
|
||||||
style = typography.s.semiBold,
|
style = typography.s.semiBold,
|
||||||
@@ -175,6 +184,23 @@ fun SettingsScreen() {
|
|||||||
maxLines = 1
|
maxLines = 1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (withAlert) {
|
||||||
|
Canvas(
|
||||||
|
modifier = Modifier
|
||||||
|
.size(8.dp)
|
||||||
|
) {
|
||||||
|
drawCircle(
|
||||||
|
color = colorPalette.red,
|
||||||
|
center = size.center.copy(x = size.width),
|
||||||
|
radius = 4.dp.toPx(),
|
||||||
|
shadow = Shadow(
|
||||||
|
color = colorPalette.red,
|
||||||
|
blurRadius = 4.dp.toPx()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +241,11 @@ fun SettingsScreen() {
|
|||||||
icon = R.drawable.shapes,
|
icon = R.drawable.shapes,
|
||||||
title = "Other",
|
title = "Other",
|
||||||
description = "Advanced settings",
|
description = "Advanced settings",
|
||||||
route = otherSettingsRoute
|
route = otherSettingsRoute,
|
||||||
|
withAlert = LocalPreferences.current.isFirstLaunch,
|
||||||
|
onClick = {
|
||||||
|
preferences.isFirstLaunch = false
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
Entry(
|
Entry(
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import it.vfsfitvnm.youtubemusic.YouTube
|
|||||||
@Stable
|
@Stable
|
||||||
class Preferences(
|
class Preferences(
|
||||||
private val edit: (action: SharedPreferences.Editor.() -> Unit) -> Unit,
|
private val edit: (action: SharedPreferences.Editor.() -> Unit) -> Unit,
|
||||||
|
initialIsFirstLaunch: Boolean,
|
||||||
initialSongSortBy: SongSortBy,
|
initialSongSortBy: SongSortBy,
|
||||||
initialSongSortOrder: SortOrder,
|
initialSongSortOrder: SortOrder,
|
||||||
initialColorPaletteMode: ColorPaletteMode,
|
initialColorPaletteMode: ColorPaletteMode,
|
||||||
@@ -30,6 +31,7 @@ class Preferences(
|
|||||||
edit = { action: SharedPreferences.Editor.() -> Unit ->
|
edit = { action: SharedPreferences.Editor.() -> Unit ->
|
||||||
preferences.edit(action = action)
|
preferences.edit(action = action)
|
||||||
},
|
},
|
||||||
|
initialIsFirstLaunch = preferences.getBoolean(Keys.isFirstLaunch, true),
|
||||||
initialSongSortBy = preferences.getEnum(Keys.songSortBy, SongSortBy.DateAdded),
|
initialSongSortBy = preferences.getEnum(Keys.songSortBy, SongSortBy.DateAdded),
|
||||||
initialSongSortOrder = preferences.getEnum(Keys.songSortOrder, SortOrder.Descending),
|
initialSongSortOrder = preferences.getEnum(Keys.songSortOrder, SortOrder.Descending),
|
||||||
initialColorPaletteMode = preferences.getEnum(Keys.colorPaletteMode, ColorPaletteMode.System),
|
initialColorPaletteMode = preferences.getEnum(Keys.colorPaletteMode, ColorPaletteMode.System),
|
||||||
@@ -44,6 +46,9 @@ class Preferences(
|
|||||||
initialIsInvincibilityEnabled = preferences.getBoolean(Keys.isInvincibilityEnabled, false),
|
initialIsInvincibilityEnabled = preferences.getBoolean(Keys.isInvincibilityEnabled, false),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var isFirstLaunch = initialIsFirstLaunch
|
||||||
|
set(value) = edit { putBoolean(Keys.isFirstLaunch, value) }
|
||||||
|
|
||||||
var songSortBy = initialSongSortBy
|
var songSortBy = initialSongSortBy
|
||||||
set(value) = edit { putEnum(Keys.songSortBy, value) }
|
set(value) = edit { putEnum(Keys.songSortBy, value) }
|
||||||
|
|
||||||
@@ -81,6 +86,7 @@ class Preferences(
|
|||||||
set(value) = edit { putBoolean(Keys.isInvincibilityEnabled, value) }
|
set(value) = edit { putBoolean(Keys.isInvincibilityEnabled, value) }
|
||||||
|
|
||||||
object Keys {
|
object Keys {
|
||||||
|
const val isFirstLaunch = "isFirstLaunch"
|
||||||
const val songSortOrder = "songSortOrder"
|
const val songSortOrder = "songSortOrder"
|
||||||
const val songSortBy = "songSortBy"
|
const val songSortBy = "songSortBy"
|
||||||
const val colorPaletteMode = "colorPaletteMode"
|
const val colorPaletteMode = "colorPaletteMode"
|
||||||
|
|||||||
Reference in New Issue
Block a user