From ff1af89ce178bdd619717909b61b35df59162b1a Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Sun, 26 Sep 2021 19:10:29 +0900 Subject: [PATCH] about/settings button style consistency --- lib/l10n/app_en.arb | 2 +- lib/widgets/about/bug_report.dart | 9 ++--- lib/widgets/about/licenses.dart | 5 +-- lib/widgets/common/identity/buttons.dart | 34 +++++++++++++++++++ .../navigation/drawer_tab_albums.dart | 11 +++--- 5 files changed, 45 insertions(+), 16 deletions(-) create mode 100644 lib/widgets/common/identity/buttons.dart diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 9dc88b889..b98607d1a 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -425,7 +425,7 @@ "@aboutLicensesFlutterPackages": {}, "aboutLicensesDartPackages": "Dart Packages", "@aboutLicensesDartPackages": {}, - "aboutLicensesShowAllButtonLabel": "SHOW ALL LICENSES", + "aboutLicensesShowAllButtonLabel": "Show All Licenses", "@aboutLicensesShowAllButtonLabel": {}, "collectionPageTitle": "Collection", diff --git a/lib/widgets/about/bug_report.dart b/lib/widgets/about/bug_report.dart index b21ad76ab..d98e99898 100644 --- a/lib/widgets/about/bug_report.dart +++ b/lib/widgets/about/bug_report.dart @@ -9,6 +9,7 @@ import 'package:aves/utils/constants.dart'; import 'package:aves/widgets/common/action_mixins/feedback.dart'; import 'package:aves/widgets/common/extensions/build_context.dart'; import 'package:aves/widgets/common/identity/aves_filter_chip.dart'; +import 'package:aves/widgets/common/identity/buttons.dart'; import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -109,13 +110,9 @@ class _BugReportState extends State with FeedbackMixin { const SizedBox(width: 8), Expanded(child: Text(text)), const SizedBox(width: 8), - OutlinedButton( + AvesOutlinedButton( + label: buttonText, onPressed: onPressed, - style: ButtonStyle( - side: MaterialStateProperty.all(BorderSide(color: Theme.of(context).colorScheme.secondary)), - foregroundColor: MaterialStateProperty.all(Colors.white), - ), - child: Text(buttonText), ) ], ), diff --git a/lib/widgets/about/licenses.dart b/lib/widgets/about/licenses.dart index 44cdd6384..86c5b43aa 100644 --- a/lib/widgets/about/licenses.dart +++ b/lib/widgets/about/licenses.dart @@ -3,6 +3,7 @@ import 'package:aves/utils/constants.dart'; import 'package:aves/widgets/common/basic/link_chip.dart'; import 'package:aves/widgets/common/extensions/build_context.dart'; import 'package:aves/widgets/common/identity/aves_expansion_tile.dart'; +import 'package:aves/widgets/common/identity/buttons.dart'; import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; @@ -69,7 +70,8 @@ class _LicensesState extends State { children: _dartPackages.map((package) => LicenseRow(package: package)).toList(), ), Center( - child: TextButton( + child: AvesOutlinedButton( + label: context.l10n.aboutLicensesShowAllButtonLabel, onPressed: () => Navigator.push( context, MaterialPageRoute( @@ -82,7 +84,6 @@ class _LicensesState extends State { ), ), ), - child: Text(context.l10n.aboutLicensesShowAllButtonLabel), ), ), ], diff --git a/lib/widgets/common/identity/buttons.dart b/lib/widgets/common/identity/buttons.dart new file mode 100644 index 000000000..6d6b971e9 --- /dev/null +++ b/lib/widgets/common/identity/buttons.dart @@ -0,0 +1,34 @@ +import 'package:flutter/material.dart'; + +class AvesOutlinedButton extends StatelessWidget { + final Widget? icon; + final String label; + final VoidCallback? onPressed; + + const AvesOutlinedButton({ + Key? key, + this.icon, + required this.label, + required this.onPressed, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + final style = ButtonStyle( + side: MaterialStateProperty.all(BorderSide(color: Theme.of(context).colorScheme.secondary)), + foregroundColor: MaterialStateProperty.all(Colors.white), + ); + return icon != null + ? OutlinedButton.icon( + onPressed: onPressed, + style: style, + icon: icon!, + label: Text(label), + ) + : OutlinedButton( + onPressed: onPressed, + style: style, + child: Text(label), + ); + } +} diff --git a/lib/widgets/settings/navigation/drawer_tab_albums.dart b/lib/widgets/settings/navigation/drawer_tab_albums.dart index 2f35c25e8..cf8de04f5 100644 --- a/lib/widgets/settings/navigation/drawer_tab_albums.dart +++ b/lib/widgets/settings/navigation/drawer_tab_albums.dart @@ -2,6 +2,7 @@ import 'package:aves/model/filters/album.dart'; import 'package:aves/model/source/collection_source.dart'; import 'package:aves/theme/icons.dart'; import 'package:aves/widgets/common/extensions/build_context.dart'; +import 'package:aves/widgets/common/identity/buttons.dart'; import 'package:aves/widgets/drawer/tile.dart'; import 'package:aves/widgets/filter_grids/album_pick.dart'; import 'package:aves/widgets/settings/navigation/drawer_editor_banner.dart'; @@ -59,7 +60,9 @@ class _DrawerAlbumTabState extends State { ), const Divider(height: 0), const SizedBox(height: 8), - OutlinedButton.icon( + AvesOutlinedButton( + icon: const Icon(AIcons.add), + label: context.l10n.settingsNavigationDrawerAddAlbum, onPressed: () async { final source = context.read(); final album = await Navigator.push( @@ -76,12 +79,6 @@ class _DrawerAlbumTabState extends State { widget.items.add(album); }); }, - style: ButtonStyle( - side: MaterialStateProperty.all(BorderSide(color: Theme.of(context).colorScheme.secondary)), - foregroundColor: MaterialStateProperty.all(Colors.white), - ), - icon: const Icon(AIcons.add), - label: Text(context.l10n.settingsNavigationDrawerAddAlbum), ) ], );