Skip to content

Commit 1958e13

Browse files
committed
feat: dialog badges
1 parent 328728f commit 1958e13

File tree

6 files changed

+95
-15
lines changed

6 files changed

+95
-15
lines changed

lib/brixies/circle_badge.dart

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
3+
part of devspace;
4+
5+
6+
7+
8+
class CircleBadge extends StatelessWidget {
9+
10+
final bool show;
11+
final String content;
12+
final badges.BadgePosition? position;
13+
final Widget? child;
14+
15+
const CircleBadge({
16+
super.key,
17+
this.show = true,
18+
required this.content,
19+
this.position,
20+
this.child,
21+
});
22+
23+
@override
24+
Widget build(BuildContext context)
25+
{
26+
if (!show)
27+
{
28+
return child ?? EmptyWidget();
29+
}
30+
31+
return badges.Badge(
32+
badgeStyle: badges.BadgeStyle(
33+
elevation: 0,
34+
badgeColor: context.colors.primary,
35+
),
36+
position: position ?? badges.BadgePosition.topEnd(top: -context.dimensions.spaceSValue, end: 0),
37+
badgeAnimation: const badges.BadgeAnimation.fade(
38+
toAnimate: false
39+
),
40+
stackFit: StackFit.passthrough,
41+
badgeContent: Padding(
42+
padding: context.paddingXXS,
43+
child: TextBody.small(content,
44+
color: context.colors.onPrimary,
45+
),
46+
),
47+
child: child,
48+
);
49+
}
50+
}

lib/core/dialog/default_dialog.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ class DefaultDialog extends StatelessWidget {
5555
);
5656
}
5757

58+
if (action.badge != null)
59+
{
60+
double offset = context.dimensions.spaceSValue + context.dimensions.spaceXXSValue;
61+
62+
button = CircleBadge(
63+
show: true,
64+
content: action.badge!,
65+
position: badges.BadgePosition.topEnd(top: -context.dimensions.spaceSValue - 0.5 - offset, end: -offset),
66+
child: button,
67+
);
68+
}
69+
70+
71+
5872
button = ConstrainedBox(
5973
constraints: BoxConstraints(
6074
minWidth: context.dimensions.reasonableButtonWidth(context)

lib/core/dialog/dialog_action.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class DialogAction {
1212
/// If set, overrides the icon for this action type
1313
final IconData? iconOverride;
1414
final DateTime? markAsNewUntil;
15+
final String? badge;
1516

1617
DialogAction({
1718
this.enabled = true,
@@ -20,6 +21,7 @@ class DialogAction {
2021
this.type = kButtonType.regular,
2122
this.iconOverride,
2223
this.markAsNewUntil,
24+
this.badge,
2325
});
2426

2527
bool get isCustom => this is CustomDialogAction;
@@ -30,6 +32,7 @@ class DialogAction {
3032
kButtonType? type,
3133
IconData? iconOverride,
3234
DateTime? markAsNewUntil,
35+
String? badge,
3336
})
3437
{
3538
return DialogAction(
@@ -38,6 +41,7 @@ class DialogAction {
3841
type: type ?? this.type,
3942
iconOverride: iconOverride ?? this.iconOverride,
4043
markAsNewUntil: markAsNewUntil ?? this.markAsNewUntil,
44+
badge: badge ?? this.badge,
4145
);
4246
}
4347

@@ -83,6 +87,7 @@ class CustomDialogAction extends DialogAction {
8387
kButtonType? type,
8488
IconData? iconOverride,
8589
DateTime? markAsNewUntil,
90+
String? badge,
8691
})
8792
{
8893
return CustomDialogAction(

lib/devspace.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import 'package:simple_animations/simple_animations.dart';
4040
import 'package:super_tooltip/super_tooltip.dart';
4141
import 'package:url_launcher/url_launcher.dart' as p_url_launcher;
4242
import 'package:cached_network_image/cached_network_image.dart';
43+
import 'package:badges/badges.dart' as badges;
4344

4445
import 'lib_strings.dart';
4546

@@ -165,6 +166,7 @@ part 'blue_forms/widgets/form_page.dart';
165166
part 'blue_forms/widgets/form_page_info.dart';
166167
// brixies
167168

169+
part 'brixies/circle_badge.dart';
168170
part 'brixies/circle_button_close.dart';
169171
part 'brixies/controller_holder.dart';
170172
part 'brixies/edge_shadow.dart';

pubspec.lock

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ packages:
137137
url: "https://pub.dev"
138138
source: hosted
139139
version: "0.6.1"
140+
badges:
141+
dependency: "direct main"
142+
description:
143+
name: badges
144+
sha256: a7b6bbd60dce418df0db3058b53f9d083c22cdb5132a052145dc267494df0b84
145+
url: "https://pub.dev"
146+
source: hosted
147+
version: "3.1.2"
140148
boolean_selector:
141149
dependency: transitive
142150
description:
@@ -221,10 +229,10 @@ packages:
221229
dependency: transitive
222230
description:
223231
name: collection
224-
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
232+
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
225233
url: "https://pub.dev"
226234
source: hosted
227-
version: "1.18.0"
235+
version: "1.19.0"
228236
connectivity_plus:
229237
dependency: transitive
230238
description:
@@ -673,18 +681,18 @@ packages:
673681
dependency: transitive
674682
description:
675683
name: leak_tracker
676-
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
684+
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
677685
url: "https://pub.dev"
678686
source: hosted
679-
version: "10.0.5"
687+
version: "10.0.7"
680688
leak_tracker_flutter_testing:
681689
dependency: transitive
682690
description:
683691
name: leak_tracker_flutter_testing
684-
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
692+
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
685693
url: "https://pub.dev"
686694
source: hosted
687-
version: "3.0.5"
695+
version: "3.0.8"
688696
leak_tracker_testing:
689697
dependency: transitive
690698
description:
@@ -1009,7 +1017,7 @@ packages:
10091017
dependency: transitive
10101018
description: flutter
10111019
source: sdk
1012-
version: "0.0.99"
1020+
version: "0.0.0"
10131021
sliver_tools:
10141022
dependency: transitive
10151023
description:
@@ -1102,10 +1110,10 @@ packages:
11021110
dependency: transitive
11031111
description:
11041112
name: stack_trace
1105-
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
1113+
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
11061114
url: "https://pub.dev"
11071115
source: hosted
1108-
version: "1.11.1"
1116+
version: "1.12.0"
11091117
stream_channel:
11101118
dependency: transitive
11111119
description:
@@ -1126,10 +1134,10 @@ packages:
11261134
dependency: transitive
11271135
description:
11281136
name: string_scanner
1129-
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
1137+
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
11301138
url: "https://pub.dev"
11311139
source: hosted
1132-
version: "1.2.0"
1140+
version: "1.3.0"
11331141
super_tooltip:
11341142
dependency: "direct main"
11351143
description:
@@ -1158,10 +1166,10 @@ packages:
11581166
dependency: transitive
11591167
description:
11601168
name: test_api
1161-
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
1169+
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
11621170
url: "https://pub.dev"
11631171
source: hosted
1164-
version: "0.7.2"
1172+
version: "0.7.3"
11651173
tuple:
11661174
dependency: transitive
11671175
description:
@@ -1262,10 +1270,10 @@ packages:
12621270
dependency: transitive
12631271
description:
12641272
name: vm_service
1265-
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
1273+
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
12661274
url: "https://pub.dev"
12671275
source: hosted
1268-
version: "14.2.5"
1276+
version: "14.3.0"
12691277
web:
12701278
dependency: transitive
12711279
description:

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ dependencies:
4141
path: ^1.9.0
4242
crop_your_image: ^1.1.0
4343
cached_network_image: ^3.4.0
44+
badges: ^3.1.2
4445

4546
dev_dependencies:
4647
flutter_test:

0 commit comments

Comments
 (0)