TF-801 Show notification message when vacation enabled
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_bindings.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/usecases/verify_name_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/repository/manage_account_repository.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/get_all_vacation_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/update_vacation_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/vacation/vacation_controller.dart';
|
||||
|
||||
class VacationBindings extends BaseBindings {
|
||||
|
||||
@override
|
||||
void bindingsController() {
|
||||
Get.lazyPut(() => VacationController(
|
||||
Get.find<GetAllVacationInteractor>(),
|
||||
Get.find<UpdateVacationInteractor>(),
|
||||
Get.find<VerifyNameInteractor>()));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSource() {
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSourceImpl() {
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsInteractor() {
|
||||
Get.lazyPut(() => GetAllVacationInteractor(Get.find<ManageAccountRepository>()));
|
||||
Get.lazyPut(() => UpdateVacationInteractor(Get.find<ManageAccountRepository>()));
|
||||
Get.lazyPut(() => VerifyNameInteractor());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepository() {
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepositoryImpl() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,266 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/vacation/vacation_response.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_controller.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/model/verification/empty_name_validator.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/state/verify_name_view_state.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/usecases/verify_name_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/presentation/extensions/validator_failure_extension.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/state/get_all_vacation_state.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/state/update_vacation_state.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/get_all_vacation_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/update_vacation_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/extensions/vacation_response_extension.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/manage_account_dashboard_controller.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/vacation/date_type.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';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
|
||||
class VacationController extends BaseController {
|
||||
|
||||
final _accountDashBoardController = Get.find<ManageAccountDashBoardController>();
|
||||
final _appToast = Get.find<AppToast>();
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
|
||||
final GetAllVacationInteractor _getAllVacationInteractor;
|
||||
final UpdateVacationInteractor _updateVacationInteractor;
|
||||
final VerifyNameInteractor _verifyNameInteractor;
|
||||
|
||||
final vacationPresentation = VacationPresentation.initialize().obs;
|
||||
final errorMessageBody = Rxn<String>();
|
||||
|
||||
final TextEditingController messageBodyEditorController = TextEditingController();
|
||||
|
||||
VacationController(
|
||||
this._getAllVacationInteractor,
|
||||
this._updateVacationInteractor,
|
||||
this._verifyNameInteractor
|
||||
);
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
_getAllVacation();
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onDone() {
|
||||
viewState.value.fold(
|
||||
(failure) => null,
|
||||
(success) {
|
||||
if (success is GetAllVacationSuccess) {
|
||||
_handleGetAllVacationSuccess(success);
|
||||
} else if (success is UpdateVacationSuccess) {
|
||||
_handleUpdateVacationSuccess(success);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void onError(error) {}
|
||||
|
||||
void _getAllVacation() {
|
||||
final accountId = _accountDashBoardController.accountId.value;
|
||||
if (accountId != null) {
|
||||
consumeState(_getAllVacationInteractor.execute(accountId));
|
||||
}
|
||||
}
|
||||
|
||||
void _handleGetAllVacationSuccess(GetAllVacationSuccess success) {
|
||||
if (success.listVacationResponse.isNotEmpty) {
|
||||
final currentVacation = success.listVacationResponse.first;
|
||||
log('VacationController::_handleGetAllVacationSuccess(): $currentVacation');
|
||||
|
||||
final newVacationPresentation = currentVacation.toVacationPresentation();
|
||||
vacationPresentation.value = newVacationPresentation;
|
||||
messageBodyEditorController.text = newVacationPresentation.messageBody ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
bool get isVacationDeactivated => !vacationPresentation.value.isEnabled;
|
||||
|
||||
bool get isVacationStopEnabled => vacationPresentation.value.vacationStopEnabled;
|
||||
|
||||
bool get canChangeEndDate => !isVacationDeactivated && isVacationStopEnabled;
|
||||
|
||||
void updateVacationPresentation({
|
||||
VacationResponderStatus? newStatus,
|
||||
DateTime? startDate,
|
||||
TimeOfDay? startTime,
|
||||
DateTime? endDate,
|
||||
TimeOfDay? endTime,
|
||||
bool? vacationStopEnabled,
|
||||
String? messageBody
|
||||
}) {
|
||||
final currentVacation = vacationPresentation.value;
|
||||
final newVacation = currentVacation.copyWidth(
|
||||
status: newStatus,
|
||||
startDate: startDate,
|
||||
startTime: startTime,
|
||||
endDate: endDate,
|
||||
endTime: endTime,
|
||||
vacationStopEnabled: vacationStopEnabled,
|
||||
messageBody: messageBody);
|
||||
log('VacationController::updateVacationPresentation():newVacation: $newVacation');
|
||||
vacationPresentation.value = newVacation;
|
||||
}
|
||||
|
||||
void selectDate(BuildContext context, DateType dateType, DateTime? currentDate) async {
|
||||
final datePicked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: currentDate ?? DateTime.now(),
|
||||
initialDatePickerMode: DatePickerMode.day,
|
||||
firstDate: DateTime(1900),
|
||||
lastDate: DateTime(2100),
|
||||
locale: Localizations.localeOf(context),
|
||||
builder: (context, child) {
|
||||
return Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
colorScheme: const ColorScheme.light(
|
||||
primary: AppColor.primaryColor,
|
||||
onPrimary: Colors.white,
|
||||
onSurface: Colors.black),
|
||||
textButtonTheme: TextButtonThemeData(
|
||||
style: TextButton.styleFrom(primary: AppColor.primaryColor))),
|
||||
child: child!);
|
||||
}
|
||||
);
|
||||
|
||||
if (datePicked == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (dateType == DateType.start) {
|
||||
updateVacationPresentation(startDate: datePicked);
|
||||
} else {
|
||||
updateVacationPresentation(endDate: datePicked);
|
||||
}
|
||||
}
|
||||
|
||||
void selectTime(BuildContext context, DateType dateType, TimeOfDay? currentTime) async {
|
||||
final timePicked = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: currentTime ?? TimeOfDay.now(),
|
||||
builder: (context, child) {
|
||||
return Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
colorScheme: const ColorScheme.light(
|
||||
primary: AppColor.primaryColor,
|
||||
onPrimary: Colors.white,
|
||||
onSurface: Colors.black),
|
||||
textButtonTheme: TextButtonThemeData(
|
||||
style: TextButton.styleFrom(primary: AppColor.primaryColor))),
|
||||
child: MediaQuery(
|
||||
data: const MediaQueryData(alwaysUse24HourFormat: true),
|
||||
child: child!),
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
if (timePicked == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (dateType == DateType.start) {
|
||||
updateVacationPresentation(startTime: timePicked);
|
||||
} else {
|
||||
updateVacationPresentation(endTime: timePicked);
|
||||
}
|
||||
}
|
||||
|
||||
String? _getErrorStringByInputValue(BuildContext context, String? inputValue) {
|
||||
return _verifyNameInteractor.execute(inputValue, [EmptyNameValidator()]).fold(
|
||||
(failure) {
|
||||
if (failure is VerifyNameFailure) {
|
||||
return failure.getMessageVacation(context);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
(success) => null
|
||||
);
|
||||
}
|
||||
|
||||
void updateMessageBody(BuildContext context, String? value) {
|
||||
errorMessageBody.value = _getErrorStringByInputValue(context, value);
|
||||
}
|
||||
|
||||
void saveVacation(BuildContext context) {
|
||||
FocusScope.of(context).unfocus();
|
||||
|
||||
if (vacationPresentation.value.isEnabled) {
|
||||
final fromDate = vacationPresentation.value.fromDate;
|
||||
if (fromDate == null) {
|
||||
_appToast.showToastWithIcon(
|
||||
context,
|
||||
bgColor: AppColor.toastErrorBackgroundColor,
|
||||
textColor: Colors.white,
|
||||
message: AppLocalizations.of(context).errorMessageWhenStartDateVacationIsEmpty);
|
||||
return;
|
||||
}
|
||||
|
||||
final vacationStopEnabled = vacationPresentation.value.vacationStopEnabled;
|
||||
final toDate = vacationPresentation.value.toDate;
|
||||
if (vacationStopEnabled && toDate != null && toDate.isBefore(fromDate)) {
|
||||
_appToast.showToastWithIcon(
|
||||
context,
|
||||
bgColor: AppColor.toastErrorBackgroundColor,
|
||||
textColor: Colors.white,
|
||||
message: AppLocalizations.of(context).errorMessageWhenEndDateVacationIsInValid);
|
||||
return;
|
||||
}
|
||||
|
||||
final messageBody = messageBodyEditorController.text;
|
||||
if (messageBody.isEmpty) {
|
||||
_appToast.showToastWithIcon(
|
||||
context,
|
||||
bgColor: AppColor.toastErrorBackgroundColor,
|
||||
textColor: Colors.white,
|
||||
message: AppLocalizations.of(context).errorMessageWhenMessageVacationIsEmpty);
|
||||
return;
|
||||
}
|
||||
|
||||
final newVacationPresentation = vacationPresentation.value.copyWidth(messageBody: messageBody);
|
||||
log('VacationController::saveVacation(): newVacationPresentation: $newVacationPresentation');
|
||||
final newVacationResponse = newVacationPresentation.toVacationResponse();
|
||||
log('VacationController::saveVacation(): newVacationResponse: $newVacationResponse');
|
||||
_updateVacationAction(newVacationResponse);
|
||||
}
|
||||
}
|
||||
|
||||
void _updateVacationAction(VacationResponse vacationResponse) {
|
||||
final accountId = _accountDashBoardController.accountId.value;
|
||||
if (accountId != null) {
|
||||
consumeState(_updateVacationInteractor.execute(accountId, vacationResponse));
|
||||
}
|
||||
}
|
||||
|
||||
void _handleUpdateVacationSuccess(UpdateVacationSuccess success) {
|
||||
if (success.listVacationResponse.isNotEmpty) {
|
||||
if (currentContext != null && currentOverlayContext != null) {
|
||||
_appToast.showToastWithIcon(
|
||||
currentOverlayContext!,
|
||||
message: AppLocalizations.of(currentContext!).vacationSettingSaved,
|
||||
icon: _imagePaths.icChecked);
|
||||
}
|
||||
final currentVacation = success.listVacationResponse.first;
|
||||
log('VacationController::_handleUpdateVacationSuccess(): $currentVacation');
|
||||
|
||||
final newVacationPresentation = currentVacation.toVacationPresentation();
|
||||
vacationPresentation.value = newVacationPresentation;
|
||||
messageBodyEditorController.text = newVacationPresentation.messageBody ?? '';
|
||||
|
||||
_accountDashBoardController.updateVacationResponse(currentVacation);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
messageBodyEditorController.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,501 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/base/widget/border_button_field.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/vacation/vacation_controller.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/vacation/widgets/vacation_input_decoration_builder.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/vacation/date_type.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/vacation/vacation_responder_status.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
class VacationView extends GetWidget<VacationController> {
|
||||
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
|
||||
VacationView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: _responsiveUtils.isWebDesktop(context)
|
||||
? AppColor.colorBgDesktop
|
||||
: Colors.white,
|
||||
body: GestureDetector(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
margin: _responsiveUtils.isWebDesktop(context)
|
||||
? const EdgeInsets.all(24)
|
||||
: EdgeInsets.zero,
|
||||
decoration: _responsiveUtils.isWebDesktop(context)
|
||||
? BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(color: AppColor.colorBorderBodyThread, width: 1),
|
||||
color: Colors.white)
|
||||
: null,
|
||||
padding: _getPaddingView(context),
|
||||
child: ResponsiveWidget(
|
||||
responsiveUtils: _responsiveUtils,
|
||||
desktop: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(children: [
|
||||
Container(
|
||||
width: 200,
|
||||
color: Colors.white,
|
||||
child: Text(
|
||||
AppLocalizations.of(context).vacationResponder,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black))),
|
||||
const SizedBox(width: 16),
|
||||
Obx(() {
|
||||
return Row(
|
||||
children: [
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
controller.updateVacationPresentation(newStatus: VacationResponderStatus.deactivated);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context).deactivated,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
controller.isVacationDeactivated ? 1.0 : 0.3))),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 3, right: 16, left: 16),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
final newStatus = controller.isVacationDeactivated
|
||||
? VacationResponderStatus.activated
|
||||
: VacationResponderStatus.deactivated;
|
||||
controller.updateVacationPresentation(newStatus: newStatus);
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
controller.isVacationDeactivated
|
||||
? _imagePaths.icSwitchOff
|
||||
: _imagePaths.icSwitchOn,
|
||||
fit: BoxFit.fill,
|
||||
width: 24,
|
||||
height: 24)),
|
||||
),
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
controller.updateVacationPresentation(newStatus: VacationResponderStatus.activated);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context).activated,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
controller.isVacationDeactivated ? 0.3 : 1.0))),
|
||||
),
|
||||
)
|
||||
]);
|
||||
})
|
||||
]),
|
||||
const SizedBox(height: 16),
|
||||
Obx(() => AbsorbPointer(
|
||||
absorbing: controller.isVacationDeactivated,
|
||||
child: Row(children: [
|
||||
Container(
|
||||
width: 200,
|
||||
color: Colors.white,
|
||||
child: Text(
|
||||
AppLocalizations.of(context).startDate,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
controller.isVacationDeactivated ? 0.5 : 1.0)))),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: Obx(() => BorderButtonField<DateTime>(
|
||||
value: controller.vacationPresentation.value.startDate,
|
||||
mouseCursor: SystemMouseCursors.text,
|
||||
isEmpty: !controller.isVacationDeactivated &&
|
||||
controller.vacationPresentation.value.startDateIsNull,
|
||||
textStyle: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
controller.isVacationDeactivated ? 0.5 : 1.0)),
|
||||
hintText: AppLocalizations.of(context).startDate,
|
||||
icon: SvgPicture.asset(_imagePaths.icCalendar),
|
||||
tapActionCallback: (value) =>
|
||||
controller.selectDate(context, DateType.start, value)))),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: Obx(() => BorderButtonField<TimeOfDay>(
|
||||
value: controller.vacationPresentation.value.startTime,
|
||||
mouseCursor: SystemMouseCursors.text,
|
||||
isEmpty: !controller.isVacationDeactivated &&
|
||||
controller.vacationPresentation.value.starTimeIsNull,
|
||||
textStyle: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
controller.isVacationDeactivated ? 0.5 : 1.0)),
|
||||
hintText: AppLocalizations.of(context).noStartTime,
|
||||
icon: SvgPicture.asset(_imagePaths.icClock),
|
||||
tapActionCallback: (value) =>
|
||||
controller.selectTime(context, DateType.start, value)))),
|
||||
]),
|
||||
)),
|
||||
const SizedBox(height: 16),
|
||||
Obx(() => AbsorbPointer(
|
||||
absorbing: controller.isVacationDeactivated,
|
||||
child: Container(
|
||||
width: 200,
|
||||
color: Colors.white,
|
||||
child: CheckboxListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
activeColor: AppColor.primaryColor.withOpacity(
|
||||
controller.isVacationDeactivated ? 0.5 : 1.0),
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
value: controller.vacationPresentation.value.vacationStopEnabled,
|
||||
onChanged: (value) =>
|
||||
controller.updateVacationPresentation(vacationStopEnabled: value),
|
||||
title: Text(AppLocalizations.of(context).vacationStopsAt,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
controller.isVacationDeactivated ? 0.5 : 1.0))),
|
||||
),
|
||||
),
|
||||
)),
|
||||
Obx(() => AbsorbPointer(
|
||||
absorbing: !controller.canChangeEndDate,
|
||||
child: Row(children: [
|
||||
Container(
|
||||
width: 200,
|
||||
color: Colors.white,
|
||||
child: Text(
|
||||
AppLocalizations.of(context).endDate,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
!controller.canChangeEndDate ? 0.5 : 1.0)))),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: Obx(() => BorderButtonField<DateTime>(
|
||||
value: controller.vacationPresentation.value.endDate,
|
||||
mouseCursor: SystemMouseCursors.text,
|
||||
isEmpty: controller.canChangeEndDate &&
|
||||
controller.vacationPresentation.value.endDateIsNull,
|
||||
textStyle: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
!controller.canChangeEndDate ? 0.5 : 1.0)),
|
||||
hintText: AppLocalizations.of(context).noEndDate,
|
||||
icon: SvgPicture.asset(_imagePaths.icCalendar),
|
||||
tapActionCallback: (value) =>
|
||||
controller.selectDate(context, DateType.end, value)))),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: Obx(() => BorderButtonField<TimeOfDay>(
|
||||
value: controller.vacationPresentation.value.endTime,
|
||||
mouseCursor: SystemMouseCursors.text,
|
||||
isEmpty: controller.canChangeEndDate &&
|
||||
controller.vacationPresentation.value.endTimeIsNull,
|
||||
textStyle: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
!controller.canChangeEndDate ? 0.5 : 1.0)),
|
||||
hintText: AppLocalizations.of(context).noEndTime,
|
||||
icon: SvgPicture.asset(_imagePaths.icClock),
|
||||
tapActionCallback: (value) =>
|
||||
controller.selectTime(context, DateType.end, value)))),
|
||||
])
|
||||
)),
|
||||
const SizedBox(height: 16),
|
||||
Obx(() => AbsorbPointer(
|
||||
absorbing: controller.isVacationDeactivated,
|
||||
child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Container(
|
||||
width: 200,
|
||||
color: Colors.white,
|
||||
child: Text(
|
||||
AppLocalizations.of(context).messageBody,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
controller.isVacationDeactivated ? 0.5 : 1.0)))),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: _buildMessageBodyWidget(
|
||||
context,
|
||||
controller.isVacationDeactivated ? 0.5 : 1.0))
|
||||
]),
|
||||
)),
|
||||
const SizedBox(height: 16),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: buildTextButton(
|
||||
AppLocalizations.of(context).save,
|
||||
width: 128,
|
||||
height: 44,
|
||||
radius: 10,
|
||||
onTap: () => controller.saveVacation(context)),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
mobile: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).vacationResponder,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black)),
|
||||
const SizedBox(height: 10),
|
||||
Obx(() {
|
||||
return Row(
|
||||
children: [
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
controller.updateVacationPresentation(newStatus: VacationResponderStatus.deactivated);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context).deactivated,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
controller.isVacationDeactivated ? 1.0 : 0.3))),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 3, right: 16, left: 16),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
final newStatus = controller.isVacationDeactivated
|
||||
? VacationResponderStatus.activated
|
||||
: VacationResponderStatus.deactivated;
|
||||
controller.updateVacationPresentation(newStatus: newStatus);
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
controller.isVacationDeactivated
|
||||
? _imagePaths.icSwitchOff
|
||||
: _imagePaths.icSwitchOn,
|
||||
fit: BoxFit.fill,
|
||||
width: 24,
|
||||
height: 24)),
|
||||
),
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
controller.updateVacationPresentation(newStatus: VacationResponderStatus.activated);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context).activated,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
controller.isVacationDeactivated ? 0.3 : 1.0))),
|
||||
),
|
||||
)
|
||||
]);
|
||||
})
|
||||
]),
|
||||
const SizedBox(height: 16),
|
||||
Obx(() => AbsorbPointer(
|
||||
absorbing: controller.isVacationDeactivated,
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).startDate,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
controller.isVacationDeactivated ? 0.5 : 1.0))),
|
||||
const SizedBox(height: 16),
|
||||
Row(children: [
|
||||
Expanded(child: Obx(() => BorderButtonField<DateTime>(
|
||||
value: controller.vacationPresentation.value.startDate,
|
||||
mouseCursor: SystemMouseCursors.text,
|
||||
textStyle: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
controller.isVacationDeactivated ? 0.5 : 1.0)),
|
||||
hintText: AppLocalizations.of(context).startDate,
|
||||
icon: SvgPicture.asset(_imagePaths.icCalendar),
|
||||
tapActionCallback: (value) =>
|
||||
controller.selectDate(context, DateType.start, value)))),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: Obx(() => BorderButtonField<TimeOfDay>(
|
||||
value: controller.vacationPresentation.value.startTime,
|
||||
mouseCursor: SystemMouseCursors.text,
|
||||
textStyle: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
controller.isVacationDeactivated ? 0.5 : 1.0)),
|
||||
hintText: AppLocalizations.of(context).noStartTime,
|
||||
icon: SvgPicture.asset(_imagePaths.icClock),
|
||||
tapActionCallback: (value) =>
|
||||
controller.selectTime(context, DateType.start, value))))
|
||||
]),
|
||||
]),
|
||||
)),
|
||||
const SizedBox(height: 16),
|
||||
Obx(() => AbsorbPointer(
|
||||
absorbing: controller.isVacationDeactivated,
|
||||
child: CheckboxListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
activeColor: AppColor.primaryColor.withOpacity(
|
||||
controller.isVacationDeactivated ? 0.5 : 1.0),
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
value: controller.vacationPresentation.value.vacationStopEnabled,
|
||||
onChanged: (value) =>
|
||||
controller.updateVacationPresentation(vacationStopEnabled: value),
|
||||
title: Text(AppLocalizations.of(context).vacationStopsAt,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
controller.isVacationDeactivated ? 0.5 : 1.0))),
|
||||
),
|
||||
)),
|
||||
Obx(() => AbsorbPointer(
|
||||
absorbing: !controller.canChangeEndDate,
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).endDate,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
!controller.canChangeEndDate ? 0.5 : 1.0))),
|
||||
const SizedBox(height: 16),
|
||||
Row(children: [
|
||||
Expanded(child: Obx(() => BorderButtonField<DateTime>(
|
||||
value: controller.vacationPresentation.value.endDate,
|
||||
mouseCursor: SystemMouseCursors.text,
|
||||
textStyle: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
!controller.canChangeEndDate ? 0.5 : 1.0)),
|
||||
hintText: AppLocalizations.of(context).noEndDate,
|
||||
icon: SvgPicture.asset(_imagePaths.icCalendar),
|
||||
tapActionCallback: (value) =>
|
||||
controller.selectDate(context, DateType.end, value)))),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: Obx(() => BorderButtonField<TimeOfDay>(
|
||||
value: controller.vacationPresentation.value.endTime,
|
||||
mouseCursor: SystemMouseCursors.text,
|
||||
textStyle: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
!controller.canChangeEndDate ? 0.5 : 1.0)),
|
||||
hintText: AppLocalizations.of(context).noEndTime,
|
||||
icon: SvgPicture.asset(_imagePaths.icClock),
|
||||
tapActionCallback: (value) =>
|
||||
controller.selectTime(context, DateType.end, value))))
|
||||
]),
|
||||
])
|
||||
)),
|
||||
const SizedBox(height: 16),
|
||||
Obx(() => AbsorbPointer(
|
||||
absorbing: controller.isVacationDeactivated,
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).messageBody,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(
|
||||
controller.isVacationDeactivated ? 0.5 : 1.0))),
|
||||
const SizedBox(height: 16),
|
||||
_buildMessageBodyWidget(
|
||||
context,
|
||||
controller.isVacationDeactivated ? 0.5 : 1.0)
|
||||
]),
|
||||
)),
|
||||
const SizedBox(height: 16),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: buildTextButton(
|
||||
AppLocalizations.of(context).save,
|
||||
width: 128,
|
||||
height: 44,
|
||||
radius: 10,
|
||||
onTap: () => controller.saveVacation(context)),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMessageBodyWidget(BuildContext context, double opacity) {
|
||||
return Obx(() {
|
||||
return (TextFieldBuilder()
|
||||
..key(const Key('message_body_editor'))
|
||||
..cursorColor(Colors.black)
|
||||
..addController(controller.messageBodyEditorController)
|
||||
..textStyle(TextStyle(
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black.withOpacity(opacity),
|
||||
fontSize: 16))
|
||||
..textDecoration((VacationInputDecorationBuilder()
|
||||
..setContentPadding(const EdgeInsets.symmetric(
|
||||
vertical: BuildUtils.isWeb ? 16 : 12,
|
||||
horizontal: 12))
|
||||
..setHintStyle(TextStyle(
|
||||
color: AppColor.colorHintInputCreateMailbox.withOpacity(opacity),
|
||||
fontSize: 16))
|
||||
..setErrorText(controller.isVacationDeactivated
|
||||
? null
|
||||
: controller.errorMessageBody.value)
|
||||
..setHintText(AppLocalizations
|
||||
.of(context)
|
||||
.hintMessageBodyVacation))
|
||||
.build())
|
||||
..onChange((value) => controller.updateMessageBody(context, value))
|
||||
..minLines(10)
|
||||
..maxLines(null))
|
||||
.build();
|
||||
});
|
||||
}
|
||||
|
||||
EdgeInsets _getPaddingView(BuildContext context) {
|
||||
if (BuildUtils.isWeb) {
|
||||
if (_responsiveUtils.isDesktop(context)) {
|
||||
return const EdgeInsets.all(16);
|
||||
} else {
|
||||
return const EdgeInsets.only(top: 16, bottom: 16, left: 0, right: 24);
|
||||
}
|
||||
} else {
|
||||
if (_responsiveUtils.isPortraitMobile(context)) {
|
||||
return const EdgeInsets.only(top: 16, bottom: 16, left: 16, right: 24);
|
||||
} else {
|
||||
return const EdgeInsets.only(top: 16, bottom: 16, left: 0, right: 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class VacationInputDecorationBuilder extends InputDecorationBuilder {
|
||||
|
||||
@override
|
||||
InputDecoration build() {
|
||||
return InputDecoration(
|
||||
enabledBorder: enabledBorder ?? const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
borderSide: BorderSide(width: 1, color: AppColor.colorInputBorderCreateMailbox)),
|
||||
focusedBorder: enabledBorder ?? const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
borderSide: BorderSide(width: 1, color: AppColor.colorTextButton)),
|
||||
errorBorder: errorBorder ?? const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
borderSide: BorderSide(width: 1, color: AppColor.colorInputBorderErrorVerifyName)),
|
||||
focusedErrorBorder: errorBorder ?? const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
borderSide: BorderSide(width: 1, color: AppColor.colorInputBorderErrorVerifyName)),
|
||||
prefixText: prefixText,
|
||||
labelText: labelText,
|
||||
floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||
labelStyle: labelStyle ?? const TextStyle(color: Colors.black, fontSize: 16),
|
||||
hintText: hintText,
|
||||
isDense: true,
|
||||
hintStyle: hintStyle ?? const TextStyle(color: AppColor.colorHintInputCreateMailbox, fontSize: 16),
|
||||
contentPadding: contentPadding ?? const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
|
||||
errorText: errorText,
|
||||
errorStyle: errorTextStyle ?? const TextStyle(color: AppColor.colorInputBorderErrorVerifyName, fontSize: 13),
|
||||
filled: true,
|
||||
fillColor: errorText?.isNotEmpty == true
|
||||
? AppColor.colorInputBackgroundErrorVerifyName
|
||||
: Colors.white);
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/vacation/vacation_response.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
typedef DisableVacationResponderAction = Function();
|
||||
|
||||
class VacationNotificationMessageWidget extends StatelessWidget {
|
||||
|
||||
final VacationResponse vacationResponse;
|
||||
final DisableVacationResponderAction? action;
|
||||
final EdgeInsets? margin;
|
||||
final EdgeInsets? padding;
|
||||
final double? radius;
|
||||
|
||||
const VacationNotificationMessageWidget({
|
||||
super.key,
|
||||
required this.vacationResponse,
|
||||
this.action,
|
||||
this.radius,
|
||||
this.margin,
|
||||
this.padding,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
margin: margin ?? const EdgeInsets.symmetric(horizontal: 16),
|
||||
padding: padding ?? const EdgeInsets.only(top: 5, bottom: 5, left: 16),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(radius ?? 5),
|
||||
color: AppColor.colorVacationNotificationMessageBackground,
|
||||
),
|
||||
child: Row(children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).yourVacationResponderIsEnabled,
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
))),
|
||||
buildTextButton(
|
||||
AppLocalizations.of(context).disable.allInCaps,
|
||||
textStyle: const TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 16,
|
||||
color: AppColor.colorTextButton),
|
||||
backgroundColor: Colors.transparent,
|
||||
width: 128,
|
||||
height: 44,
|
||||
radius: 10,
|
||||
onTap: () => action?.call())
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user