浏览代码

Show simpler strings for certain days

Vishnu Mohandas 4 年之前
父节点
当前提交
c83bca34c3
共有 1 个文件被更改,包括 9 次插入1 次删除
  1. 9 1
      lib/ui/gallery.dart

+ 9 - 1
lib/ui/gallery.dart

@@ -242,8 +242,16 @@ class _GalleryState extends State<Gallery> {
   }
 
   Widget _getDay(int timestamp) {
-    var date = DateTime.fromMicrosecondsSinceEpoch(timestamp);
+    final date = DateTime.fromMicrosecondsSinceEpoch(timestamp);
+    final now = DateTime.now();
     var title = getDayAndMonth(date);
+    if (date.year == now.year && date.month == now.month) {
+      if (date.day == now.day) {
+        title = "Today";
+      } else if (date.day == now.day - 1) {
+        title = "Yesterday";
+      }
+    }
     if (date.year != DateTime.now().year) {
       title += " " + date.year.toString();
     }