minor changes to theme & dialogs

This commit is contained in:
Thibault Deckers 2020-11-22 21:39:09 +09:00
parent d989b6010f
commit 6fed7b0939
15 changed files with 73 additions and 50 deletions

View file

@ -57,6 +57,7 @@ class _AvesAppState extends State<AvesApp> {
accentColor: accentColor,
scaffoldBackgroundColor: Colors.grey[900],
buttonColor: accentColor,
dialogBackgroundColor: Colors.grey[850],
toggleableActiveColor: accentColor,
tooltipTheme: TooltipThemeData(
verticalOffset: 32,

View file

@ -64,8 +64,19 @@ class _LicensesState extends State<Licenses> {
),
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()),
),
),
],

View file

@ -37,6 +37,7 @@ class _AddShortcutDialogState extends State<AddShortcutDialog> {
@override
Widget build(BuildContext context) {
return AvesDialog(
context: context,
content: TextField(
controller: _nameController,
decoration: InputDecoration(

View file

@ -41,6 +41,7 @@ class _CreateAlbumDialogState extends State<CreateAlbumDialog> {
@override
Widget build(BuildContext context) {
return AvesDialog(
context: context,
title: 'New Album',
scrollController: _scrollController,
scrollableContent: [

View file

@ -152,6 +152,7 @@ class EntryActionDelegate with FeedbackMixin, PermissionAwareMixin {
context: context,
builder: (context) {
return AvesDialog(
context: context,
content: Text('Are you sure?'),
actions: [
TextButton(

View file

@ -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: [

View file

@ -39,6 +39,7 @@ class _RenameAlbumDialogState extends State<RenameAlbumDialog> {
@override
Widget build(BuildContext context) {
return AvesDialog(
context: context,
content: ValueListenableBuilder<bool>(
valueListenable: _existsNotifier,
builder: (context, exists, child) {

View file

@ -37,6 +37,7 @@ class _RenameEntryDialogState extends State<RenameEntryDialog> {
@override
Widget build(BuildContext context) {
return AvesDialog(
context: context,
content: TextField(
controller: _nameController,
decoration: InputDecoration(

View file

@ -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(

View file

@ -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: [

View file

@ -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<Widget> scrollableContent,
@ -12,31 +14,35 @@ class AvesDialog extends AlertDialog {
@required List<Widget> 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: [

View file

@ -35,6 +35,7 @@ class _AvesSelectionDialogState<T> extends State<AvesSelectionDialog> {
@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: [

View file

@ -38,37 +38,30 @@ class _AppDrawerState extends State<AppDrawer> {
@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',
),
],
),
),
],
),
],
),
),
],
),
),
);

View file

@ -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(

View file

@ -43,7 +43,7 @@ class InfoPageState extends State<InfoPage> {
key: Key('back-button'),
icon: Icon(AIcons.goUp),
onPressed: _goToImage,
tooltip: 'Back to media',
tooltip: 'Back to viewer',
),
title: Text('Info'),
floating: true,