diff --git a/lib/pages/chat_search/chat_search_style.dart b/lib/pages/chat_search/chat_search_style.dart index a77b61edd..2014c9b0c 100644 --- a/lib/pages/chat_search/chat_search_style.dart +++ b/lib/pages/chat_search/chat_search_style.dart @@ -1,6 +1,13 @@ +import 'package:fluffychat/di/global/get_it_initializer.dart'; +import 'package:fluffychat/utils/responsive/responsive_utils.dart'; import 'package:flutter/material.dart'; class ChatSearchStyle { + static ResponsiveUtils responsive = getIt.get(); + + static double toolbarHeight(BuildContext context) => + responsive.isMobile(context) ? 64 : 72; + static const EdgeInsetsGeometry inputPadding = EdgeInsetsDirectional.only(start: 8, top: 16, bottom: 16, end: 16); diff --git a/lib/pages/chat_search/chat_search_view.dart b/lib/pages/chat_search/chat_search_view.dart index 9b3d7260a..1a43caa47 100644 --- a/lib/pages/chat_search/chat_search_view.dart +++ b/lib/pages/chat_search/chat_search_view.dart @@ -1,6 +1,5 @@ import 'package:collection/collection.dart'; import 'package:fluffychat/app_state/success.dart'; -import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/domain/app_state/room/timeline_search_event_state.dart'; import 'package:fluffychat/pages/chat/chat_view_style.dart'; import 'package:fluffychat/pages/chat/events/message_download_content.dart'; @@ -43,7 +42,7 @@ class ChatSearchView extends StatelessWidget { return Scaffold( backgroundColor: LinagoraSysColors.material().onPrimary, appBar: AppBar( - toolbarHeight: AppConfig.toolbarHeight(context), + toolbarHeight: ChatSearchStyle.toolbarHeight(context), backgroundColor: LinagoraSysColors.material().onPrimary, automaticallyImplyLeading: false, title: Padding( diff --git a/lib/pages/search/search.dart b/lib/pages/search/search.dart index 458e201aa..8c74044ea 100644 --- a/lib/pages/search/search.dart +++ b/lib/pages/search/search.dart @@ -58,6 +58,9 @@ class SearchController extends State { String get searchWord => textEditingController.text; + bool get isSearchWordUserId => + searchWord.isValidMatrixId && searchWord.startsWith('@'); + String getBodyText(Event event, String searchWord) { final senderName = event.senderFromMemoryOrFallback.calcDisplayname( i18n: MatrixLocals(L10n.of(context)!), diff --git a/lib/pages/search/search_view.dart b/lib/pages/search/search_view.dart index 3e9b8200c..fb077dec1 100644 --- a/lib/pages/search/search_view.dart +++ b/lib/pages/search/search_view.dart @@ -13,7 +13,6 @@ import 'package:fluffychat/widgets/twake_components/twake_loading/center_loading import 'package:flutter/material.dart' hide SearchController; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:linagora_design_flutter/colors/linagora_sys_colors.dart'; -import 'package:matrix/matrix.dart'; class SearchView extends StatelessWidget { final SearchController searchController; @@ -73,17 +72,7 @@ class SearchView extends StatelessWidget { searchController.serverSearchController.searchResultsNotifier, builder: ((context, searchResults, child) { if (searchResults is PresentationServerSideEmptySearch) { - final keyword = searchController.textEditingController.text; - if (searchController.searchContactAndRecentChatController! - .recentAndContactsNotifier.value.isNotEmpty || - (keyword.isValidMatrixId && keyword.startsWith('@'))) { - return child!; - } - return _SearchHeader( - header: L10n.of(context)!.messages, - searchController: searchController, - needShowMore: false, - ); + return child!; } if (searchResults is PresentationServerSideSearch) { @@ -130,7 +119,7 @@ class SearchView extends StatelessWidget { builder: (context, contacts, emptyChild) { if (contacts.isEmpty) { final keyword = searchController.textEditingController.text; - if (keyword.isValidMatrixId && keyword.startsWith("@")) { + if (searchController.isSearchWordUserId) { return SearchExternalContactWidget( keyword: keyword, searchController: searchController, diff --git a/lib/pages/search/server_search_view.dart b/lib/pages/search/server_search_view.dart index 7e2f38e6e..75247dff2 100644 --- a/lib/pages/search/server_search_view.dart +++ b/lib/pages/search/server_search_view.dart @@ -28,10 +28,9 @@ class ServerSearchMessagesList extends StatelessWidget { searchController.serverSearchController.searchResultsNotifier, builder: (context, serverSearchNotifier, child) { if (serverSearchNotifier is PresentationServerSideEmptySearch) { - final keyword = searchController.textEditingController.text; if (searchController.searchContactAndRecentChatController! .recentAndContactsNotifier.value.isEmpty && - !(keyword.isValidMatrixId && keyword.startsWith('@'))) { + !(searchController.isSearchWordUserId)) { return child!; } return const SizedBox.shrink();