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 ? k.animationDurationNormal
: const Duration(milliseconds: 1), : const Duration(milliseconds: 1),
child: ViewerBottomAppBar( child: ViewerBottomAppBar(
onSharePressed: () => _onSharePressed(context), children: [
onDownloadPressed: () => _onDownloadPressed(context), if (platform_k.isAndroid)
onDeletePressed: () => _onDeletePressed(context), 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/material.dart';
import 'package:flutter/widgets.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 { class ViewerBottomAppBar extends StatelessWidget {
ViewerBottomAppBar({ ViewerBottomAppBar({
this.onSharePressed, required this.children,
this.onDownloadPressed,
this.onDeletePressed,
}); });
@override @override
@ -28,47 +27,15 @@ class ViewerBottomAppBar extends StatelessWidget {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
children: <Widget>[ children: children
if (platform_k.isAndroid) .map((e) => Expanded(
Expanded(
flex: 1, flex: 1,
child: IconButton( child: e,
icon: Icon( ))
Icons.share_outlined, .toList(),
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 List<Widget> children;
final VoidCallback? onDownloadPressed;
final VoidCallback? onDeletePressed;
} }