Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 1a302a2d authored by Wolf-Martell Montwé's avatar Wolf-Martell Montwé Committed by GitHub
Browse files

Merge pull request #6795 from thundernest/add_onboarding_feature

Add onboarding feature
parents 10d93775 64f9a7fd
Loading
Loading
Loading
Loading
+49 −28
Original line number Diff line number Diff line
@@ -10,7 +10,10 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import app.k9mail.core.ui.compose.common.DevicePreviews
import app.k9mail.core.ui.compose.designsystem.atom.Surface
import app.k9mail.core.ui.compose.designsystem.template.ResponsiveContent
import app.k9mail.core.ui.compose.theme.K9Theme
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.imageItems
@@ -30,6 +33,7 @@ fun CatalogContent(
    modifier: Modifier = Modifier,
) {
    Surface {
        ResponsiveContent {
            LazyVerticalGrid(
                columns = GridCells.Adaptive(300.dp),
                contentPadding = contentPadding,
@@ -54,10 +58,12 @@ fun CatalogContent(
            }
        }
    }
}

@DevicePreviews
@Composable
internal fun CatalogContentPreview() {
internal fun CatalogContentK9ThemePreview() {
    K9Theme {
        CatalogContent(
            catalogTheme = CatalogTheme.K9,
            catalogThemeVariant = CatalogThemeVariant.LIGHT,
@@ -66,3 +72,18 @@ internal fun CatalogContentPreview() {
            contentPadding = PaddingValues(),
        )
    }
}

@DevicePreviews
@Composable
internal fun CatalogContentThunderbirdThemePreview() {
    ThunderbirdTheme {
        CatalogContent(
            catalogTheme = CatalogTheme.THUNDERBIRD,
            catalogThemeVariant = CatalogThemeVariant.LIGHT,
            onThemeChange = {},
            onThemeVariantChange = {},
            contentPadding = PaddingValues(),
        )
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -578,6 +578,8 @@ style:
    ignoreConstantDeclaration: true
    ignoreCompanionObjectPropertyDeclaration: true
    ignoreAnnotation: false
    ignoreAnnotated:
      - 'Preview'
    ignoreNamedArgument: true
    ignoreEnums: false
    ignoreRanges: false
+4 −4
Original line number Diff line number Diff line
@@ -12,11 +12,11 @@ enum class WindowSizeClass {
    ;

    companion object {
        private const val COMPACT_MAX_WIDTH = 600
        private const val COMPACT_MAX_HEIGHT = 480
        const val COMPACT_MAX_WIDTH = 600
        const val COMPACT_MAX_HEIGHT = 480

        private const val MEDIUM_MAX_WIDTH = 840
        private const val MEDIUM_MAX_HEIGHT = 900
        const val MEDIUM_MAX_WIDTH = 840
        const val MEDIUM_MAX_HEIGHT = 900

        fun fromWidth(width: Int): WindowSizeClass {
            return when {
+3 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ 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 app.k9mail.core.ui.compose.theme.MainTheme
import app.k9mail.core.ui.compose.theme.PreviewWithThemes
import androidx.compose.material.Surface as MaterialSurface
@@ -13,11 +14,13 @@ import androidx.compose.material.Surface as MaterialSurface
fun Surface(
    modifier: Modifier = Modifier,
    color: Color = MainTheme.colors.surface,
    elevation: Dp = MainTheme.elevations.default,
    content: @Composable () -> Unit,
) {
    MaterialSurface(
        modifier = modifier,
        content = content,
        elevation = elevation,
        color = color,
    )
}
+86 −0
Original line number Diff line number Diff line
package app.k9mail.core.ui.compose.designsystem.template

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.dp
import app.k9mail.core.ui.compose.designsystem.atom.Surface
import app.k9mail.core.ui.compose.theme.K9Theme

/**
 * The [LazyColumnWithFooter] composable creates a [LazyColumn] with a footer.
 *
 * @param modifier The modifier to be applied to the layout.
 * @param verticalArrangement The vertical arrangement of the children.
 * @param horizontalAlignment The horizontal alignment of the children.
 * @param footer The footer to be displayed at the bottom of the [LazyColumn].
 * @param content The content of the [LazyColumn].
 */
@Composable
fun LazyColumnWithFooter(
    modifier: Modifier = Modifier,
    verticalArrangement: Arrangement.Vertical = Arrangement.Top,
    horizontalAlignment: Alignment.Horizontal = Alignment.Start,
    footer: @Composable () -> Unit = {},
    content: LazyListScope.() -> Unit,
) {
    LazyColumn(
        modifier = modifier,
        verticalArrangement = verticalArrangementWithFooter(verticalArrangement),
        horizontalAlignment = horizontalAlignment,
    ) {
        content()
        item { footer() }
    }
}

@Composable
private fun verticalArrangementWithFooter(verticalArrangement: Arrangement.Vertical) = remember {
    object : Arrangement.Vertical {
        override fun Density.arrange(
            totalSize: Int,
            sizes: IntArray,
            outPositions: IntArray,
        ) {
            val innerSizes = sizes.dropLast(1).toIntArray()
            val footerSize = sizes.last()
            val innerTotalSize = totalSize - footerSize

            with(verticalArrangement) {
                arrange(
                    totalSize = innerTotalSize,
                    sizes = innerSizes,
                    outPositions = outPositions,
                )
            }

            outPositions[outPositions.lastIndex] = totalSize - footerSize
        }
    }
}

@Composable
@Preview
internal fun LazyColumnWithFooterPreview() {
    K9Theme {
        Surface {
            LazyColumnWithFooter(
                modifier = Modifier.fillMaxSize(),
                verticalArrangement = Arrangement.spacedBy(32.dp, Alignment.CenterVertically),
                footer = { Text(text = "Footer") },
            ) {
                items(10) {
                    Text(text = "Item $it")
                }
            }
        }
    }
}
Loading