b3ce1f076c
TF-3881 Thread Detail Unsubscribe context menu TF-3881 Thread Detail Update date time format TF-3881 Thread Detail Update sender receiver spacing TF-3881 Thread Detail Add messageId and references to presentation email TF-3881 Thread Detail Filter created email on refresh TF-3881 Thread Detail Fix CI TF-3881 Thread Detail Fix previous action throws out of index TF-3881 Thread Detail Update sender receiver spacing TF-3881 Thread Detail Adjust email actions when expanded TF-3881 Thread Detail Adjust days ago received time TF-3881 Thread Detail Fix debouncer when update setting TF-3881 Thread Detail Adjust days ago received time TF-3881 Thread Detail Adjust email actions when expanded TF-3881 Thread Detail Hide next previous if not in range TF-3881 Thread Detail Arrange more action according to text direction TF-3881 Thread Detail Hide next previous if not in range TF-3881 Thread Detail Fix move email on tablet
60 lines
2.0 KiB
Dart
60 lines
2.0 KiB
Dart
|
|
import 'package:core/domain/extensions/datetime_extension.dart';
|
|
import 'package:core/presentation/extensions/color_extension.dart';
|
|
import 'package:core/presentation/utils/style_utils.dart';
|
|
import 'package:core/presentation/utils/theme_utils.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:jmap_dart_client/jmap/core/utc_date.dart';
|
|
import 'package:model/email/presentation_email.dart';
|
|
import 'package:model/extensions/presentation_email_extension.dart';
|
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
|
|
|
class ReceivedTimeBuilder extends StatelessWidget {
|
|
|
|
final PresentationEmail emailSelected;
|
|
final EdgeInsetsGeometry? padding;
|
|
final bool showDaysAgo;
|
|
|
|
const ReceivedTimeBuilder({
|
|
Key? key,
|
|
required this.emailSelected,
|
|
this.padding,
|
|
this.showDaysAgo = false,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final appLocalizations = AppLocalizations.of(context);
|
|
final daysPast = getDaysPast(emailSelected.receivedAt, appLocalizations);
|
|
|
|
return Padding(
|
|
padding: padding ?? const EdgeInsetsDirectional.only(start: 16),
|
|
child: Text(
|
|
emailSelected.getReceivedAt(
|
|
Localizations.localeOf(context).toLanguageTag(),
|
|
pattern: emailSelected.receivedAt?.value.toLocal().toPatternForEmailView()
|
|
).toLowerCase() + daysPast,
|
|
maxLines: 1,
|
|
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
softWrap: CommonTextStyle.defaultSoftWrap,
|
|
style: ThemeUtils.textStyleBodyBody3(color: AppColor.steelGray400).copyWith(
|
|
height: 1,
|
|
letterSpacing: -0.14
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
String getDaysPast(UTCDate? utcDate, AppLocalizations appLocalizations) {
|
|
if (!showDaysAgo || utcDate == null) return '';
|
|
|
|
final from = utcDate.value;
|
|
final to = DateTime.now();
|
|
if (from.isAfter(to)) return '';
|
|
|
|
final days = to.difference(from).inDays;
|
|
if (days >=7) return '';
|
|
|
|
return appLocalizations.daysAgo(days);
|
|
}
|
|
} |