Create NotificationScreen

This commit is contained in:
vfsfitvnm
2022-06-11 18:57:32 +02:00
parent baea3d252c
commit afc64cae74
10 changed files with 277 additions and 21 deletions

View File

@@ -0,0 +1,51 @@
package it.vfsfitvnm.vimusic.ui.components.themed
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.center
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shadow
import androidx.compose.ui.unit.dp
import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette
import it.vfsfitvnm.vimusic.utils.drawCircle
@Composable
fun Switch(
isChecked: Boolean,
modifier: Modifier = Modifier,
) {
val colorPalette = LocalColorPalette.current
val backgroundColor by animateColorAsState(if (isChecked) colorPalette.primaryContainer else colorPalette.lightBackground)
val color by animateColorAsState(if (isChecked) colorPalette.onPrimaryContainer else colorPalette.textDisabled)
val offset by animateDpAsState(if (isChecked) 36.dp else 12.dp)
Spacer(
modifier = modifier
.width(48.dp)
.height(24.dp)
.background(color = backgroundColor, shape = CircleShape)
.drawBehind {
drawCircle(
color = color,
radius = 8.dp.toPx(),
center = size.center.copy(x = offset.toPx()),
shadow = Shadow(
color = Color.Black.copy(alpha = 0.4f),
blurRadius = 8.dp.toPx(),
offset = Offset(x = -1.dp.toPx(), y = 1.dp.toPx())
)
)
}
)
}