TF-3603 Adapt search bar when inside Cozy

This commit is contained in:
DatDang
2025-04-18 14:38:03 +07:00
committed by Dat H. Pham
parent b5280c805d
commit d62e2861cf
3 changed files with 117 additions and 41 deletions
@@ -1,4 +1,5 @@
import 'package:core/core.dart';
import 'package:cozy/cozy_config_manager/cozy_config_manager.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_portal/flutter_portal.dart';
@@ -31,6 +32,7 @@ import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/co
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/download/download_task_item_widget.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/mark_mailbox_as_read_loading_banner.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/navigation_bar/navigation_bar_widget.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/profile_setting/profile_setting_icon.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/recover_deleted_message_loading_banner_widget.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/search_filters/filter_message_button.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/search_filters/search_filter_button.dart';
@@ -67,29 +69,38 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView {
child: Container(
color: AppColor.colorBgDesktop,
child: Column(children: [
Obx(() {
final accountId = controller.accountId.value;
FutureBuilder(
future: CozyConfigManager().isInsideCozy,
builder: (context, snapshot) {
if (snapshot.data == true) {
return const SizedBox.shrink();
}
return NavigationBarWidget(
imagePaths: controller.imagePaths,
accountId: accountId,
ownEmailAddress: controller.getOwnEmailAddress(),
contactSupportCapability: accountId != null
? controller.sessionCurrent?.getContactSupportCapability(accountId)
: null,
searchForm: SearchInputFormWidget(),
appGridController: controller.appGridDashboardController,
settingActionTypes: ProfileSettingActionType.values,
onTapApplicationLogoAction: controller.redirectToInboxAction,
onTapContactSupportAction: (contactSupport) =>
controller.onGetHelpOrReportBug(contactSupport),
onProfileSettingActionTypeClick: (actionType) =>
controller.handleProfileSettingActionTypeClick(
context: context,
actionType: actionType,
),
);
}),
return Obx(() {
final accountId = controller.accountId.value;
return NavigationBarWidget(
imagePaths: controller.imagePaths,
accountId: accountId,
ownEmailAddress: controller.getOwnEmailAddress(),
contactSupportCapability: accountId != null
? controller.sessionCurrent?.getContactSupportCapability(accountId)
: null,
searchForm: SearchInputFormWidget(),
appGridController: controller.appGridDashboardController,
settingActionTypes: ProfileSettingActionType.values,
onTapApplicationLogoAction: controller.redirectToInboxAction,
onTapContactSupportAction: (contactSupport) =>
controller.onGetHelpOrReportBug(contactSupport),
onProfileSettingActionTypeClick: (actionType) =>
controller.handleProfileSettingActionTypeClick(
context: context,
actionType: actionType,
),
);
});
}
),
Expanded(child: Row(children: [
Column(children: [
ComposeButtonWidget(
@@ -112,6 +123,48 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView {
]),
Expanded(child: Column(children: [
const SizedBox(height: 16),
FutureBuilder(
future: CozyConfigManager().isInsideCozy,
builder: (context, snapshot) {
if (snapshot.data != true) {
return const SizedBox.shrink();
}
return Padding(
padding: const EdgeInsets.only(bottom: 16),
child: Row(
children: [
SizedBox(
width: MediaQuery.sizeOf(context).width * 0.4,
height: 44,
child: SearchInputFormWidget(
fontSize: 15,
contentPadding: const EdgeInsets.only(bottom: 4),
),
),
const Spacer(),
Obx(() {
final accountId = controller.accountId.value;
final ownEmailAddress = accountId == null
? ''
: controller.getOwnEmailAddress();
return ProfileSettingIcon(
ownEmailAddress: ownEmailAddress,
settingActionTypes: ProfileSettingActionType.values,
onProfileSettingActionTypeClick: (actionType) =>
controller.handleProfileSettingActionTypeClick(
context: context,
actionType: actionType,
),
isInsideCozy: true,
);
}),
],
),
);
}
),
Obx(() => RecoverDeletedMessageLoadingBannerWidget(
isLoading: controller.isRecoveringDeletedMessage.value,
horizontalLoadingWidget: horizontalLoadingWidget,
@@ -2,6 +2,7 @@ import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/extensions/string_extension.dart';
import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/utils/app_toast.dart';
import 'package:core/presentation/views/button/tmail_button_widget.dart';
import 'package:core/presentation/views/image/avatar_builder.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -15,12 +16,14 @@ class ProfileSettingIcon extends StatefulWidget {
final String ownEmailAddress;
final List<ProfileSettingActionType> settingActionTypes;
final OnProfileSettingActionTypeClick onProfileSettingActionTypeClick;
final bool isInsideCozy;
const ProfileSettingIcon({
super.key,
required this.ownEmailAddress,
required this.settingActionTypes,
required this.onProfileSettingActionTypeClick,
this.isInsideCozy = false,
});
@override
@@ -57,7 +60,7 @@ class _ProfileSettingIconState extends State<ProfileSettingIcon> {
target: AppUtils.isDirectionRTL(context)
? Alignment.bottomLeft
: Alignment.bottomRight,
offset: const Offset(0, 8),
offset: Offset(widget.isInsideCozy ? -16 : 0, 8),
),
portalFollower: ProfileSettingMenuOverlay(
ownEmailAddress: widget.ownEmailAddress,
@@ -74,22 +77,32 @@ class _ProfileSettingIconState extends State<ProfileSettingIcon> {
onCloseProfileSettingMenuAction: _toggleOpenMenu,
),
visible: isExpanded,
child: (AvatarBuilder()
..text(widget.ownEmailAddress.firstCharacterToUpperCase)
..backgroundColor(Colors.white)
..textColor(Colors.black)
..context(context)
..size(48)
..addOnTapActionClick(_toggleOpenMenu)
..addBoxShadows([
const BoxShadow(
color: AppColor.colorShadowBgContentEmail,
spreadRadius: 1,
blurRadius: 1,
offset: Offset(0, 0.5),
)
]))
.build(),
child: widget.isInsideCozy
? TMailButtonWidget.fromIcon(
icon: _imagePaths.icSetting,
iconColor: AppColor.steelGrayA540,
backgroundColor: Colors.transparent,
onTapActionAtPositionCallback: (position) {
_toggleOpenMenu();
},
margin: const EdgeInsetsDirectional.only(end: 16),
)
: (AvatarBuilder()
..text(widget.ownEmailAddress.firstCharacterToUpperCase)
..backgroundColor(Colors.white)
..textColor(Colors.black)
..context(context)
..size(48)
..addOnTapActionClick(_toggleOpenMenu)
..addBoxShadows([
const BoxShadow(
color: AppColor.colorShadowBgContentEmail,
spreadRadius: 1,
blurRadius: 1,
offset: Offset(0, 0.5),
)
]))
.build(),
),
);
},
@@ -40,7 +40,14 @@ class SearchInputFormWidget extends StatelessWidget with AppLoaderMixin {
final _imagePaths = Get.find<ImagePaths>();
final _responsiveUtils = Get.find<ResponsiveUtils>();
SearchInputFormWidget({Key? key}) : super(key: key);
SearchInputFormWidget({
super.key,
this.fontSize = 16,
this.contentPadding = EdgeInsets.zero,
});
final double fontSize;
final EdgeInsetsGeometry contentPadding;
@override
Widget build(BuildContext context) {
@@ -239,6 +246,9 @@ class SearchInputFormWidget extends StatelessWidget with AppLoaderMixin {
return QuickSearchTextFieldConfiguration(
controller: _searchController.searchInputController,
focusNode: _searchController.searchFocus,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
fontSize: fontSize,
),
textInputAction: TextInputAction.done,
cursorColor: AppColor.primaryColor,
textDirection: DirectionUtils.getDirectionByLanguage(context),
@@ -247,7 +257,7 @@ class SearchInputFormWidget extends StatelessWidget with AppLoaderMixin {
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
contentPadding: EdgeInsets.zero,
contentPadding: contentPadding,
hintText: AppLocalizations.of(context).search_emails,
hintStyle: ThemeUtils.textStyleBodyBody2(
color: AppColor.steelGray400,