design: New date separators in timeline

This commit is contained in:
Krille 2024-03-27 08:44:02 +01:00
commit f15b81c5a6
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652
6 changed files with 134 additions and 79 deletions

View file

@ -45,7 +45,7 @@ extension DateTimeExtension on DateTime {
/// Returns [localizedTimeOfDay()] if the ChatTime is today, the name of the week
/// day if the ChatTime is this week and a date string else.
String localizedTimeShort(BuildContext context) {
String localizedTimeShort(BuildContext context, {bool dateOnly = false}) {
final now = DateTime.now();
final sameYear = now.year == year;
@ -58,7 +58,7 @@ extension DateTimeExtension on DateTime {
1000 * 60 * 60 * 24 * 7;
if (sameDay) {
return localizedTimeOfDay(context);
return dateOnly ? L10n.of(context)!.today : localizedTimeOfDay(context);
} else if (sameWeek) {
return DateFormat.EEEE(Localizations.localeOf(context).languageCode)
.format(this);
@ -92,5 +92,9 @@ extension DateTimeExtension on DateTime {
);
}
bool isSameDate(DateTime other) {
return year == other.year && month == other.month && day == other.day;
}
static String _z(int i) => i < 10 ? '0${i.toString()}' : i.toString();
}