From 148d17da9e2a8371bd6753af871542376e755c02 Mon Sep 17 00:00:00 2001 From: Magellan Date: Tue, 24 Mar 2026 14:51:46 +0200 Subject: [PATCH 1/2] update search form --- .../conversation/view/messages_list.dart | 16 +- .../forward_messages/forward_search_form.dart | 146 ++++-------------- .../conversation/widgets/select_input.dart | 15 +- .../view/conversation_create_form.dart | 19 ++- .../view/group_create_form.dart | 54 ++++--- .../group_info/view/group_info_form.dart | 115 ++++++++------ .../features/profile/view/profile_page.dart | 2 +- .../src/features/search/view/search_bar.dart | 64 ++++---- .../src/features/search/view/search_form.dart | 90 +++++------ .../src/features/search/view/search_page.dart | 37 ----- .../lib/src/navigation/app_router.dart | 7 - .../lib/src/navigation/constants.dart | 1 - 12 files changed, 231 insertions(+), 335 deletions(-) delete mode 100644 sama_chat_client/lib/src/features/search/view/search_page.dart diff --git a/sama_chat_client/lib/src/features/conversation/view/messages_list.dart b/sama_chat_client/lib/src/features/conversation/view/messages_list.dart index bf6e7e20..48e1cecf 100644 --- a/sama_chat_client/lib/src/features/conversation/view/messages_list.dart +++ b/sama_chat_client/lib/src/features/conversation/view/messages_list.dart @@ -367,20 +367,16 @@ class MessageItem extends StatelessWidget { leadingIcon: const Icon(Icons.forward_outlined), title: const Text('Forward'), onPressed: () { - print('forward message= ${message.body}'); showModalBottomSheet( isScrollControlled: true, - useSafeArea: false, context: context, - backgroundColor: black, + backgroundColor: Colors.transparent, builder: (BuildContext bc) { - return Container( - color: lightWhite, - margin: EdgeInsets.only( - top: MediaQueryData.fromView( - View.of(context)) - .padding - .top), + return ClipRRect( + borderRadius: + const BorderRadius.vertical( + top: Radius.circular(24), + ), child: BlocProvider.value( value: BlocProvider.of( diff --git a/sama_chat_client/lib/src/features/conversation/widgets/forward_messages/forward_search_form.dart b/sama_chat_client/lib/src/features/conversation/widgets/forward_messages/forward_search_form.dart index 5279237b..403f768d 100644 --- a/sama_chat_client/lib/src/features/conversation/widgets/forward_messages/forward_search_form.dart +++ b/sama_chat_client/lib/src/features/conversation/widgets/forward_messages/forward_search_form.dart @@ -13,6 +13,7 @@ import '../../../conversations_list/widgets/avatar_letter_icon.dart'; import '../../../search/bloc/global_search_bloc.dart'; import '../../../search/bloc/global_search_state.dart'; import '../../../search/view/search_bar.dart'; +import '../../../search/view/search_form.dart'; import '../../bloc/conversation_bloc.dart'; import '../../bloc/forward_message/forward_messages_bloc.dart'; import '../../models/chat_message.dart'; @@ -27,12 +28,27 @@ class ForwardSearchForm extends StatelessWidget { @override Widget build(BuildContext context) { - return Column( - children: [ - const GlobalSearchBar(withBack: false), - _SearchBody(forwardMessages), - ], - ); + return Scaffold( + appBar: AppBar( + backgroundColor: black, + automaticallyImplyLeading: false, + centerTitle: true, + toolbarHeight: kToolbarHeight + 5, + title: const Padding( + padding: EdgeInsets.only(top: 10), + child: Text( + 'Forward message', + style: TextStyle(color: white), + ))), + body: Container( + padding: const EdgeInsets.only(left: 20, right: 20, top: 20), + child: Column( + spacing: 4, + children: [ + const GlobalSearchBar(), + _SearchBody(forwardMessages), + ], + ))); } } @@ -116,7 +132,12 @@ class _SearchBody extends StatelessWidget { padding: EdgeInsets.only(top: 18.0), child: Text('Please start typing to find chat'), ) - : Expanded(child: _SearchResults(null, chats, forwardMessages)), + : Expanded( + child: SearchResults(null, chats, chatOnTap: (chat) { + context + .read() + .add(SendForwardMessage([chat], forwardMessages)); + })), SearchStateLoading() => const Padding( padding: EdgeInsets.only(top: 18.0), child: CircularProgressIndicator.adaptive(), @@ -126,114 +147,15 @@ class _SearchBody extends StatelessWidget { child: Text(state.error), ), SearchStateSuccess() => Expanded( - child: _SearchResults( - state.users, state.conversations, forwardMessages)), + child: SearchResults(state.users, state.conversations, + chatOnTap: (chat) { + context + .read() + .add(SendForwardMessage([chat], forwardMessages)); + })), }; }, ), ); } } - -class _SearchResults extends StatelessWidget { - final List? users; - final List chats; - final Set forwardMessages; - - const _SearchResults(this.users, this.chats, this.forwardMessages); - - Widget _header(String title) { - return Padding( - padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), - child: Container( - padding: const EdgeInsets.only(left: 18.0), - width: double.maxFinite, - color: gainsborough, //define the background color - child: Text( - title, - style: const TextStyle(fontSize: 18), - ), - ), - ); - } - - Widget _emptyListText(String title) { - return Padding( - padding: const EdgeInsets.all(10.0), - child: Text( - title, - style: const TextStyle( - fontWeight: FontWeight.w300, - fontSize: 16, - ), - textAlign: TextAlign.center, - ), - ); - } - - @override - Widget build(BuildContext context) { - final userList = users == null - ? null - : users!.isEmpty - ? _emptyListText('We couldn\'t find the specified users') - : ListView.builder( - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemCount: users!.length, - itemBuilder: (BuildContext context, int index) { - final user = users![index]; - return ListTile( - leading: AvatarLetterIcon( - name: user.login!, avatar: user.avatar), - title: Text( - user.login!, - style: const TextStyle( - fontWeight: FontWeight.w500, fontSize: 20), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - contentPadding: - const EdgeInsets.fromLTRB(18.0, 8.0, 18.0, 8.0), - onTap: () { - context - .read() - .add(ConversationCreated(user: user, type: 'u')); - }, - ); - }, - ); - - final conversationList = chats.isEmpty - ? _emptyListText('We couldn\'t find the specified chats') - : ListView.builder( - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemCount: chats.length, - itemBuilder: (BuildContext context, int index) { - final conversation = chats[index]; - return ConversationListItem( - conversation: conversation, - onTap: () { - context - .read() - .add(SendForwardMessage([conversation], forwardMessages)); - }, - ); - }, - ); - - return MediaQuery.removePadding( - context: context, - removeTop: true, - child: ListView( - padding: const EdgeInsets.only(top: 10.0), - children: [ - if (userList != null) ...[_header('Users'), userList], - _header('Chats'), - conversationList, - ], - ), - ); - } -} diff --git a/sama_chat_client/lib/src/features/conversation/widgets/select_input.dart b/sama_chat_client/lib/src/features/conversation/widgets/select_input.dart index b668bf89..6921c0f2 100644 --- a/sama_chat_client/lib/src/features/conversation/widgets/select_input.dart +++ b/sama_chat_client/lib/src/features/conversation/widgets/select_input.dart @@ -121,17 +121,14 @@ class _SelectInputState extends State { context, () => showModalBottomSheet( isScrollControlled: true, - useSafeArea: false, context: context, - backgroundColor: black, + backgroundColor: Colors.transparent, builder: (BuildContext bc) { - return Container( - color: lightWhite, - margin: EdgeInsets.only( - top: MediaQueryData.fromView( - View.of(context)) - .padding - .top), + return ClipRRect( + borderRadius: + const BorderRadius.vertical( + top: Radius.circular(24), + ), child: BlocProvider.value( value: BlocProvider.of( diff --git a/sama_chat_client/lib/src/features/conversation_create/view/conversation_create_form.dart b/sama_chat_client/lib/src/features/conversation_create/view/conversation_create_form.dart index 06c5a3cc..3e76e2b2 100644 --- a/sama_chat_client/lib/src/features/conversation_create/view/conversation_create_form.dart +++ b/sama_chat_client/lib/src/features/conversation_create/view/conversation_create_form.dart @@ -23,17 +23,28 @@ class ConversationCreateFormState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: const GlobalSearchBar(), + appBar: AppBar( + backgroundColor: black, + iconTheme: const IconThemeData( + color: white, + ), + title: const Text( + 'Create chat', + style: TextStyle(color: white), + ), + centerTitle: true, + ), body: Container( - padding: const EdgeInsets.symmetric(horizontal: 28, vertical: 4), + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ + const GlobalSearchBar(), Row(children: [ Expanded( child: Padding( - padding: const EdgeInsets.only(top: 20.0, bottom: 16.0), + padding: const EdgeInsets.fromLTRB(15, 20, 15, 16), child: TextButton.icon( style: const ButtonStyle( backgroundColor: WidgetStatePropertyAll(slateBlue), @@ -65,7 +76,7 @@ class ConversationCreateFormState extends State { ), ), ), - SearchBody(searchType: SearchType.users) + SearchForm(searchType: SearchType.both) ])) ]), )); diff --git a/sama_chat_client/lib/src/features/conversation_group_create/view/group_create_form.dart b/sama_chat_client/lib/src/features/conversation_group_create/view/group_create_form.dart index 3dbbfbce..574e1fe0 100644 --- a/sama_chat_client/lib/src/features/conversation_group_create/view/group_create_form.dart +++ b/sama_chat_client/lib/src/features/conversation_group_create/view/group_create_form.dart @@ -34,30 +34,38 @@ class GroupCreateFormState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: const GlobalSearchBar(), - body: Container( - padding: const EdgeInsets.symmetric(horizontal: 28, vertical: 4), - child: BlocListener( - listener: (context, state) { - if (state.status.isInitial) { - } else if (state.status.isFailure) { - ScaffoldMessenger.of(context) - ..hideCurrentSnackBar() - ..showSnackBar( - SnackBar(content: Text(state.errorMessage ?? '')), - ); - } else if (state.status.isSuccess) { - context - .read() - .add(ConversationGroupCreated( - users: state.participants.value.toList(), - type: 'g', - name: state.groupname.value, - avatarUrl: state.avatar.value, - )); - } - }, + appBar: AppBar( + backgroundColor: black, + leading: const BackButton(color: white), + centerTitle: true, + title: const Text( + 'Group create', + style: TextStyle(color: white), + )), + body: BlocListener( + listener: (context, state) { + if (state.status.isInitial) { + } else if (state.status.isFailure) { + ScaffoldMessenger.of(context) + ..hideCurrentSnackBar() + ..showSnackBar( + SnackBar(content: Text(state.errorMessage ?? '')), + ); + } else if (state.status.isSuccess) { + context + .read() + .add(ConversationGroupCreated( + users: state.participants.value.toList(), + type: 'g', + name: state.groupname.value, + avatarUrl: state.avatar.value, + )); + } + }, + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16), child: Column(mainAxisSize: MainAxisSize.min, children: [ + const GlobalSearchBar(), Expanded( child: BlocBuilder( buildWhen: (previous, current) { diff --git a/sama_chat_client/lib/src/features/group_info/view/group_info_form.dart b/sama_chat_client/lib/src/features/group_info/view/group_info_form.dart index a3c6f9c2..f7b59fdc 100644 --- a/sama_chat_client/lib/src/features/group_info/view/group_info_form.dart +++ b/sama_chat_client/lib/src/features/group_info/view/group_info_form.dart @@ -312,57 +312,74 @@ void _showSearchScreenDialog(BuildContext context) { RepositoryProvider.of(context), ), child: Scaffold( - appBar: const GlobalSearchBar(), + appBar: AppBar( + backgroundColor: black, + leading: const BackButton(color: white), + centerTitle: false, + title: const Text( + 'Group info', + style: TextStyle(color: white), + )), body: Container( - padding: - const EdgeInsets.symmetric(horizontal: 28, vertical: 4), - child: BlocProvider.value( - value: BlocProvider.of(context), - child: BlocConsumer( - listener: (context, state) { - if (state.addParticipants.displayError == - GroupParticipantsValidationError.long) { - ScaffoldMessenger.of(context) - ..hideCurrentSnackBar() - ..showSnackBar( - const SnackBar( - content: Text( - 'you\'ve reached maximum participant limit')), - ); - } - }, buildWhen: (previous, current) { - return previous.addParticipants != - current.addParticipants; - }, builder: (context, state) { - var currentParticipants = List.of( - state.participants.value..remove(state.currentUser)); - return ParticipantsForm( - users: List.of(currentParticipants) - ..addAll(state.addParticipants.value), - nonRemovableUsers: currentParticipants, - onAddParticipants: (user) { - if (!state.participants.value.contains(user)) { - context - .read() - .add(GroupAddParticipantsAdded(user)); - } else { - ScaffoldMessenger.of(context) - ..hideCurrentSnackBar() - ..showSnackBar( - const SnackBar( - content: Text('user is already in chat')), + padding: const EdgeInsets.symmetric( + horizontal: 20, vertical: 16), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const GlobalSearchBar(), + Expanded( + child: BlocProvider.value( + value: BlocProvider.of(context), + child: BlocConsumer( + listener: (context, state) { + if (state.addParticipants.displayError == + GroupParticipantsValidationError.long) { + ScaffoldMessenger.of(context) + ..hideCurrentSnackBar() + ..showSnackBar( + const SnackBar( + content: Text( + 'you\'ve reached maximum participant limit')), + ); + } + }, buildWhen: (previous, current) { + return previous.addParticipants != + current.addParticipants; + }, builder: (context, state) { + var currentParticipants = List.of( + state.participants.value + ..remove(state.currentUser)); + return ParticipantsForm( + users: List.of(currentParticipants) + ..addAll(state.addParticipants.value), + nonRemovableUsers: currentParticipants, + onAddParticipants: (user) { + if (!state.participants.value + .contains(user)) { + context + .read() + .add(GroupAddParticipantsAdded(user)); + } else { + ScaffoldMessenger.of(context) + ..hideCurrentSnackBar() + ..showSnackBar( + const SnackBar( + content: Text( + 'user is already in chat')), + ); + } + }, + onRemoveParticipants: (user) { + context + .read() + .add(GroupAddParticipantsRemoved(user)); + }, ); - } - }, - onRemoveParticipants: (user) { - context - .read() - .add(GroupAddParticipantsRemoved(user)); - }, - ); - }), - ), - ), + }), + ), + ), + ], + )), floatingActionButton: StatefulBuilder(builder: (_, setState) { return BlocProvider.value( value: BlocProvider.of(context), diff --git a/sama_chat_client/lib/src/features/profile/view/profile_page.dart b/sama_chat_client/lib/src/features/profile/view/profile_page.dart index eb4dd8a7..1c20429d 100644 --- a/sama_chat_client/lib/src/features/profile/view/profile_page.dart +++ b/sama_chat_client/lib/src/features/profile/view/profile_page.dart @@ -17,7 +17,7 @@ class ProfilePage extends StatelessWidget { appBar: AppBar( backgroundColor: black, iconTheme: const IconThemeData( - color: white, //change your color here + color: white, ), title: const Text( 'Personal information', diff --git a/sama_chat_client/lib/src/features/search/view/search_bar.dart b/sama_chat_client/lib/src/features/search/view/search_bar.dart index 05f5e40e..df51fb03 100644 --- a/sama_chat_client/lib/src/features/search/view/search_bar.dart +++ b/sama_chat_client/lib/src/features/search/view/search_bar.dart @@ -7,9 +7,7 @@ import '../bloc/global_search_bloc.dart'; import '../bloc/global_search_event.dart'; class GlobalSearchBar extends StatefulWidget implements PreferredSizeWidget { - final bool withBack; - - const GlobalSearchBar({this.withBack = true, super.key}); + const GlobalSearchBar({super.key}); @override State createState() => _GlobalSearchBarState(); @@ -36,39 +34,39 @@ class _GlobalSearchBarState extends State { @override Widget build(BuildContext context) { - return AppBar( - backgroundColor: black, - leading: widget.withBack ? const BackButton(color: white) : null, - automaticallyImplyLeading: widget.withBack, - title: SizedBox( - height: kToolbarHeight - 18, - child: TextField( - controller: _textController, - autocorrect: false, - onChanged: (text) { - if (text.length >= 2) { - _globalSearchBloc.add( - TextChanged(text: text), - ); - } - }, - decoration: InputDecoration( - filled: true, - fillColor: white, - contentPadding: const EdgeInsets.only(top: 14.0), - prefixIcon: const Icon(Icons.search), - suffixIcon: GestureDetector( - onTap: _onClearTapped, - child: const Icon(Icons.clear), - ), - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(10.0), - ), - hintText: 'Search', + return Container( + height: kToolbarHeight - 16, + padding: const EdgeInsetsGeometry.symmetric(horizontal: 15), + child: TextField( + controller: _textController, + autocorrect: false, + onChanged: (text) { + if (text.length >= 2) { + _globalSearchBloc.add( + TextChanged(text: text), + ); + } + }, + decoration: InputDecoration( + filled: true, + fillColor: paleMallow, + contentPadding: const EdgeInsets.only(top: 14.0), + prefixIcon: const Icon(Icons.search), + suffixIcon: GestureDetector( + onTap: _onClearTapped, + child: const Icon(Icons.clear), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(20.0), + borderSide: const BorderSide(color: lightMallow, width: 1), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(20.0), + borderSide: const BorderSide(color: slateBlue, width: 2), ), + hintText: 'Search', ), ), - centerTitle: !widget.withBack, ); } diff --git a/sama_chat_client/lib/src/features/search/view/search_form.dart b/sama_chat_client/lib/src/features/search/view/search_form.dart index b152cf91..1cee97c6 100644 --- a/sama_chat_client/lib/src/features/search/view/search_form.dart +++ b/sama_chat_client/lib/src/features/search/view/search_form.dart @@ -16,21 +16,7 @@ import '../bloc/global_search_bloc.dart'; import '../bloc/global_search_state.dart'; class SearchForm extends StatelessWidget { - const SearchForm({super.key}); - - @override - Widget build(BuildContext context) { - return const Column( - children: [ - GlobalSearchBar(), - SearchBody(), - ], - ); - } -} - -class SearchBody extends StatelessWidget { - const SearchBody({this.searchType = SearchType.both, super.key}); + const SearchForm({this.searchType = SearchType.both, super.key}); final SearchType searchType; @@ -72,8 +58,8 @@ class SearchBody extends StatelessWidget { child: Text(state.error), ), SearchStateSuccess() => Expanded( - child: _SearchResults( - state.users, state.conversations, searchType)), + child: SearchResults(state.users, state.conversations, + searchType: searchType)), }; }, ), @@ -87,12 +73,14 @@ enum SearchType { both, } -class _SearchResults extends StatelessWidget { - const _SearchResults(this.users, this.conversations, this.searchType); +class SearchResults extends StatelessWidget { + const SearchResults(this.users, this.conversations, + {super.key, this.searchType = SearchType.both, this.chatOnTap}); - final List users; + final List? users; final List conversations; final SearchType searchType; + final void Function(ConversationModel)? chatOnTap; Widget _header(String title) { return Padding( @@ -125,33 +113,36 @@ class _SearchResults extends StatelessWidget { @override Widget build(BuildContext context) { - final userList = users.isEmpty - ? _emptyListText('We couldn\'t find the specified users') - : ListView.builder( - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemCount: users.length, - itemBuilder: (BuildContext context, int index) { - final user = users[index]; - return ListTile( - leading: - AvatarLetterIcon(name: user.login!, avatar: user.avatar), - title: Text( - user.login!, - style: const TextStyle( - fontWeight: FontWeight.w500, fontSize: 20), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - contentPadding: const EdgeInsets.fromLTRB(18.0, 8.0, 18.0, 8.0), - onTap: () { - context - .read() - .add(ConversationCreated(user: user, type: 'u')); + final userList = users == null + ? null + : users!.isEmpty + ? _emptyListText('We couldn\'t find the specified users') + : ListView.builder( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: users!.length, + itemBuilder: (BuildContext context, int index) { + final user = users![index]; + return ListTile( + leading: AvatarLetterIcon( + name: user.login!, avatar: user.avatar), + title: Text( + user.login!, + style: const TextStyle( + fontWeight: FontWeight.w500, fontSize: 20), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + contentPadding: + const EdgeInsets.fromLTRB(18.0, 8.0, 18.0, 8.0), + onTap: () { + context + .read() + .add(ConversationCreated(user: user, type: 'u')); + }, + ); }, ); - }, - ); final conversationList = conversations.isEmpty ? _emptyListText('We couldn\'t find the specified chats') @@ -160,8 +151,9 @@ class _SearchResults extends StatelessWidget { shrinkWrap: true, itemCount: conversations.length, itemBuilder: (BuildContext context, int index) { - final conversation = conversations[index]; - return ConversationListItem(conversation: conversation); + final chat = conversations[index]; + return ConversationListItem( + conversation: chat, onTap: () => chatOnTap?.call(chat)); }, ); @@ -173,8 +165,8 @@ class _SearchResults extends StatelessWidget { children: [ if (searchType == SearchType.both || searchType == SearchType.users) ...[ - if (searchType == SearchType.both) _header('Users'), - userList, + if (searchType == SearchType.both) + if (userList != null) ...[_header('Users'), userList], ], if (searchType == SearchType.both || searchType == SearchType.chats) ...[ diff --git a/sama_chat_client/lib/src/features/search/view/search_page.dart b/sama_chat_client/lib/src/features/search/view/search_page.dart deleted file mode 100644 index ef9288a0..00000000 --- a/sama_chat_client/lib/src/features/search/view/search_page.dart +++ /dev/null @@ -1,37 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; - -import '../../../features/search/view/search_form.dart'; -import '../../../repository/conversation/conversation_repository.dart'; -import '../../../repository/global_search/global_search_repository.dart'; -import '../../conversation_create/bloc/conversation_create_bloc.dart'; -import '../bloc/global_search_bloc.dart'; - -class SearchPage extends StatelessWidget { - const SearchPage({super.key}); - - static MultiBlocProvider route() { - return MultiBlocProvider( - providers: [ - BlocProvider( - create: (context) => GlobalSearchBloc( - globalSearchRepository: - RepositoryProvider.of(context), - ), - ), - BlocProvider( - create: (context) => ConversationCreateBloc( - conversationRepository: - RepositoryProvider.of(context), - ), - ), - ], - child: const SearchPage(), - ); - } - - @override - Widget build(BuildContext context) { - return const Scaffold(body: SearchForm()); - } -} diff --git a/sama_chat_client/lib/src/navigation/app_router.dart b/sama_chat_client/lib/src/navigation/app_router.dart index 4841c584..9e34f0a3 100644 --- a/sama_chat_client/lib/src/navigation/app_router.dart +++ b/sama_chat_client/lib/src/navigation/app_router.dart @@ -12,7 +12,6 @@ import '../features/conversation/view/conversation_page.dart'; import '../features/login/view/login_page.dart'; import '../features/profile/view/profile_page.dart'; import '../features/reset_password/view/reset_password_page.dart'; -import '../features/search/view/search_page.dart'; import '../features/splash_page.dart'; import '../features/user_info/view/user_info_page.dart'; import '../repository/authentication/authentication_repository.dart'; @@ -66,12 +65,6 @@ GoRouter router(BuildContext context, navigatorKey) => GoRouter( return const SplashPage(); }, ), - GoRoute( - path: globalSearchPath, - builder: (context, state) { - return SearchPage.route(); - }, - ), GoRoute( path: conversationCreateScreenPath, builder: (context, state) { diff --git a/sama_chat_client/lib/src/navigation/constants.dart b/sama_chat_client/lib/src/navigation/constants.dart index 3d861e0a..c9fcd645 100644 --- a/sama_chat_client/lib/src/navigation/constants.dart +++ b/sama_chat_client/lib/src/navigation/constants.dart @@ -3,7 +3,6 @@ const String loginScreenPath = '/login'; const String splashScreenPath = '/splash'; const String conversationListScreenPath = '/conversations'; const String conversationScreenSubPath = 'conversation'; -const String globalSearchPath = '/global_search'; const String groupCreateScreenPath = '/group_create'; const String conversationCreateScreenPath = '/conversation_create'; const String profilePath = '/profile'; From b5e27f0645ea4e364a28581b698241126717d289 Mon Sep 17 00:00:00 2001 From: Magellan Date: Fri, 3 Apr 2026 02:09:40 +0300 Subject: [PATCH 2/2] fix Forward message screen --- .../conversation/view/messages_list.dart | 17 ++---- .../forward_messages/forward_search_form.dart | 54 ++++++++++--------- .../conversation/widgets/select_input.dart | 18 +++---- 3 files changed, 41 insertions(+), 48 deletions(-) diff --git a/sama_chat_client/lib/src/features/conversation/view/messages_list.dart b/sama_chat_client/lib/src/features/conversation/view/messages_list.dart index 48e1cecf..6aa26fb6 100644 --- a/sama_chat_client/lib/src/features/conversation/view/messages_list.dart +++ b/sama_chat_client/lib/src/features/conversation/view/messages_list.dart @@ -372,18 +372,11 @@ class MessageItem extends StatelessWidget { context: context, backgroundColor: Colors.transparent, builder: (BuildContext bc) { - return ClipRRect( - borderRadius: - const BorderRadius.vertical( - top: Radius.circular(24), - ), - child: BlocProvider.value( - value: - BlocProvider.of( - context), - child: - ForwardMessagesWidget({message}), - )); + return BlocProvider.value( + value: BlocProvider.of( + context), + child: ForwardMessagesWidget({message}), + ); }); }), FocusedPopupMenuItem( diff --git a/sama_chat_client/lib/src/features/conversation/widgets/forward_messages/forward_search_form.dart b/sama_chat_client/lib/src/features/conversation/widgets/forward_messages/forward_search_form.dart index 403f768d..15a54c5f 100644 --- a/sama_chat_client/lib/src/features/conversation/widgets/forward_messages/forward_search_form.dart +++ b/sama_chat_client/lib/src/features/conversation/widgets/forward_messages/forward_search_form.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; @@ -6,10 +8,7 @@ import '../../../../db/models/models.dart'; import '../../../../navigation/constants.dart'; import '../../../../shared/ui/colors.dart'; import '../../../conversation_create/bloc/conversation_create_bloc.dart'; -import '../../../conversation_create/bloc/conversation_create_event.dart'; import '../../../conversation_create/bloc/conversation_create_state.dart'; -import '../../../conversations_list/conversations_list.dart'; -import '../../../conversations_list/widgets/avatar_letter_icon.dart'; import '../../../search/bloc/global_search_bloc.dart'; import '../../../search/bloc/global_search_state.dart'; import '../../../search/view/search_bar.dart'; @@ -28,27 +27,34 @@ class ForwardSearchForm extends StatelessWidget { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - backgroundColor: black, - automaticallyImplyLeading: false, - centerTitle: true, - toolbarHeight: kToolbarHeight + 5, - title: const Padding( - padding: EdgeInsets.only(top: 10), - child: Text( - 'Forward message', - style: TextStyle(color: white), - ))), - body: Container( - padding: const EdgeInsets.only(left: 20, right: 20, top: 20), - child: Column( - spacing: 4, - children: [ - const GlobalSearchBar(), - _SearchBody(forwardMessages), - ], - ))); + final window = WidgetsBinding.instance.platformDispatcher.views.first; + double topPadding = window.viewPadding.top / window.devicePixelRatio - + (Platform.isIOS ? 30 : 15); + return ClipRRect( + borderRadius: const BorderRadius.vertical( + top: Radius.circular(28), + ), + child: Scaffold( + appBar: AppBar( + backgroundColor: black, + automaticallyImplyLeading: false, + centerTitle: true, + toolbarHeight: kToolbarHeight + topPadding, + title: Padding( + padding: EdgeInsets.only(top: topPadding + 5), + child: const Text( + 'Forward message', + style: TextStyle(color: white), + ))), + body: Container( + padding: const EdgeInsets.only(left: 20, right: 20, top: 20), + child: Column( + spacing: 4, + children: [ + const GlobalSearchBar(), + _SearchBody(forwardMessages), + ], + )))); } } diff --git a/sama_chat_client/lib/src/features/conversation/widgets/select_input.dart b/sama_chat_client/lib/src/features/conversation/widgets/select_input.dart index 6921c0f2..7e3ebe1e 100644 --- a/sama_chat_client/lib/src/features/conversation/widgets/select_input.dart +++ b/sama_chat_client/lib/src/features/conversation/widgets/select_input.dart @@ -124,18 +124,12 @@ class _SelectInputState extends State { context: context, backgroundColor: Colors.transparent, builder: (BuildContext bc) { - return ClipRRect( - borderRadius: - const BorderRadius.vertical( - top: Radius.circular(24), - ), - child: BlocProvider.value( - value: - BlocProvider.of( - context), - child: ForwardMessagesWidget( - state.selectedMessages.value), - )); + return BlocProvider.value( + value: BlocProvider.of( + context), + child: ForwardMessagesWidget( + state.selectedMessages.value), + ); })); }, ),