collection / filter pages: extend below status bar
This commit is contained in:
parent
77bf6a2b58
commit
d0f293abb2
3 changed files with 44 additions and 18 deletions
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:aves/app_mode.dart';
|
import 'package:aves/app_mode.dart';
|
||||||
import 'package:aves/model/actions/entry_set_actions.dart';
|
import 'package:aves/model/actions/entry_set_actions.dart';
|
||||||
|
@ -45,13 +46,14 @@ class CollectionAppBar extends StatefulWidget {
|
||||||
State<CollectionAppBar> createState() => _CollectionAppBarState();
|
State<CollectionAppBar> createState() => _CollectionAppBarState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerProviderStateMixin {
|
class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerProviderStateMixin, WidgetsBindingObserver {
|
||||||
final List<StreamSubscription> _subscriptions = [];
|
final List<StreamSubscription> _subscriptions = [];
|
||||||
final EntrySetActionDelegate _actionDelegate = EntrySetActionDelegate();
|
final EntrySetActionDelegate _actionDelegate = EntrySetActionDelegate();
|
||||||
late AnimationController _browseToSelectAnimation;
|
late AnimationController _browseToSelectAnimation;
|
||||||
final ValueNotifier<bool> _isSelectingNotifier = ValueNotifier(false);
|
final ValueNotifier<bool> _isSelectingNotifier = ValueNotifier(false);
|
||||||
final FocusNode _queryBarFocusNode = FocusNode();
|
final FocusNode _queryBarFocusNode = FocusNode();
|
||||||
late final Listenable _queryFocusRequestNotifier;
|
late final Listenable _queryFocusRequestNotifier;
|
||||||
|
double _statusBarHeight = 0;
|
||||||
|
|
||||||
CollectionLens get collection => widget.collection;
|
CollectionLens get collection => widget.collection;
|
||||||
|
|
||||||
|
@ -76,7 +78,11 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
|
||||||
);
|
);
|
||||||
_isSelectingNotifier.addListener(_onActivityChange);
|
_isSelectingNotifier.addListener(_onActivityChange);
|
||||||
_registerWidget(widget);
|
_registerWidget(widget);
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) => _onFilterChanged());
|
WidgetsBinding.instance.addObserver(this);
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_updateStatusBarHeight();
|
||||||
|
_onFilterChanged();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -95,6 +101,7 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
|
||||||
_subscriptions
|
_subscriptions
|
||||||
..forEach((sub) => sub.cancel())
|
..forEach((sub) => sub.cancel())
|
||||||
..clear();
|
..clear();
|
||||||
|
WidgetsBinding.instance.removeObserver(this);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +113,11 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
|
||||||
widget.collection.filterChangeNotifier.removeListener(_onFilterChanged);
|
widget.collection.filterChangeNotifier.removeListener(_onFilterChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeMetrics() {
|
||||||
|
_updateStatusBarHeight();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final appMode = context.watch<ValueNotifier<AppMode>>().value;
|
final appMode = context.watch<ValueNotifier<AppMode>>().value;
|
||||||
|
@ -418,7 +430,14 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
|
||||||
|
|
||||||
void _onQueryFocusRequest() => _queryBarFocusNode.requestFocus();
|
void _onQueryFocusRequest() => _queryBarFocusNode.requestFocus();
|
||||||
|
|
||||||
void _updateAppBarHeight() => widget.appBarHeightNotifier.value = kToolbarHeight + appBarBottomHeight;
|
void _updateStatusBarHeight() {
|
||||||
|
_statusBarHeight = EdgeInsets.fromWindowPadding(window.padding, window.devicePixelRatio).top;
|
||||||
|
_updateAppBarHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _updateAppBarHeight() {
|
||||||
|
widget.appBarHeightNotifier.value = _statusBarHeight + kToolbarHeight + appBarBottomHeight;
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _onActionSelected(EntrySetAction action) async {
|
Future<void> _onActionSelected(EntrySetAction action) async {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
|
|
@ -110,6 +110,7 @@ class _CollectionPageState extends State<CollectionPage> {
|
||||||
child: DoubleBackPopScope(
|
child: DoubleBackPopScope(
|
||||||
child: GestureAreaProtectorStack(
|
child: GestureAreaProtectorStack(
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
|
top: false,
|
||||||
bottom: false,
|
bottom: false,
|
||||||
child: ChangeNotifierProvider<CollectionLens>.value(
|
child: ChangeNotifierProvider<CollectionLens>.value(
|
||||||
value: _collection,
|
value: _collection,
|
||||||
|
|
|
@ -94,22 +94,28 @@ class FilterGridPage<T extends CollectionFilter> extends StatelessWidget {
|
||||||
child: DoubleBackPopScope(
|
child: DoubleBackPopScope(
|
||||||
child: GestureAreaProtectorStack(
|
child: GestureAreaProtectorStack(
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
|
top: false,
|
||||||
bottom: false,
|
bottom: false,
|
||||||
child: FilterGrid<T>(
|
child: Selector<MediaQueryData, double>(
|
||||||
// key is expected by test driver
|
selector: (context, mq) => mq.padding.top,
|
||||||
key: const Key('filter-grid'),
|
builder: (context, mqPaddingTop, child) {
|
||||||
settingsRouteKey: settingsRouteKey,
|
return FilterGrid<T>(
|
||||||
appBar: appBar,
|
// key is expected by test driver
|
||||||
appBarHeight: appBarHeight,
|
key: const Key('filter-grid'),
|
||||||
sections: sections,
|
settingsRouteKey: settingsRouteKey,
|
||||||
newFilters: newFilters,
|
appBar: appBar,
|
||||||
sortFactor: sortFactor,
|
appBarHeight: mqPaddingTop + appBarHeight,
|
||||||
showHeaders: showHeaders,
|
sections: sections,
|
||||||
selectable: selectable,
|
newFilters: newFilters,
|
||||||
queryNotifier: queryNotifier,
|
sortFactor: sortFactor,
|
||||||
applyQuery: applyQuery,
|
showHeaders: showHeaders,
|
||||||
emptyBuilder: emptyBuilder,
|
selectable: selectable,
|
||||||
heroType: heroType,
|
queryNotifier: queryNotifier,
|
||||||
|
applyQuery: applyQuery,
|
||||||
|
emptyBuilder: emptyBuilder,
|
||||||
|
heroType: heroType,
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue