From 6fed7b0939788e4e5e71c1f7dff8a203815abb04 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Sun, 22 Nov 2020 21:39:09 +0900 Subject: [PATCH] minor changes to theme & dialogs --- lib/main.dart | 1 + lib/widgets/about/licenses.dart | 15 +++++- .../action_delegates/add_shortcut_dialog.dart | 1 + .../action_delegates/create_album_dialog.dart | 1 + .../entry_action_delegate.dart | 1 + .../action_delegates/permission_aware.dart | 1 + .../action_delegates/rename_album_dialog.dart | 1 + .../action_delegates/rename_entry_dialog.dart | 1 + .../selection_action_delegate.dart | 1 + .../common/action_delegates/size_aware.dart | 1 + lib/widgets/common/aves_dialog.dart | 44 +++++++++------- lib/widgets/common/aves_selection_dialog.dart | 1 + lib/widgets/drawer/app_drawer.dart | 51 ++++++++----------- .../common/chip_action_delegate.dart | 1 + lib/widgets/fullscreen/info/info_page.dart | 2 +- 15 files changed, 73 insertions(+), 50 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index e5ee4e35a..350685a69 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -57,6 +57,7 @@ class _AvesAppState extends State { accentColor: accentColor, scaffoldBackgroundColor: Colors.grey[900], buttonColor: accentColor, + dialogBackgroundColor: Colors.grey[850], toggleableActiveColor: accentColor, tooltipTheme: TooltipThemeData( verticalOffset: 32, diff --git a/lib/widgets/about/licenses.dart b/lib/widgets/about/licenses.dart index c47615cd1..1944dcbbe 100644 --- a/lib/widgets/about/licenses.dart +++ b/lib/widgets/about/licenses.dart @@ -64,8 +64,19 @@ class _LicensesState extends State { ), Center( child: TextButton( - onPressed: () => showLicensePage(context: context), - child: Text('All Licenses'.toUpperCase()), + onPressed: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => Theme( + data: Theme.of(context).copyWith( + // as of Flutter v1.22.4, `cardColor` is used as a background color by `LicensePage` + cardColor: Theme.of(context).scaffoldBackgroundColor, + ), + child: LicensePage(), + ), + ), + ), + child: Text('Show All Licenses'.toUpperCase()), ), ), ], diff --git a/lib/widgets/common/action_delegates/add_shortcut_dialog.dart b/lib/widgets/common/action_delegates/add_shortcut_dialog.dart index f17316720..93e2522a2 100644 --- a/lib/widgets/common/action_delegates/add_shortcut_dialog.dart +++ b/lib/widgets/common/action_delegates/add_shortcut_dialog.dart @@ -37,6 +37,7 @@ class _AddShortcutDialogState extends State { @override Widget build(BuildContext context) { return AvesDialog( + context: context, content: TextField( controller: _nameController, decoration: InputDecoration( diff --git a/lib/widgets/common/action_delegates/create_album_dialog.dart b/lib/widgets/common/action_delegates/create_album_dialog.dart index 498bb4edf..02d41d050 100644 --- a/lib/widgets/common/action_delegates/create_album_dialog.dart +++ b/lib/widgets/common/action_delegates/create_album_dialog.dart @@ -41,6 +41,7 @@ class _CreateAlbumDialogState extends State { @override Widget build(BuildContext context) { return AvesDialog( + context: context, title: 'New Album', scrollController: _scrollController, scrollableContent: [ diff --git a/lib/widgets/common/action_delegates/entry_action_delegate.dart b/lib/widgets/common/action_delegates/entry_action_delegate.dart index 19c9a03ec..3b0e4c63e 100644 --- a/lib/widgets/common/action_delegates/entry_action_delegate.dart +++ b/lib/widgets/common/action_delegates/entry_action_delegate.dart @@ -152,6 +152,7 @@ class EntryActionDelegate with FeedbackMixin, PermissionAwareMixin { context: context, builder: (context) { return AvesDialog( + context: context, content: Text('Are you sure?'), actions: [ TextButton( diff --git a/lib/widgets/common/action_delegates/permission_aware.dart b/lib/widgets/common/action_delegates/permission_aware.dart index 13098a4d4..69816d96f 100644 --- a/lib/widgets/common/action_delegates/permission_aware.dart +++ b/lib/widgets/common/action_delegates/permission_aware.dart @@ -25,6 +25,7 @@ mixin PermissionAwareMixin { context: context, builder: (context) { return AvesDialog( + context: context, title: 'Storage Volume Access', content: Text('Please select the $dirDisplayName directory of “$volumeDescription” in the next screen, so that this app can access it and complete your request.'), actions: [ diff --git a/lib/widgets/common/action_delegates/rename_album_dialog.dart b/lib/widgets/common/action_delegates/rename_album_dialog.dart index 7679fb620..76e90580a 100644 --- a/lib/widgets/common/action_delegates/rename_album_dialog.dart +++ b/lib/widgets/common/action_delegates/rename_album_dialog.dart @@ -39,6 +39,7 @@ class _RenameAlbumDialogState extends State { @override Widget build(BuildContext context) { return AvesDialog( + context: context, content: ValueListenableBuilder( valueListenable: _existsNotifier, builder: (context, exists, child) { diff --git a/lib/widgets/common/action_delegates/rename_entry_dialog.dart b/lib/widgets/common/action_delegates/rename_entry_dialog.dart index 87d258fc5..7bd875f14 100644 --- a/lib/widgets/common/action_delegates/rename_entry_dialog.dart +++ b/lib/widgets/common/action_delegates/rename_entry_dialog.dart @@ -37,6 +37,7 @@ class _RenameEntryDialogState extends State { @override Widget build(BuildContext context) { return AvesDialog( + context: context, content: TextField( controller: _nameController, decoration: InputDecoration( diff --git a/lib/widgets/common/action_delegates/selection_action_delegate.dart b/lib/widgets/common/action_delegates/selection_action_delegate.dart index b110940a4..698cd5178 100644 --- a/lib/widgets/common/action_delegates/selection_action_delegate.dart +++ b/lib/widgets/common/action_delegates/selection_action_delegate.dart @@ -146,6 +146,7 @@ class SelectionActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAwar context: context, builder: (context) { return AvesDialog( + context: context, content: Text('Are you sure you want to delete ${Intl.plural(count, one: 'this item', other: 'these $count items')}?'), actions: [ TextButton( diff --git a/lib/widgets/common/action_delegates/size_aware.dart b/lib/widgets/common/action_delegates/size_aware.dart index f9af342c7..1b49dedda 100644 --- a/lib/widgets/common/action_delegates/size_aware.dart +++ b/lib/widgets/common/action_delegates/size_aware.dart @@ -34,6 +34,7 @@ mixin SizeAwareMixin { context: context, builder: (context) { return AvesDialog( + context: context, title: 'Not Enough Space', content: Text('This operation needs ${formatFilesize(needed)} of free space on “${destinationVolume.description}” to complete, but there is only ${formatFilesize(free)} left.'), actions: [ diff --git a/lib/widgets/common/aves_dialog.dart b/lib/widgets/common/aves_dialog.dart index 6863f6273..2753de93d 100644 --- a/lib/widgets/common/aves_dialog.dart +++ b/lib/widgets/common/aves_dialog.dart @@ -3,8 +3,10 @@ import 'package:flutter/widgets.dart'; class AvesDialog extends AlertDialog { static const contentHorizontalPadding = EdgeInsets.symmetric(horizontal: 24); + static const borderWidth = 1.0; AvesDialog({ + @required BuildContext context, String title, ScrollController scrollController, List scrollableContent, @@ -12,31 +14,35 @@ class AvesDialog extends AlertDialog { @required List actions, }) : assert((scrollableContent != null) ^ (content != null)), super( - title: title != null ? DialogTitle(title: title) : null, + title: title != null ? Padding( + // padding to avoid transparent border overlapping + padding: EdgeInsets.symmetric(horizontal: borderWidth), + child: DialogTitle(title: title), + ) : null, titlePadding: EdgeInsets.zero, // the `scrollable` flag of `AlertDialog` makes it // scroll both the title and the content together, // and overflow feedback ignores the dialog shape, // so we restrict scrolling to the content instead content: scrollableContent != null - ? Builder( - builder: (context) => Container( - // workaround because the dialog tries - // to size itself to the content intrinsic size, - // but the `ListView` viewport does not have one - width: 1, - child: DecoratedBox( - decoration: BoxDecoration( - border: Border( - bottom: Divider.createBorderSide(context, width: 1), - ), - ), - child: ListView( - controller: scrollController ?? ScrollController(), - shrinkWrap: true, - children: scrollableContent, + ? Container( + // padding to avoid transparent border overlapping + padding: EdgeInsets.symmetric(horizontal: borderWidth), + // workaround because the dialog tries + // to size itself to the content intrinsic size, + // but the `ListView` viewport does not have one + width: 1, + child: DecoratedBox( + decoration: BoxDecoration( + border: Border( + bottom: Divider.createBorderSide(context, width: borderWidth), ), ), + child: ListView( + controller: scrollController ?? ScrollController(), + shrinkWrap: true, + children: scrollableContent, + ), ), ) : content, @@ -44,6 +50,7 @@ class AvesDialog extends AlertDialog { actions: actions, actionsPadding: EdgeInsets.symmetric(horizontal: 8), shape: RoundedRectangleBorder( + side: Divider.createBorderSide(context, width: borderWidth), borderRadius: BorderRadius.circular(24), ), ); @@ -61,7 +68,7 @@ class DialogTitle extends StatelessWidget { padding: const EdgeInsets.symmetric(vertical: 20), decoration: BoxDecoration( border: Border( - bottom: Divider.createBorderSide(context, width: 1), + bottom: Divider.createBorderSide(context, width: AvesDialog.borderWidth), ), ), child: Text( @@ -80,6 +87,7 @@ void showNoMatchingAppDialog(BuildContext context) { context: context, builder: (context) { return AvesDialog( + context: context, title: 'No Matching App', content: Text('There are no apps that can handle this.'), actions: [ diff --git a/lib/widgets/common/aves_selection_dialog.dart b/lib/widgets/common/aves_selection_dialog.dart index 5c32ca2e6..920626ffe 100644 --- a/lib/widgets/common/aves_selection_dialog.dart +++ b/lib/widgets/common/aves_selection_dialog.dart @@ -35,6 +35,7 @@ class _AvesSelectionDialogState extends State { @override Widget build(BuildContext context) { return AvesDialog( + context: context, title: widget.title, scrollableContent: widget.options.entries.map((kv) => _buildRadioListTile(kv.key, kv.value)).toList(), actions: [ diff --git a/lib/widgets/drawer/app_drawer.dart b/lib/widgets/drawer/app_drawer.dart index c09791276..cbb1d70ad 100644 --- a/lib/widgets/drawer/app_drawer.dart +++ b/lib/widgets/drawer/app_drawer.dart @@ -38,37 +38,30 @@ class _AppDrawerState extends State { @override Widget build(BuildContext context) { final header = Container( - decoration: BoxDecoration( - border: Border( - bottom: Divider.createBorderSide(context), - ), - ), - child: Container( - padding: EdgeInsets.all(16), - color: Theme.of(context).accentColor, - child: SafeArea( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Align( - alignment: AlignmentDirectional.centerStart, - child: Wrap( - spacing: 16, - crossAxisAlignment: WrapCrossAlignment.center, - children: [ - AvesLogo(size: 64), - Text( - 'Aves', - style: TextStyle( - fontSize: 44, - fontFamily: 'Concourse Caps', - ), + padding: EdgeInsets.all(16), + color: Theme.of(context).accentColor, + child: SafeArea( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Align( + alignment: AlignmentDirectional.centerStart, + child: Wrap( + spacing: 16, + crossAxisAlignment: WrapCrossAlignment.center, + children: [ + AvesLogo(size: 64), + Text( + 'Aves', + style: TextStyle( + fontSize: 44, + fontFamily: 'Concourse Caps', ), - ], - ), + ), + ], ), - ], - ), + ), + ], ), ), ); diff --git a/lib/widgets/filter_grids/common/chip_action_delegate.dart b/lib/widgets/filter_grids/common/chip_action_delegate.dart index 8b8ab2b47..40e708dc7 100644 --- a/lib/widgets/filter_grids/common/chip_action_delegate.dart +++ b/lib/widgets/filter_grids/common/chip_action_delegate.dart @@ -58,6 +58,7 @@ class AlbumChipActionDelegate extends ChipActionDelegate with FeedbackMixin, Per context: context, builder: (context) { return AvesDialog( + context: context, content: Text('Are you sure you want to delete this album and its ${Intl.plural(count, one: 'item', other: '$count items')}?'), actions: [ TextButton( diff --git a/lib/widgets/fullscreen/info/info_page.dart b/lib/widgets/fullscreen/info/info_page.dart index aa64afb0b..edaedd16d 100644 --- a/lib/widgets/fullscreen/info/info_page.dart +++ b/lib/widgets/fullscreen/info/info_page.dart @@ -43,7 +43,7 @@ class InfoPageState extends State { key: Key('back-button'), icon: Icon(AIcons.goUp), onPressed: _goToImage, - tooltip: 'Back to media', + tooltip: 'Back to viewer', ), title: Text('Info'), floating: true,