Skip to content

Commit 324c5e8

Browse files
committed
Add more drawer preview for corner cases
1 parent 0b4939d commit 324c5e8

File tree

2 files changed

+229
-0
lines changed

2 files changed

+229
-0
lines changed

feature/navigation/drawer/src/debug/kotlin/app/k9mail/feature/navigation/drawer/ui/DrawerContentPreview.kt

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
package app.k9mail.feature.navigation.drawer.ui
22

3+
import androidx.compose.foundation.layout.height
4+
import androidx.compose.foundation.layout.width
35
import androidx.compose.runtime.Composable
6+
import androidx.compose.ui.Modifier
47
import androidx.compose.ui.tooling.preview.Preview
8+
import androidx.compose.ui.unit.dp
59
import app.k9mail.core.ui.compose.designsystem.PreviewWithTheme
10+
import app.k9mail.core.ui.compose.designsystem.atom.Surface
611
import app.k9mail.feature.navigation.drawer.ui.FakeData.DISPLAY_ACCOUNT
712
import app.k9mail.feature.navigation.drawer.ui.FakeData.DISPLAY_FOLDER
813
import app.k9mail.feature.navigation.drawer.ui.FakeData.UNIFIED_FOLDER
14+
import app.k9mail.feature.navigation.drawer.ui.FakeData.createAccountList
15+
import app.k9mail.feature.navigation.drawer.ui.FakeData.createDisplayFolderList
916
import kotlinx.collections.immutable.persistentListOf
1017

1118
@Composable
@@ -99,3 +106,133 @@ internal fun DrawerContentWithSelectedUnifiedFolderPreview() {
99106
)
100107
}
101108
}
109+
110+
@Composable
111+
@Preview(showBackground = true)
112+
internal fun DrawerContentSingleAccountPreview() {
113+
PreviewWithTheme {
114+
DrawerContent(
115+
state = DrawerContract.State(
116+
accounts = persistentListOf(
117+
DISPLAY_ACCOUNT,
118+
),
119+
selectedAccountId = DISPLAY_ACCOUNT.id,
120+
folders = createDisplayFolderList(hasUnifiedFolder = false),
121+
selectedFolderId = UNIFIED_FOLDER.id,
122+
showAccountSelector = false,
123+
),
124+
onEvent = {},
125+
)
126+
}
127+
}
128+
129+
@Composable
130+
@Preview(showBackground = true)
131+
internal fun DrawerContentSingleAccountWithAccountSelectionPreview() {
132+
PreviewWithTheme {
133+
DrawerContent(
134+
state = DrawerContract.State(
135+
accounts = persistentListOf(
136+
DISPLAY_ACCOUNT,
137+
),
138+
selectedAccountId = DISPLAY_ACCOUNT.id,
139+
folders = createDisplayFolderList(hasUnifiedFolder = false),
140+
selectedFolderId = UNIFIED_FOLDER.id,
141+
),
142+
onEvent = {},
143+
)
144+
}
145+
}
146+
147+
@Composable
148+
@Preview(showBackground = true)
149+
internal fun DrawerContentMultipleAccountsAccountPreview() {
150+
PreviewWithTheme {
151+
DrawerContent(
152+
state = DrawerContract.State(
153+
accounts = createAccountList(),
154+
selectedAccountId = "account1",
155+
folders = createDisplayFolderList(hasUnifiedFolder = true),
156+
selectedFolderId = UNIFIED_FOLDER.id,
157+
showAccountSelector = false,
158+
),
159+
onEvent = {},
160+
)
161+
}
162+
}
163+
164+
@Composable
165+
@Preview(showBackground = true)
166+
internal fun DrawerContentMultipleAccountsWithAccountSelectionPreview() {
167+
PreviewWithTheme {
168+
DrawerContent(
169+
state = DrawerContract.State(
170+
accounts = createAccountList(),
171+
selectedAccountId = "account1",
172+
folders = createDisplayFolderList(hasUnifiedFolder = true),
173+
selectedFolderId = UNIFIED_FOLDER.id,
174+
),
175+
onEvent = {},
176+
)
177+
}
178+
}
179+
180+
@Composable
181+
@Preview(showBackground = true)
182+
internal fun DrawerContentMultipleAccountsWithAccountSelection2Preview() {
183+
PreviewWithTheme {
184+
DrawerContent(
185+
state = DrawerContract.State(
186+
accounts = createAccountList(),
187+
selectedAccountId = "account3",
188+
folders = createDisplayFolderList(hasUnifiedFolder = true),
189+
selectedFolderId = UNIFIED_FOLDER.id,
190+
),
191+
onEvent = {},
192+
)
193+
}
194+
}
195+
196+
@Composable
197+
@Preview(showBackground = true)
198+
internal fun DrawerContentSmallScreenPreview() {
199+
PreviewWithTheme {
200+
Surface(
201+
modifier = Modifier
202+
.width(320.dp)
203+
.height(480.dp),
204+
) {
205+
DrawerContent(
206+
state = DrawerContract.State(
207+
accounts = createAccountList(),
208+
selectedAccountId = "account3",
209+
folders = createDisplayFolderList(hasUnifiedFolder = true),
210+
selectedFolderId = UNIFIED_FOLDER.id,
211+
),
212+
onEvent = {},
213+
)
214+
}
215+
}
216+
}
217+
218+
@Composable
219+
@Preview(showBackground = true)
220+
internal fun DrawerContentVerySmallScreenPreview() {
221+
PreviewWithTheme {
222+
Surface(
223+
modifier = Modifier
224+
.width(240.dp)
225+
.height(320.dp),
226+
) {
227+
DrawerContent(
228+
state = DrawerContract.State(
229+
accounts = createAccountList(),
230+
selectedAccountId = "account3",
231+
folders = createDisplayFolderList(hasUnifiedFolder = true),
232+
selectedFolderId = UNIFIED_FOLDER.id,
233+
),
234+
onEvent = {},
235+
)
236+
}
237+
}
238+
}

feature/navigation/drawer/src/debug/kotlin/app/k9mail/feature/navigation/drawer/ui/FakeData.kt

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ import app.k9mail.core.mail.folder.api.Folder
66
import app.k9mail.core.mail.folder.api.FolderType
77
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayAccount
88
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayAccountFolder
9+
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayFolder
910
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayUnifiedFolder
1011
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayUnifiedFolderType
1112
import app.k9mail.legacy.account.Account
1213
import app.k9mail.legacy.account.Identity
14+
import kotlinx.collections.immutable.PersistentList
15+
import kotlinx.collections.immutable.persistentListOf
16+
import kotlinx.collections.immutable.toPersistentList
1317

1418
internal object FakeData {
1519

@@ -66,4 +70,92 @@ internal object FakeData {
6670
unreadMessageCount = 123,
6771
starredMessageCount = 567,
6872
)
73+
74+
fun createAccountList(): PersistentList<DisplayAccount> {
75+
return persistentListOf(
76+
DisplayAccount(
77+
id = "account1",
78+
name = "job@example.com",
79+
email = "job@example.com",
80+
color = Color.Green.toArgb(),
81+
unreadMessageCount = 2,
82+
starredMessageCount = 0,
83+
),
84+
DisplayAccount(
85+
id = "account2",
86+
name = "Jodie Doe",
87+
email = "jodie@example.com",
88+
color = Color.Red.toArgb(),
89+
unreadMessageCount = 12,
90+
starredMessageCount = 0,
91+
),
92+
DisplayAccount(
93+
id = "account3",
94+
name = "John Doe",
95+
email = "john@example.com",
96+
color = Color.Cyan.toArgb(),
97+
unreadMessageCount = 0,
98+
starredMessageCount = 0,
99+
),
100+
)
101+
}
102+
103+
fun createDisplayFolderList(hasUnifiedFolder: Boolean): PersistentList<DisplayFolder> {
104+
val folders = mutableListOf<DisplayFolder>()
105+
106+
if (hasUnifiedFolder) {
107+
folders.add(UNIFIED_FOLDER)
108+
}
109+
110+
folders.addAll(
111+
listOf(
112+
DISPLAY_FOLDER.copy(
113+
folder = FOLDER.copy(id = 2, name = "Inbox", type = FolderType.INBOX),
114+
unreadMessageCount = 12,
115+
),
116+
DISPLAY_FOLDER.copy(
117+
folder = FOLDER.copy(id = 3, name = "Outbox", type = FolderType.OUTBOX),
118+
unreadMessageCount = 0,
119+
),
120+
DISPLAY_FOLDER.copy(
121+
folder = FOLDER.copy(id = 4, name = "Drafts", type = FolderType.DRAFTS),
122+
unreadMessageCount = 0,
123+
),
124+
DISPLAY_FOLDER.copy(
125+
folder = FOLDER.copy(id = 5, name = "Sent", type = FolderType.SENT),
126+
unreadMessageCount = 0,
127+
),
128+
DISPLAY_FOLDER.copy(
129+
folder = FOLDER.copy(id = 6, name = "Spam", type = FolderType.SPAM),
130+
unreadMessageCount = 5,
131+
),
132+
DISPLAY_FOLDER.copy(
133+
folder = FOLDER.copy(id = 7, name = "Trash", type = FolderType.TRASH),
134+
unreadMessageCount = 0,
135+
),
136+
DISPLAY_FOLDER.copy(
137+
folder = FOLDER.copy(id = 8, name = "Archive", type = FolderType.ARCHIVE),
138+
unreadMessageCount = 0,
139+
),
140+
DISPLAY_FOLDER.copy(
141+
folder = FOLDER.copy(id = 9, name = "Work", type = FolderType.REGULAR),
142+
unreadMessageCount = 3,
143+
),
144+
DISPLAY_FOLDER.copy(
145+
folder = FOLDER.copy(id = 10, name = "Personal", type = FolderType.REGULAR),
146+
unreadMessageCount = 4,
147+
),
148+
DISPLAY_FOLDER.copy(
149+
folder = FOLDER.copy(id = 11, name = "Important", type = FolderType.REGULAR),
150+
unreadMessageCount = 0,
151+
),
152+
DISPLAY_FOLDER.copy(
153+
folder = FOLDER.copy(id = 12, name = "Later", type = FolderType.REGULAR),
154+
unreadMessageCount = 0,
155+
),
156+
),
157+
)
158+
159+
return folders.toPersistentList()
160+
}
69161
}

0 commit comments

Comments
 (0)