mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-26 02:21:39 +00:00

* feat: add inbox/unread/archived tabs * feat: dump notification info * chore: add reminder bloc * feat: support unread / archive notification tab * feat: support archive all & mark all as read * feat: add empty page * chore: optimize gesture * feat: add red dot above notification icon * chore: optimize code logic * feat: optimize tabbar animation * fix: notification align issue * fix: todo list icon align issue * feat: disable emoji button inside callout in read-only mode * feat: optimize icon size in editor * chore: improve text color in dark mode
43 lines
1.5 KiB
Dart
43 lines
1.5 KiB
Dart
import 'package:appflowy/generated/locale_keys.g.dart';
|
|
import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart';
|
|
import 'package:appflowy/workspace/application/settings/date_time/date_format_ext.dart';
|
|
import 'package:appflowy/workspace/application/settings/date_time/time_format_ext.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:time/time.dart';
|
|
|
|
String formatTimestampWithContext(
|
|
BuildContext context, {
|
|
required int timestamp,
|
|
String? prefix,
|
|
}) {
|
|
final now = DateTime.now();
|
|
final dateTime = DateTime.fromMillisecondsSinceEpoch(timestamp);
|
|
final difference = now.difference(dateTime);
|
|
final String date;
|
|
|
|
final dateFormate = context.read<AppearanceSettingsCubit>().state.dateFormat;
|
|
final timeFormate = context.read<AppearanceSettingsCubit>().state.timeFormat;
|
|
|
|
if (difference.inMinutes < 1) {
|
|
date = LocaleKeys.sideBar_justNow.tr();
|
|
} else if (difference.inHours < 1 && dateTime.isToday) {
|
|
// Less than 1 hour
|
|
date = LocaleKeys.sideBar_minutesAgo
|
|
.tr(namedArgs: {'count': difference.inMinutes.toString()});
|
|
} else if (difference.inHours >= 1 && dateTime.isToday) {
|
|
// in same day
|
|
date = timeFormate.formatTime(dateTime);
|
|
} else {
|
|
date = dateFormate.formatDate(dateTime, false);
|
|
}
|
|
|
|
if (difference.inHours >= 1 && prefix != null) {
|
|
return '$prefix $date';
|
|
}
|
|
|
|
return date;
|
|
}
|