@@ -10,23 +10,20 @@ import 'theme.dart';
1010/// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=2037-186671&m=dev
1111/// It looks like that component was created for the main menu,
1212/// then adapted for various other contexts, like the Inbox page.
13+ /// See [UnreadCountBadgeStyle] .
1314///
14- /// Currently this widget supports only those other contexts (not the main menu)
15- /// and only the component's "kind=unread" variant (not "kind=quantity").
16- /// For example, the "Channels" page and the topic-list page:
17- /// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=6205-26001&m=dev
18- /// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=6823-37113&m=dev
19- /// (We use this for the topic-list page even though the Figma makes it a bit
20- /// more compact there…the inconsistency seems worse and might be accidental.)
21- // TODO support the main-menu context, update dartdoc
15+ /// Currently this widget supports only the component's "kind=unread" variant,
16+ /// not "kind=quantity".
2217// TODO support the "kind=quantity" variant, update dartdoc
2318class UnreadCountBadge extends StatelessWidget {
2419 const UnreadCountBadge ({
2520 super .key,
21+ this .style = UnreadCountBadgeStyle .other,
2622 required this .count,
2723 required this .channelIdForBackground,
2824 });
2925
26+ final UnreadCountBadgeStyle style;
3027 final int count;
3128
3229 /// An optional [Subscription.streamId] , for a channel-colorized background.
@@ -55,23 +52,52 @@ class UnreadCountBadge extends StatelessWidget {
5552 backgroundColor = designVariables.bgCounterUnread;
5653 }
5754
55+ final padding = switch (style) {
56+ UnreadCountBadgeStyle .mainMenu =>
57+ const EdgeInsets .symmetric (horizontal: 5 , vertical: 4 ),
58+ UnreadCountBadgeStyle .other =>
59+ const EdgeInsets .symmetric (horizontal: 5 , vertical: 3 ),
60+ };
61+
62+ final double wght = switch (style) {
63+ UnreadCountBadgeStyle .mainMenu => 600 ,
64+ UnreadCountBadgeStyle .other => 500 ,
65+ };
66+
5867 return DecoratedBox (
5968 decoration: BoxDecoration (
6069 borderRadius: BorderRadius .circular (5 ),
6170 color: backgroundColor,
6271 ),
6372 child: Padding (
64- padding: const EdgeInsets . symmetric (horizontal : 5 , vertical : 3 ) ,
73+ padding: padding ,
6574 child: Text (
6675 style: TextStyle (
6776 fontSize: 16 ,
6877 height: (16 / 16 ),
6978 color: textColor,
70- ).merge (weightVariableTextStyle (context, wght: 500 )),
79+ ).merge (weightVariableTextStyle (context, wght: wght )),
7180 count.toString ())));
7281 }
7382}
7483
84+ enum UnreadCountBadgeStyle {
85+ /// The style to use in the main menu.
86+ ///
87+ /// Figma:
88+ /// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=2037-185126&m=dev
89+ mainMenu,
90+
91+ /// The style to use in other contexts besides the main menu.
92+ ///
93+ /// Other contexts include the "Channels" page and the topic-list page:
94+ /// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=6205-26001&m=dev
95+ /// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=6823-37113&m=dev
96+ /// (We use this for the topic-list page even though the Figma makes it a bit
97+ /// more compact there…the inconsistency seems worse and might be accidental.)
98+ other,
99+ }
100+
75101class MutedUnreadBadge extends StatelessWidget {
76102 const MutedUnreadBadge ({super .key});
77103
0 commit comments