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

Unverified Commit 5b00628f authored by Wolf-Martell Montwé's avatar Wolf-Martell Montwé
Browse files

Wrap ErrorView and LoadingView in a box to be able to scale them to fillSize...

Wrap ErrorView and LoadingView in a box to be able to scale them to fillSize without changing their content size
parent 16768c8e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ fun LazyGridScope.stateItems() {
@Composable
private fun StatefulContentLoadingErrorState() {
    val state = remember {
        mutableStateOf<ContentLoadingErrorState>(ContentLoadingErrorState.Loading)
        mutableStateOf(ContentLoadingErrorState.Loading)
    }

    ContentLoadingErrorView(
+4 −6
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ fun ContentLoadingErrorView(
    ) {
        AnimatedContent(
            targetState = state,
            label = "CleView",
            label = "ContentLoadingErrorView",
        ) { targetState ->
            when (targetState) {
                ContentLoadingErrorState.Loading -> loading()
@@ -41,10 +41,8 @@ fun ContentLoadingErrorView(
    }
}

sealed interface ContentLoadingErrorState {
    object Loading : ContentLoadingErrorState
    object Content : ContentLoadingErrorState
    object Error : ContentLoadingErrorState
enum class ContentLoadingErrorState {
    Loading, Content, Error
}

@Composable
@@ -52,7 +50,7 @@ sealed interface ContentLoadingErrorState {
internal fun ContentLoadingErrorViewPreview() {
    PreviewWithThemes {
        val state = remember {
            mutableStateOf<ContentLoadingErrorState>(ContentLoadingErrorState.Loading)
            mutableStateOf(ContentLoadingErrorState.Loading)
        }

        ContentLoadingErrorView(
+43 −35
Original line number Diff line number Diff line
package app.k9mail.core.ui.compose.designsystem.molecule

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
@@ -26,6 +27,13 @@ fun ErrorView(
    modifier: Modifier = Modifier,
    message: String? = null,
    onRetry: () -> Unit = { },
    contentAlignment: Alignment = Alignment.Center,
) {
    Box(
        modifier = Modifier
            .fillMaxWidth()
            .then(modifier),
        contentAlignment = contentAlignment,
    ) {
        Column(
            modifier = Modifier
@@ -33,8 +41,7 @@ fun ErrorView(
                .padding(
                    vertical = MainTheme.spacings.default,
                    horizontal = MainTheme.spacings.double,
            )
            .then(modifier),
                ),
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalArrangement = Arrangement.spacedBy(MainTheme.spacings.default),
        ) {
@@ -72,6 +79,7 @@ fun ErrorView(
            }
        }
    }
}

@Preview(showBackground = true)
@Composable
+21 −10
Original line number Diff line number Diff line
package app.k9mail.core.ui.compose.designsystem.molecule

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
@@ -18,6 +20,13 @@ import app.k9mail.core.ui.compose.theme.PreviewWithThemes
fun LoadingView(
    modifier: Modifier = Modifier,
    message: String? = null,
    contentAlignment: Alignment = Alignment.Center,
) {
    Box(
        modifier = Modifier
            .fillMaxWidth()
            .then(modifier),
        contentAlignment = contentAlignment,
    ) {
        Column(
            modifier = Modifier
@@ -25,6 +34,7 @@ fun LoadingView(
                .padding(MainTheme.spacings.default)
                .then(modifier),
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalArrangement = Arrangement.Center,
        ) {
            if (message != null) {
                TextSubtitle1(text = message)
@@ -37,6 +47,7 @@ fun LoadingView(
            }
        }
    }
}

@Preview(showBackground = true)
@Composable
+2 −2
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ internal fun AccountAutoDiscoveryContent(
            .then(modifier),
    ) {
        val resources = LocalContext.current.resources
        val cleState = remember(key1 = state.isLoading, key2 = state.error) {
        val viewState = remember(key1 = state.isLoading, key2 = state.error) {
            when {
                state.isLoading -> ContentLoadingErrorState.Loading
                state.error != null -> ContentLoadingErrorState.Error
@@ -55,7 +55,7 @@ internal fun AccountAutoDiscoveryContent(
        }

        ContentLoadingErrorView(
            state = cleState,
            state = viewState,
            loading = {
                LoadingView(
                    message = stringResource(id = R.string.account_setup_auto_discovery_loading_message),