diff --git a/example/lib/src/controls/buttons.dart b/example/lib/src/controls/buttons.dart index 712c847c..e89b721e 100644 --- a/example/lib/src/controls/buttons.dart +++ b/example/lib/src/controls/buttons.dart @@ -2,21 +2,9 @@ import 'package:flutter/material.dart'; import 'package:yaru_example/src/constants.dart'; import 'package:yaru_icons/yaru_icons.dart'; -class Buttons extends StatefulWidget { +class Buttons extends StatelessWidget { const Buttons({super.key}); - @override - State createState() => _ButtonsState(); -} - -class _ButtonsState extends State { - void incrementCounter() { - setState(() { - ScaffoldMessenger.of(context) - .showSnackBar(const SnackBar(content: Text('Yay! ❤️ for Yaru'))); - }); - } - @override Widget build(BuildContext context) { const icon = Icon(YaruIcons.notification_filled); diff --git a/example/lib/src/controls/fabs.dart b/example/lib/src/controls/fabs.dart index 112c8190..56d9f54a 100644 --- a/example/lib/src/controls/fabs.dart +++ b/example/lib/src/controls/fabs.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:yaru_example/src/constants.dart'; +import 'package:yaru_example/src/utils.dart'; import 'package:yaru_icons/yaru_icons.dart'; class Fabs extends StatelessWidget { @@ -7,8 +8,7 @@ class Fabs extends StatelessWidget { @override Widget build(BuildContext context) { - void onPressed() => ScaffoldMessenger.of(context) - .showSnackBar(const SnackBar(content: Text('Yay! ❤️ for Yaru'))); + void onPressed() => showSnack(context); return Wrap( spacing: kWrapSpacing, diff --git a/example/lib/src/home/home_page.dart b/example/lib/src/home/home_page.dart index cddbf71a..d85bf23c 100644 --- a/example/lib/src/home/home_page.dart +++ b/example/lib/src/home/home_page.dart @@ -8,6 +8,7 @@ import 'package:yaru_example/src/controls/controls_view.dart'; import 'package:yaru_example/src/fonts/fonts_view.dart'; import 'package:yaru_example/src/home/color_disk.dart'; import 'package:yaru_example/src/textfields/text_fields_view.dart'; +import 'package:yaru_example/src/utils.dart'; import 'package:yaru_icons/yaru_icons.dart'; final GlobalKey _scaffoldKey = GlobalKey(); @@ -78,9 +79,13 @@ class HomePageState extends State { ), ), title: const _Title(), - actions: const [ - Padding( - padding: EdgeInsets.only(right: kWrapSpacing), + actions: [ + IconButton( + onPressed: () => showSnack(context), + icon: const Icon(YaruIcons.plus), + ), + const Padding( + padding: EdgeInsets.symmetric(horizontal: kWrapSpacing), child: _ThemeButton(), ), ], diff --git a/example/lib/src/utils.dart b/example/lib/src/utils.dart new file mode 100644 index 00000000..6919bc6e --- /dev/null +++ b/example/lib/src/utils.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +ScaffoldFeatureController showSnack( + BuildContext context, +) { + return ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: const Text('Yay! ❤️ for Yaru'), + action: SnackBarAction( + label: 'Ok', + onPressed: () {}, + ), + ), + ); +} diff --git a/lib/src/themes/common_themes.dart b/lib/src/themes/common_themes.dart index 6d1a4abe..a44d6771 100644 --- a/lib/src/themes/common_themes.dart +++ b/lib/src/themes/common_themes.dart @@ -590,14 +590,11 @@ DrawerThemeData _createDrawerTheme(ColorScheme colorScheme) { SnackBarThemeData _createSnackBarTheme(ColorScheme colorScheme) { const fg = Colors.white; return SnackBarThemeData( - width: kSnackBarWidth, - backgroundColor: const Color.fromARGB(255, 20, 20, 20).withOpacity(0.95), + backgroundColor: const Color.fromARGB(250, 20, 20, 20), closeIconColor: fg, - actionTextColor: Colors.white, + actionTextColor: colorScheme.primary, contentTextStyle: const TextStyle(color: fg), - actionBackgroundColor: Colors.transparent, disabledActionTextColor: fg.withOpacity(0.7), - disabledActionBackgroundColor: Colors.transparent, behavior: SnackBarBehavior.floating, elevation: 0, shape: RoundedRectangleBorder(