|  |  |  | @ -34,13 +34,6 @@ class _ChatHomeScreenState extends State<ChatHomeScreen> { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   final RefreshController _rc = RefreshController(initialRefresh: false); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void getMoreChat() async { | 
		
	
		
			
				|  |  |  |  |     data.getUserRecentChats(); | 
		
	
		
			
				|  |  |  |  |     await Future.delayed( | 
		
	
		
			
				|  |  |  |  |       const Duration(milliseconds: 1000), | 
		
	
		
			
				|  |  |  |  |     ); | 
		
	
		
			
				|  |  |  |  |     _rc.loadComplete(); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   @override | 
		
	
		
			
				|  |  |  |  |   void initState() { | 
		
	
	
		
			
				
					|  |  |  | @ -95,135 +88,123 @@ class _ChatHomeScreenState extends State<ChatHomeScreen> { | 
		
	
		
			
				|  |  |  |  |                       ), | 
		
	
		
			
				|  |  |  |  |                     ).paddingOnly(top: 20, bottom: 14), | 
		
	
		
			
				|  |  |  |  |                     if (m.searchedChats != null) | 
		
	
		
			
				|  |  |  |  |                       SmartRefresher( | 
		
	
		
			
				|  |  |  |  |                         enablePullDown: true, | 
		
	
		
			
				|  |  |  |  |                         enablePullUp: false, | 
		
	
		
			
				|  |  |  |  |                         onRefresh: (){ | 
		
	
		
			
				|  |  |  |  |                           getMoreChat(); | 
		
	
		
			
				|  |  |  |  |                         }, | 
		
	
		
			
				|  |  |  |  |                         header: const MaterialClassicHeader( | 
		
	
		
			
				|  |  |  |  |                           color: MyColors.gradiantEndColor, | 
		
	
		
			
				|  |  |  |  |                         ), | 
		
	
		
			
				|  |  |  |  |                         controller: _rc, | 
		
	
		
			
				|  |  |  |  |                         reverse: false, | 
		
	
		
			
				|  |  |  |  |                         child: ListView.separated( | 
		
	
		
			
				|  |  |  |  |                           itemCount: m.searchedChats!.length, | 
		
	
		
			
				|  |  |  |  |                           shrinkWrap: true, | 
		
	
		
			
				|  |  |  |  |                           physics: const ClampingScrollPhysics(), | 
		
	
		
			
				|  |  |  |  |                           padding: const EdgeInsets.only(bottom: 80.0), | 
		
	
		
			
				|  |  |  |  |                           itemBuilder: (BuildContext context, int index) { | 
		
	
		
			
				|  |  |  |  |                             return SizedBox( | 
		
	
		
			
				|  |  |  |  |                               height: 55, | 
		
	
		
			
				|  |  |  |  |                               child: Row( | 
		
	
		
			
				|  |  |  |  |                                 children: [ | 
		
	
		
			
				|  |  |  |  |                                   Stack( | 
		
	
		
			
				|  |  |  |  |                                     children: <Widget>[ | 
		
	
		
			
				|  |  |  |  |                                       if (m.searchedChats![index].isImageLoading!) | 
		
	
		
			
				|  |  |  |  |                                         const SizedBox( | 
		
	
		
			
				|  |  |  |  |                                           height: 48, | 
		
	
		
			
				|  |  |  |  |                                           width: 48, | 
		
	
		
			
				|  |  |  |  |                                         ).toShimmer().circle(30), | 
		
	
		
			
				|  |  |  |  |                                       if (m.searchedChats![index].isImageLoaded! && m.searchedChats![index].image.isNotEmpty) | 
		
	
		
			
				|  |  |  |  |                                         CircularAvatar( | 
		
	
		
			
				|  |  |  |  |                                           radius: 20, | 
		
	
		
			
				|  |  |  |  |                                           height: 48, | 
		
	
		
			
				|  |  |  |  |                                           width: 48, | 
		
	
		
			
				|  |  |  |  |                                           url: m.searchedChats![index].image, | 
		
	
		
			
				|  |  |  |  |                                           isImageBase64: true, | 
		
	
		
			
				|  |  |  |  |                                         ), | 
		
	
		
			
				|  |  |  |  |                                       if (!m.searchedChats![index].isImageLoading! && m.searchedChats![index].isImageLoaded! && m.searchedChats![index].image.isEmpty) | 
		
	
		
			
				|  |  |  |  |                                         SvgPicture.asset( | 
		
	
		
			
				|  |  |  |  |                                           "assets/images/user.svg", | 
		
	
		
			
				|  |  |  |  |                                           height: 48, | 
		
	
		
			
				|  |  |  |  |                                           width: 48, | 
		
	
		
			
				|  |  |  |  |                       ListView.separated( | 
		
	
		
			
				|  |  |  |  |                         itemCount: m.searchedChats!.length, | 
		
	
		
			
				|  |  |  |  |                         shrinkWrap: true, | 
		
	
		
			
				|  |  |  |  |                         physics: const ClampingScrollPhysics(), | 
		
	
		
			
				|  |  |  |  |                         padding: const EdgeInsets.only(bottom: 80.0), | 
		
	
		
			
				|  |  |  |  |                         itemBuilder: (BuildContext context, int index) { | 
		
	
		
			
				|  |  |  |  |                           return SizedBox( | 
		
	
		
			
				|  |  |  |  |                             height: 55, | 
		
	
		
			
				|  |  |  |  |                             child: Row( | 
		
	
		
			
				|  |  |  |  |                               children: [ | 
		
	
		
			
				|  |  |  |  |                                 Stack( | 
		
	
		
			
				|  |  |  |  |                                   children: <Widget>[ | 
		
	
		
			
				|  |  |  |  |                                     if (m.searchedChats![index].isImageLoading!) | 
		
	
		
			
				|  |  |  |  |                                       const SizedBox( | 
		
	
		
			
				|  |  |  |  |                                         height: 48, | 
		
	
		
			
				|  |  |  |  |                                         width: 48, | 
		
	
		
			
				|  |  |  |  |                                       ).toShimmer().circle(30), | 
		
	
		
			
				|  |  |  |  |                                     if (m.searchedChats![index].isImageLoaded! && m.searchedChats![index].image.isNotEmpty) | 
		
	
		
			
				|  |  |  |  |                                       CircularAvatar( | 
		
	
		
			
				|  |  |  |  |                                         radius: 20, | 
		
	
		
			
				|  |  |  |  |                                         height: 48, | 
		
	
		
			
				|  |  |  |  |                                         width: 48, | 
		
	
		
			
				|  |  |  |  |                                         url: m.searchedChats![index].image, | 
		
	
		
			
				|  |  |  |  |                                         isImageBase64: true, | 
		
	
		
			
				|  |  |  |  |                                       ), | 
		
	
		
			
				|  |  |  |  |                                     if (!m.searchedChats![index].isImageLoading! && m.searchedChats![index].isImageLoaded! && m.searchedChats![index].image.isEmpty) | 
		
	
		
			
				|  |  |  |  |                                       SvgPicture.asset( | 
		
	
		
			
				|  |  |  |  |                                         "assets/images/user.svg", | 
		
	
		
			
				|  |  |  |  |                                         height: 48, | 
		
	
		
			
				|  |  |  |  |                                         width: 48, | 
		
	
		
			
				|  |  |  |  |                                       ), | 
		
	
		
			
				|  |  |  |  |                                     Positioned( | 
		
	
		
			
				|  |  |  |  |                                       right: 5, | 
		
	
		
			
				|  |  |  |  |                                       bottom: 1, | 
		
	
		
			
				|  |  |  |  |                                       child: Container( | 
		
	
		
			
				|  |  |  |  |                                         width: 10, | 
		
	
		
			
				|  |  |  |  |                                         height: 10, | 
		
	
		
			
				|  |  |  |  |                                         decoration: BoxDecoration( | 
		
	
		
			
				|  |  |  |  |                                           color: m.searchedChats![index].userStatus == 1 ? MyColors.green2DColor : Colors.red, | 
		
	
		
			
				|  |  |  |  |                                         ), | 
		
	
		
			
				|  |  |  |  |                                       Positioned( | 
		
	
		
			
				|  |  |  |  |                                         right: 5, | 
		
	
		
			
				|  |  |  |  |                                         bottom: 1, | 
		
	
		
			
				|  |  |  |  |                                         child: Container( | 
		
	
		
			
				|  |  |  |  |                                           width: 10, | 
		
	
		
			
				|  |  |  |  |                                           height: 10, | 
		
	
		
			
				|  |  |  |  |                                           decoration: BoxDecoration( | 
		
	
		
			
				|  |  |  |  |                                             color: m.searchedChats![index].userStatus == 1 ? MyColors.green2DColor : Colors.red, | 
		
	
		
			
				|  |  |  |  |                                       ).circle(10), | 
		
	
		
			
				|  |  |  |  |                                     ) | 
		
	
		
			
				|  |  |  |  |                                   ], | 
		
	
		
			
				|  |  |  |  |                                 ).onPress(() { | 
		
	
		
			
				|  |  |  |  |                                   print(jsonEncode(m.searchedChats![index])); | 
		
	
		
			
				|  |  |  |  |                                 }), | 
		
	
		
			
				|  |  |  |  |                                 Column( | 
		
	
		
			
				|  |  |  |  |                                   mainAxisAlignment: MainAxisAlignment.start, | 
		
	
		
			
				|  |  |  |  |                                   crossAxisAlignment: CrossAxisAlignment.start, | 
		
	
		
			
				|  |  |  |  |                                   children: [ | 
		
	
		
			
				|  |  |  |  |                                     (m.searchedChats![index].userName!.replaceFirst(".", " ").capitalizeFirstofEach ?? "").toText14(color: MyColors.darkTextColor).paddingOnly(left: 11, top: 13), | 
		
	
		
			
				|  |  |  |  |                                   ], | 
		
	
		
			
				|  |  |  |  |                                 ).expanded, | 
		
	
		
			
				|  |  |  |  |                                 SizedBox( | 
		
	
		
			
				|  |  |  |  |                                   width: 60, | 
		
	
		
			
				|  |  |  |  |                                   child: Row( | 
		
	
		
			
				|  |  |  |  |                                     crossAxisAlignment: CrossAxisAlignment.center, | 
		
	
		
			
				|  |  |  |  |                                     mainAxisAlignment: MainAxisAlignment.end, | 
		
	
		
			
				|  |  |  |  |                                     mainAxisSize: MainAxisSize.max, | 
		
	
		
			
				|  |  |  |  |                                     children: <Widget>[ | 
		
	
		
			
				|  |  |  |  |                                       if (m.searchedChats![index].unreadMessageCount! > 0) | 
		
	
		
			
				|  |  |  |  |                                         Container( | 
		
	
		
			
				|  |  |  |  |                                           alignment: Alignment.center, | 
		
	
		
			
				|  |  |  |  |                                           width: 18, | 
		
	
		
			
				|  |  |  |  |                                           height: 18, | 
		
	
		
			
				|  |  |  |  |                                           decoration: const BoxDecoration( | 
		
	
		
			
				|  |  |  |  |                                             color: MyColors.redColor, | 
		
	
		
			
				|  |  |  |  |                                             borderRadius: BorderRadius.all( | 
		
	
		
			
				|  |  |  |  |                                               Radius.circular(20), | 
		
	
		
			
				|  |  |  |  |                                             ), | 
		
	
		
			
				|  |  |  |  |                                           ), | 
		
	
		
			
				|  |  |  |  |                                         ).circle(10), | 
		
	
		
			
				|  |  |  |  |                                       ) | 
		
	
		
			
				|  |  |  |  |                                     ], | 
		
	
		
			
				|  |  |  |  |                                   ).onPress(() { | 
		
	
		
			
				|  |  |  |  |                                     print(jsonEncode(m.searchedChats![index])); | 
		
	
		
			
				|  |  |  |  |                                   }), | 
		
	
		
			
				|  |  |  |  |                                   Column( | 
		
	
		
			
				|  |  |  |  |                                     mainAxisAlignment: MainAxisAlignment.start, | 
		
	
		
			
				|  |  |  |  |                                     crossAxisAlignment: CrossAxisAlignment.start, | 
		
	
		
			
				|  |  |  |  |                                     children: [ | 
		
	
		
			
				|  |  |  |  |                                       (m.searchedChats![index].userName!.replaceFirst(".", " ").capitalizeFirstofEach ?? "").toText14(color: MyColors.darkTextColor).paddingOnly(left: 11, top: 13), | 
		
	
		
			
				|  |  |  |  |                                           child: (m.searchedChats![index].unreadMessageCount!.toString()) | 
		
	
		
			
				|  |  |  |  |                                               .toText10( | 
		
	
		
			
				|  |  |  |  |                                                 color: MyColors.white, | 
		
	
		
			
				|  |  |  |  |                                               ) | 
		
	
		
			
				|  |  |  |  |                                               .center, | 
		
	
		
			
				|  |  |  |  |                                         ).paddingOnly(right: 10).center, | 
		
	
		
			
				|  |  |  |  |                                       Icon( | 
		
	
		
			
				|  |  |  |  |                                         m.searchedChats![index].isFav != null && m.searchedChats![index].isFav == false ? Icons.star_sharp : Icons.star_sharp, | 
		
	
		
			
				|  |  |  |  |                                         color: m.searchedChats![index].isFav != null && m.searchedChats![index].isFav == true ? MyColors.yellowColor : MyColors.grey35Color, | 
		
	
		
			
				|  |  |  |  |                                       ).onPress( | 
		
	
		
			
				|  |  |  |  |                                         () { | 
		
	
		
			
				|  |  |  |  |                                           if (m.searchedChats![index].isFav == null || m.searchedChats![index].isFav == false) { | 
		
	
		
			
				|  |  |  |  |                                             m.favoriteUser( | 
		
	
		
			
				|  |  |  |  |                                               userID: AppState().chatDetails!.response!.id!, | 
		
	
		
			
				|  |  |  |  |                                               targetUserID: m.searchedChats![index].id!, | 
		
	
		
			
				|  |  |  |  |                                             ); | 
		
	
		
			
				|  |  |  |  |                                           } else if (m.searchedChats![index].isFav == true) { | 
		
	
		
			
				|  |  |  |  |                                             m.unFavoriteUser( | 
		
	
		
			
				|  |  |  |  |                                               userID: AppState().chatDetails!.response!.id!, | 
		
	
		
			
				|  |  |  |  |                                               targetUserID: m.searchedChats![index].id!, | 
		
	
		
			
				|  |  |  |  |                                             ); | 
		
	
		
			
				|  |  |  |  |                                           } else { | 
		
	
		
			
				|  |  |  |  |                                             m.favoriteUser( | 
		
	
		
			
				|  |  |  |  |                                               userID: AppState().chatDetails!.response!.id!, | 
		
	
		
			
				|  |  |  |  |                                               targetUserID: m.searchedChats![index].id!, | 
		
	
		
			
				|  |  |  |  |                                             ); | 
		
	
		
			
				|  |  |  |  |                                           } | 
		
	
		
			
				|  |  |  |  |                                         }, | 
		
	
		
			
				|  |  |  |  |                                       ).center | 
		
	
		
			
				|  |  |  |  |                                     ], | 
		
	
		
			
				|  |  |  |  |                                   ).expanded, | 
		
	
		
			
				|  |  |  |  |                                   SizedBox( | 
		
	
		
			
				|  |  |  |  |                                     width: 60, | 
		
	
		
			
				|  |  |  |  |                                     child: Row( | 
		
	
		
			
				|  |  |  |  |                                       crossAxisAlignment: CrossAxisAlignment.center, | 
		
	
		
			
				|  |  |  |  |                                       mainAxisAlignment: MainAxisAlignment.end, | 
		
	
		
			
				|  |  |  |  |                                       mainAxisSize: MainAxisSize.max, | 
		
	
		
			
				|  |  |  |  |                                       children: <Widget>[ | 
		
	
		
			
				|  |  |  |  |                                         if (m.searchedChats![index].unreadMessageCount! > 0) | 
		
	
		
			
				|  |  |  |  |                                           Container( | 
		
	
		
			
				|  |  |  |  |                                             alignment: Alignment.center, | 
		
	
		
			
				|  |  |  |  |                                             width: 18, | 
		
	
		
			
				|  |  |  |  |                                             height: 18, | 
		
	
		
			
				|  |  |  |  |                                             decoration: const BoxDecoration( | 
		
	
		
			
				|  |  |  |  |                                               color: MyColors.redColor, | 
		
	
		
			
				|  |  |  |  |                                               borderRadius: BorderRadius.all( | 
		
	
		
			
				|  |  |  |  |                                                 Radius.circular(20), | 
		
	
		
			
				|  |  |  |  |                                               ), | 
		
	
		
			
				|  |  |  |  |                                             ), | 
		
	
		
			
				|  |  |  |  |                                             child: (m.searchedChats![index].unreadMessageCount!.toString()) | 
		
	
		
			
				|  |  |  |  |                                                 .toText10( | 
		
	
		
			
				|  |  |  |  |                                                   color: MyColors.white, | 
		
	
		
			
				|  |  |  |  |                                                 ) | 
		
	
		
			
				|  |  |  |  |                                                 .center, | 
		
	
		
			
				|  |  |  |  |                                           ).paddingOnly(right: 10).center, | 
		
	
		
			
				|  |  |  |  |                                         Icon( | 
		
	
		
			
				|  |  |  |  |                                           m.searchedChats![index].isFav != null && m.searchedChats![index].isFav == false ? Icons.star_sharp : Icons.star_sharp, | 
		
	
		
			
				|  |  |  |  |                                           color: m.searchedChats![index].isFav != null && m.searchedChats![index].isFav == true ? MyColors.yellowColor : MyColors.grey35Color, | 
		
	
		
			
				|  |  |  |  |                                         ).onPress( | 
		
	
		
			
				|  |  |  |  |                                           () { | 
		
	
		
			
				|  |  |  |  |                                             if (m.searchedChats![index].isFav == null || m.searchedChats![index].isFav == false) { | 
		
	
		
			
				|  |  |  |  |                                               m.favoriteUser( | 
		
	
		
			
				|  |  |  |  |                                                 userID: AppState().chatDetails!.response!.id!, | 
		
	
		
			
				|  |  |  |  |                                                 targetUserID: m.searchedChats![index].id!, | 
		
	
		
			
				|  |  |  |  |                                               ); | 
		
	
		
			
				|  |  |  |  |                                             } else if (m.searchedChats![index].isFav == true) { | 
		
	
		
			
				|  |  |  |  |                                               m.unFavoriteUser( | 
		
	
		
			
				|  |  |  |  |                                                 userID: AppState().chatDetails!.response!.id!, | 
		
	
		
			
				|  |  |  |  |                                                 targetUserID: m.searchedChats![index].id!, | 
		
	
		
			
				|  |  |  |  |                                               ); | 
		
	
		
			
				|  |  |  |  |                                             } else { | 
		
	
		
			
				|  |  |  |  |                                               m.favoriteUser( | 
		
	
		
			
				|  |  |  |  |                                                 userID: AppState().chatDetails!.response!.id!, | 
		
	
		
			
				|  |  |  |  |                                                 targetUserID: m.searchedChats![index].id!, | 
		
	
		
			
				|  |  |  |  |                                               ); | 
		
	
		
			
				|  |  |  |  |                                             } | 
		
	
		
			
				|  |  |  |  |                                           }, | 
		
	
		
			
				|  |  |  |  |                                         ).center | 
		
	
		
			
				|  |  |  |  |                                       ], | 
		
	
		
			
				|  |  |  |  |                                     ), | 
		
	
		
			
				|  |  |  |  |                                   ), | 
		
	
		
			
				|  |  |  |  |                                 ], | 
		
	
		
			
				|  |  |  |  |                               ), | 
		
	
		
			
				|  |  |  |  |                             ).onPress(() { | 
		
	
		
			
				|  |  |  |  |                               Navigator.pushNamed( | 
		
	
		
			
				|  |  |  |  |                                 context, | 
		
	
		
			
				|  |  |  |  |                                 AppRoutes.chatDetailed, | 
		
	
		
			
				|  |  |  |  |                                 arguments: {"targetUser": m.searchedChats![index], "isNewChat": false}, | 
		
	
		
			
				|  |  |  |  |                               ).then((Object? value) { | 
		
	
		
			
				|  |  |  |  |                                 m.clearSelections(); | 
		
	
		
			
				|  |  |  |  |                                 m.notifyListeners(); | 
		
	
		
			
				|  |  |  |  |                               }); | 
		
	
		
			
				|  |  |  |  |                                 ), | 
		
	
		
			
				|  |  |  |  |                               ], | 
		
	
		
			
				|  |  |  |  |                             ), | 
		
	
		
			
				|  |  |  |  |                           ).onPress(() { | 
		
	
		
			
				|  |  |  |  |                             Navigator.pushNamed( | 
		
	
		
			
				|  |  |  |  |                               context, | 
		
	
		
			
				|  |  |  |  |                               AppRoutes.chatDetailed, | 
		
	
		
			
				|  |  |  |  |                               arguments: {"targetUser": m.searchedChats![index], "isNewChat": false}, | 
		
	
		
			
				|  |  |  |  |                             ).then((Object? value) { | 
		
	
		
			
				|  |  |  |  |                               m.clearSelections(); | 
		
	
		
			
				|  |  |  |  |                               m.notifyListeners(); | 
		
	
		
			
				|  |  |  |  |                             }); | 
		
	
		
			
				|  |  |  |  |                           }, | 
		
	
		
			
				|  |  |  |  |                           separatorBuilder: (BuildContext context, int index) => const Divider(color: MyColors.lightGreyE5Color).paddingOnly(left: 59), | 
		
	
		
			
				|  |  |  |  |                         ), | 
		
	
		
			
				|  |  |  |  |                           }); | 
		
	
		
			
				|  |  |  |  |                         }, | 
		
	
		
			
				|  |  |  |  |                         separatorBuilder: (BuildContext context, int index) => const Divider(color: MyColors.lightGreyE5Color).paddingOnly(left: 59), | 
		
	
		
			
				|  |  |  |  |                       ).expanded, | 
		
	
		
			
				|  |  |  |  |                   ], | 
		
	
		
			
				|  |  |  |  |                 ).paddingOnly(left: 21, right: 21); | 
		
	
	
		
			
				
					|  |  |  | 
 |