diff --git a/lib/ui/detail_page.dart b/lib/ui/detail_page.dart index b90e0e814..1359dce01 100644 --- a/lib/ui/detail_page.dart +++ b/lib/ui/detail_page.dart @@ -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 { 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 { }, ); } + + Future _displayInfo(Photo photo) async { + final asset = await photo.getAsset(); + return showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text(photo.title), + content: SingleChildScrollView( + child: ListBody( + children: [ + 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: [ + FlatButton( + child: Text('Ok'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } } diff --git a/lib/utils/date_time_util.dart b/lib/utils/date_time_util.dart index e5bbcfc23..75d0bb726 100644 --- a/lib/utils/date_time_util.dart +++ b/lib/utils/date_time_util.dart @@ -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); +}