diff --git a/forui/lib/src/widgets/alert/alert.dart b/forui/lib/src/widgets/alert/alert.dart index 9a7a19157..9b764407c 100644 --- a/forui/lib/src/widgets/alert/alert.dart +++ b/forui/lib/src/widgets/alert/alert.dart @@ -14,8 +14,8 @@ part 'alert_styles.dart'; /// * https://forui.dev/docs/alert for working examples. /// * [FAlertStyle] for customizing an alert's appearance. class FAlert extends StatelessWidget { - /// The icon. - final Widget? icon; + /// The icon. Defaults to [FAssets.icons.circleAlert]. + final SvgAsset? icon; /// The title. final Widget? title; @@ -52,20 +52,21 @@ class FAlert extends StatelessWidget { Variant.primary => context.theme.alertStyles.primary, Variant.destructive => context.theme.alertStyles.destructive, }; - final icon = this.icon ?? - FAssets.icons.circleAlert( - height: style.iconSize, - colorFilter: ColorFilter.mode(style.iconColor, BlendMode.srcIn), - ); + final icon = this.icon ?? FAssets.icons.circleAlert; + return DecoratedBox( decoration: style.decoration, child: Padding( padding: style.padding, child: Column( + mainAxisSize: MainAxisSize.min, children: [ Row( children: [ - icon, + icon( + height: style.iconSize, + colorFilter: ColorFilter.mode(style.iconColor, BlendMode.srcIn), + ), Flexible( child: Padding( padding: const EdgeInsets.only(left: 8), diff --git a/forui/test/golden/alert/zinc-dark-Variant.destructive-with-default-icon.png b/forui/test/golden/alert/zinc-dark-Variant.destructive-with-default-icon.png new file mode 100644 index 000000000..133702824 Binary files /dev/null and b/forui/test/golden/alert/zinc-dark-Variant.destructive-with-default-icon.png differ diff --git a/forui/test/golden/alert/zinc-dark-Variant.destructive-without-user-icon.png b/forui/test/golden/alert/zinc-dark-Variant.destructive-without-user-icon.png new file mode 100644 index 000000000..74d2535d8 Binary files /dev/null and b/forui/test/golden/alert/zinc-dark-Variant.destructive-without-user-icon.png differ diff --git a/forui/test/golden/alert/zinc-dark-Variant.primary-with-default-icon.png b/forui/test/golden/alert/zinc-dark-Variant.primary-with-default-icon.png new file mode 100644 index 000000000..d631ee8c5 Binary files /dev/null and b/forui/test/golden/alert/zinc-dark-Variant.primary-with-default-icon.png differ diff --git a/forui/test/golden/alert/zinc-dark-Variant.primary-without-user-icon.png b/forui/test/golden/alert/zinc-dark-Variant.primary-without-user-icon.png new file mode 100644 index 000000000..a00c60d1a Binary files /dev/null and b/forui/test/golden/alert/zinc-dark-Variant.primary-without-user-icon.png differ diff --git a/forui/test/golden/alert/zinc-light-Variant.destructive-with-default-icon.png b/forui/test/golden/alert/zinc-light-Variant.destructive-with-default-icon.png new file mode 100644 index 000000000..dad4c5221 Binary files /dev/null and b/forui/test/golden/alert/zinc-light-Variant.destructive-with-default-icon.png differ diff --git a/forui/test/golden/alert/zinc-light-Variant.destructive-without-user-icon.png b/forui/test/golden/alert/zinc-light-Variant.destructive-without-user-icon.png new file mode 100644 index 000000000..e19d9638c Binary files /dev/null and b/forui/test/golden/alert/zinc-light-Variant.destructive-without-user-icon.png differ diff --git a/forui/test/golden/alert/zinc-light-Variant.primary-with-default-icon.png b/forui/test/golden/alert/zinc-light-Variant.primary-with-default-icon.png new file mode 100644 index 000000000..cd9f874a4 Binary files /dev/null and b/forui/test/golden/alert/zinc-light-Variant.primary-with-default-icon.png differ diff --git a/forui/test/golden/alert/zinc-light-Variant.primary-without-user-icon.png b/forui/test/golden/alert/zinc-light-Variant.primary-without-user-icon.png new file mode 100644 index 000000000..977b1e021 Binary files /dev/null and b/forui/test/golden/alert/zinc-light-Variant.primary-without-user-icon.png differ diff --git a/forui/test/src/widgets/alert_golden_test.dart b/forui/test/src/widgets/alert_golden_test.dart new file mode 100644 index 000000000..e287b71ba --- /dev/null +++ b/forui/test/src/widgets/alert_golden_test.dart @@ -0,0 +1,61 @@ +@Tags(['golden']) +library; + +import 'package:flutter/material.dart'; + +import 'package:flutter_test/flutter_test.dart'; + +import 'package:forui/forui.dart'; +import 'package:forui/src/widgets/alert/alert.dart'; +import '../test_scaffold.dart'; + +void main() { + group('FAlert', () { + for (final (name, theme, _) in TestScaffold.themes) { + for (final variant in Variant.values) { + testWidgets('$name with default icon', (tester) async { + await tester.pumpWidget( + TestScaffold( + data: theme, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), + child: FAlert( + title: const Text('Alert Title'), + subtitle: const Text('Alert description with extra text'), + style: variant, + ), + ), + ), + ); + + await expectLater( + find.byType(TestScaffold), + matchesGoldenFile('alert/$name-$variant-with-default-icon.png'), + ); + }); + + testWidgets('$name without user icon', (tester) async { + await tester.pumpWidget( + TestScaffold( + data: theme, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), + child: FAlert( + icon: FAssets.icons.badgeAlert, + title: const Text('Alert Title'), + subtitle: const Text('Alert description with extra text'), + style: variant, + ), + ), + ), + ); + + await expectLater( + find.byType(TestScaffold), + matchesGoldenFile('alert/$name-$variant-without-user-icon.png'), + ); + }); + } + } + }); +}