feat: style of home and notification screen

This commit is contained in:
Rongjian Zhang
2019-01-26 22:10:18 +08:00
parent 2458c63a0c
commit 4e28608714
17 changed files with 389 additions and 366 deletions

25
lib/utils/timeago.dart Normal file
View File

@@ -0,0 +1,25 @@
import 'dart:core';
class TimeAgo {
static String _ceil(double n) => n.ceil().toString();
static String _pluralize(double time, String unit) {
if (time == 1) {
return '${_ceil(time)} $unit ago';
}
return '${_ceil(time)} ${unit}s ago';
}
static String format(DateTime time) {
double diff =
(DateTime.now().millisecondsSinceEpoch - time.millisecondsSinceEpoch) /
1000;
if (diff < 3600) {
return _pluralize(diff / 60, 'minute');
} else if (diff < 86400) {
return _pluralize(diff / 3600, 'hour');
} else {
return _pluralize(diff / 86400, 'day');
}
}
}