From 4d6f91966075eaddce7b3dad4a4924e6a2bc1bed Mon Sep 17 00:00:00 2001 From: hieubt Date: Fri, 3 Nov 2023 16:06:30 +0700 Subject: [PATCH] TF-2196 Add 'From; field fow mobile (cherry picked from commit 2e754c1331ce4833b20a21e52f736ccd8fcbb207) --- .../from_composer_mobile_widget_style.dart | 44 ++++++++ .../mobile/from_composer_mobile_widget.dart | 100 ++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 lib/features/composer/presentation/styles/mobile/from_composer_mobile_widget_style.dart create mode 100644 lib/features/composer/presentation/widgets/mobile/from_composer_mobile_widget.dart diff --git a/lib/features/composer/presentation/styles/mobile/from_composer_mobile_widget_style.dart b/lib/features/composer/presentation/styles/mobile/from_composer_mobile_widget_style.dart new file mode 100644 index 000000000..941658d0d --- /dev/null +++ b/lib/features/composer/presentation/styles/mobile/from_composer_mobile_widget_style.dart @@ -0,0 +1,44 @@ +import 'package:core/presentation/extensions/color_extension.dart'; +import 'package:flutter/material.dart'; + +class FromComposerMobileWidgetStyle { + static const double space = 8.0; + static const double identityButtonHeight = 32.0; + static const double identityButtonWidthMobileLandscape = 421.0; + + static const EdgeInsetsGeometry identityButtonInkWellPadding = EdgeInsets.symmetric(vertical: 8.0); + static const EdgeInsetsGeometry identityButtonPadding = EdgeInsets.only( + top: 4, + bottom: 4, + right: 4, + left: 8, + ); + + static const BorderRadius identityButtonInkWellBorderRadius = BorderRadius.all(Radius.circular(10)); + static const BoxDecoration identityButtonDecoration = BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(10)), + color: AppColor.colorComposerAppBar, + ); + static const Border border = Border( + bottom: BorderSide( + color: AppColor.colorLineComposer, + width: 1, + ) + ); + + static const TextStyle prefixTextStyle = TextStyle( + fontSize: 14, + fontWeight: FontWeight.w400, + color: AppColor.colorLabelComposer + ); + static const TextStyle buttonTitleTextStyle = TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: AppColor.colorCalendarEventUnread + ); + static const TextStyle buttonSubTitleTextStyle = TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: AppColor.colorLabelComposer + ); +} \ No newline at end of file diff --git a/lib/features/composer/presentation/widgets/mobile/from_composer_mobile_widget.dart b/lib/features/composer/presentation/widgets/mobile/from_composer_mobile_widget.dart new file mode 100644 index 000000000..b46d365e3 --- /dev/null +++ b/lib/features/composer/presentation/widgets/mobile/from_composer_mobile_widget.dart @@ -0,0 +1,100 @@ +import 'package:core/presentation/resources/image_paths.dart'; +import 'package:core/presentation/utils/responsive_utils.dart'; +import 'package:core/presentation/utils/style_utils.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:jmap_dart_client/jmap/identities/identity.dart'; +import 'package:model/email/prefix_email_address.dart'; +import 'package:tmail_ui_user/features/composer/presentation/extensions/prefix_email_address_extension.dart'; +import 'package:tmail_ui_user/features/composer/presentation/styles/mobile/from_composer_mobile_widget_style.dart'; + +class FromComposerMobileWidget extends StatelessWidget { + + final Identity? selectedIdentity; + final ImagePaths imagePaths; + final ResponsiveUtils responsiveUtils; + final EdgeInsetsGeometry? padding; + final EdgeInsetsGeometry? margin; + final void Function()? onTap; + + const FromComposerMobileWidget({ + super.key, + required this.imagePaths, + required this.responsiveUtils, + this.selectedIdentity, + this.padding, + this.margin, + this.onTap, + }); + + @override + Widget build(BuildContext context) { + return Container( + decoration: const BoxDecoration( + border: FromComposerMobileWidgetStyle.border + ), + padding: padding, + margin: margin, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsetsDirectional.only(top: 16), + child: Text( + '${PrefixEmailAddress.from.asName(context)}:', + style: FromComposerMobileWidgetStyle.prefixTextStyle, + ), + ), + const SizedBox(width: FromComposerMobileWidgetStyle.space), + Expanded( + child: Container( + padding: FromComposerMobileWidgetStyle.identityButtonInkWellPadding, + child: InkWell( + borderRadius: FromComposerMobileWidgetStyle.identityButtonInkWellBorderRadius, + onTap: onTap, + child: Container( + height: FromComposerMobileWidgetStyle.identityButtonHeight, + width: responsiveUtils.isLandscapeMobile(context) + ? FromComposerMobileWidgetStyle.identityButtonWidthMobileLandscape + : 0, + padding: FromComposerMobileWidgetStyle.identityButtonPadding, + decoration: FromComposerMobileWidgetStyle.identityButtonDecoration, + child: Row( + children: [ + if (selectedIdentity != null) + Expanded( + child: RichText( + maxLines: 1, + softWrap: CommonTextStyle.defaultSoftWrap, + overflow: CommonTextStyle.defaultTextOverFlow, + text: TextSpan( + children: [ + if (selectedIdentity!.name!.isNotEmpty) + TextSpan( + text: '${selectedIdentity!.name} ', + style: FromComposerMobileWidgetStyle.buttonTitleTextStyle, + ), + TextSpan( + text: '(${selectedIdentity!.email})', + style: selectedIdentity!.name!.isNotEmpty + ? FromComposerMobileWidgetStyle.buttonSubTitleTextStyle + : FromComposerMobileWidgetStyle.buttonTitleTextStyle + ) + ] + ), + ) + ) + else + const SizedBox.shrink(), + SvgPicture.asset(imagePaths.icDropDown) + ], + ), + ), + ), + ), + ), + ], + ), + ); + } +} \ No newline at end of file