minor fixes
This commit is contained in:
parent
d8a1d21f6c
commit
b75e01185b
3 changed files with 105 additions and 63 deletions
|
@ -1,5 +1,4 @@
|
||||||
import 'package:aves/model/settings/settings.dart';
|
import 'package:aves/model/settings/settings.dart';
|
||||||
import 'package:aves/theme/colors.dart';
|
|
||||||
import 'package:aves/theme/durations.dart';
|
import 'package:aves/theme/durations.dart';
|
||||||
import 'package:aves/widgets/aves_app.dart';
|
import 'package:aves/widgets/aves_app.dart';
|
||||||
import 'package:aves/widgets/common/basic/insets.dart';
|
import 'package:aves/widgets/common/basic/insets.dart';
|
||||||
|
@ -32,71 +31,72 @@ class AvesAppBar extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final useTvLayout = settings.useTvLayout;
|
||||||
return Selector<MediaQueryData, double>(
|
return Selector<MediaQueryData, double>(
|
||||||
selector: (context, mq) => mq.padding.top,
|
selector: (context, mq) => mq.padding.top,
|
||||||
builder: (context, mqPaddingTop, child) {
|
builder: (context, mqPaddingTop, child) {
|
||||||
final useTvLayout = settings.useTvLayout;
|
|
||||||
return SliverPersistentHeader(
|
return SliverPersistentHeader(
|
||||||
floating: !useTvLayout,
|
floating: !useTvLayout,
|
||||||
pinned: pinned,
|
pinned: pinned,
|
||||||
delegate: _SliverAppBarDelegate(
|
delegate: _SliverAppBarDelegate(
|
||||||
height: mqPaddingTop + appBarHeightForContentHeight(contentHeight),
|
height: mqPaddingTop + appBarHeightForContentHeight(contentHeight),
|
||||||
child: DirectionalSafeArea(
|
child: child!,
|
||||||
start: !useTvLayout,
|
|
||||||
bottom: false,
|
|
||||||
child: AvesFloatingBar(
|
|
||||||
builder: (context, backgroundColor, child) => Material(
|
|
||||||
color: backgroundColor,
|
|
||||||
child: child,
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
height: kToolbarHeight,
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
leading != null
|
|
||||||
? Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
|
||||||
child: Hero(
|
|
||||||
tag: leadingHeroTag,
|
|
||||||
flightShuttleBuilder: _flightShuttleBuilder,
|
|
||||||
transitionOnUserGestures: true,
|
|
||||||
child: leading!,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: const SizedBox(width: 16),
|
|
||||||
Expanded(
|
|
||||||
child: DefaultTextStyle(
|
|
||||||
style: context.select<AvesColorsData, TextStyle>((v) => Theme.of(context).appBarTheme.titleTextStyle!),
|
|
||||||
child: Hero(
|
|
||||||
tag: titleHeroTag,
|
|
||||||
flightShuttleBuilder: _flightShuttleBuilder,
|
|
||||||
transitionOnUserGestures: true,
|
|
||||||
child: AnimatedSwitcher(
|
|
||||||
duration: context.read<DurationsData>().iconAnimation,
|
|
||||||
child: Row(
|
|
||||||
key: ValueKey(transitionKey),
|
|
||||||
children: [
|
|
||||||
Expanded(child: title),
|
|
||||||
...actions,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (bottom != null) bottom!,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
child: DirectionalSafeArea(
|
||||||
|
start: !useTvLayout,
|
||||||
|
bottom: false,
|
||||||
|
child: AvesFloatingBar(
|
||||||
|
builder: (context, backgroundColor, child) => Material(
|
||||||
|
color: backgroundColor,
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: kToolbarHeight,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
leading != null
|
||||||
|
? Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
|
child: Hero(
|
||||||
|
tag: leadingHeroTag,
|
||||||
|
flightShuttleBuilder: _flightShuttleBuilder,
|
||||||
|
transitionOnUserGestures: true,
|
||||||
|
child: leading!,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const SizedBox(width: 16),
|
||||||
|
Expanded(
|
||||||
|
child: DefaultTextStyle(
|
||||||
|
style: Theme.of(context).appBarTheme.titleTextStyle!,
|
||||||
|
child: Hero(
|
||||||
|
tag: titleHeroTag,
|
||||||
|
flightShuttleBuilder: _flightShuttleBuilder,
|
||||||
|
transitionOnUserGestures: true,
|
||||||
|
child: AnimatedSwitcher(
|
||||||
|
duration: context.read<DurationsData>().iconAnimation,
|
||||||
|
child: Row(
|
||||||
|
key: ValueKey(transitionKey),
|
||||||
|
children: [
|
||||||
|
Expanded(child: title),
|
||||||
|
...actions,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (bottom != null) bottom!,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@ import 'package:aves/widgets/common/basic/wheel.dart';
|
||||||
import 'package:aves/widgets/common/extensions/build_context.dart';
|
import 'package:aves/widgets/common/extensions/build_context.dart';
|
||||||
import 'package:aves/widgets/common/providers/media_query_data_provider.dart';
|
import 'package:aves/widgets/common/providers/media_query_data_provider.dart';
|
||||||
import 'package:aves/widgets/dialogs/aves_dialog.dart';
|
import 'package:aves/widgets/dialogs/aves_dialog.dart';
|
||||||
import 'package:aves/widgets/dialogs/pick_dialogs/item_pick_page.dart';
|
|
||||||
import 'package:aves/widgets/dialogs/item_picker.dart';
|
import 'package:aves/widgets/dialogs/item_picker.dart';
|
||||||
|
import 'package:aves/widgets/dialogs/pick_dialogs/item_pick_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ class _EditEntryDateDialogState extends State<EditEntryDateDialog> {
|
||||||
late ValueNotifier<String> _shiftSign;
|
late ValueNotifier<String> _shiftSign;
|
||||||
bool _showOptions = false;
|
bool _showOptions = false;
|
||||||
final Set<MetadataField> _fields = {...DateModifier.writableFields};
|
final Set<MetadataField> _fields = {...DateModifier.writableFields};
|
||||||
|
final ValueNotifier<bool> _isValidNotifier = ValueNotifier(false);
|
||||||
|
|
||||||
DateTime get copyItemDate => _copyItemSource.bestDate ?? DateTime.now();
|
DateTime get copyItemDate => _copyItemSource.bestDate ?? DateTime.now();
|
||||||
|
|
||||||
|
@ -52,6 +53,13 @@ class _EditEntryDateDialogState extends State<EditEntryDateDialog> {
|
||||||
_initCustom();
|
_initCustom();
|
||||||
_initCopyItem();
|
_initCopyItem();
|
||||||
_initShift(minutesInHour);
|
_initShift(minutesInHour);
|
||||||
|
_validate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_isValidNotifier.dispose();
|
||||||
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _initCustom() {
|
void _initCustom() {
|
||||||
|
@ -88,7 +96,11 @@ class _EditEntryDateDialogState extends State<EditEntryDateDialog> {
|
||||||
values: DateEditAction.values,
|
values: DateEditAction.values,
|
||||||
valueText: (v) => v.getText(context),
|
valueText: (v) => v.getText(context),
|
||||||
value: _action,
|
value: _action,
|
||||||
onChanged: (v) => setState(() => _action = v!),
|
onChanged: (v) {
|
||||||
|
_action = v!;
|
||||||
|
_validate();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
dropdownColor: Themes.thirdLayerColor(context),
|
dropdownColor: Themes.thirdLayerColor(context),
|
||||||
),
|
),
|
||||||
|
@ -113,9 +125,14 @@ class _EditEntryDateDialogState extends State<EditEntryDateDialog> {
|
||||||
],
|
],
|
||||||
actions: [
|
actions: [
|
||||||
const CancelButton(),
|
const CancelButton(),
|
||||||
TextButton(
|
ValueListenableBuilder<bool>(
|
||||||
onPressed: () => _submit(context),
|
valueListenable: _isValidNotifier,
|
||||||
child: Text(l10n.applyButtonLabel),
|
builder: (context, isValid, child) {
|
||||||
|
return TextButton(
|
||||||
|
onPressed: isValid ? () => _submit(context) : null,
|
||||||
|
child: Text(l10n.applyButtonLabel),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -265,7 +282,11 @@ class _EditEntryDateDialogState extends State<EditEntryDateDialog> {
|
||||||
children: DateModifier.writableFields
|
children: DateModifier.writableFields
|
||||||
.map((field) => SwitchListTile(
|
.map((field) => SwitchListTile(
|
||||||
value: _fields.contains(field),
|
value: _fields.contains(field),
|
||||||
onChanged: (selected) => setState(() => selected ? _fields.add(field) : _fields.remove(field)),
|
onChanged: (selected) {
|
||||||
|
selected ? _fields.add(field) : _fields.remove(field);
|
||||||
|
_validate();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
title: Text(field.title),
|
title: Text(field.title),
|
||||||
))
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
|
@ -346,5 +367,24 @@ class _EditEntryDateDialogState extends State<EditEntryDateDialog> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _submit(BuildContext context) => Navigator.pop(context, _getModifier());
|
void _validate() {
|
||||||
|
switch (_action) {
|
||||||
|
case DateEditAction.setCustom:
|
||||||
|
case DateEditAction.copyField:
|
||||||
|
case DateEditAction.copyItem:
|
||||||
|
case DateEditAction.extractFromTitle:
|
||||||
|
_isValidNotifier.value = true;
|
||||||
|
break;
|
||||||
|
case DateEditAction.shift:
|
||||||
|
case DateEditAction.remove:
|
||||||
|
_isValidNotifier.value = _fields.isNotEmpty;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _submit(BuildContext context) {
|
||||||
|
if (_isValidNotifier.value) {
|
||||||
|
Navigator.pop(context, _getModifier());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@ class _RenameAlbumDialogState extends State<RenameAlbumDialog> {
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_nameController.dispose();
|
_nameController.dispose();
|
||||||
|
_existsNotifier.dispose();
|
||||||
|
_isValidNotifier.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +68,7 @@ class _RenameAlbumDialogState extends State<RenameAlbumDialog> {
|
||||||
child: Text(context.l10n.applyButtonLabel),
|
child: Text(context.l10n.applyButtonLabel),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue