diff --git a/lib/widgets/common/basic/popup/menu_button.dart b/lib/widgets/common/basic/popup/menu_button.dart deleted file mode 100644 index f0f3d178b..000000000 --- a/lib/widgets/common/basic/popup/menu_button.dart +++ /dev/null @@ -1,37 +0,0 @@ -import 'package:flutter/material.dart'; - -class AvesPopupMenuButton extends PopupMenuButton { - final VoidCallback? onMenuOpened; - - const AvesPopupMenuButton({ - super.key, - required super.itemBuilder, - super.initialValue, - super.onSelected, - super.onCanceled, - super.tooltip, - super.elevation, - super.padding = const EdgeInsets.all(8), - super.child, - super.icon, - super.offset = Offset.zero, - super.enabled = true, - super.shape, - super.color, - super.enableFeedback, - super.iconSize, - this.onMenuOpened, - super.popUpAnimationStyle, - }); - - @override - PopupMenuButtonState createState() => _AvesPopupMenuButtonState(); -} - -class _AvesPopupMenuButtonState extends PopupMenuButtonState { - @override - void showButtonMenu() { - (widget as AvesPopupMenuButton).onMenuOpened?.call(); - super.showButtonMenu(); - } -} diff --git a/lib/widgets/common/identity/aves_app_bar.dart b/lib/widgets/common/identity/aves_app_bar.dart index d0d7e6ba9..38c19167d 100644 --- a/lib/widgets/common/identity/aves_app_bar.dart +++ b/lib/widgets/common/identity/aves_app_bar.dart @@ -40,6 +40,50 @@ class AvesAppBar extends StatelessWidget { final colorScheme = theme.colorScheme; final textScaler = MediaQuery.textScalerOf(context); final useTvLayout = settings.useTvLayout; + + Widget? _leading = leading; + if (_leading != null) { + _leading = FontSizeIconTheme( + child: _leading, + ); + } + + Widget _title = FontSizeIconTheme( + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + key: ValueKey(transitionKey), + children: [ + Expanded(child: title), + ...(actions(context, max(0, constraints.maxWidth - _titleMinWidth))), + ], + ); + }, + ), + ); + + final animate = context.select((v) => v.animate); + if (animate) { + _title = Hero( + tag: titleHeroTag, + flightShuttleBuilder: _flightShuttleBuilder, + transitionOnUserGestures: true, + child: AnimatedSwitcher( + duration: context.read().iconAnimation, + child: _title, + ), + ); + + if (_leading != null) { + _leading = Hero( + tag: leadingHeroTag, + flightShuttleBuilder: _flightShuttleBuilder, + transitionOnUserGestures: true, + child: _leading, + ); + } + } + return SliverPersistentHeader( floating: !useTvLayout, pinned: pinned, @@ -70,43 +114,16 @@ class AvesAppBar extends StatelessWidget { height: textScaler.scale(kToolbarHeight), child: Row( children: [ - leading != null + _leading != null ? Padding( padding: const EdgeInsets.symmetric(horizontal: 4), - child: Hero( - tag: leadingHeroTag, - flightShuttleBuilder: _flightShuttleBuilder, - transitionOnUserGestures: true, - child: FontSizeIconTheme( - child: leading!, - ), - ), + child: _leading, ) : const SizedBox(width: 16), Expanded( child: DefaultTextStyle( style: theme.appBarTheme.titleTextStyle!, - child: Hero( - tag: titleHeroTag, - flightShuttleBuilder: _flightShuttleBuilder, - transitionOnUserGestures: true, - child: AnimatedSwitcher( - duration: context.read().iconAnimation, - child: FontSizeIconTheme( - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - key: ValueKey(transitionKey), - children: [ - Expanded(child: title), - ...(actions(context, max(0, constraints.maxWidth - _titleMinWidth))), - ], - ); - }, - ), - ), - ), - ), + child: _title, ), ), ], diff --git a/lib/widgets/navigation/nav_bar/nav_bar.dart b/lib/widgets/navigation/nav_bar/nav_bar.dart index e4c3a9f3f..0b7891c72 100644 --- a/lib/widgets/navigation/nav_bar/nav_bar.dart +++ b/lib/widgets/navigation/nav_bar/nav_bar.dart @@ -75,42 +75,47 @@ class _AppBottomNavBarState extends State { const AvesBottomNavItem(route: AlbumListPage.routeName), ]; - Widget child = AvesFloatingBar( - builder: (context, backgroundColor, child) => BottomNavigationBar( - items: items - .map((item) => BottomNavigationBarItem( - icon: item.icon(context), - label: item.label(context), - tooltip: item.label(context), - )) - .toList(), - onTap: (index) => _goTo(context, items, index), - currentIndex: _getCurrentIndex(context, items), - type: BottomNavigationBarType.fixed, - backgroundColor: backgroundColor, - showSelectedLabels: false, - showUnselectedLabels: false, - ), - ); - - return Hero( - tag: 'nav-bar', - flightShuttleBuilder: (flight, animation, direction, fromHero, toHero) { - return MediaQuery.removeViewInsets( - context: context, - removeBottom: true, - child: toHero.widget, - ); - }, - child: FloatingNavBar( - scrollController: PrimaryScrollController.of(context), - events: widget.events, - childHeight: AppBottomNavBar.height + context.select((mq) => mq.effectiveBottomPadding), - child: SafeArea( - child: child, + Widget child = FloatingNavBar( + scrollController: PrimaryScrollController.of(context), + events: widget.events, + childHeight: AppBottomNavBar.height + context.select((mq) => mq.effectiveBottomPadding), + child: SafeArea( + child: AvesFloatingBar( + builder: (context, backgroundColor, child) => BottomNavigationBar( + items: items + .map((item) => BottomNavigationBarItem( + icon: item.icon(context), + label: item.label(context), + tooltip: item.label(context), + )) + .toList(), + onTap: (index) => _goTo(context, items, index), + currentIndex: _getCurrentIndex(context, items), + type: BottomNavigationBarType.fixed, + backgroundColor: backgroundColor, + showSelectedLabels: false, + showUnselectedLabels: false, + ), ), ), ); + + final animate = context.select((v) => v.animate); + if (animate) { + child = Hero( + tag: 'nav-bar', + flightShuttleBuilder: (flight, animation, direction, fromHero, toHero) { + return MediaQuery.removeViewInsets( + context: context, + removeBottom: true, + child: toHero.widget, + ); + }, + child: child, + ); + } + + return child; } void _onCollectionFilterChanged() => setState(() {}); diff --git a/lib/widgets/viewer/overlay/viewer_buttons.dart b/lib/widgets/viewer/overlay/viewer_buttons.dart index ae99d9a76..2b757b544 100644 --- a/lib/widgets/viewer/overlay/viewer_buttons.dart +++ b/lib/widgets/viewer/overlay/viewer_buttons.dart @@ -19,7 +19,6 @@ import 'package:aves/widgets/common/action_controls/togglers/play.dart'; import 'package:aves/widgets/common/basic/font_size_icon_theme.dart'; import 'package:aves/widgets/common/basic/popup/container.dart'; import 'package:aves/widgets/common/basic/popup/expansion_panel.dart'; -import 'package:aves/widgets/common/basic/popup/menu_button.dart'; import 'package:aves/widgets/common/basic/popup/menu_row.dart'; import 'package:aves/widgets/common/extensions/build_context.dart'; import 'package:aves/widgets/common/identity/buttons/captioned_button.dart'; @@ -269,7 +268,7 @@ class _ViewerButtonRowContentState extends State { child: OverlayButton( scale: widget.scale, child: FontSizeIconTheme( - child: AvesPopupMenuButton( + child: PopupMenuButton( key: const Key('entry-menu-button'), itemBuilder: (context) { final exportInternalActions = exportActions.whereNot(EntryActions.exportExternal.contains).toList(); @@ -305,6 +304,7 @@ class _ViewerButtonRowContentState extends State { ] ]; }, + onOpened: () => PopupMenuOpenedNotification().dispatch(context), onSelected: (action) async { _popupExpandedNotifier.value = null; // wait for the popup menu to hide before proceeding with the action @@ -315,7 +315,6 @@ class _ViewerButtonRowContentState extends State { _popupExpandedNotifier.value = null; }, iconSize: IconTheme.of(context).size, - onMenuOpened: () => PopupMenuOpenedNotification().dispatch(context), popUpAnimationStyle: animations.popUpAnimationStyle, ), ),