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

Unverified Commit 3e1c976a authored by Wolf-Martell Montwé's avatar Wolf-Martell Montwé
Browse files

Add account view to drawer content

parent 1dce31a5
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -3,11 +3,30 @@ package app.k9mail.feature.navigation.drawer.ui
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.ui.compose.designsystem.PreviewWithTheme
import app.k9mail.feature.navigation.drawer.ui.account.FakeData.DISPLAY_ACCOUNT

@Composable
@Preview(showBackground = true)
internal fun DrawerContentPreview() {
    PreviewWithTheme {
        DrawerContent()
        DrawerContent(
            state = DrawerContract.State(
                accounts = emptyList(),
                currentAccount = null,
            ),
        )
    }
}

@Composable
@Preview(showBackground = true)
fun DrawerContentWithAccountPreview() {
    PreviewWithTheme {
        DrawerContent(
            state = DrawerContract.State(
                accounts = listOf(DISPLAY_ACCOUNT),
                currentAccount = DISPLAY_ACCOUNT,
            ),
        )
    }
}
+3 −7
Original line number Diff line number Diff line
@@ -3,6 +3,9 @@ package app.k9mail.feature.navigation.drawer.ui.account
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.ui.compose.designsystem.PreviewWithThemes
import app.k9mail.feature.navigation.drawer.ui.account.FakeData.DISPLAY_NAME
import app.k9mail.feature.navigation.drawer.ui.account.FakeData.EMAIL_ADDRESS
import app.k9mail.feature.navigation.drawer.ui.account.FakeData.LONG_TEXT

@Composable
@Preview(showBackground = true)
@@ -51,10 +54,3 @@ internal fun AccountViewWithLongEmailPreview() {
        )
    }
}

private const val DISPLAY_NAME = "Account Name"

private const val EMAIL_ADDRESS = "test@example.com"

private const val LONG_TEXT = "loremipsumdolorsitametconsetetursadipscingelitr" +
    "seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyameratseddiamvoluptua"
+37 −0
Original line number Diff line number Diff line
package app.k9mail.feature.navigation.drawer.ui.account

import app.k9mail.feature.navigation.drawer.domain.entity.DisplayAccount
import app.k9mail.legacy.account.Account
import app.k9mail.legacy.account.Identity

internal object FakeData {

    const val ACCOUNT_UUID = "uuid"
    const val DISPLAY_NAME = "Account Name"
    const val EMAIL_ADDRESS = "test@example.com"

    const val LONG_TEXT = "loremipsumdolorsitametconsetetursadipscingelitr" +
        "seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyameratseddiamvoluptua"

    val ACCOUNT = Account(
        uuid = ACCOUNT_UUID,
    ).apply {
        identities = ArrayList()

        val identity = Identity(
            signatureUse = false,
            signature = "",
            description = "",
        )
        identities.add(identity)

        name = DISPLAY_NAME
        email = EMAIL_ADDRESS
    }

    val DISPLAY_ACCOUNT = DisplayAccount(
        account = ACCOUNT,
        unreadMessageCount = 0,
        starredMessageCount = 0,
    )
}
+5 −1
Original line number Diff line number Diff line
@@ -39,5 +39,9 @@ val navigationDrawerModule: Module = module {
        )
    }

    viewModel { DrawerViewModel() }
    viewModel {
        DrawerViewModel(
            getDisplayAccounts = get(),
        )
    }
}
+40 −19
Original line number Diff line number Diff line
package app.k9mail.feature.navigation.drawer.ui

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import app.k9mail.core.ui.compose.designsystem.atom.DividerHorizontal
import app.k9mail.core.ui.compose.designsystem.atom.Surface
import app.k9mail.core.ui.compose.designsystem.organism.drawer.NavigationDrawerItem
import app.k9mail.core.ui.compose.theme2.MainTheme
import app.k9mail.feature.navigation.drawer.ui.DrawerContract.State
import app.k9mail.feature.navigation.drawer.ui.account.AccountView

@Composable
fun DrawerContent(
    state: State,
    modifier: Modifier = Modifier,
) {
    Surface(
@@ -19,12 +25,26 @@ fun DrawerContent(
            .fillMaxSize()
            .testTag("DrawerContent"),
    ) {
        LazyColumn(
        Column(
            modifier = Modifier
                .fillMaxSize()
                .padding(
                    vertical = MainTheme.spacings.oneHalf,
                ),
            verticalArrangement = Arrangement.spacedBy(MainTheme.spacings.default),
        ) {
            state.currentAccount?.let {
                AccountView(
                    displayName = it.account.displayName,
                    emailAddress = it.account.email,
                    accountColor = it.account.chipColor,
                )

                DividerHorizontal()
            }
            LazyColumn(
                modifier = Modifier
                    .fillMaxSize(),
            ) {
                item {
                    NavigationDrawerItem(
@@ -50,3 +70,4 @@ fun DrawerContent(
            }
        }
    }
}
Loading