Skip to content

Commit 4fae1dd

Browse files
committed
feat: add new badge
1 parent bcbf53a commit 4fae1dd

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

lib/brixies/new_badge.dart

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
3+
part of devspace;
4+
5+
6+
class NewBadge extends StatelessWidget {
7+
8+
final Widget child;
9+
10+
const NewBadge({
11+
super.key,
12+
required this.child,
13+
});
14+
15+
@override
16+
Widget build(BuildContext context)
17+
{
18+
return Stack(
19+
fit: StackFit.passthrough,
20+
children: [
21+
child,
22+
Positioned(
23+
top: 0,
24+
right: 0,
25+
child: Container(
26+
margin: context.paddingS,
27+
padding: context.paddingS_XXS,
28+
decoration: BoxDecoration(
29+
color: context.colors.error,
30+
borderRadius: BorderRadius.circular(100),
31+
boxShadow: [context.highlights.boxShadowS]
32+
),
33+
child: TextBody.small(LibStrings.lib_general_flagNew.tr(), color: context.colors.onError),
34+
),
35+
),
36+
],
37+
);
38+
}
39+
}

lib/core/dialog/default_dialog.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ class DefaultDialog extends StatelessWidget {
4848
button = RepaintBoundary(child: button.glassShimmerRepeated(delay: 500.asDuration));
4949
}
5050

51+
if (action.markAsNewUntil != null && action.markAsNewUntil!.isAfter(DateTime.now()))
52+
{
53+
button = NewBadge(
54+
child: button,
55+
);
56+
}
57+
5158
button = ConstrainedBox(
5259
constraints: BoxConstraints(
5360
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
@@ -11,13 +11,15 @@ class DialogAction {
1111
final kButtonType type;
1212
/// If set, overrides the icon for this action type
1313
final IconData? iconOverride;
14+
final DateTime? markAsNewUntil;
1415

1516
DialogAction({
1617
this.enabled = true,
1718
required this.title,
1819
this.onPressed,
1920
this.type = kButtonType.regular,
2021
this.iconOverride,
22+
this.markAsNewUntil,
2123
});
2224

2325
bool get isCustom => this is CustomDialogAction;
@@ -27,13 +29,15 @@ class DialogAction {
2729
VoidCallback? onPressed,
2830
kButtonType? type,
2931
IconData? iconOverride,
32+
DateTime? markAsNewUntil,
3033
})
3134
{
3235
return DialogAction(
3336
title: title ?? this.title,
3437
onPressed: onPressed ?? this.onPressed,
3538
type: type ?? this.type,
3639
iconOverride: iconOverride ?? this.iconOverride,
40+
markAsNewUntil: markAsNewUntil ?? this.markAsNewUntil,
3741
);
3842
}
3943

@@ -78,6 +82,7 @@ class CustomDialogAction extends DialogAction {
7882
VoidCallback? onPressed,
7983
kButtonType? type,
8084
IconData? iconOverride,
85+
DateTime? markAsNewUntil,
8186
})
8287
{
8388
return CustomDialogAction(

lib/devspace.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ part 'brixies/intrinsic_height_page_view.dart';
175175
part 'brixies/layout_builder.dart';
176176
part 'brixies/line_divider.dart';
177177
part 'brixies/multi_transform.dart';
178+
part 'brixies/new_badge.dart';
178179
part 'brixies/search_delay.dart';
179180
part 'brixies/smooth_swap.dart';
180181
part 'brixies/spaced_flex.dart';

lib/lib_strings.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ abstract class LibStrings {
99

1010
LibStrings._();
1111

12+
static const String lib_general_flagNew = 'lib_general_flagNew';
1213
static const String lib_general_valueNotSet = 'lib_general_valueNotSet';
1314
static const String lib_general_valueNotYetSet = 'lib_general_valueNotYetSet';
1415
static const String lib_general_valueNotAvailable = 'lib_general_valueNotAvailable';
@@ -111,6 +112,7 @@ abstract class LibStrings {
111112
static const String lib_exception_UnexpectedError = 'lib_exception_UnexpectedError';
112113

113114
static const List<String> allKeys = [
115+
'lib_general_flagNew',
114116
'lib_general_valueNotSet',
115117
'lib_general_valueNotYetSet',
116118
'lib_general_valueNotAvailable',

0 commit comments

Comments
 (0)