From 287b6b74b0932d0ddf876527a21b68cc795334c2 Mon Sep 17 00:00:00 2001 From: dab246 Date: Wed, 17 Jul 2024 03:31:07 +0700 Subject: [PATCH] TF-2929 Fix vacation banner is truncated in french --- .../email/presentation/email_view.dart | 2 +- .../mailbox_dashboard_view_web.dart | 12 +- .../manage_account_dashboard_view.dart | 38 ++-- .../menu/settings/settings_view.dart | 26 +-- .../vacation_notification_message_widget.dart | 171 ++++++++++-------- 5 files changed, 129 insertions(+), 120 deletions(-) diff --git a/lib/features/email/presentation/email_view.dart b/lib/features/email/presentation/email_view.dart index f86424382..ac1264d5e 100644 --- a/lib/features/email/presentation/email_view.dart +++ b/lib/features/email/presentation/email_view.dart @@ -113,7 +113,7 @@ class EmailView extends GetWidget { ) ) { return VacationNotificationMessageWidget( - margin: const EdgeInsets.only(left: 12, right: 12, bottom: 5), + margin: const EdgeInsetsDirectional.only(start: 12, end: 12, top: 8), vacationResponse: vacation!, actionGotoVacationSetting: controller.mailboxDashBoardController.goToVacationSetting, actionEndNow: controller.mailboxDashBoardController.disableVacationResponder diff --git a/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart b/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart index 622fa1d07..8cfd02094 100644 --- a/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart +++ b/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart @@ -544,14 +544,10 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView { return Obx(() { if (controller.vacationResponse.value?.vacationResponderIsValid == true) { return VacationNotificationMessageWidget( - margin: EdgeInsets.only( - top: 16, - right: AppUtils.isDirectionRTL(context) ? 0 : 16, - left: AppUtils.isDirectionRTL(context) ? 16 : 0, - ), - vacationResponse: controller.vacationResponse.value!, - actionGotoVacationSetting: () => controller.goToVacationSetting(), - actionEndNow: () => controller.disableVacationResponder()); + margin: const EdgeInsetsDirectional.only(top: 8, end: 16), + vacationResponse: controller.vacationResponse.value!, + actionGotoVacationSetting: controller.goToVacationSetting, + actionEndNow: controller.disableVacationResponder); } else { return const SizedBox.shrink(); } diff --git a/lib/features/manage_account/presentation/manage_account_dashboard_view.dart b/lib/features/manage_account/presentation/manage_account_dashboard_view.dart index 8d3a0096d..2d5f40d6c 100644 --- a/lib/features/manage_account/presentation/manage_account_dashboard_view.dart +++ b/lib/features/manage_account/presentation/manage_account_dashboard_view.dart @@ -4,7 +4,6 @@ import 'package:core/presentation/utils/responsive_utils.dart'; import 'package:core/presentation/views/image/avatar_builder.dart'; import 'package:core/presentation/views/responsive/responsive_widget.dart'; import 'package:core/presentation/views/text/slogan_builder.dart'; -import 'package:core/utils/platform_info.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:model/model.dart'; @@ -78,31 +77,26 @@ class ManageAccountDashBoardView extends GetWidget controller.selectAccountMenuItem(AccountMenuItem.vacation) - : null, - actionEndNow: () => controller.disableVacationResponder()); + margin: const EdgeInsetsDirectional.only(top: 16, start: 16, end: 16), + fromAccountDashBoard: true, + vacationResponse: controller.vacationResponse.value!, + actionGotoVacationSetting: !controller.inVacationSettings() + ? () => controller.selectAccountMenuItem(AccountMenuItem.vacation) + : null, + actionEndNow: controller.disableVacationResponder); } else if ((controller.vacationResponse.value?.vacationResponderIsWaiting == true || controller.vacationResponse.value?.vacationResponderIsStopped == true) && controller.accountMenuItemSelected.value == AccountMenuItem.vacation) { return VacationNotificationMessageWidget( - margin: const EdgeInsets.only( - top: 16, - left: PlatformInfo.isWeb ? 24 : 16, - right: PlatformInfo.isWeb ? 24 : 16), - fromAccountDashBoard: true, - vacationResponse: controller.vacationResponse.value!, - padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16), - leadingIcon: const Padding( - padding: EdgeInsets.only(right: 16), - child: Icon(Icons.timer, size: 20), - )); + margin: const EdgeInsetsDirectional.only(top: 16, start: 16, end: 16), + fromAccountDashBoard: true, + vacationResponse: controller.vacationResponse.value!, + padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16), + leadingIcon: const Padding( + padding: EdgeInsetsDirectional.only(end: 12), + child: Icon(Icons.timer, size: 20), + ) + ); } else { return const SizedBox.shrink(); } diff --git a/lib/features/manage_account/presentation/menu/settings/settings_view.dart b/lib/features/manage_account/presentation/menu/settings/settings_view.dart index 3a85a77e9..43fd0249b 100644 --- a/lib/features/manage_account/presentation/menu/settings/settings_view.dart +++ b/lib/features/manage_account/presentation/menu/settings/settings_view.dart @@ -2,7 +2,6 @@ import 'package:core/presentation/extensions/color_extension.dart'; import 'package:core/presentation/utils/style_utils.dart'; import 'package:core/presentation/views/button/icon_button_web.dart'; import 'package:core/utils/direction_utils.dart'; -import 'package:core/utils/platform_info.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; @@ -61,16 +60,14 @@ class SettingsView extends GetWidget { top: false, bottom: false, child: VacationNotificationMessageWidget( - margin: const EdgeInsetsDirectional.only( - start: PlatformInfo.isWeb ? 24 : 16, - end: PlatformInfo.isWeb ? 24 : 16, - top: 16), - fromAccountDashBoard: true, - vacationResponse: controller.manageAccountDashboardController.vacationResponse.value!, - actionGotoVacationSetting: !controller.manageAccountDashboardController.inVacationSettings() - ? () => controller.manageAccountDashboardController.selectAccountMenuItem(AccountMenuItem.vacation) - : null, - actionEndNow: () => controller.manageAccountDashboardController.disableVacationResponder()), + margin: const EdgeInsetsDirectional.only(start: 12, end: 12, top: 8), + fromAccountDashBoard: true, + vacationResponse: controller.manageAccountDashboardController.vacationResponse.value!, + actionGotoVacationSetting: !controller.manageAccountDashboardController.inVacationSettings() + ? () => controller.manageAccountDashboardController.selectAccountMenuItem(AccountMenuItem.vacation) + : null, + actionEndNow: controller.manageAccountDashboardController.disableVacationResponder + ), ); } else if ((controller.manageAccountDashboardController.vacationResponse.value?.vacationResponderIsWaiting == true || controller.manageAccountDashboardController.vacationResponse.value?.vacationResponderIsStopped == true) @@ -79,15 +76,12 @@ class SettingsView extends GetWidget { top: false, bottom: false, child: VacationNotificationMessageWidget( - margin: const EdgeInsetsDirectional.only( - start: PlatformInfo.isWeb ? 24 : 16, - end: PlatformInfo.isWeb ? 24 : 16, - top: 16), + margin: const EdgeInsetsDirectional.only(start: 12, end: 12, top: 8), fromAccountDashBoard: true, vacationResponse: controller.manageAccountDashboardController.vacationResponse.value!, padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16), leadingIcon: const Padding( - padding: EdgeInsetsDirectional.only(end: 16), + padding: EdgeInsetsDirectional.only(end: 12), child: Icon(Icons.timer, size: 20), ) ), diff --git a/lib/features/manage_account/presentation/vacation/widgets/vacation_notification_message_widget.dart b/lib/features/manage_account/presentation/vacation/widgets/vacation_notification_message_widget.dart index 8fc8e9c42..3efde2984 100644 --- a/lib/features/manage_account/presentation/vacation/widgets/vacation_notification_message_widget.dart +++ b/lib/features/manage_account/presentation/vacation/widgets/vacation_notification_message_widget.dart @@ -41,7 +41,7 @@ class VacationNotificationMessageWidget extends StatelessWidget { return Container( width: double.infinity, margin: margin ?? const EdgeInsets.symmetric(horizontal: 12), - padding: padding ?? const EdgeInsetsDirectional.only(start: 12), + padding: padding ?? const EdgeInsets.symmetric(horizontal: 12, vertical: 5), decoration: BoxDecoration( borderRadius: BorderRadius.circular(radius ?? 8), color: backgroundColor ?? AppColor.colorBackgroundNotificationVacationSetting, @@ -66,86 +66,111 @@ class VacationNotificationMessageWidget extends StatelessWidget { return Row(children: [ if (leadingIcon != null) leadingIcon!, Expanded( + child: Tooltip( + message: vacationResponse.getNotificationMessage(context), child: Text( - vacationResponse.getNotificationMessage(context), - style: TextStyle( - color: Colors.black, - fontSize: 16, - fontWeight: fontWeight ?? FontWeight.normal, - ))), + vacationResponse.getNotificationMessage(context), + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontWeight: fontWeight ?? FontWeight.normal, + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ) + ), if (actionEndNow != null) - buildTextButton( - AppLocalizations.of(context).endNow, - textStyle: const TextStyle( - fontWeight: FontWeight.w500, - fontSize: 16, - color: AppColor.colorTextButton), - backgroundColor: Colors.transparent, - width: 90, - height: 44, - radius: 10, - onTap: () => actionEndNow!.call()), + TMailButtonWidget.fromText( + text: AppLocalizations.of(context).endNow, + textStyle: const TextStyle( + fontWeight: FontWeight.w500, + fontSize: 16, + color: AppColor.colorTextButton), + backgroundColor: Colors.transparent, + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 5), + borderRadius: 10, + maxWidth: 180, + maxLines: 1, + tooltipMessage: AppLocalizations.of(context).endNow, + onTapActionCallback: actionEndNow), if (actionGotoVacationSetting != null) - buildTextButton( - AppLocalizations.of(context).vacationSetting, - textStyle: const TextStyle( - fontWeight: FontWeight.w500, - fontSize: 16, - color: AppColor.colorTextButton), - backgroundColor: Colors.transparent, - width: 150, - height: 44, - radius: 10, - onTap: () => actionGotoVacationSetting!.call()) + TMailButtonWidget.fromText( + text: AppLocalizations.of(context).vacationSetting, + textStyle: const TextStyle( + fontWeight: FontWeight.w500, + fontSize: 16, + color: AppColor.colorTextButton), + backgroundColor: Colors.transparent, + borderRadius: 10, + maxWidth: 310, + maxLines: 1, + tooltipMessage: AppLocalizations.of(context).vacationSetting, + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 5), + onTapActionCallback: actionGotoVacationSetting) ]); } Widget _buildBodyForMobile(BuildContext context) { - return Column(children: [ - Row(children: [ + return Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: [ if (leadingIcon != null) leadingIcon!, - Expanded( - child: Padding( - padding: const EdgeInsets.only(right: 12, top: 12), - child: Center( - child: Text( - vacationResponse.getNotificationMessage(context), - style: TextStyle( - color: Colors.black, - fontSize: 16, - fontWeight: fontWeight ?? FontWeight.normal, - )), + Tooltip( + message: vacationResponse.getNotificationMessage(context), + child: Text( + vacationResponse.getNotificationMessage(context), + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontWeight: fontWeight ?? FontWeight.normal, + ), + maxLines: 1, + textAlign: TextAlign.center, + overflow: TextOverflow.ellipsis, + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (actionEndNow != null) + Flexible( + child: TMailButtonWidget.fromText( + text: AppLocalizations.of(context).endNow, + textStyle: const TextStyle( + fontWeight: FontWeight.w500, + fontSize: 16, + color: AppColor.colorTextButton), + backgroundColor: Colors.transparent, + borderRadius: 10, + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 5), + maxWidth: 180, + maxLines: 1, + tooltipMessage: AppLocalizations.of(context).endNow, + onTapActionCallback: actionEndNow + ), ), - )), - ]), - Row(children: [ - const Spacer(), - if (actionEndNow != null) - buildTextButton( - AppLocalizations.of(context).endNow, - textStyle: const TextStyle( - fontWeight: FontWeight.w500, - fontSize: 16, - color: AppColor.colorTextButton), - backgroundColor: Colors.transparent, - width: 90, - height: 36, - radius: 10, - onTap: () => actionEndNow!.call()), - if (actionGotoVacationSetting != null) - buildTextButton( - AppLocalizations.of(context).vacationSetting, - textStyle: const TextStyle( - fontWeight: FontWeight.w500, - fontSize: 16, - color: AppColor.colorTextButton), - backgroundColor: Colors.transparent, - width: 150, - height: 36, - radius: 10, - onTap: () => actionGotoVacationSetting!.call()), - const Spacer(), - ]) - ]); + if (actionGotoVacationSetting != null) + Flexible( + child: TMailButtonWidget.fromText( + text: AppLocalizations.of(context).vacationSetting, + textStyle: const TextStyle( + fontWeight: FontWeight.w500, + fontSize: 16, + color: AppColor.colorTextButton), + backgroundColor: Colors.transparent, + borderRadius: 10, + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 5), + maxWidth: 180, + maxLines: 1, + tooltipMessage: AppLocalizations.of(context).vacationSetting, + onTapActionCallback: actionGotoVacationSetting + ), + ), + ] + ) + ] + ); } } \ No newline at end of file