Add dot to make the user aware of battery restrictions

This commit is contained in:
vfsfitvnm
2022-07-11 20:25:40 +02:00
parent 742e8702e5
commit 10b8c66887
3 changed files with 62 additions and 4 deletions

View File

@@ -22,11 +22,13 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
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.text.style.TextOverflow
import androidx.compose.ui.unit.dp
@@ -196,6 +198,26 @@ fun HomeScreen() {
settingsRoute()
}
.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)
)

View File

@@ -12,6 +12,7 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.geometry.center
import androidx.compose.ui.graphics.*
import androidx.compose.ui.res.painterResource
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.utils.*
@ExperimentalAnimationApi
@Composable
fun SettingsScreen() {
@@ -92,6 +94,7 @@ fun SettingsScreen() {
host {
val colorPalette = LocalColorPalette.current
val typography = LocalTypography.current
val preferences = LocalPreferences.current
Column(
modifier = Modifier
@@ -132,7 +135,9 @@ fun SettingsScreen() {
color: Color,
title: String,
description: String,
route: Route0
route: Route0,
withAlert: Boolean = false,
onClick: (() -> Unit)? = null
) {
Row(
verticalAlignment = Alignment.CenterVertically,
@@ -143,6 +148,7 @@ fun SettingsScreen() {
interactionSource = remember { MutableInteractionSource() },
onClick = {
route()
onClick?.invoke()
}
)
.padding(horizontal = 16.dp, vertical = 12.dp)
@@ -163,7 +169,10 @@ fun SettingsScreen() {
)
}
Column {
Column(
modifier = Modifier
.weight(1f)
) {
BasicText(
text = title,
style = typography.s.semiBold,
@@ -175,6 +184,23 @@ fun SettingsScreen() {
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,
title = "Other",
description = "Advanced settings",
route = otherSettingsRoute
route = otherSettingsRoute,
withAlert = LocalPreferences.current.isFirstLaunch,
onClick = {
preferences.isFirstLaunch = false
}
)
Entry(