TF-801 Enable vacation responder setting

This commit is contained in:
dab246
2022-08-17 20:34:26 +07:00
committed by Dat H. Pham
parent f3e6d892d8
commit c4d78f732d
10 changed files with 666 additions and 418 deletions
@@ -5,18 +5,26 @@ extension DateTimeExtension on DateTime? {
String formatDate({String pattern = 'yyyy/MM/dd', String locale = 'en_US'}) {
if (this != null) {
return DateFormat(pattern, locale).format(this!.toLocal());
return DateFormat(pattern, locale).format(this!);
} else {
return '';
}
}
DateTime? applied(TimeOfDay? time) {
if (this != null && time != null) {
return DateTime.utc(this!.year, this!.month, this!.day, time.hour, time.minute);
}
return null;
}
}
extension TimeOfDayExtension on TimeOfDay? {
String formatTime(BuildContext context) {
if (this != null) {
return this!.format(context);
return MaterialLocalizations.of(context)
.formatTimeOfDay(this!, alwaysUse24HourFormat: true);
}
return '';
}
@@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
import 'package:jmap_dart_client/jmap/mail/vacation/vacation_response.dart';
import 'package:tmail_ui_user/features/manage_account/presentation/model/vacation/vacation_presentation.dart';
import 'package:tmail_ui_user/features/manage_account/presentation/model/vacation/vacation_responder_status.dart';
extension VacationResponseExtension on VacationResponse {
VacationPresentation toVacationPresentation() {
return VacationPresentation(
status: isEnabled == true
? VacationResponderStatus.activated
: VacationResponderStatus.deactivated,
startDate: fromDate?.value.toUtc(),
startTime: fromDate?.value != null
? TimeOfDay.fromDateTime(fromDate!.value.toUtc())
: null,
endDate: toDate?.value.toUtc(),
endTime: toDate?.value != null
? TimeOfDay.fromDateTime(toDate!.value.toUtc())
: null,
messageBody: textBody ?? htmlBody,
vacationStopEnabled: toDate != null
);
}
}