2021-07-06 23:21:25 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:photos/models/file.dart';
|
|
|
|
import 'package:photos/models/file_type.dart';
|
2021-07-06 23:43:39 +00:00
|
|
|
import 'package:photos/ui/file_info_dialog.dart';
|
2021-07-06 23:21:25 +00:00
|
|
|
import 'package:photos/utils/share_util.dart';
|
|
|
|
|
|
|
|
class FadingBottomBar extends StatefulWidget {
|
|
|
|
final File file;
|
|
|
|
final Function(File) onEditRequested;
|
|
|
|
|
|
|
|
FadingBottomBar(
|
2021-07-11 08:01:47 +00:00
|
|
|
this.file,
|
|
|
|
this.onEditRequested, {
|
2021-07-06 23:21:25 +00:00
|
|
|
Key key,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
FadingBottomBarState createState() => FadingBottomBarState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class FadingBottomBarState extends State<FadingBottomBar> {
|
|
|
|
bool _shouldHide = false;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return _getBottomBar();
|
|
|
|
}
|
|
|
|
|
|
|
|
void hide() {
|
|
|
|
setState(() {
|
|
|
|
_shouldHide = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void show() {
|
|
|
|
setState(() {
|
|
|
|
_shouldHide = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _getBottomBar() {
|
|
|
|
List<Widget> children = [];
|
|
|
|
children.add(
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 12, bottom: 12),
|
|
|
|
child: IconButton(
|
|
|
|
icon: Icon(
|
|
|
|
Platform.isAndroid ? Icons.info_outline : CupertinoIcons.info),
|
|
|
|
onPressed: () {
|
|
|
|
_displayInfo(widget.file);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
if (widget.file.fileType == FileType.image) {
|
|
|
|
children.add(
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 12, bottom: 12),
|
|
|
|
child: IconButton(
|
|
|
|
icon: Icon(Icons.tune_outlined),
|
|
|
|
onPressed: () {
|
|
|
|
widget.onEditRequested(widget.file);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
children.add(
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 12, bottom: 12),
|
|
|
|
child: IconButton(
|
|
|
|
icon: Icon(
|
|
|
|
Platform.isAndroid ? Icons.share_outlined : CupertinoIcons.share),
|
|
|
|
onPressed: () {
|
|
|
|
share(context, [widget.file]);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
return AnimatedOpacity(
|
|
|
|
child: Align(
|
2021-07-11 08:17:44 +00:00
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
gradient: LinearGradient(
|
|
|
|
begin: Alignment.topCenter,
|
|
|
|
end: Alignment.bottomCenter,
|
|
|
|
colors: [
|
|
|
|
Colors.transparent,
|
|
|
|
Colors.black.withOpacity(0.5),
|
|
|
|
Colors.black.withOpacity(0.64),
|
|
|
|
],
|
|
|
|
stops: [0, 0.8, 1],
|
|
|
|
),
|
2021-07-06 23:21:25 +00:00
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
|
children: children,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
opacity: _shouldHide ? 0 : 1,
|
|
|
|
duration: Duration(milliseconds: 150),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _displayInfo(File file) async {
|
|
|
|
return showDialog<void>(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
2021-07-07 01:01:14 +00:00
|
|
|
return FileInfoWidget(file);
|
2021-07-06 23:21:25 +00:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|