Add an info button to photos
This commit is contained in:
parent
b42bbbe0b4
commit
e4017d91df
2 changed files with 118 additions and 4 deletions
|
@ -7,6 +7,7 @@ import 'package:photos/favorite_photos_repository.dart';
|
|||
import 'package:photos/models/photo.dart';
|
||||
import 'package:photos/ui/extents_page_view.dart';
|
||||
import 'package:photos/ui/zoomable_image.dart';
|
||||
import 'package:photos/utils/date_time_util.dart';
|
||||
import 'package:photos/utils/share_util.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
|
@ -93,10 +94,41 @@ class _DetailPageState extends State<DetailPage> {
|
|||
if (_photos[_selectedIndex].localId != null) {
|
||||
actions.add(_getFavoriteButton());
|
||||
}
|
||||
actions.add(IconButton(
|
||||
icon: Icon(Icons.share),
|
||||
onPressed: () async {
|
||||
share(_photos[_selectedIndex]);
|
||||
actions.add(PopupMenuButton(
|
||||
itemBuilder: (context) {
|
||||
return [
|
||||
PopupMenuItem(
|
||||
value: 1,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.share),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
),
|
||||
Text("Share"),
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 2,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.info),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
),
|
||||
Text("Info"),
|
||||
],
|
||||
),
|
||||
)
|
||||
];
|
||||
},
|
||||
onSelected: (value) {
|
||||
if (value == 1) {
|
||||
share(_photos[_selectedIndex]);
|
||||
} else if (value == 2) {
|
||||
_displayInfo(_photos[_selectedIndex]);
|
||||
}
|
||||
},
|
||||
));
|
||||
return AppBar(
|
||||
|
@ -113,4 +145,56 @@ class _DetailPageState extends State<DetailPage> {
|
|||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _displayInfo(Photo photo) async {
|
||||
final asset = await photo.getAsset();
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(photo.title),
|
||||
content: SingleChildScrollView(
|
||||
child: ListBody(
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.timer),
|
||||
Padding(padding: EdgeInsets.all(4)),
|
||||
Text(getFormattedTime(DateTime.fromMicrosecondsSinceEpoch(
|
||||
photo.createTimestamp))),
|
||||
],
|
||||
),
|
||||
Padding(padding: EdgeInsets.all(4)),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.folder),
|
||||
Padding(padding: EdgeInsets.all(4)),
|
||||
Text(photo.deviceFolder),
|
||||
],
|
||||
),
|
||||
Padding(padding: EdgeInsets.all(4)),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.photo_size_select_actual),
|
||||
Padding(padding: EdgeInsets.all(4)),
|
||||
Text(asset.width.toString() +
|
||||
" x " +
|
||||
asset.height.toString()),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: Text('Ok'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,3 +34,33 @@ String getDayAndMonth(DateTime dateTime) {
|
|||
" " +
|
||||
dateTime.day.toString();
|
||||
}
|
||||
|
||||
String getDay(DateTime dateTime) {
|
||||
return _days[dateTime.weekday];
|
||||
}
|
||||
|
||||
String getMonth(DateTime dateTime) {
|
||||
return _months[dateTime.month];
|
||||
}
|
||||
|
||||
String getTime(DateTime dateTime) {
|
||||
final hours = dateTime.hour > 9
|
||||
? dateTime.hour.toString()
|
||||
: "0" + dateTime.hour.toString();
|
||||
final minutes = dateTime.minute > 9
|
||||
? dateTime.minute.toString()
|
||||
: "0" + dateTime.minute.toString();
|
||||
return hours + ":" + minutes;
|
||||
}
|
||||
|
||||
String getFormattedTime(DateTime dateTime) {
|
||||
return getDay(dateTime) +
|
||||
", " +
|
||||
getMonth(dateTime) +
|
||||
" " +
|
||||
dateTime.day.toString() +
|
||||
", " +
|
||||
dateTime.year.toString() +
|
||||
" - " +
|
||||
getTime(dateTime);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue