Skip to content

Commit

Permalink
Merge pull request #2663 from nextcloud/fix/notifications_app/handle-…
Browse files Browse the repository at this point in the history
…without-icon
  • Loading branch information
provokateurin authored Nov 19, 2024
2 parents 291b405 + b389406 commit e7d35f9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
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'));
});
}

0 comments on commit e7d35f9

Please sign in to comment.