Explorar o código

Show year within gallery if not within the same year

Vishnu Mohandas %!s(int64=4) %!d(string=hai) anos
pai
achega
ed80f9dc9f
Modificáronse 2 ficheiros con 9 adicións e 3 borrados
  1. 7 1
      lib/ui/gallery.dart
  2. 2 2
      lib/utils/date_time_util.dart

+ 7 - 1
lib/ui/gallery.dart

@@ -208,11 +208,17 @@ class _GalleryState extends State<Gallery> {
   }
 
   Widget _getDay(int timestamp) {
+    var date = DateTime.fromMicrosecondsSinceEpoch(timestamp);
+    var title = getDayAndMonth(date);
+    if (date.year != DateTime.now().year) {
+      title += " " + date.year.toString();
+    }
+
     return Container(
       padding: const EdgeInsets.all(8.0),
       alignment: Alignment.centerLeft,
       child: Text(
-        getDayAndMonth(DateTime.fromMicrosecondsSinceEpoch(timestamp)),
+        title,
         style: TextStyle(fontSize: 16),
       ),
     );

+ 2 - 2
lib/utils/date_time_util.dart

@@ -45,9 +45,9 @@ String getMonthAndYear(DateTime dateTime) {
 String getDayAndMonth(DateTime dateTime) {
   return _days[dateTime.weekday] +
       ", " +
-      _months[dateTime.month] +
+      dateTime.day.toString() +
       " " +
-      dateTime.day.toString();
+      _months[dateTime.month];
 }
 
 String getDay(DateTime dateTime) {