Skip to content

Commit

Permalink
TW-1923:Removed messages section when search result is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
KhaledNjim authored and nqhhdev committed Nov 25, 2024
1 parent c1810e9 commit 0479eda
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
7 changes: 7 additions & 0 deletions lib/pages/chat_search/chat_search_style.dart
Original file line number Diff line number Diff line change
@@ -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<ResponsiveUtils>();

static double toolbarHeight(BuildContext context) =>
responsive.isMobile(context) ? 64 : 72;

static const EdgeInsetsGeometry inputPadding =
EdgeInsetsDirectional.only(start: 8, top: 16, bottom: 16, end: 16);

Expand Down
3 changes: 1 addition & 2 deletions lib/pages/chat_search/chat_search_view.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions lib/pages/search/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class SearchController extends State<Search> {

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)!),
Expand Down
15 changes: 2 additions & 13 deletions lib/pages/search/search_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions lib/pages/search/server_search_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 0479eda

Please sign in to comment.