-
Notifications
You must be signed in to change notification settings - Fork 9
feat(cat-voices): unification of notifications #3457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
damian-molinski
merged 14 commits into
feat/incident_reporting_3158
from
feat/unification_of_notifications_3414
Oct 9, 2025
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
45af416
wip: CatalystMessenger with initial banners
damian-molinski 8eeeffb
notification type colors and icons
damian-molinski aab004f
fix: reading map while removing
damian-molinski c38fe1c
wip
damian-molinski c6511a0
Merge branch 'feat/incident_reporting_3158' into feat/unification_of_…
damian-molinski 8c769d5
chore: remove old banners
damian-molinski ee23a62
chore: remove exiting banners + add event bus
damian-molinski a742df5
move CatalystNotification to app
damian-molinski 966aba6
Bring back user verification banner
damian-molinski bcca709
chore: remove unused class
damian-molinski aa263a2
chore: cleanup
damian-molinski cd966e6
chore: spacer
damian-molinski bce67fc
Use ScaffoldMessenger.maybeOf instead of global key
damian-molinski a1ccc81
Merge feat/incident_reporting_3158 into feat/unification_of_notificat…
damian-molinski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
catalyst_voices/apps/voices/lib/notification/banner_close_button.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:catalyst_voices/widgets/buttons/voices_icon_button.dart'; | ||
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class BannerCloseButton extends StatelessWidget { | ||
const BannerCloseButton({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return VoicesIconButton( | ||
style: const ButtonStyle(iconSize: WidgetStatePropertyAll(18)), | ||
onTap: () { | ||
final messengerState = ScaffoldMessenger.maybeOf(context); | ||
if (messengerState == null) { | ||
if (kDebugMode) { | ||
print('Can not dismiss banner because messenger key state is empty!'); | ||
} | ||
return; | ||
} | ||
|
||
messengerState.hideCurrentMaterialBanner(reason: MaterialBannerClosedReason.dismiss); | ||
}, | ||
child: VoicesAssets.icons.x.buildIcon(), | ||
); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
catalyst_voices/apps/voices/lib/notification/banner_content.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import 'package:catalyst_voices/notification/catalyst_notification.dart'; | ||
import 'package:catalyst_voices/widgets/widgets.dart'; | ||
import 'package:flutter/gestures.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
const _titleKey = 'title'; | ||
|
||
class BannerContent extends StatefulWidget { | ||
final BannerNotification notification; | ||
|
||
const BannerContent({ | ||
super.key, | ||
required this.notification, | ||
}); | ||
|
||
@override | ||
State<BannerContent> createState() => _BannerContentState(); | ||
} | ||
|
||
class _BannerContentState extends State<BannerContent> { | ||
final _gestureRecognizers = <String, GestureRecognizer>{}; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final title = widget.notification.title(context); | ||
final message = widget.notification.message(context); | ||
|
||
final text = '{$_titleKey}: ${message.text}'; | ||
final placeholders = <String, CatalystNotificationTextPart>{ | ||
_titleKey: CatalystNotificationTextPart(text: title, bold: true), | ||
...message.placeholders, | ||
}; | ||
|
||
return PlaceholderRichText( | ||
text, | ||
placeholderSpanBuilder: (context, placeholder) { | ||
if (!placeholders.containsKey(placeholder)) { | ||
return TextSpan(text: placeholder); | ||
} | ||
|
||
final replacement = placeholders[placeholder]!; | ||
final onTap = replacement.onTap; | ||
|
||
return TextSpan( | ||
text: replacement.text, | ||
style: TextStyle( | ||
fontWeight: replacement.bold ? FontWeight.bold : null, | ||
decoration: replacement.underlined ? TextDecoration.underline : null, | ||
), | ||
recognizer: onTap != null | ||
? _gestureRecognizers.putIfAbsent( | ||
placeholder, | ||
() => TapGestureRecognizer()..onTap = () => onTap(context), | ||
) | ||
: null, | ||
); | ||
}, | ||
); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
final keys = List.of(_gestureRecognizers.keys); | ||
for (final key in keys) { | ||
_gestureRecognizers.remove(key)?.dispose(); | ||
} | ||
super.dispose(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
catalyst_voices/apps/voices/lib/notification/banner_notification.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
part of 'catalyst_notification.dart'; | ||
|
||
abstract base class BannerNotification extends CatalystNotification { | ||
const BannerNotification({ | ||
required super.id, | ||
super.priority, | ||
super.type, | ||
super.routerPredicate, | ||
}); | ||
|
||
BannerNotificationMessage message(BuildContext context); | ||
|
||
String title(BuildContext context); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.