diff --git a/lib/widget/viewer.dart b/lib/widget/viewer.dart index f4615b38..eb5820cc 100644 --- a/lib/widget/viewer.dart +++ b/lib/widget/viewer.dart @@ -25,6 +25,7 @@ import 'package:nc_photos/use_case/remove.dart'; import 'package:nc_photos/widget/animated_visibility.dart'; import 'package:nc_photos/widget/image_viewer.dart'; import 'package:nc_photos/widget/video_viewer.dart'; +import 'package:nc_photos/widget/viewer_bottom_app_bar.dart'; import 'package:nc_photos/widget/viewer_detail_pane.dart'; class ViewerArguments { @@ -286,59 +287,10 @@ class _ViewerState extends State { duration: !_isDetailPaneActive ? k.animationDurationNormal : const Duration(milliseconds: 1), - child: Container( - height: kToolbarHeight, - alignment: Alignment.center, - decoration: BoxDecoration( - gradient: LinearGradient( - begin: const Alignment(0, -1), - end: const Alignment(0, 1), - colors: [ - Color.fromARGB(0, 0, 0, 0), - Color.fromARGB(192, 0, 0, 0), - ], - ), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - if (platform_k.isAndroid) - Expanded( - flex: 1, - child: IconButton( - icon: Icon( - Icons.share_outlined, - color: Colors.white.withOpacity(.87), - ), - tooltip: L10n.of(context).shareTooltip, - onPressed: () => _onSharePressed(context), - ), - ), - Expanded( - flex: 1, - child: IconButton( - icon: Icon( - Icons.download_outlined, - color: Colors.white.withOpacity(.87), - ), - tooltip: L10n.of(context).downloadTooltip, - onPressed: () => _onDownloadPressed(context), - ), - ), - Expanded( - flex: 1, - child: IconButton( - icon: Icon( - Icons.delete_outlined, - color: Colors.white.withOpacity(.87), - ), - tooltip: L10n.of(context).deleteTooltip, - onPressed: () => _onDeletePressed(context), - ), - ), - ], - ), + child: ViewerBottomAppBar( + onSharePressed: () => _onSharePressed(context), + onDownloadPressed: () => _onDownloadPressed(context), + onDeletePressed: () => _onDeletePressed(context), ), ), ), diff --git a/lib/widget/viewer_bottom_app_bar.dart b/lib/widget/viewer_bottom_app_bar.dart new file mode 100644 index 00000000..0f1ffb7b --- /dev/null +++ b/lib/widget/viewer_bottom_app_bar.dart @@ -0,0 +1,74 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:nc_photos/app_localizations.dart'; +import 'package:nc_photos/platform/k.dart' as platform_k; + +class ViewerBottomAppBar extends StatelessWidget { + ViewerBottomAppBar({ + this.onSharePressed, + this.onDownloadPressed, + this.onDeletePressed, + }); + + @override + build(BuildContext context) { + return Container( + height: kToolbarHeight, + alignment: Alignment.center, + decoration: BoxDecoration( + gradient: LinearGradient( + begin: const Alignment(0, -1), + end: const Alignment(0, 1), + colors: [ + Color.fromARGB(0, 0, 0, 0), + Color.fromARGB(192, 0, 0, 0), + ], + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + if (platform_k.isAndroid) + Expanded( + flex: 1, + child: IconButton( + icon: Icon( + Icons.share_outlined, + color: Colors.white.withOpacity(.87), + ), + tooltip: L10n.of(context).shareTooltip, + onPressed: onSharePressed, + ), + ), + Expanded( + flex: 1, + child: IconButton( + icon: Icon( + Icons.download_outlined, + color: Colors.white.withOpacity(.87), + ), + tooltip: L10n.of(context).downloadTooltip, + onPressed: onDownloadPressed, + ), + ), + Expanded( + flex: 1, + child: IconButton( + icon: Icon( + Icons.delete_outlined, + color: Colors.white.withOpacity(.87), + ), + tooltip: L10n.of(context).deleteTooltip, + onPressed: onDeletePressed, + ), + ), + ], + ), + ); + } + + final VoidCallback? onSharePressed; + final VoidCallback? onDownloadPressed; + final VoidCallback? onDeletePressed; +}