Change remaining atoms to Material 3

This commit is contained in:
Wolf-Martell Montwé 2024-03-21 12:08:58 +01:00
parent 65288cc334
commit c52c898dd3
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72
20 changed files with 247 additions and 172 deletions

View file

@ -6,7 +6,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.ui.compose.designsystem.atom.Divider
import app.k9mail.core.ui.compose.designsystem.atom.DividerHorizontal
import app.k9mail.core.ui.compose.designsystem.atom.text.TextHeadline6
import app.k9mail.core.ui.compose.theme.MainTheme
import app.k9mail.core.ui.compose.theme.PreviewWithThemes
@ -29,7 +29,7 @@ fun DrawerHeaderItem(
TextHeadline6(
text = text,
)
Divider()
DividerHorizontal()
}
}

View file

@ -6,7 +6,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.grid.GridItemSpan
import androidx.compose.foundation.lazy.grid.LazyGridScope
import androidx.compose.ui.Modifier
import app.k9mail.core.ui.compose.designsystem.atom.Divider
import app.k9mail.core.ui.compose.designsystem.atom.DividerHorizontal
import app.k9mail.core.ui.compose.designsystem.atom.text.TextHeadline6
import app.k9mail.core.ui.compose.theme.MainTheme
@ -26,7 +26,7 @@ fun LazyGridScope.sectionHeaderItem(
TextHeadline6(
text = text,
)
Divider()
DividerHorizontal()
}
}
}

View file

@ -6,7 +6,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.grid.GridItemSpan
import androidx.compose.foundation.lazy.grid.LazyGridScope
import androidx.compose.ui.Modifier
import app.k9mail.core.ui.compose.designsystem.atom.Divider
import app.k9mail.core.ui.compose.designsystem.atom.DividerHorizontal
import app.k9mail.core.ui.compose.designsystem.atom.text.TextSubtitle1
import app.k9mail.core.ui.compose.theme.MainTheme
@ -26,7 +26,7 @@ fun LazyGridScope.sectionSubtitleItem(
TextSubtitle1(
text = text,
)
Divider()
DividerHorizontal()
}
}
}

View file

@ -0,0 +1,28 @@
package app.k9mail.core.ui.compose.designsystem.atom
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.ui.compose.designsystem.PreviewWithThemes
@Composable
@Preview(showBackground = true)
internal fun CheckboxPreview() {
PreviewWithThemes {
Checkbox(
checked = true,
onCheckedChange = {},
)
}
}
@Composable
@Preview(showBackground = true)
internal fun CheckboxDisabledPreview() {
PreviewWithThemes {
Checkbox(
checked = true,
onCheckedChange = {},
enabled = false,
)
}
}

View file

@ -0,0 +1,27 @@
package app.k9mail.core.ui.compose.designsystem.atom
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.ui.compose.designsystem.PreviewWithThemes
import app.k9mail.core.ui.compose.theme2.MainTheme
@Composable
@Preview(showBackground = true)
internal fun CircularProgressIndicatorPreview() {
PreviewWithThemes {
CircularProgressIndicator(
progress = { 0.75f },
)
}
}
@Composable
@Preview(showBackground = true)
internal fun CircularProgressIndicatorColoredPreview() {
PreviewWithThemes {
CircularProgressIndicator(
progress = { 0.75f },
color = MainTheme.colors.secondary,
)
}
}

View file

@ -0,0 +1,26 @@
package app.k9mail.core.ui.compose.designsystem.atom
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.ui.compose.designsystem.PreviewWithThemes
import app.k9mail.core.ui.compose.theme2.MainTheme
@Composable
@Preview(showBackground = true)
internal fun DividerHorizontalPreview() {
PreviewWithThemes {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(MainTheme.spacings.double),
) {
DividerHorizontal(
modifier = Modifier.fillMaxWidth(),
)
}
}
}

View file

@ -0,0 +1,26 @@
package app.k9mail.core.ui.compose.designsystem.atom
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.ui.compose.designsystem.PreviewWithThemes
import app.k9mail.core.ui.compose.theme2.MainTheme
@Composable
@Preview(showBackground = true)
internal fun DividerVerticalPreview() {
PreviewWithThemes {
Row(
modifier = Modifier
.fillMaxHeight()
.padding(MainTheme.spacings.double),
) {
DividerVertical(
modifier = Modifier.fillMaxHeight(),
)
}
}
}

View file

@ -0,0 +1,37 @@
package app.k9mail.core.ui.compose.designsystem.atom
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.ui.compose.designsystem.PreviewWithThemes
import app.k9mail.core.ui.compose.theme2.MainTheme
@Composable
@Preview(showBackground = true)
internal fun SurfacePreview() {
PreviewWithThemes {
Surface(
modifier = Modifier
.requiredHeight(MainTheme.sizes.larger)
.requiredWidth(MainTheme.sizes.larger),
content = {},
)
}
}
@Composable
@Preview(showBackground = true)
internal fun SurfaceWithShapePreview() {
PreviewWithThemes {
Surface(
modifier = Modifier
.requiredHeight(MainTheme.sizes.larger)
.requiredWidth(MainTheme.sizes.larger),
shape = MainTheme.shapes.small,
color = MainTheme.colors.primary,
content = {},
)
}
}

View file

@ -0,0 +1,28 @@
package app.k9mail.core.ui.compose.designsystem.atom
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.ui.compose.designsystem.PreviewWithThemes
@Composable
@Preview(showBackground = true)
internal fun SwitchPreview() {
PreviewWithThemes {
Switch(
checked = true,
onCheckedChange = {},
)
}
}
@Composable
@Preview(showBackground = true)
internal fun SwitchDisabledPreview() {
PreviewWithThemes {
Switch(
checked = true,
onCheckedChange = {},
enabled = false,
)
}
}

View file

@ -2,9 +2,7 @@ package app.k9mail.core.ui.compose.designsystem.atom
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.ui.compose.theme.PreviewWithThemes
import androidx.compose.material.Checkbox as MaterialCheckbox
import androidx.compose.material3.Checkbox as Material3Checkbox
@Composable
fun Checkbox(
@ -13,33 +11,10 @@ fun Checkbox(
modifier: Modifier = Modifier,
enabled: Boolean = true,
) {
MaterialCheckbox(
Material3Checkbox(
checked = checked,
onCheckedChange = onCheckedChange,
modifier = modifier,
enabled = enabled,
)
}
@Preview(showBackground = true)
@Composable
internal fun CheckboxPreview() {
PreviewWithThemes {
Checkbox(
checked = true,
onCheckedChange = {},
)
}
}
@Preview(showBackground = true)
@Composable
internal fun CheckboxDisabledPreview() {
PreviewWithThemes {
Checkbox(
checked = true,
onCheckedChange = {},
enabled = false,
)
}
}

View file

@ -1,20 +1,18 @@
package app.k9mail.core.ui.compose.designsystem.atom
import androidx.compose.material3.ProgressIndicatorDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.ui.compose.theme.MainTheme
import app.k9mail.core.ui.compose.theme.PreviewWithThemes
import androidx.compose.material.CircularProgressIndicator as MaterialCircularProgressIndicator
import androidx.compose.material3.CircularProgressIndicator as Material3CircularProgressIndicator
@Composable
fun CircularProgressIndicator(
progress: Float,
progress: () -> Float,
modifier: Modifier = Modifier,
color: Color = MainTheme.colors.secondary,
color: Color = ProgressIndicatorDefaults.circularColor,
) {
MaterialCircularProgressIndicator(
Material3CircularProgressIndicator(
progress = progress,
modifier = modifier,
color = color,
@ -24,18 +22,10 @@ fun CircularProgressIndicator(
@Composable
fun CircularProgressIndicator(
modifier: Modifier = Modifier,
color: Color = MainTheme.colors.secondary,
color: Color = ProgressIndicatorDefaults.circularColor,
) {
MaterialCircularProgressIndicator(
Material3CircularProgressIndicator(
modifier = modifier,
color = color,
)
}
@Preview
@Composable
internal fun CircularProgressIndicatorPreview() {
PreviewWithThemes {
CircularProgressIndicator(progress = 0.75f)
}
}

View file

@ -1,5 +1,6 @@
package app.k9mail.core.ui.compose.designsystem.atom
import androidx.compose.material3.ProgressIndicatorDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
@ -9,7 +10,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import app.k9mail.core.ui.compose.common.visibility.hide
import app.k9mail.core.ui.compose.theme.MainTheme
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
@ -23,7 +23,7 @@ private const val LOADING_INDICATOR_DELAY = 500L
@Composable
fun DelayedCircularProgressIndicator(
modifier: Modifier = Modifier,
color: Color = MainTheme.colors.secondary,
color: Color = ProgressIndicatorDefaults.circularColor,
) {
var progressIndicatorVisible by remember { mutableStateOf(false) }

View file

@ -1,48 +0,0 @@
package app.k9mail.core.ui.compose.designsystem.atom
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import app.k9mail.core.ui.compose.theme.MainTheme
import app.k9mail.core.ui.compose.theme.PreviewWithThemes
import androidx.compose.material.Divider as MaterialDivider
@Composable
fun Divider(
modifier: Modifier = Modifier,
color: Color = MaterialTheme.colors.onSurface.copy(alpha = DIVIDER_ALPHA),
thickness: Dp = 1.dp,
startIndent: Dp = 0.dp,
) {
MaterialDivider(
modifier = modifier,
color = color,
thickness = thickness,
startIndent = startIndent,
)
}
private const val DIVIDER_ALPHA = 0.12f
@Preview(showBackground = true)
@Composable
internal fun DividerPreview() {
PreviewWithThemes {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(MainTheme.spacings.double),
) {
Divider(
modifier = Modifier.fillMaxWidth(),
)
}
}
}

View file

@ -0,0 +1,21 @@
package app.k9mail.core.ui.compose.designsystem.atom
import androidx.compose.material3.DividerDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.material3.HorizontalDivider as Material3HorizontalDivider
@Composable
fun DividerHorizontal(
modifier: Modifier = Modifier,
thickness: Dp = DividerDefaults.Thickness,
color: Color = DividerDefaults.color,
) {
Material3HorizontalDivider(
modifier = modifier,
thickness = thickness,
color = color,
)
}

View file

@ -0,0 +1,21 @@
package app.k9mail.core.ui.compose.designsystem.atom
import androidx.compose.material3.DividerDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.material3.VerticalDivider as Material3VerticalDivider
@Composable
fun DividerVertical(
modifier: Modifier = Modifier,
thickness: Dp = DividerDefaults.Thickness,
color: Color = DividerDefaults.color,
) {
Material3VerticalDivider(
modifier = modifier,
thickness = thickness,
color = color,
)
}

View file

@ -1,62 +1,27 @@
package app.k9mail.core.ui.compose.designsystem.atom
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import app.k9mail.core.ui.compose.theme.MainTheme
import app.k9mail.core.ui.compose.theme.PreviewWithThemes
import androidx.compose.material.Surface as MaterialSurface
import app.k9mail.core.ui.compose.theme2.MainTheme
import androidx.compose.material3.Surface as Material3Surface
@Composable
fun Surface(
modifier: Modifier = Modifier,
shape: Shape = RectangleShape,
color: Color = MainTheme.colors.surface,
elevation: Dp = MainTheme.elevations.default,
color: Color = Color.Unspecified,
tonalElevation: Dp = MainTheme.elevations.level0,
content: @Composable () -> Unit,
) {
MaterialSurface(
Material3Surface(
modifier = modifier,
shape = shape,
content = content,
elevation = elevation,
tonalElevation = tonalElevation,
color = color,
)
}
@Preview(showBackground = true)
@Composable
internal fun SurfacePreview() {
PreviewWithThemes {
Surface(
modifier = Modifier
.requiredHeight(100.dp)
.requiredWidth(100.dp),
content = {},
)
}
}
@Preview(showBackground = true)
@Composable
internal fun SurfaceWithShapePreview() {
PreviewWithThemes {
Background {
Surface(
modifier = Modifier
.requiredHeight(MainTheme.sizes.larger)
.requiredWidth(MainTheme.sizes.larger),
shape = MainTheme.shapes.small,
color = MainTheme.colors.primary,
content = {},
)
}
}
}

View file

@ -2,9 +2,7 @@ package app.k9mail.core.ui.compose.designsystem.atom
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.ui.compose.theme.PreviewWithThemes
import androidx.compose.material.Switch as MaterialSwitch
import androidx.compose.material3.Switch as Material3Switch
@Composable
fun Switch(
@ -13,33 +11,10 @@ fun Switch(
modifier: Modifier = Modifier,
enabled: Boolean = true,
) {
MaterialSwitch(
Material3Switch(
checked = checked,
onCheckedChange = onCheckedChange,
modifier = modifier,
enabled = enabled,
)
}
@Preview(showBackground = true)
@Composable
internal fun SwitchPreview() {
PreviewWithThemes {
Switch(
checked = true,
onCheckedChange = {},
)
}
}
@Preview(showBackground = true)
@Composable
internal fun SwitchDisabledPreview() {
PreviewWithThemes {
Switch(
checked = true,
onCheckedChange = {},
enabled = false,
)
}
}

View file

@ -87,7 +87,7 @@ private fun ExpandedContent(
) {
Surface(
modifier = Modifier.requiredWidth(WindowSizeClass.MEDIUM_MAX_WIDTH.dp),
elevation = MainTheme.elevations.raised,
tonalElevation = MainTheme.elevations.raised,
) {
content()
}
@ -105,7 +105,7 @@ private fun ExpandedContent(
modifier = Modifier
.requiredWidth(WindowSizeClass.MEDIUM_MAX_WIDTH.dp)
.requiredHeight(WindowSizeClass.MEDIUM_MAX_HEIGHT.dp),
elevation = MainTheme.elevations.raised,
tonalElevation = MainTheme.elevations.raised,
) {
content()
}

View file

@ -85,7 +85,9 @@ private fun ButtonBar(
label = "BottomBarElevation",
)
Surface(elevation = elevation) {
Surface(
tonalElevation = elevation,
) {
ResponsiveWidthContainer(
modifier = Modifier
.padding(

View file

@ -144,7 +144,9 @@ private fun BottomBar(
label = "BottomBarElevation",
)
Surface(elevation = elevation) {
Surface(
tonalElevation = elevation,
) {
ResponsiveWidthContainer(
modifier = Modifier.fillMaxWidth(),
) {