Skip to content

Commit 3814850

Browse files
Merge pull request thunderbird#10025 from rafaeltonholo/feat/9989/display-account-visual-in-app-error-indication
feat(in-app-notifications): add account error indication
2 parents 9688eb8 + 21fb582 commit 3814850

12 files changed

Lines changed: 322 additions & 12 deletions

File tree

core/ui/compose/designsystem/src/main/kotlin/app/k9mail/core/ui/compose/designsystem/atom/icon/Icons.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,6 @@ object Icons {
144144
val VisibilityOff: ImageVector
145145
get() = MaterialIcons.Filled.VisibilityOff
146146
}
147+
148+
object DualTone
147149
}
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
package net.thunderbird.core.ui.compose.designsystem.atom.icon.dualtone
2+
3+
import androidx.compose.foundation.Image
4+
import androidx.compose.foundation.layout.Column
5+
import androidx.compose.runtime.Composable
6+
import androidx.compose.ui.graphics.Color
7+
import androidx.compose.ui.graphics.SolidColor
8+
import androidx.compose.ui.graphics.vector.ImageVector
9+
import androidx.compose.ui.graphics.vector.path
10+
import androidx.compose.ui.tooling.preview.Preview
11+
import androidx.compose.ui.unit.dp
12+
import app.k9mail.core.ui.compose.designsystem.atom.icon.Icon
13+
import app.k9mail.core.ui.compose.designsystem.atom.icon.Icons
14+
15+
@Suppress("MagicNumber", "UnusedReceiverParameter")
16+
val Icons.DualTone.Warning: ImageVector
17+
get() {
18+
val current = _warningDualTone
19+
if (current != null) return current
20+
21+
return ImageVector.Builder(
22+
name = "app.k9mail.core.ui.compose.theme2.MainTheme.WarningDualTone",
23+
defaultWidth = 24.0.dp,
24+
defaultHeight = 24.0.dp,
25+
viewportWidth = 24.0f,
26+
viewportHeight = 24.0f,
27+
).apply {
28+
path(
29+
fill = SolidColor(Color(0xFF4C4D58)),
30+
fillAlpha = 0.2f,
31+
strokeAlpha = 0.2f,
32+
) {
33+
moveTo(x = 20.2f, y = 20.25f)
34+
horizontalLineTo(x = 3.8f)
35+
arcToRelative(
36+
a = 1.5f,
37+
b = 1.5f,
38+
theta = 0.0f,
39+
isMoreThanHalf = false,
40+
isPositiveArc = true,
41+
dx1 = -1.35f,
42+
dy1 = -2.24f,
43+
)
44+
lineToRelative(dx = 8.2f, dy = -14.24f)
45+
arcToRelative(
46+
a = 1.57f,
47+
b = 1.57f,
48+
theta = 0.0f,
49+
isMoreThanHalf = false,
50+
isPositiveArc = true,
51+
dx1 = 2.7f,
52+
dy1 = 0.0f,
53+
)
54+
lineToRelative(dx = 8.2f, dy = 14.24f)
55+
arcToRelative(
56+
a = 1.5f,
57+
b = 1.5f,
58+
theta = 0.0f,
59+
isMoreThanHalf = false,
60+
isPositiveArc = true,
61+
dx1 = -1.35f,
62+
dy1 = 2.24f,
63+
)
64+
}
65+
path(
66+
fill = SolidColor(Color(0xFF4C4D58)),
67+
) {
68+
moveTo(x = 22.2f, y = 17.63f)
69+
lineTo(x = 14.0f, y = 3.4f)
70+
arcToRelative(
71+
a = 2.32f,
72+
b = 2.32f,
73+
theta = 0.0f,
74+
isMoreThanHalf = false,
75+
isPositiveArc = false,
76+
dx1 = -4.0f,
77+
dy1 = 0.0f,
78+
)
79+
lineTo(x = 1.8f, y = 17.63f)
80+
arcToRelative(
81+
a = 2.2f,
82+
b = 2.2f,
83+
theta = 0.0f,
84+
isMoreThanHalf = false,
85+
isPositiveArc = false,
86+
dx1 = 0.0f,
87+
dy1 = 2.23f,
88+
)
89+
arcToRelative(
90+
a = 2.3f,
91+
b = 2.3f,
92+
theta = 0.0f,
93+
isMoreThanHalf = false,
94+
isPositiveArc = false,
95+
dx1 = 2.0f,
96+
dy1 = 1.14f,
97+
)
98+
horizontalLineToRelative(dx = 16.4f)
99+
arcToRelative(
100+
a = 2.3f,
101+
b = 2.3f,
102+
theta = 0.0f,
103+
isMoreThanHalf = false,
104+
isPositiveArc = false,
105+
dx1 = 2.3f,
106+
dy1 = -2.25f,
107+
)
108+
arcToRelative(
109+
a = 2.0f,
110+
b = 2.0f,
111+
theta = 0.0f,
112+
isMoreThanHalf = false,
113+
isPositiveArc = false,
114+
dx1 = -0.3f,
115+
dy1 = -1.12f,
116+
)
117+
moveToRelative(dx = -1.3f, dy = 1.48f)
118+
arcToRelative(
119+
a = 0.8f,
120+
b = 0.8f,
121+
theta = 0.0f,
122+
isMoreThanHalf = false,
123+
isPositiveArc = true,
124+
dx1 = -0.7f,
125+
dy1 = 0.39f,
126+
)
127+
horizontalLineTo(x = 3.8f)
128+
arcToRelative(
129+
a = 0.8f,
130+
b = 0.8f,
131+
theta = 0.0f,
132+
isMoreThanHalf = false,
133+
isPositiveArc = true,
134+
dx1 = -0.7f,
135+
dy1 = -0.4f,
136+
)
137+
arcToRelative(
138+
a = 0.7f,
139+
b = 0.7f,
140+
theta = 0.0f,
141+
isMoreThanHalf = false,
142+
isPositiveArc = true,
143+
dx1 = 0.0f,
144+
dy1 = -0.72f,
145+
)
146+
lineToRelative(dx = 8.2f, dy = -14.24f)
147+
arcToRelative(
148+
a = 0.82f,
149+
b = 0.82f,
150+
theta = 0.0f,
151+
isMoreThanHalf = false,
152+
isPositiveArc = true,
153+
dx1 = 1.4f,
154+
dy1 = 0.0f,
155+
)
156+
lineToRelative(dx = 8.2f, dy = 14.24f)
157+
arcToRelative(
158+
a = 0.7f,
159+
b = 0.7f,
160+
theta = 0.0f,
161+
isMoreThanHalf = false,
162+
isPositiveArc = true,
163+
dx1 = 0.0f,
164+
dy1 = 0.73f,
165+
)
166+
moveToRelative(dx = -9.65f, dy = -5.61f)
167+
verticalLineTo(y = 9.75f)
168+
arcToRelative(
169+
a = 0.75f,
170+
b = 0.75f,
171+
theta = 0.0f,
172+
isMoreThanHalf = true,
173+
isPositiveArc = true,
174+
dx1 = 1.5f,
175+
dy1 = 0.0f,
176+
)
177+
verticalLineToRelative(dy = 3.75f)
178+
arcToRelative(
179+
a = 0.75f,
180+
b = 0.75f,
181+
theta = 0.0f,
182+
isMoreThanHalf = false,
183+
isPositiveArc = true,
184+
dx1 = -1.5f,
185+
dy1 = 0.0f,
186+
)
187+
moveToRelative(dx = 1.88f, dy = 3.38f)
188+
arcToRelative(
189+
a = 1.13f,
190+
b = 1.13f,
191+
theta = 0.0f,
192+
isMoreThanHalf = true,
193+
isPositiveArc = true,
194+
dx1 = -2.26f,
195+
dy1 = 0.0f,
196+
)
197+
arcToRelative(
198+
a = 1.13f,
199+
b = 1.13f,
200+
theta = 0.0f,
201+
isMoreThanHalf = false,
202+
isPositiveArc = true,
203+
dx1 = 2.26f,
204+
dy1 = 0.0f,
205+
)
206+
}
207+
}.build().also { _warningDualTone = it }
208+
}
209+
210+
@Suppress("ObjectPropertyName")
211+
private var _warningDualTone: ImageVector? = null
212+
213+
@Preview(showBackground = true)
214+
@Composable
215+
private fun Preview() {
216+
Column {
217+
Image(imageVector = Icons.DualTone.Warning, contentDescription = null)
218+
Icon(imageVector = Icons.DualTone.Warning, contentDescription = null, tint = Color.Red)
219+
}
220+
}

feature/navigation/drawer/dropdown/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ dependencies {
2323
implementation(projects.feature.account.avatar.impl)
2424
implementation(projects.feature.mail.account.api)
2525
implementation(projects.feature.mail.folder.api)
26+
implementation(projects.feature.notification.api)
2627

2728
implementation(projects.feature.search.implLegacy)
2829
implementation(projects.legacy.mailstore)

feature/navigation/drawer/dropdown/src/debug/kotlin/net/thunderbird/feature/navigation/drawer/dropdown/ui/FakeData.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ internal object FakeData {
4242
val UNIFIED_DISPLAY_ACCOUNT = UnifiedDisplayAccount(
4343
unreadMessageCount = 224,
4444
starredMessageCount = 42,
45+
hasError = false,
4546
)
4647

4748
val MAIL_DISPLAY_ACCOUNT = MailDisplayAccount(
@@ -51,6 +52,7 @@ internal object FakeData {
5152
color = Color.Red.toArgb(),
5253
unreadMessageCount = 0,
5354
starredMessageCount = 0,
55+
hasError = false,
5456
)
5557

5658
val FOLDER = Folder(
@@ -156,6 +158,7 @@ internal object FakeData {
156158
color = Color.Green.toArgb(),
157159
unreadMessageCount = 2,
158160
starredMessageCount = 0,
161+
hasError = false,
159162
),
160163
MailDisplayAccount(
161164
id = "account2",
@@ -164,6 +167,7 @@ internal object FakeData {
164167
color = Color.Red.toArgb(),
165168
unreadMessageCount = 12,
166169
starredMessageCount = 0,
170+
hasError = false,
167171
),
168172
MailDisplayAccount(
169173
id = "account3",
@@ -172,6 +176,7 @@ internal object FakeData {
172176
color = Color.Cyan.toArgb(),
173177
unreadMessageCount = 0,
174178
starredMessageCount = 0,
179+
hasError = false,
175180
),
176181
)
177182
}

feature/navigation/drawer/dropdown/src/debug/kotlin/net/thunderbird/feature/navigation/drawer/dropdown/ui/account/AccountListItemPreview.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,29 @@ internal fun AccountListItemSelectedPreview() {
3030
)
3131
}
3232
}
33+
34+
@Composable
35+
@Preview(showBackground = true)
36+
internal fun AccountListItemWithErrorPreview() {
37+
PreviewWithThemes {
38+
AccountListItem(
39+
account = MAIL_DISPLAY_ACCOUNT.copy(hasError = true),
40+
onClick = { },
41+
selected = false,
42+
showStarredCount = false,
43+
)
44+
}
45+
}
46+
47+
@Composable
48+
@Preview(showBackground = true)
49+
internal fun AccountListItemSelectedWithErrorPreview() {
50+
PreviewWithThemes {
51+
AccountListItem(
52+
account = MAIL_DISPLAY_ACCOUNT.copy(hasError = true),
53+
onClick = { },
54+
selected = true,
55+
showStarredCount = false,
56+
)
57+
}
58+
}

feature/navigation/drawer/dropdown/src/main/kotlin/net/thunderbird/feature/navigation/drawer/dropdown/NavigationDrawerModule.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ val navigationDropDownDrawerModule: Module = module {
3939
accountManager = get(),
4040
messageCountsProvider = get(),
4141
messageListRepository = get(),
42+
notificationStream = get(),
43+
featureFlagProvider = get(),
4244
)
4345
}
4446

feature/navigation/drawer/dropdown/src/main/kotlin/net/thunderbird/feature/navigation/drawer/dropdown/domain/entity/DisplayAccount.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ sealed interface DisplayAccount {
44
val id: String
55
val unreadMessageCount: Int
66
val starredMessageCount: Int
7+
val hasError: Boolean
78
}

feature/navigation/drawer/dropdown/src/main/kotlin/net/thunderbird/feature/navigation/drawer/dropdown/domain/entity/MailDisplayAccount.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ internal data class MailDisplayAccount(
77
val color: Int,
88
override val unreadMessageCount: Int,
99
override val starredMessageCount: Int,
10+
override val hasError: Boolean,
1011
) : DisplayAccount

feature/navigation/drawer/dropdown/src/main/kotlin/net/thunderbird/feature/navigation/drawer/dropdown/domain/entity/UnifiedDisplayAccount.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package net.thunderbird.feature.navigation.drawer.dropdown.domain.entity
33
data class UnifiedDisplayAccount(
44
override val unreadMessageCount: Int,
55
override val starredMessageCount: Int,
6+
override val hasError: Boolean,
67
) : DisplayAccount {
78
override val id: String = UNIFIED_ACCOUNT_ID
89

0 commit comments

Comments
 (0)