Skip to content
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

fix(notifications_app): Handle notifications without icon #2663

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,16 @@ class NotificationsNotification extends StatelessWidget {
)
.toList(),
),
leading: NeonUriImage(
account: NeonProvider.of<Account>(context),
uri: Uri.parse(notification.icon!),
size: const Size.square(largeIconSize),
svgColorFilter: ColorFilter.mode(Theme.of(context).colorScheme.primary, BlendMode.srcIn),
),
leading: notification.icon!.isNotEmpty
? NeonUriImage(
account: NeonProvider.of<Account>(context),
uri: Uri.parse(notification.icon!),
size: const Size.square(largeIconSize),
svgColorFilter: ColorFilter.mode(Theme.of(context).colorScheme.primary, BlendMode.srcIn),
)
: const SizedBox.square(
dimension: largeIconSize,
),
onTap: notification.link.isNotEmpty
? () async => launchUrl(NeonProvider.of<Account>(context), notification.link)
: null,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void main() {
when(() => notification.messageRichParameters).thenReturn(BuiltMap());
when(() => notification.datetime).thenReturn(tz.TZDateTime.now(tz.UTC).toIso8601String());
when(() => notification.actions).thenReturn(BuiltList());
when(() => notification.icon).thenReturn('');
when(() => notification.icon).thenReturn('/icon');
when(() => notification.link).thenReturn('/link');

return notification;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void main() {
when(() => notification.messageRichParameters).thenReturn(BuiltMap());
when(() => notification.datetime).thenReturn(tz.TZDateTime.now(tz.UTC).toIso8601String());
when(() => notification.actions).thenReturn(BuiltList([primaryAction, secondaryAction]));
when(() => notification.icon).thenReturn('');
when(() => notification.icon).thenReturn('/icon');
when(() => notification.link).thenReturn('/link');

callback = MockCallbackFunction<void>().call;
Expand Down Expand Up @@ -131,4 +131,26 @@ void main() {
expect(find.byType(NeonRichObjectMention), findsExactly(2));
await expectLater(find.byType(TestApp), matchesGoldenFile('goldens/notification_rich.png'));
});

testWidgets('Without icon', (tester) async {
when(() => notification.icon).thenReturn('');

await tester.pumpWidgetWithAccessibility(
TestApp(
localizationsDelegates: NotificationsLocalizations.localizationsDelegates,
supportedLocales: NotificationsLocalizations.supportedLocales,
providers: [
Provider<BuiltSet<AppImplementation>>.value(value: BuiltSet()),
Provider<Account>.value(value: account),
],
child: NotificationsNotification(
notification: notification,
onDelete: callback,
),
),
);

expect(find.byType(NeonUriImage), findsNothing);
await expectLater(find.byType(TestApp), matchesGoldenFile('goldens/notification_without_icon.png'));
});
}