TF-801 Enable vacation responder setting
This commit is contained in:
@@ -17,6 +17,7 @@ class BorderButtonField<T> extends StatelessWidget {
|
|||||||
final TextStyle? textStyle;
|
final TextStyle? textStyle;
|
||||||
final MouseCursor? mouseCursor;
|
final MouseCursor? mouseCursor;
|
||||||
final String? hintText;
|
final String? hintText;
|
||||||
|
final bool isEmpty;
|
||||||
|
|
||||||
const BorderButtonField({
|
const BorderButtonField({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -26,6 +27,7 @@ class BorderButtonField<T> extends StatelessWidget {
|
|||||||
this.textStyle,
|
this.textStyle,
|
||||||
this.mouseCursor,
|
this.mouseCursor,
|
||||||
this.hintText,
|
this.hintText,
|
||||||
|
this.isEmpty = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -40,7 +42,7 @@ class BorderButtonField<T> extends StatelessWidget {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: AppColor.colorInputBorderCreateMailbox,
|
color: _getBorderColor(),
|
||||||
width: 1),
|
width: 1),
|
||||||
color: Colors.white),
|
color: Colors.white),
|
||||||
padding: const EdgeInsets.only(left: 12, right: 10),
|
padding: const EdgeInsets.only(left: 12, right: 10),
|
||||||
@@ -80,4 +82,11 @@ class BorderButtonField<T> extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
return hintText ?? '';
|
return hintText ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color _getBorderColor() {
|
||||||
|
if (!isEmpty) {
|
||||||
|
return AppColor.colorInputBorderCreateMailbox;
|
||||||
|
}
|
||||||
|
return AppColor.colorInputBorderErrorVerifyName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -42,4 +42,12 @@ extension ValicatorFailureExtension on VerifyNameFailure {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getMessageVacation(BuildContext context) {
|
||||||
|
if (exception is EmptyNameException) {
|
||||||
|
return AppLocalizations.of(context).this_field_cannot_be_blank;
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+8
-1
@@ -1,14 +1,19 @@
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:tmail_ui_user/features/base/base_bindings.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/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/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/configuration/vacation/vacation_controller.dart';
|
import 'package:tmail_ui_user/features/manage_account/presentation/configuration/vacation/vacation_controller.dart';
|
||||||
|
|
||||||
class VacationBindings extends BaseBindings {
|
class VacationBindings extends BaseBindings {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void bindingsController() {
|
void bindingsController() {
|
||||||
Get.lazyPut(() => VacationController(Get.find<GetAllVacationInteractor>()));
|
Get.lazyPut(() => VacationController(
|
||||||
|
Get.find<GetAllVacationInteractor>(),
|
||||||
|
Get.find<UpdateVacationInteractor>(),
|
||||||
|
Get.find<VerifyNameInteractor>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -22,6 +27,8 @@ class VacationBindings extends BaseBindings {
|
|||||||
@override
|
@override
|
||||||
void bindingsInteractor() {
|
void bindingsInteractor() {
|
||||||
Get.lazyPut(() => GetAllVacationInteractor(Get.find<ManageAccountRepository>()));
|
Get.lazyPut(() => GetAllVacationInteractor(Get.find<ManageAccountRepository>()));
|
||||||
|
Get.lazyPut(() => UpdateVacationInteractor(Get.find<ManageAccountRepository>()));
|
||||||
|
Get.lazyPut(() => VerifyNameInteractor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
+118
-36
@@ -1,28 +1,44 @@
|
|||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/core.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/vacation/vacation_response.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/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/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/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/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/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_presentation.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/vacation/vacation_responder_status.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 {
|
class VacationController extends BaseController {
|
||||||
|
|
||||||
final _accountDashBoardController = Get.find<ManageAccountDashBoardController>();
|
final _accountDashBoardController = Get.find<ManageAccountDashBoardController>();
|
||||||
|
final _appToast = Get.find<AppToast>();
|
||||||
|
final _imagePaths = Get.find<ImagePaths>();
|
||||||
|
|
||||||
final GetAllVacationInteractor _getAllVacationInteractor;
|
final GetAllVacationInteractor _getAllVacationInteractor;
|
||||||
|
final UpdateVacationInteractor _updateVacationInteractor;
|
||||||
|
final VerifyNameInteractor _verifyNameInteractor;
|
||||||
|
|
||||||
final vacationPresentation = VacationPresentation.initialize().obs;
|
final vacationPresentation = VacationPresentation.initialize().obs;
|
||||||
|
final errorMessageBody = Rxn<String>();
|
||||||
|
|
||||||
final TextEditingController messageBodyEditorController = TextEditingController();
|
final TextEditingController messageBodyEditorController = TextEditingController();
|
||||||
|
|
||||||
VacationResponse? currentVacation;
|
VacationController(
|
||||||
|
this._getAllVacationInteractor,
|
||||||
VacationController(this._getAllVacationInteractor);
|
this._updateVacationInteractor,
|
||||||
|
this._verifyNameInteractor
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
@@ -37,6 +53,8 @@ class VacationController extends BaseController {
|
|||||||
(success) {
|
(success) {
|
||||||
if (success is GetAllVacationSuccess) {
|
if (success is GetAllVacationSuccess) {
|
||||||
_handleGetAllVacationSuccess(success);
|
_handleGetAllVacationSuccess(success);
|
||||||
|
} else if (success is UpdateVacationSuccess) {
|
||||||
|
_handleUpdateVacationSuccess(success);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -53,41 +71,17 @@ class VacationController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handleGetAllVacationSuccess(GetAllVacationSuccess success) {
|
void _handleGetAllVacationSuccess(GetAllVacationSuccess success) {
|
||||||
if (success.listVacationResponse?.isNotEmpty == true) {
|
if (success.listVacationResponse.isNotEmpty) {
|
||||||
currentVacation = success.listVacationResponse!.first;
|
final currentVacation = success.listVacationResponse.first;
|
||||||
log('VacationController::_handleGetAllVacationSuccess(): $currentVacation');
|
log('VacationController::_handleGetAllVacationSuccess(): $currentVacation');
|
||||||
|
|
||||||
final vacationStatus = currentVacation?.isEnabled;
|
final newVacationPresentation = currentVacation.toVacationPresentation();
|
||||||
final startDate = currentVacation?.fromDate?.value;
|
vacationPresentation.value = newVacationPresentation;
|
||||||
final endDate = currentVacation?.toDate?.value;
|
messageBodyEditorController.text = newVacationPresentation.messageBody ?? '';
|
||||||
final messageBody = currentVacation?.htmlBody ?? currentVacation?.textBody;
|
|
||||||
final startTime = startDate != null
|
|
||||||
? TimeOfDay.fromDateTime(startDate)
|
|
||||||
: null;
|
|
||||||
final endTime = endDate != null
|
|
||||||
? TimeOfDay.fromDateTime(endDate)
|
|
||||||
: null;
|
|
||||||
final vacationStopEnabled = endDate != null;
|
|
||||||
|
|
||||||
if (messageBody != null) {
|
|
||||||
messageBodyEditorController.text = messageBody;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateVacationPresentation(
|
|
||||||
newStatus: vacationStatus == true
|
|
||||||
? VacationResponderStatus.activated
|
|
||||||
: VacationResponderStatus.deactivated,
|
|
||||||
startDate: startDate,
|
|
||||||
startTime: startTime,
|
|
||||||
endDate: endDate,
|
|
||||||
endTime: endTime,
|
|
||||||
vacationStopEnabled: vacationStopEnabled,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get isVacationDeactivated =>
|
bool get isVacationDeactivated => !vacationPresentation.value.isEnabled;
|
||||||
vacationPresentation.value.status == VacationResponderStatus.deactivated;
|
|
||||||
|
|
||||||
bool get isVacationStopEnabled => vacationPresentation.value.vacationStopEnabled;
|
bool get isVacationStopEnabled => vacationPresentation.value.vacationStopEnabled;
|
||||||
|
|
||||||
@@ -100,6 +94,7 @@ class VacationController extends BaseController {
|
|||||||
DateTime? endDate,
|
DateTime? endDate,
|
||||||
TimeOfDay? endTime,
|
TimeOfDay? endTime,
|
||||||
bool? vacationStopEnabled,
|
bool? vacationStopEnabled,
|
||||||
|
String? messageBody
|
||||||
}) {
|
}) {
|
||||||
final currentVacation = vacationPresentation.value;
|
final currentVacation = vacationPresentation.value;
|
||||||
final newVacation = currentVacation.copyWidth(
|
final newVacation = currentVacation.copyWidth(
|
||||||
@@ -108,7 +103,9 @@ class VacationController extends BaseController {
|
|||||||
startTime: startTime,
|
startTime: startTime,
|
||||||
endDate: endDate,
|
endDate: endDate,
|
||||||
endTime: endTime,
|
endTime: endTime,
|
||||||
vacationStopEnabled: vacationStopEnabled);
|
vacationStopEnabled: vacationStopEnabled,
|
||||||
|
messageBody: messageBody);
|
||||||
|
log('VacationController::updateVacationPresentation():newVacation: $newVacation');
|
||||||
vacationPresentation.value = newVacation;
|
vacationPresentation.value = newVacation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,6 +134,11 @@ class VacationController extends BaseController {
|
|||||||
final timePicked = await showTimePicker(
|
final timePicked = await showTimePicker(
|
||||||
context: context,
|
context: context,
|
||||||
initialTime: currentTime ?? TimeOfDay.now(),
|
initialTime: currentTime ?? TimeOfDay.now(),
|
||||||
|
builder: (context, child) {
|
||||||
|
return MediaQuery(
|
||||||
|
data: const MediaQueryData(alwaysUse24HourFormat: true),
|
||||||
|
child: child!);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (timePicked == null) {
|
if (timePicked == null) {
|
||||||
@@ -150,8 +152,88 @@ class VacationController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveVacation(BuildContext context) {
|
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 ?? '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
+392
-376
@@ -20,349 +20,144 @@ class VacationView extends GetWidget<VacationController> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
body: Container(
|
body: GestureDetector(
|
||||||
width: double.infinity,
|
onTap: () => FocusScope.of(context).unfocus(),
|
||||||
color: Colors.white,
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16),
|
width: double.infinity,
|
||||||
child: ResponsiveWidget(
|
color: Colors.white,
|
||||||
responsiveUtils: _responsiveUtils,
|
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16),
|
||||||
desktop: SingleChildScrollView(
|
child: ResponsiveWidget(
|
||||||
child: Column(
|
responsiveUtils: _responsiveUtils,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
desktop: SingleChildScrollView(
|
||||||
children: [
|
child: Column(
|
||||||
Row(children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Container(
|
children: [
|
||||||
width: 200,
|
Row(children: [
|
||||||
color: Colors.white,
|
|
||||||
child: Text(
|
|
||||||
AppLocalizations.of(context).vacationResponder,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
fontWeight: FontWeight.normal,
|
|
||||||
color: Colors.black))),
|
|
||||||
const SizedBox(width: 16),
|
|
||||||
ToggleSwitch(
|
|
||||||
minWidth: 150.0,
|
|
||||||
cornerRadius: 20.0,
|
|
||||||
activeBgColors: const [[Colors.green], [Colors.redAccent]],
|
|
||||||
activeFgColor: Colors.white,
|
|
||||||
inactiveBgColor: Colors.grey,
|
|
||||||
inactiveFgColor: Colors.white,
|
|
||||||
initialLabelIndex: 1,
|
|
||||||
totalSwitches: VacationResponderStatus.values.length,
|
|
||||||
labels: VacationResponderStatus.values
|
|
||||||
.map((status) => status.getTitle(context))
|
|
||||||
.toList(),
|
|
||||||
radiusStyle: true,
|
|
||||||
onToggle: (index) {
|
|
||||||
log('VacationView::build():ToggleSwitch:index: $index');
|
|
||||||
final newStatus = index == 0
|
|
||||||
? VacationResponderStatus.activated
|
|
||||||
: VacationResponderStatus.deactivated;
|
|
||||||
controller.updateVacationPresentation(newStatus: newStatus);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
Obx(() => AbsorbPointer(
|
|
||||||
absorbing: controller.isVacationDeactivated,
|
|
||||||
child: Row(children: [
|
|
||||||
Container(
|
Container(
|
||||||
width: 200,
|
width: 200,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: Text(
|
child: Text(
|
||||||
AppLocalizations.of(context).startDate,
|
AppLocalizations.of(context).vacationResponder,
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
fontWeight: FontWeight.normal,
|
fontWeight: FontWeight.normal,
|
||||||
color: Colors.black.withOpacity(
|
color: Colors.black))),
|
||||||
controller.isVacationDeactivated ? 0.5 : 1.0)))),
|
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
Expanded(child: Obx(() => BorderButtonField<DateTime>(
|
Obx(() => ToggleSwitch(
|
||||||
value: controller.vacationPresentation.value.startDate,
|
minWidth: 150.0,
|
||||||
mouseCursor: SystemMouseCursors.text,
|
cornerRadius: 20.0,
|
||||||
textStyle: TextStyle(
|
activeBgColors: const [[Colors.green], [Colors.redAccent]],
|
||||||
fontSize: 16,
|
activeFgColor: Colors.white,
|
||||||
fontWeight: FontWeight.normal,
|
inactiveBgColor: Colors.grey,
|
||||||
color: Colors.black.withOpacity(
|
inactiveFgColor: Colors.white,
|
||||||
controller.isVacationDeactivated ? 0.5 : 1.0)),
|
initialLabelIndex: controller.isVacationDeactivated ? 1 : 0,
|
||||||
hintText: AppLocalizations.of(context).startDate,
|
totalSwitches: VacationResponderStatus.values.length,
|
||||||
icon: const Icon(
|
labels: VacationResponderStatus.values
|
||||||
Icons.date_range,
|
.map((status) => status.getTitle(context))
|
||||||
color: AppColor.colorIconTextField,
|
.toList(),
|
||||||
size: 20),
|
radiusStyle: true,
|
||||||
tapActionCallback: (value) =>
|
onToggle: (index) {
|
||||||
controller.selectDate(context, DateType.start, value)))),
|
final newStatus = index == 0
|
||||||
const SizedBox(width: 16),
|
? VacationResponderStatus.activated
|
||||||
Expanded(child: Obx(() => BorderButtonField<TimeOfDay>(
|
: VacationResponderStatus.deactivated;
|
||||||
value: controller.vacationPresentation.value.startTime,
|
controller.updateVacationPresentation(newStatus: newStatus);
|
||||||
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: const Icon(
|
|
||||||
Icons.timer,
|
|
||||||
color: AppColor.colorIconTextField,
|
|
||||||
size: 20),
|
|
||||||
tapActionCallback: (value) =>
|
|
||||||
controller.selectTime(context, DateType.start, value)))),
|
|
||||||
]),
|
]),
|
||||||
)),
|
const SizedBox(height: 20),
|
||||||
const SizedBox(height: 20),
|
Obx(() => AbsorbPointer(
|
||||||
Obx(() => AbsorbPointer(
|
absorbing: controller.isVacationDeactivated,
|
||||||
absorbing: controller.isVacationDeactivated,
|
child: Row(children: [
|
||||||
child: Container(
|
Container(
|
||||||
width: 200,
|
width: 200,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: CheckboxListTile(
|
child: Text(
|
||||||
contentPadding: EdgeInsets.zero,
|
AppLocalizations.of(context).startDate,
|
||||||
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,
|
|
||||||
textStyle: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.normal,
|
|
||||||
color: Colors.black.withOpacity(
|
|
||||||
!controller.canChangeEndDate ? 0.5 : 1.0)),
|
|
||||||
hintText: AppLocalizations.of(context).noEndDate,
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.date_range,
|
|
||||||
color: AppColor.colorIconTextField,
|
|
||||||
size: 20),
|
|
||||||
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: const Icon(
|
|
||||||
Icons.timer,
|
|
||||||
color: AppColor.colorIconTextField,
|
|
||||||
size: 20),
|
|
||||||
tapActionCallback: (value) =>
|
|
||||||
controller.selectTime(context, DateType.end, value)))),
|
|
||||||
])
|
|
||||||
)),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
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(
|
style: TextStyle(
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
fontWeight: FontWeight.normal,
|
fontWeight: FontWeight.normal,
|
||||||
color: Colors.black.withOpacity(
|
color: Colors.black.withOpacity(
|
||||||
controller.isVacationDeactivated ? 0.5 : 1.0)))),
|
controller.isVacationDeactivated ? 0.5 : 1.0)))),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
Expanded(child: _buildMessageBodyWidget(
|
Expanded(child: Obx(() => BorderButtonField<DateTime>(
|
||||||
context,
|
value: controller.vacationPresentation.value.startDate,
|
||||||
controller.isVacationDeactivated ? 0.5 : 1.0))
|
mouseCursor: SystemMouseCursors.text,
|
||||||
]),
|
isEmpty: !controller.isVacationDeactivated &&
|
||||||
)),
|
controller.vacationPresentation.value.startDateIsNull,
|
||||||
const SizedBox(height: 20),
|
textStyle: TextStyle(
|
||||||
Align(
|
fontSize: 16,
|
||||||
alignment: Alignment.centerRight,
|
fontWeight: FontWeight.normal,
|
||||||
child: buildTextButton(
|
color: Colors.black.withOpacity(
|
||||||
AppLocalizations.of(context).save,
|
controller.isVacationDeactivated ? 0.5 : 1.0)),
|
||||||
width: 128,
|
hintText: AppLocalizations.of(context).startDate,
|
||||||
height: 44,
|
icon: const Icon(
|
||||||
radius: 10,
|
Icons.date_range,
|
||||||
onTap: () => controller.saveVacation(context)),
|
color: AppColor.colorIconTextField,
|
||||||
)
|
size: 20),
|
||||||
]
|
tapActionCallback: (value) =>
|
||||||
),
|
controller.selectDate(context, DateType.start, value)))),
|
||||||
),
|
const SizedBox(width: 16),
|
||||||
mobile: SingleChildScrollView(
|
Expanded(child: Obx(() => BorderButtonField<TimeOfDay>(
|
||||||
child: Column(
|
value: controller.vacationPresentation.value.startTime,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
mouseCursor: SystemMouseCursors.text,
|
||||||
children: [
|
isEmpty: !controller.isVacationDeactivated &&
|
||||||
if (_responsiveUtils.isPortraitMobile(context))
|
controller.vacationPresentation.value.starTimeIsNull,
|
||||||
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
textStyle: TextStyle(
|
||||||
Text(
|
fontSize: 16,
|
||||||
AppLocalizations.of(context).vacationResponder,
|
fontWeight: FontWeight.normal,
|
||||||
style: const TextStyle(
|
color: Colors.black.withOpacity(
|
||||||
fontSize: 15,
|
controller.isVacationDeactivated ? 0.5 : 1.0)),
|
||||||
fontWeight: FontWeight.normal,
|
hintText: AppLocalizations.of(context).noStartTime,
|
||||||
color: Colors.black)),
|
icon: const Icon(
|
||||||
const SizedBox(height: 16),
|
Icons.timer,
|
||||||
ToggleSwitch(
|
color: AppColor.colorIconTextField,
|
||||||
minWidth: 150.0,
|
size: 20),
|
||||||
cornerRadius: 20.0,
|
tapActionCallback: (value) =>
|
||||||
activeBgColors: const [[Colors.green], [Colors.redAccent]],
|
controller.selectTime(context, DateType.start, value)))),
|
||||||
activeFgColor: Colors.white,
|
]),
|
||||||
inactiveBgColor: Colors.grey,
|
)),
|
||||||
inactiveFgColor: Colors.white,
|
const SizedBox(height: 20),
|
||||||
initialLabelIndex: 1,
|
Obx(() => AbsorbPointer(
|
||||||
totalSwitches: VacationResponderStatus.values.length,
|
absorbing: controller.isVacationDeactivated,
|
||||||
labels: VacationResponderStatus.values
|
child: Container(
|
||||||
.map((status) => status.getTitle(context))
|
width: 200,
|
||||||
.toList(),
|
color: Colors.white,
|
||||||
radiusStyle: true,
|
child: CheckboxListTile(
|
||||||
onToggle: (index) {
|
contentPadding: EdgeInsets.zero,
|
||||||
log('VacationView::build():ToggleSwitch:index: $index');
|
activeColor: AppColor.primaryColor.withOpacity(
|
||||||
final newStatus = index == 0
|
controller.isVacationDeactivated ? 0.5 : 1.0),
|
||||||
? VacationResponderStatus.activated
|
controlAffinity: ListTileControlAffinity.leading,
|
||||||
: VacationResponderStatus.deactivated;
|
value: controller.vacationPresentation.value.vacationStopEnabled,
|
||||||
controller.updateVacationPresentation(newStatus: newStatus);
|
onChanged: (value) =>
|
||||||
},
|
controller.updateVacationPresentation(vacationStopEnabled: value),
|
||||||
)
|
title: Text(AppLocalizations.of(context).vacationStopsAt,
|
||||||
])
|
style: TextStyle(
|
||||||
else
|
fontSize: 15,
|
||||||
Row(children: [
|
fontWeight: FontWeight.normal,
|
||||||
Expanded(
|
color: Colors.black.withOpacity(
|
||||||
child: Text(
|
controller.isVacationDeactivated ? 0.5 : 1.0))),
|
||||||
AppLocalizations.of(context).vacationResponder,
|
),
|
||||||
style: const TextStyle(
|
),
|
||||||
fontSize: 15,
|
)),
|
||||||
fontWeight: FontWeight.normal,
|
Obx(() => AbsorbPointer(
|
||||||
color: Colors.black)),
|
absorbing: !controller.canChangeEndDate,
|
||||||
),
|
child: Row(children: [
|
||||||
const SizedBox(width: 16),
|
Container(
|
||||||
ToggleSwitch(
|
width: 200,
|
||||||
minWidth: 150.0,
|
color: Colors.white,
|
||||||
cornerRadius: 20.0,
|
child: Text(
|
||||||
activeBgColors: const [[Colors.green], [Colors.redAccent]],
|
AppLocalizations.of(context).endDate,
|
||||||
activeFgColor: Colors.white,
|
style: TextStyle(
|
||||||
inactiveBgColor: Colors.grey,
|
fontSize: 15,
|
||||||
inactiveFgColor: Colors.white,
|
fontWeight: FontWeight.normal,
|
||||||
initialLabelIndex: 1,
|
color: Colors.black.withOpacity(
|
||||||
totalSwitches: VacationResponderStatus.values.length,
|
!controller.canChangeEndDate ? 0.5 : 1.0)))),
|
||||||
labels: VacationResponderStatus.values
|
const SizedBox(width: 16),
|
||||||
.map((status) => status.getTitle(context))
|
|
||||||
.toList(),
|
|
||||||
radiusStyle: true,
|
|
||||||
onToggle: (index) {
|
|
||||||
log('VacationView::build():ToggleSwitch:index: $index');
|
|
||||||
final newStatus = index == 0
|
|
||||||
? VacationResponderStatus.activated
|
|
||||||
: VacationResponderStatus.deactivated;
|
|
||||||
controller.updateVacationPresentation(newStatus: newStatus);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
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: const Icon(
|
|
||||||
Icons.date_range,
|
|
||||||
color: AppColor.colorIconTextField,
|
|
||||||
size: 20),
|
|
||||||
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: const Icon(
|
|
||||||
Icons.timer,
|
|
||||||
color: AppColor.colorIconTextField,
|
|
||||||
size: 20),
|
|
||||||
tapActionCallback: (value) =>
|
|
||||||
controller.selectTime(context, DateType.start, value))))
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
)),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
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>(
|
Expanded(child: Obx(() => BorderButtonField<DateTime>(
|
||||||
value: controller.vacationPresentation.value.endDate,
|
value: controller.vacationPresentation.value.endDate,
|
||||||
mouseCursor: SystemMouseCursors.text,
|
mouseCursor: SystemMouseCursors.text,
|
||||||
|
isEmpty: controller.canChangeEndDate &&
|
||||||
|
controller.vacationPresentation.value.endDateIsNull,
|
||||||
textStyle: TextStyle(
|
textStyle: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.normal,
|
fontWeight: FontWeight.normal,
|
||||||
@@ -379,6 +174,8 @@ class VacationView extends GetWidget<VacationController> {
|
|||||||
Expanded(child: Obx(() => BorderButtonField<TimeOfDay>(
|
Expanded(child: Obx(() => BorderButtonField<TimeOfDay>(
|
||||||
value: controller.vacationPresentation.value.endTime,
|
value: controller.vacationPresentation.value.endTime,
|
||||||
mouseCursor: SystemMouseCursors.text,
|
mouseCursor: SystemMouseCursors.text,
|
||||||
|
isEmpty: controller.canChangeEndDate &&
|
||||||
|
controller.vacationPresentation.value.endTimeIsNull,
|
||||||
textStyle: TextStyle(
|
textStyle: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.normal,
|
fontWeight: FontWeight.normal,
|
||||||
@@ -390,38 +187,249 @@ class VacationView extends GetWidget<VacationController> {
|
|||||||
color: AppColor.colorIconTextField,
|
color: AppColor.colorIconTextField,
|
||||||
size: 20),
|
size: 20),
|
||||||
tapActionCallback: (value) =>
|
tapActionCallback: (value) =>
|
||||||
controller.selectTime(context, DateType.end, value))))
|
controller.selectTime(context, DateType.end, value)))),
|
||||||
|
])
|
||||||
|
)),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
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: 20),
|
||||||
|
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: [
|
||||||
|
if (_responsiveUtils.isPortraitMobile(context))
|
||||||
|
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||||
|
Text(
|
||||||
|
AppLocalizations.of(context).vacationResponder,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.normal,
|
||||||
|
color: Colors.black)),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Obx(() => ToggleSwitch(
|
||||||
|
minWidth: 150.0,
|
||||||
|
cornerRadius: 20.0,
|
||||||
|
activeBgColors: const [[Colors.green], [Colors.redAccent]],
|
||||||
|
activeFgColor: Colors.white,
|
||||||
|
inactiveBgColor: Colors.grey,
|
||||||
|
inactiveFgColor: Colors.white,
|
||||||
|
initialLabelIndex: controller.isVacationDeactivated ? 1 : 0,
|
||||||
|
totalSwitches: VacationResponderStatus.values.length,
|
||||||
|
labels: VacationResponderStatus.values
|
||||||
|
.map((status) => status.getTitle(context))
|
||||||
|
.toList(),
|
||||||
|
radiusStyle: true,
|
||||||
|
onToggle: (index) {
|
||||||
|
final newStatus = index == 0
|
||||||
|
? VacationResponderStatus.activated
|
||||||
|
: VacationResponderStatus.deactivated;
|
||||||
|
controller.updateVacationPresentation(newStatus: newStatus);
|
||||||
|
},
|
||||||
|
))
|
||||||
])
|
])
|
||||||
)),
|
else
|
||||||
const SizedBox(height: 20),
|
Row(children: [
|
||||||
Obx(() => AbsorbPointer(
|
Expanded(
|
||||||
absorbing: controller.isVacationDeactivated,
|
child: Text(
|
||||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
AppLocalizations.of(context).vacationResponder,
|
||||||
Text(
|
style: const TextStyle(
|
||||||
AppLocalizations.of(context).messageBody,
|
fontSize: 15,
|
||||||
style: TextStyle(
|
fontWeight: FontWeight.normal,
|
||||||
fontSize: 15,
|
color: Colors.black)),
|
||||||
fontWeight: FontWeight.normal,
|
),
|
||||||
color: Colors.black.withOpacity(
|
const SizedBox(width: 16),
|
||||||
controller.isVacationDeactivated ? 0.5 : 1.0))),
|
Obx(() => ToggleSwitch(
|
||||||
const SizedBox(height: 16),
|
minWidth: 150.0,
|
||||||
_buildMessageBodyWidget(
|
cornerRadius: 20.0,
|
||||||
context,
|
activeBgColors: const [[Colors.green], [Colors.redAccent]],
|
||||||
controller.isVacationDeactivated ? 0.5 : 1.0)
|
activeFgColor: Colors.white,
|
||||||
]),
|
inactiveBgColor: Colors.grey,
|
||||||
)),
|
inactiveFgColor: Colors.white,
|
||||||
const SizedBox(height: 20),
|
initialLabelIndex: controller.isVacationDeactivated ? 1 : 0,
|
||||||
Align(
|
totalSwitches: VacationResponderStatus.values.length,
|
||||||
alignment: Alignment.centerRight,
|
labels: VacationResponderStatus.values
|
||||||
child: buildTextButton(
|
.map((status) => status.getTitle(context))
|
||||||
AppLocalizations.of(context).save,
|
.toList(),
|
||||||
width: 128,
|
radiusStyle: true,
|
||||||
height: 44,
|
onToggle: (index) {
|
||||||
radius: 10,
|
final newStatus = index == 0
|
||||||
onTap: () => controller.saveVacation(context)),
|
? VacationResponderStatus.activated
|
||||||
)
|
: VacationResponderStatus.deactivated;
|
||||||
]
|
controller.updateVacationPresentation(newStatus: newStatus);
|
||||||
|
},
|
||||||
|
))
|
||||||
|
]),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
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: const Icon(
|
||||||
|
Icons.date_range,
|
||||||
|
color: AppColor.colorIconTextField,
|
||||||
|
size: 20),
|
||||||
|
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: const Icon(
|
||||||
|
Icons.timer,
|
||||||
|
color: AppColor.colorIconTextField,
|
||||||
|
size: 20),
|
||||||
|
tapActionCallback: (value) =>
|
||||||
|
controller.selectTime(context, DateType.start, value))))
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
)),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
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: const Icon(
|
||||||
|
Icons.date_range,
|
||||||
|
color: AppColor.colorIconTextField,
|
||||||
|
size: 20),
|
||||||
|
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: const Icon(
|
||||||
|
Icons.timer,
|
||||||
|
color: AppColor.colorIconTextField,
|
||||||
|
size: 20),
|
||||||
|
tapActionCallback: (value) =>
|
||||||
|
controller.selectTime(context, DateType.end, value))))
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
)),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
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: 20),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: buildTextButton(
|
||||||
|
AppLocalizations.of(context).save,
|
||||||
|
width: 128,
|
||||||
|
height: 44,
|
||||||
|
radius: 10,
|
||||||
|
onTap: () => controller.saveVacation(context)),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -430,25 +438,33 @@ class VacationView extends GetWidget<VacationController> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildMessageBodyWidget(BuildContext context, double opacity) {
|
Widget _buildMessageBodyWidget(BuildContext context, double opacity) {
|
||||||
return (TextFieldBuilder()
|
return Obx(() {
|
||||||
..key(const Key('message_body_editor'))
|
return (TextFieldBuilder()
|
||||||
..cursorColor(Colors.black)
|
..key(const Key('message_body_editor'))
|
||||||
..addController(controller.messageBodyEditorController)
|
..cursorColor(Colors.black)
|
||||||
..textStyle(TextStyle(
|
..addController(controller.messageBodyEditorController)
|
||||||
fontWeight: FontWeight.normal,
|
..textStyle(TextStyle(
|
||||||
color: Colors.black.withOpacity(opacity),
|
fontWeight: FontWeight.normal,
|
||||||
fontSize: 16))
|
color: Colors.black.withOpacity(opacity),
|
||||||
..textDecoration((VacationInputDecorationBuilder()
|
|
||||||
..setContentPadding(const EdgeInsets.symmetric(
|
|
||||||
vertical: BuildUtils.isWeb ? 16 : 12,
|
|
||||||
horizontal: 12))
|
|
||||||
..setHintStyle(TextStyle(
|
|
||||||
color: AppColor.colorHintInputCreateMailbox.withOpacity(opacity),
|
|
||||||
fontSize: 16))
|
fontSize: 16))
|
||||||
..setHintText(AppLocalizations.of(context).hintMessageBodyVacation))
|
..textDecoration((VacationInputDecorationBuilder()
|
||||||
.build())
|
..setContentPadding(const EdgeInsets.symmetric(
|
||||||
..minLines(8)
|
vertical: BuildUtils.isWeb ? 16 : 12,
|
||||||
..maxLines(null))
|
horizontal: 12))
|
||||||
.build();
|
..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(8)
|
||||||
|
..maxLines(null))
|
||||||
|
.build();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,18 +5,26 @@ extension DateTimeExtension on DateTime? {
|
|||||||
|
|
||||||
String formatDate({String pattern = 'yyyy/MM/dd', String locale = 'en_US'}) {
|
String formatDate({String pattern = 'yyyy/MM/dd', String locale = 'en_US'}) {
|
||||||
if (this != null) {
|
if (this != null) {
|
||||||
return DateFormat(pattern, locale).format(this!.toLocal());
|
return DateFormat(pattern, locale).format(this!);
|
||||||
} else {
|
} else {
|
||||||
return '';
|
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? {
|
extension TimeOfDayExtension on TimeOfDay? {
|
||||||
|
|
||||||
String formatTime(BuildContext context) {
|
String formatTime(BuildContext context) {
|
||||||
if (this != null) {
|
if (this != null) {
|
||||||
return this!.format(context);
|
return MaterialLocalizations.of(context)
|
||||||
|
.formatTimeOfDay(this!, alwaysUse24HourFormat: true);
|
||||||
}
|
}
|
||||||
return '';
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
|
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/utc_date.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/mail/vacation/vacation_response.dart';
|
||||||
|
import 'package:tmail_ui_user/features/manage_account/presentation/extensions/datetime_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/vacation/vacation_responder_status.dart';
|
import 'package:tmail_ui_user/features/manage_account/presentation/model/vacation/vacation_responder_status.dart';
|
||||||
|
|
||||||
class VacationPresentation {
|
class VacationPresentation with EquatableMixin {
|
||||||
final VacationResponderStatus status;
|
final VacationResponderStatus status;
|
||||||
final DateTime? startDate;
|
final DateTime? startDate;
|
||||||
final TimeOfDay? startTime;
|
final TimeOfDay? startTime;
|
||||||
@@ -44,4 +48,40 @@ class VacationPresentation {
|
|||||||
vacationStopEnabled: vacationStopEnabled ?? this.vacationStopEnabled
|
vacationStopEnabled: vacationStopEnabled ?? this.vacationStopEnabled
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get startDateIsNull => startDate == null;
|
||||||
|
|
||||||
|
bool get starTimeIsNull => startTime == null;
|
||||||
|
|
||||||
|
bool get endDateIsNull => endDate == null;
|
||||||
|
|
||||||
|
bool get endTimeIsNull => endTime == null;
|
||||||
|
|
||||||
|
DateTime? get fromDate => startDate.applied(startTime);
|
||||||
|
|
||||||
|
DateTime? get toDate => endDate.applied(endTime);
|
||||||
|
|
||||||
|
bool get isEnabled => status == VacationResponderStatus.activated;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [
|
||||||
|
status,
|
||||||
|
startDate,
|
||||||
|
startTime,
|
||||||
|
endDate,
|
||||||
|
endTime,
|
||||||
|
vacationStopEnabled,
|
||||||
|
messageBody
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
extension VacationPresentationExtension on VacationPresentation {
|
||||||
|
VacationResponse toVacationResponse() {
|
||||||
|
return VacationResponse(
|
||||||
|
isEnabled: isEnabled,
|
||||||
|
fromDate: fromDate != null ? UTCDate(fromDate!) : null,
|
||||||
|
toDate: toDate != null ? UTCDate(toDate!) : null,
|
||||||
|
textBody: messageBody
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"@@last_modified": "2022-08-17T17:27:40.386002",
|
"@@last_modified": "2022-08-17T20:19:48.796318",
|
||||||
"initializing_data": "Initializing data...",
|
"initializing_data": "Initializing data...",
|
||||||
"@initializing_data": {
|
"@initializing_data": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -1981,5 +1981,29 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"placeholders_order": [],
|
"placeholders_order": [],
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"errorMessageWhenStartDateVacationIsEmpty": "Please enter a valid start date",
|
||||||
|
"@errorMessageWhenStartDateVacationIsEmpty": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"errorMessageWhenEndDateVacationIsInValid": "End date must be greater than start date",
|
||||||
|
"@errorMessageWhenEndDateVacationIsInValid": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"errorMessageWhenMessageVacationIsEmpty": "Message body cannot be blank",
|
||||||
|
"@errorMessageWhenMessageVacationIsEmpty": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"vacationSettingSaved": "Vacation settings saved",
|
||||||
|
"@vacationSettingSaved": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2050,4 +2050,32 @@ class AppLocalizations {
|
|||||||
name: 'noEndDate',
|
name: 'noEndDate',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String get errorMessageWhenStartDateVacationIsEmpty {
|
||||||
|
return Intl.message(
|
||||||
|
'Please enter a valid start date',
|
||||||
|
name: 'errorMessageWhenStartDateVacationIsEmpty',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String get errorMessageWhenEndDateVacationIsInValid {
|
||||||
|
return Intl.message(
|
||||||
|
'End date must be greater than start date',
|
||||||
|
name: 'errorMessageWhenEndDateVacationIsInValid',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String get errorMessageWhenMessageVacationIsEmpty {
|
||||||
|
return Intl.message(
|
||||||
|
'Message body cannot be blank',
|
||||||
|
name: 'errorMessageWhenMessageVacationIsEmpty',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String get vacationSettingSaved {
|
||||||
|
return Intl.message(
|
||||||
|
'Vacation settings saved',
|
||||||
|
name: 'vacationSettingSaved',
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user