Refactoring

This commit is contained in:
Ming Ming 2021-08-14 01:30:47 +08:00
parent 058320ffe4
commit 8f8b5c2319
2 changed files with 38 additions and 47 deletions

View file

@ -178,9 +178,33 @@ class _ViewerState extends State<Viewer> {
? k.animationDurationNormal
: const Duration(milliseconds: 1),
child: ViewerBottomAppBar(
onSharePressed: () => _onSharePressed(context),
onDownloadPressed: () => _onDownloadPressed(context),
onDeletePressed: () => _onDeletePressed(context),
children: [
if (platform_k.isAndroid)
IconButton(
icon: Icon(
Icons.share_outlined,
color: Colors.white.withOpacity(.87),
),
tooltip: L10n.of(context).shareTooltip,
onPressed: () => _onSharePressed(context),
),
IconButton(
icon: Icon(
Icons.download_outlined,
color: Colors.white.withOpacity(.87),
),
tooltip: L10n.of(context).downloadTooltip,
onPressed: () => _onDownloadPressed(context),
),
IconButton(
icon: Icon(
Icons.delete_outlined,
color: Colors.white.withOpacity(.87),
),
tooltip: L10n.of(context).deleteTooltip,
onPressed: () => _onDeletePressed(context),
),
],
),
),
),

View file

@ -1,13 +1,12 @@
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;
/// Button bar near the bottom of viewer
///
/// Buttons are spread evenly across the horizontal axis
class ViewerBottomAppBar extends StatelessWidget {
ViewerBottomAppBar({
this.onSharePressed,
this.onDownloadPressed,
this.onDeletePressed,
required this.children,
});
@override
@ -28,47 +27,15 @@ class ViewerBottomAppBar extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
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,
),
),
],
children: children
.map((e) => Expanded(
flex: 1,
child: e,
))
.toList(),
),
);
}
final VoidCallback? onSharePressed;
final VoidCallback? onDownloadPressed;
final VoidCallback? onDeletePressed;
final List<Widget> children;
}