diff --git a/lib/features/chat/presentation/pages/chat_screen.dart b/lib/features/chat/presentation/pages/chat_screen.dart index a95c93fd..3f809e28 100644 --- a/lib/features/chat/presentation/pages/chat_screen.dart +++ b/lib/features/chat/presentation/pages/chat_screen.dart @@ -59,23 +59,29 @@ class _ChatScreenState extends State { centerTitle: false, title: Row( children: [ - Container( - width: 40, - height: 40, - alignment: Alignment.center, - decoration: BoxDecoration( - color: Color(0xFFEBF4FF), - shape: BoxShape.circle, + if (state.chatRoom.users['to_chat_user']!.profilePhotoUrl != null) + CircleAvatar( + radius: 20, + foregroundImage: NetworkImage(state.chatRoom.users['to_chat_user']!.profilePhotoUrl!), ), - child: Text( - state.chatRoom.users['to_chat_user']!.name.split(' ').first[0] + state.chatRoom.users['to_chat_user']!.name.split(' ')[1][0], - style: TextStyle( - color: Color(0xFF7F9CF5), - fontWeight: FontWeight.w400, - fontSize: 20, + if (state.chatRoom.users['to_chat_user']!.profilePhotoUrl == null) + Container( + width: 40, + height: 40, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Color(0xFFEBF4FF), + shape: BoxShape.circle, + ), + child: Text( + state.chatRoom.users['to_chat_user']!.name.split(' ').first[0] + state.chatRoom.users['to_chat_user']!.name.split(' ')[1][0], + style: TextStyle( + color: Color(0xFF7F9CF5), + fontWeight: FontWeight.w400, + fontSize: 20, + ), ), ), - ), SizedBox(width: 16), Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/features/chat/presentation/pages/chat_select_screen.dart b/lib/features/chat/presentation/pages/chat_select_screen.dart index bdb3d9ce..74925e29 100644 --- a/lib/features/chat/presentation/pages/chat_select_screen.dart +++ b/lib/features/chat/presentation/pages/chat_select_screen.dart @@ -39,6 +39,7 @@ class _ChatSelectScreenState extends State { title: Padding( padding: const EdgeInsets.only(top: 8), child: ChatSearchBarWidget( + onSuffixIconTap: () => context.read().getChatRooms(), onChanged: (query) { if (query.length > 2) { EasyDebounce.debounce( diff --git a/lib/features/chat/presentation/widgets/chat_search_bar_widget.dart b/lib/features/chat/presentation/widgets/chat_search_bar_widget.dart index d2baebb1..62199d0f 100644 --- a/lib/features/chat/presentation/widgets/chat_search_bar_widget.dart +++ b/lib/features/chat/presentation/widgets/chat_search_bar_widget.dart @@ -1,4 +1,5 @@ import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/features/chat/presentation/bloc/chat_select_cubit/chat_select_cubit.dart'; import 'package:flutter/material.dart'; class ChatSearchBarWidget extends StatelessWidget { @@ -25,6 +26,7 @@ class ChatSearchBarWidget extends StatelessWidget { this.filled = true, this.validator, this.onChanged, + required this.onSuffixIconTap, }) : super(key: key); final Alignment? alignment; @@ -69,6 +71,8 @@ class ChatSearchBarWidget extends StatelessWidget { final Function(String)? onChanged; + final Function() onSuffixIconTap; + @override Widget build(BuildContext context) { return searchViewWidget(context); @@ -111,7 +115,10 @@ class ChatSearchBarWidget extends StatelessWidget { ), suffixIcon: suffix ?? IconButton( - onPressed: () => controller!.clear(), + onPressed: () { + controller!.clear(); + onSuffixIconTap(); + }, icon: Icon( Icons.clear, color: Colors.grey.shade600,