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

Unverified Commit 8afe58c6 authored by Wolf-Martell Montwé's avatar Wolf-Martell Montwé
Browse files

Add OnAccountClick event to trigger account selection and add...

Add OnAccountClick event to trigger account selection and add OnAccountViewClick on the account view for testing
parent 8d34ada1
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -12,10 +12,11 @@ internal fun DrawerContentPreview() {
    PreviewWithTheme {
        DrawerContent(
            state = DrawerContract.State(
                currentAccount = null,
                accounts = persistentListOf(),
                currentAccount = null,
                folders = persistentListOf(),
            ),
            onEvent = {},
        )
    }
}
@@ -29,6 +30,7 @@ fun DrawerContentWithAccountPreview() {
                accounts = persistentListOf(DISPLAY_ACCOUNT),
                currentAccount = DISPLAY_ACCOUNT,
            ),
            onEvent = {},
        )
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ internal fun AccountViewPreview() {
            displayName = DISPLAY_NAME,
            emailAddress = EMAIL_ADDRESS,
            accountColor = 0,
            onClick = {},
        )
    }
}
@@ -27,6 +28,7 @@ internal fun AccountViewWithColorPreview() {
            displayName = DISPLAY_NAME,
            emailAddress = EMAIL_ADDRESS,
            accountColor = 0xFF0000,
            onClick = {},
        )
    }
}
@@ -39,6 +41,7 @@ internal fun AccountViewWithLongDisplayName() {
            displayName = "$LONG_TEXT $DISPLAY_NAME",
            emailAddress = EMAIL_ADDRESS,
            accountColor = 0,
            onClick = {},
        )
    }
}
@@ -51,6 +54,7 @@ internal fun AccountViewWithLongEmailPreview() {
            displayName = DISPLAY_NAME,
            emailAddress = "$LONG_TEXT@example.com",
            accountColor = 0,
            onClick = {},
        )
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ 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.theme2.MainTheme
import app.k9mail.feature.navigation.drawer.ui.DrawerContract.Event
import app.k9mail.feature.navigation.drawer.ui.DrawerContract.State
import app.k9mail.feature.navigation.drawer.ui.account.AccountView
import app.k9mail.feature.navigation.drawer.ui.folder.FolderList
@@ -17,6 +18,7 @@ import app.k9mail.feature.navigation.drawer.ui.folder.FolderList
@Composable
fun DrawerContent(
    state: State,
    onEvent: (Event) -> Unit,
    modifier: Modifier = Modifier,
) {
    Surface(
@@ -37,6 +39,7 @@ fun DrawerContent(
                    displayName = it.account.displayName,
                    emailAddress = it.account.email,
                    accountColor = it.account.chipColor,
                    onClick = { onEvent(Event.OnAccountViewClick(it)) },
                )

                DividerHorizontal()
+2 −1
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ import app.k9mail.core.ui.compose.common.mvi.UnidirectionalViewModel
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayAccount
import app.k9mail.legacy.ui.folder.DisplayFolder
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.immutableListOf
import kotlinx.collections.immutable.persistentListOf

interface DrawerContract {
@@ -23,6 +22,8 @@ interface DrawerContract {

    sealed interface Event {
        data object OnRefresh : Event
        data class OnAccountClick(val account: DisplayAccount) : Event
        data class OnAccountViewClick(val account: DisplayAccount) : Event
    }

    sealed interface Effect
+2 −1
Original line number Diff line number Diff line
@@ -3,9 +3,9 @@ package app.k9mail.feature.navigation.drawer.ui
import androidx.compose.runtime.Composable
import app.k9mail.core.ui.compose.common.mvi.observe
import app.k9mail.core.ui.compose.designsystem.molecule.PullToRefreshBox
import org.koin.androidx.compose.koinViewModel
import app.k9mail.feature.navigation.drawer.ui.DrawerContract.Event
import app.k9mail.feature.navigation.drawer.ui.DrawerContract.ViewModel
import org.koin.androidx.compose.koinViewModel

@Composable
fun DrawerView(
@@ -19,6 +19,7 @@ fun DrawerView(
    ) {
        DrawerContent(
            state = state.value,
            onEvent = { dispatch(it) },
        )
    }
}
Loading