Skip to content

Commit

Permalink
Merge pull request #8155 from wmontwe/add-drawer-unified-folder-support
Browse files Browse the repository at this point in the history
Add drawer unified folder support
  • Loading branch information
wmontwe authored Sep 24, 2024
2 parents 0bde0ae + d8d8868 commit 32cf76e
Show file tree
Hide file tree
Showing 34 changed files with 424 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.material.icons.filled.Outbox
import androidx.compose.material.icons.filled.Star
import androidx.compose.material.icons.filled.VisibilityOff
import androidx.compose.material.icons.outlined.AccountCircle
import androidx.compose.material.icons.outlined.AllInbox
import androidx.compose.material.icons.outlined.Archive
import androidx.compose.material.icons.outlined.Check
import androidx.compose.material.icons.outlined.ChevronLeft
Expand Down Expand Up @@ -50,6 +51,9 @@ object Icons {
val AccountCircle: ImageVector
get() = MaterialIcons.Outlined.AccountCircle

val AllInbox: ImageVector
get() = MaterialIcons.Outlined.AllInbox

val Archive: ImageVector
get() = MaterialIcons.Outlined.Archive

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ 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.FakeData.DISPLAY_ACCOUNT
import app.k9mail.feature.navigation.drawer.ui.FakeData.DISPLAY_FOLDER
import app.k9mail.feature.navigation.drawer.ui.FakeData.UNIFIED_FOLDER
import kotlinx.collections.immutable.persistentListOf

@Composable
Expand All @@ -23,7 +25,7 @@ internal fun DrawerContentPreview() {

@Composable
@Preview(showBackground = true)
fun DrawerContentWithAccountPreview() {
internal fun DrawerContentWithAccountPreview() {
PreviewWithTheme {
DrawerContent(
state = DrawerContract.State(
Expand All @@ -35,3 +37,44 @@ fun DrawerContentWithAccountPreview() {
)
}
}

@Composable
@Preview(showBackground = true)
internal fun DrawerContentWithFoldersPreview() {
PreviewWithTheme {
DrawerContent(
state = DrawerContract.State(
accounts = persistentListOf(
DISPLAY_ACCOUNT,
),
selectedAccount = null,
folders = persistentListOf(
UNIFIED_FOLDER,
DISPLAY_FOLDER,
),
),
onEvent = {},
)
}
}

@Composable
@Preview(showBackground = true)
internal fun DrawerContentWithSelectedFolderPreview() {
PreviewWithTheme {
DrawerContent(
state = DrawerContract.State(
accounts = persistentListOf(
DISPLAY_ACCOUNT,
),
selectedAccount = DISPLAY_ACCOUNT,
folders = persistentListOf(
UNIFIED_FOLDER,
DISPLAY_FOLDER,
),
selectedFolder = DISPLAY_FOLDER,
),
onEvent = {},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import app.k9mail.core.mail.folder.api.Folder
import app.k9mail.core.mail.folder.api.FolderType
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayAccount
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayAccountFolder
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayUnifiedFolder
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayUnifiedFolderType
import app.k9mail.legacy.account.Account
import app.k9mail.legacy.account.Identity

Expand Down Expand Up @@ -52,4 +54,11 @@ internal object FakeData {
unreadMessageCount = 14,
starredMessageCount = 5,
)

val UNIFIED_FOLDER = DisplayUnifiedFolder(
id = "unified_inbox",
unifiedType = DisplayUnifiedFolderType.INBOX,
unreadMessageCount = 123,
starredMessageCount = 567,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import app.k9mail.feature.navigation.drawer.ui.FakeData.DISPLAY_ACCOUNT

@Composable
@Preview(showBackground = true)
fun AccountAvatarPreview() {
internal fun AccountAvatarPreview() {
PreviewWithThemes {
AccountAvatar(
account = DISPLAY_ACCOUNT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import app.k9mail.feature.navigation.drawer.ui.FakeData.DISPLAY_ACCOUNT

@Composable
@Preview(showBackground = true)
fun AccountListItemPreview() {
internal fun AccountListItemPreview() {
PreviewWithThemes {
AccountListItem(
account = DISPLAY_ACCOUNT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import kotlinx.collections.immutable.persistentListOf

@Composable
@Preview(showBackground = true)
fun AccountListPreview() {
internal fun AccountListPreview() {
PreviewWithTheme {
AccountList(
accounts = persistentListOf(
Expand All @@ -23,7 +23,7 @@ fun AccountListPreview() {

@Composable
@Preview(showBackground = true)
fun AccountListWithSelectedPreview() {
internal fun AccountListWithSelectedPreview() {
PreviewWithTheme {
AccountList(
accounts = persistentListOf(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,66 +1,73 @@
package app.k9mail.feature.navigation.drawer.ui.folder

import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.mail.folder.api.FolderType
import app.k9mail.core.ui.compose.designsystem.PreviewWithThemes
import app.k9mail.feature.navigation.drawer.ui.FakeData.DISPLAY_FOLDER
import app.k9mail.feature.navigation.drawer.ui.FakeData.UNIFIED_FOLDER
import app.k9mail.legacy.ui.folder.FolderNameFormatter

@Composable
@Preview(showBackground = true)
fun FolderListItemPreview() {
internal fun FolderListItemPreview() {
PreviewWithThemes {
FolderListItem(
displayFolder = DISPLAY_FOLDER,
selected = false,
showStarredCount = false,
onClick = {},
folderNameFormatter = FolderNameFormatter(LocalContext.current.resources),
)
}
}

@Composable
@Preview(showBackground = true)
fun FolderListItemSelectedPreview() {
internal fun FolderListItemSelectedPreview() {
PreviewWithThemes {
FolderListItem(
displayFolder = DISPLAY_FOLDER,
selected = true,
showStarredCount = false,
onClick = {},
folderNameFormatter = FolderNameFormatter(LocalContext.current.resources),
)
}
}

@Composable
@Preview(showBackground = true)
fun FolderListItemWithStarredPreview() {
internal fun FolderListItemWithStarredPreview() {
PreviewWithThemes {
FolderListItem(
displayFolder = DISPLAY_FOLDER,
selected = false,
showStarredCount = true,
onClick = {},
folderNameFormatter = FolderNameFormatter(LocalContext.current.resources),
)
}
}

@Composable
@Preview(showBackground = true)
fun FolderListItemWithStarredSelectedPreview() {
internal fun FolderListItemWithStarredSelectedPreview() {
PreviewWithThemes {
FolderListItem(
displayFolder = DISPLAY_FOLDER,
selected = true,
showStarredCount = true,
onClick = {},
folderNameFormatter = FolderNameFormatter(LocalContext.current.resources),
)
}
}

@Composable
@Preview(showBackground = true)
fun FolderListItemWithInboxFolderPreview() {
internal fun FolderListItemWithInboxFolderPreview() {
PreviewWithThemes {
FolderListItem(
displayFolder = DISPLAY_FOLDER.copy(
Expand All @@ -71,6 +78,21 @@ fun FolderListItemWithInboxFolderPreview() {
selected = false,
showStarredCount = true,
onClick = {},
folderNameFormatter = FolderNameFormatter(LocalContext.current.resources),
)
}
}

@Composable
@Preview(showBackground = true)
internal fun FolderListItemWithUnifiedFolderPreview() {
PreviewWithThemes {
FolderListItem(
displayFolder = UNIFIED_FOLDER,
selected = false,
showStarredCount = false,
onClick = {},
folderNameFormatter = FolderNameFormatter(LocalContext.current.resources),
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package app.k9mail.feature.navigation.drawer.ui.folder

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.FakeData.DISPLAY_FOLDER
import app.k9mail.feature.navigation.drawer.ui.FakeData.UNIFIED_FOLDER
import kotlinx.collections.immutable.persistentListOf

@Composable
@Preview(showBackground = true)
internal fun FolderListPreview() {
PreviewWithTheme {
FolderList(
folders = persistentListOf(
DISPLAY_FOLDER,
),
selectedFolder = null,
onFolderClick = {},
showStarredCount = false,
)
}
}

@Composable
@Preview(showBackground = true)
internal fun FolderListPreviewSelected() {
PreviewWithTheme {
FolderList(
folders = persistentListOf(
DISPLAY_FOLDER,
),
selectedFolder = DISPLAY_FOLDER,
onFolderClick = {},
showStarredCount = false,
)
}
}

@Composable
@Preview(showBackground = true)
internal fun FolderListWithUnifiedFolderPreview() {
PreviewWithTheme {
FolderList(
folders = persistentListOf(
UNIFIED_FOLDER,
DISPLAY_FOLDER,
),
selectedFolder = DISPLAY_FOLDER,
onFolderClick = {},
showStarredCount = false,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import app.k9mail.core.ui.compose.designsystem.PreviewWithThemes

@Composable
@Preview(showBackground = true)
fun SettingItemPreview() {
internal fun SettingItemPreview() {
PreviewWithThemes {
SettingItem(
label = "Setting",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import app.k9mail.core.ui.compose.designsystem.atom.icon.Icons

@Composable
@Preview(showBackground = true)
fun SettingListItemPreview() {
internal fun SettingListItemPreview() {
PreviewWithThemes {
SettingListItem(
label = "Settings",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import app.k9mail.core.ui.compose.designsystem.PreviewWithTheme

@Composable
@Preview(showBackground = true)
fun SettingListPreview() {
internal fun SettingListPreview() {
PreviewWithTheme {
SettingList(
onAccountSelectorClick = {},
Expand All @@ -18,7 +18,7 @@ fun SettingListPreview() {

@Composable
@Preview(showBackground = true)
fun SettingListShowAccountSelectorPreview() {
internal fun SettingListShowAccountSelectorPreview() {
PreviewWithTheme {
SettingList(
onAccountSelectorClick = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class FolderDrawer(
override val parent: AppCompatActivity,
private val openAccount: (account: Account) -> Unit,
private val openFolder: (folderId: Long) -> Unit,
private val openUnifiedFolder: () -> Unit,
private val openManageFolders: () -> Unit,
private val openSettings: () -> Unit,
createDrawerListener: () -> DrawerLayout.DrawerListener,
Expand All @@ -40,6 +41,7 @@ class FolderDrawer(
DrawerView(
openAccount = openAccount,
openFolder = openFolder,
openUnifiedFolder = openUnifiedFolder,
openManageFolders = openManageFolders,
openSettings = openSettings,
closeDrawer = { close() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ val navigationDrawerModule: Module = module {
single<UseCase.GetDisplayFoldersForAccount> {
GetDisplayFoldersForAccount(
repository = get(),
messageCountsProvider = get(),
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package app.k9mail.feature.navigation.drawer.domain

import app.k9mail.feature.navigation.drawer.domain.entity.DisplayAccount
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayAccountFolder
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayFolder
import app.k9mail.feature.navigation.drawer.domain.entity.DrawerConfig
import app.k9mail.legacy.account.Account
import kotlinx.coroutines.flow.Flow
Expand All @@ -18,7 +18,7 @@ interface DomainContract {
}

fun interface GetDisplayFoldersForAccount {
operator fun invoke(accountUuid: String): Flow<List<DisplayAccountFolder>>
operator fun invoke(accountUuid: String, includeUnifiedFolders: Boolean): Flow<List<DisplayFolder>>
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ data class DisplayAccountFolder(
val accountUuid: String,
val folder: Folder,
val isInTopGroup: Boolean,
val unreadMessageCount: Int,
val starredMessageCount: Int,
)
override val unreadMessageCount: Int,
override val starredMessageCount: Int,
) : DisplayFolder {
override val id: String = accountUuid + folder.id
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package app.k9mail.feature.navigation.drawer.domain.entity

interface DisplayFolder {
val id: String
val unreadMessageCount: Int
val starredMessageCount: Int
}
Loading

0 comments on commit 32cf76e

Please sign in to comment.