Skip to content

Commit

Permalink
Merge pull request #8139 from wmontwe/add-drawer-folder-list-part3
Browse files Browse the repository at this point in the history
Add drawer folder list - part 3
  • Loading branch information
wmontwe authored Sep 13, 2024
2 parents c05533a + 8afe58c commit 008a5e2
Show file tree
Hide file tree
Showing 26 changed files with 754 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package app.k9mail.ui.catalog.ui.atom.items
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.grid.LazyGridScope
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand All @@ -24,6 +25,28 @@ fun LazyGridScope.iconItems() {
sectionHeaderItem(
text = "Compose Icons",
)
sectionSubtitleItem(text = "Sizes")
defaultItem {
IconItem(
name = "Small",
imageVector = Icons.Outlined.Info,
modifier = Modifier.size(MainTheme.sizes.iconSmall),
)
}
defaultItem {
IconItem(
name = "Default",
imageVector = Icons.Outlined.Info,
modifier = Modifier.size(MainTheme.sizes.icon),
)
}
defaultItem {
IconItem(
name = "Large",
imageVector = Icons.Outlined.Info,
modifier = Modifier.size(MainTheme.sizes.iconLarge),
)
}
sectionSubtitleItem(text = "Filled")
getIconsFor(Icons.Filled)
sectionSubtitleItem(text = "Outlined")
Expand Down Expand Up @@ -81,13 +104,13 @@ private fun IconItem(
) {
Column(
modifier = Modifier
.padding(defaultItemPadding())
.then(modifier),
.padding(defaultItemPadding()),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(MainTheme.spacings.default),
) {
Icon(
imageVector = imageVector,
modifier = modifier,
)
TextBodySmall(text = name)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,25 @@ package app.k9mail.core.ui.compose.designsystem.organism.drawer
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.ui.compose.designsystem.PreviewWithThemes
import app.k9mail.core.ui.compose.designsystem.atom.icon.Icons

@Composable
@Preview(showBackground = true)
internal fun NavigationDrawerItemBadgePreview() {
PreviewWithThemes {
NavigationDrawerItemBadge(
label = "100+",
label = "99+",
)
}
}

@Composable
@Preview(showBackground = true)
internal fun NavigationDrawerItemBadgeWithIconPreview() {
PreviewWithThemes {
NavigationDrawerItemBadge(
label = "99+",
imageVector = Icons.Outlined.Info,
)
}
}
Original file line number Diff line number Diff line change
@@ -1,43 +1,67 @@
package app.k9mail.core.ui.compose.designsystem.atom.icon

import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material.icons.automirrored.outlined.Send
import androidx.compose.material.icons.filled.Cancel
import androidx.compose.material.icons.filled.CheckCircle
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.Archive
import androidx.compose.material.icons.outlined.Check
import androidx.compose.material.icons.outlined.Delete
import androidx.compose.material.icons.outlined.Drafts
import androidx.compose.material.icons.outlined.ErrorOutline
import androidx.compose.material.icons.outlined.ExpandLess
import androidx.compose.material.icons.outlined.ExpandMore
import androidx.compose.material.icons.outlined.Folder
import androidx.compose.material.icons.outlined.Inbox
import androidx.compose.material.icons.outlined.Info
import androidx.compose.material.icons.outlined.Menu
import androidx.compose.material.icons.outlined.Report
import androidx.compose.material.icons.outlined.Security
import androidx.compose.material.icons.outlined.Send
import androidx.compose.material.icons.outlined.Visibility
import androidx.compose.ui.graphics.vector.ImageVector
import app.k9mail.core.ui.compose.designsystem.atom.icon.filled.Dot
import androidx.compose.material.icons.Icons as MaterialIcons

// We're using getters so not all icons are loaded into memory as soon as one of the nested objects is accessed.
object Icons {
object Filled {
val Cancel: ImageVector
get() = MaterialIcons.Filled.Cancel

val CheckCircle: ImageVector
get() = MaterialIcons.Filled.CheckCircle

val Cancel: ImageVector
get() = MaterialIcons.Filled.Cancel
val Dot: ImageVector
get() = MaterialIcons.Filled.Dot

val Star: ImageVector
get() = MaterialIcons.Filled.Star
}

object Outlined {
val AccountCircle: ImageVector
get() = MaterialIcons.Outlined.AccountCircle

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

val ArrowBack: ImageVector
get() = MaterialIcons.AutoMirrored.Outlined.ArrowBack

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

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

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

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

Expand All @@ -47,6 +71,9 @@ object Icons {
val ExpandLess: ImageVector
get() = MaterialIcons.Outlined.ExpandLess

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

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

Expand All @@ -62,6 +89,12 @@ object Icons {
val Security: ImageVector
get() = MaterialIcons.Outlined.Security

val Send: ImageVector
get() = MaterialIcons.AutoMirrored.Outlined.Send

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package app.k9mail.core.ui.compose.designsystem.atom.icon.filled

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.materialIcon
import androidx.compose.material.icons.materialPath
import androidx.compose.ui.graphics.vector.ImageVector

@Suppress("MagicNumber")
val Icons.Filled.Dot: ImageVector
get() {
if (instance != null) {
return instance!!
}
instance = materialIcon(name = "Filled.Dot") {
materialPath {
moveTo(12.0f, 6.0f)
curveToRelative(-3.31f, 0.0f, -6.0f, 2.69f, -6.0f, 6.0f)
reflectiveCurveToRelative(2.69f, 6.0f, 6.0f, 6.0f)
reflectiveCurveToRelative(6.0f, -2.69f, 6.0f, -6.0f)
reflectiveCurveToRelative(-2.69f, -6.0f, -6.0f, -6.0f)
close()
}
}
return instance!!
}

private var instance: ImageVector? = null
Original file line number Diff line number Diff line change
@@ -1,16 +1,42 @@
package app.k9mail.core.ui.compose.designsystem.organism.drawer

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import app.k9mail.core.ui.compose.designsystem.atom.icon.Icon
import app.k9mail.core.ui.compose.designsystem.atom.text.TextLabelLarge
import app.k9mail.core.ui.compose.theme2.MainTheme

/**
* A badge for a navigation drawer item with an optional icon.
*
* @param label The label to display.
* @param modifier The modifier to apply.
* @param imageVector The image vector to display (optional).
*/
@Composable
fun NavigationDrawerItemBadge(
label: String,
modifier: Modifier = Modifier,
imageVector: ImageVector? = null,
) {
TextLabelLarge(
text = label,
Row(
modifier = modifier,
)
verticalAlignment = Alignment.CenterVertically,
) {
if (imageVector != null) {
Icon(
imageVector = imageVector,
modifier = Modifier.size(MainTheme.sizes.iconSmall)
.padding(end = MainTheme.spacings.quarter),
)
}
TextLabelLarge(
text = label,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ data class ThemeSizes(
val huge: Dp,
val huger: Dp,

val iconSmall: Dp,
val icon: Dp,
val largeIcon: Dp,
val iconLarge: Dp,

val topBarHeight: Dp,
val bottomBarHeight: Dp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ val defaultThemeSizes = ThemeSizes(
huge = 256.dp,
huger = 384.dp,

iconSmall = 16.dp,
icon = 24.dp,
largeIcon = 32.dp,
iconLarge = 32.dp,

topBarHeight = 64.dp,
bottomBarHeight = 80.dp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ 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
import app.k9mail.feature.navigation.drawer.ui.FakeData.DISPLAY_ACCOUNT
import kotlinx.collections.immutable.persistentListOf

@Composable
@Preview(showBackground = true)
internal fun DrawerContentPreview() {
PreviewWithTheme {
DrawerContent(
state = DrawerContract.State(
accounts = emptyList(),
accounts = persistentListOf(),
currentAccount = null,
folders = persistentListOf(),
),
onEvent = {},
)
}
}
Expand All @@ -24,9 +27,10 @@ fun DrawerContentWithAccountPreview() {
PreviewWithTheme {
DrawerContent(
state = DrawerContract.State(
accounts = listOf(DISPLAY_ACCOUNT),
accounts = persistentListOf(DISPLAY_ACCOUNT),
currentAccount = DISPLAY_ACCOUNT,
),
onEvent = {},
)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package app.k9mail.feature.navigation.drawer.ui.account
package app.k9mail.feature.navigation.drawer.ui

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.legacy.account.Account
import app.k9mail.legacy.account.Identity
import app.k9mail.legacy.ui.folder.DisplayFolder

internal object FakeData {

Expand Down Expand Up @@ -34,4 +37,18 @@ internal object FakeData {
unreadMessageCount = 0,
starredMessageCount = 0,
)

val FOLDER = Folder(
id = 1,
name = "Folder Name",
type = FolderType.REGULAR,
isLocalOnly = false,
)

val DISPLAY_FOLDER = DisplayFolder(
folder = FOLDER,
isInTopGroup = false,
unreadMessageCount = 14,
starredMessageCount = 5,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +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
import app.k9mail.feature.navigation.drawer.ui.FakeData.DISPLAY_NAME
import app.k9mail.feature.navigation.drawer.ui.FakeData.EMAIL_ADDRESS
import app.k9mail.feature.navigation.drawer.ui.FakeData.LONG_TEXT

@Composable
@Preview(showBackground = true)
Expand All @@ -15,6 +15,7 @@ internal fun AccountViewPreview() {
displayName = DISPLAY_NAME,
emailAddress = EMAIL_ADDRESS,
accountColor = 0,
onClick = {},
)
}
}
Expand All @@ -27,6 +28,7 @@ internal fun AccountViewWithColorPreview() {
displayName = DISPLAY_NAME,
emailAddress = EMAIL_ADDRESS,
accountColor = 0xFF0000,
onClick = {},
)
}
}
Expand All @@ -39,6 +41,7 @@ internal fun AccountViewWithLongDisplayName() {
displayName = "$LONG_TEXT $DISPLAY_NAME",
emailAddress = EMAIL_ADDRESS,
accountColor = 0,
onClick = {},
)
}
}
Expand All @@ -51,6 +54,7 @@ internal fun AccountViewWithLongEmailPreview() {
displayName = DISPLAY_NAME,
emailAddress = "$LONG_TEXT@example.com",
accountColor = 0,
onClick = {},
)
}
}
Loading

0 comments on commit 008a5e2

Please sign in to comment.