mirror of
https://github.com/BlueBubblesApp/bluebubbles-app.git
synced 2025-08-06 11:19:56 +08:00
Improve material convo list dates
This commit is contained in:
@ -209,7 +209,7 @@ class _MaterialTrailingState extends CustomState<MaterialTrailing, void, Convers
|
||||
return Text(
|
||||
(cachedLatestMessage?.error ?? 0) > 0
|
||||
? "Error"
|
||||
: "${indicatorText.isNotEmpty ? "$indicatorText\n" : ""}${buildDate(dateCreated)}",
|
||||
: "${indicatorText.isNotEmpty ? "$indicatorText\n" : ""}${buildChatListDateMaterial(dateCreated)}",
|
||||
textAlign: TextAlign.right,
|
||||
style: context.theme.textTheme.bodySmall!.copyWith(
|
||||
color: (cachedLatestMessage?.error ?? 0) > 0
|
||||
|
@ -34,6 +34,30 @@ String buildDate(DateTime? dateTime) {
|
||||
return date;
|
||||
}
|
||||
|
||||
String buildChatListDateMaterial(DateTime? dateTime) {
|
||||
if (dateTime == null || dateTime.millisecondsSinceEpoch == 0) return "";
|
||||
String time = ss.settings.use24HrFormat.value
|
||||
? DateFormat.Hm().format(dateTime)
|
||||
: DateFormat.jm().format(dateTime);
|
||||
String date;
|
||||
if (DateTime.now().difference(dateTime.toLocal()).inMinutes < 1) {
|
||||
date = "Just Now";
|
||||
} else if (DateTime.now().difference(dateTime.toLocal()).inHours < 1) {
|
||||
date = "${DateTime.now().difference(dateTime.toLocal()).inMinutes} min";
|
||||
}else if (DateTime.now().difference(dateTime.toLocal()).inDays <= 7) {
|
||||
date = DateFormat("EEE").format(dateTime);
|
||||
} else if (ss.settings.skin.value == Skins.Material && DateTime.now().difference(dateTime.toLocal()).inDays <= 365) {
|
||||
date = DateFormat.MMMd().format(dateTime);
|
||||
} else if (ss.settings.skin.value == Skins.Samsung && DateTime.now().year == dateTime.toLocal().year) {
|
||||
date = DateFormat.MMMd().format(dateTime);
|
||||
} else if (ss.settings.skin.value == Skins.Samsung && DateTime.now().year != dateTime.toLocal().year) {
|
||||
date = DateFormat.yMMMd().format(dateTime);
|
||||
} else {
|
||||
date = DateFormat.yMd().format(dateTime);
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
String buildSeparatorDateMaterial(DateTime dateTime) {
|
||||
return DateFormat.MMMEd().format(dateTime);
|
||||
}
|
||||
|
Reference in New Issue
Block a user