Add ContentListView to wrap repeated content view setup

This commit is contained in:
Wolf-Martell Montwé 2023-06-19 14:47:26 +02:00 committed by Wolf-Martell Montwé
parent f3d096fed4
commit cbffe44496
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72

View file

@ -0,0 +1,62 @@
package app.k9mail.feature.account.common.ui
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.ui.compose.designsystem.atom.text.TextSubtitle1
import app.k9mail.core.ui.compose.designsystem.template.ResponsiveWidthContainer
import app.k9mail.core.ui.compose.theme.MainTheme
import app.k9mail.core.ui.compose.theme.PreviewWithThemes
@Composable
fun ContentListView(
modifier: Modifier = Modifier,
contentPadding: PaddingValues = PaddingValues(),
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
verticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(MainTheme.spacings.default),
items: LazyListScope.() -> Unit,
) {
ResponsiveWidthContainer(
modifier = Modifier
.padding(contentPadding)
.fillMaxWidth()
.then(modifier),
) {
LazyColumn(
modifier = Modifier
.fillMaxSize()
.imePadding(),
horizontalAlignment = horizontalAlignment,
verticalArrangement = verticalArrangement,
) {
items()
}
}
}
@Preview
@Composable
internal fun ContentListViewPreview() {
PreviewWithThemes {
ContentListView {
item {
TextSubtitle1("Item 1")
}
item {
TextSubtitle1("Item 2")
}
item {
TextSubtitle1("Item 3")
}
}
}
}