Add Icon atom as wrapper for Material Icon

This commit is contained in:
Wolf-Martell Montwé 2023-05-10 15:23:52 +02:00
parent 5354a82b99
commit db085695f8
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72
3 changed files with 98 additions and 0 deletions

View file

@ -16,6 +16,7 @@ import app.k9mail.core.ui.compose.theme.MainTheme
import app.k9mail.core.ui.compose.theme.ThunderbirdTheme
import app.k9mail.ui.catalog.items.buttonItems
import app.k9mail.ui.catalog.items.colorItems
import app.k9mail.ui.catalog.items.iconItems
import app.k9mail.ui.catalog.items.imageItems
import app.k9mail.ui.catalog.items.selectionControlItems
import app.k9mail.ui.catalog.items.textFieldItems
@ -55,6 +56,7 @@ fun CatalogContent(
selectionControlItems()
textFieldItems()
imageItems()
iconItems()
}
}
}

View file

@ -0,0 +1,49 @@
package app.k9mail.ui.catalog.items
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.grid.LazyGridScope
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import app.k9mail.core.ui.compose.designsystem.atom.Icon
import app.k9mail.core.ui.compose.designsystem.atom.text.TextCaption
import app.k9mail.core.ui.compose.theme.Icons
import app.k9mail.core.ui.compose.theme.MainTheme
fun LazyGridScope.iconItems() {
sectionHeaderItem(text = "Icons")
item {
IconItem(
name = "Error",
imageVector = Icons.error,
)
}
}
@Composable
private fun IconItem(
name: String,
imageVector: ImageVector,
) {
Column(
modifier = Modifier.padding(MainTheme.spacings.default),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(MainTheme.spacings.default),
) {
Row {
Icon(
imageVector = imageVector,
)
Icon(
imageVector = imageVector,
tint = Color.Magenta,
)
}
TextCaption(text = name)
}
}

View file

@ -0,0 +1,47 @@
package app.k9mail.core.ui.compose.designsystem.atom
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.LocalContentColor
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.ui.compose.theme.Icons
import app.k9mail.core.ui.compose.theme.PreviewWithThemes
import androidx.compose.material.Icon as MaterialIcon
@Composable
fun Icon(
imageVector: ImageVector,
modifier: Modifier = Modifier,
tint: Color = LocalContentColor.current.copy(alpha = LocalContentAlpha.current),
) {
MaterialIcon(
imageVector = imageVector,
contentDescription = null,
modifier = modifier,
tint = tint,
)
}
@Preview(showBackground = true)
@Composable
internal fun IconPreview() {
PreviewWithThemes {
Icon(
imageVector = Icons.error,
)
}
}
@Preview(showBackground = true)
@Composable
internal fun IconTintedPreview() {
PreviewWithThemes {
Icon(
imageVector = Icons.error,
tint = Color.Magenta,
)
}
}