Chat Favorite Screen & Fixes
							parent
							
								
									ee0e774611
								
							
						
					
					
						commit
						55ff08c3f3
					
				| @ -1,224 +1,103 @@ | ||||
| import 'dart:convert'; | ||||
| 
 | ||||
| import 'package:easy_localization/easy_localization.dart'; | ||||
| import 'package:flutter/cupertino.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:flutter_svg/flutter_svg.dart'; | ||||
| import 'package:mohem_flutter_app/api/chat/chat_provider_model.dart'; | ||||
| import 'package:mohem_flutter_app/app_state/app_state.dart'; | ||||
| import 'package:mohem_flutter_app/classes/colors.dart'; | ||||
| import 'package:mohem_flutter_app/config/routes.dart'; | ||||
| import 'package:mohem_flutter_app/extensions/int_extensions.dart'; | ||||
| import 'package:mohem_flutter_app/extensions/string_extensions.dart'; | ||||
| import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; | ||||
| import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; | ||||
| import 'package:mohem_flutter_app/ui/chat/chat_home_screen.dart'; | ||||
| import 'package:mohem_flutter_app/ui/chat/favorite_users_screen.dart'; | ||||
| import 'package:mohem_flutter_app/ui/screens/items_for_sale/fragments/items_for_sale.dart'; | ||||
| import 'package:mohem_flutter_app/ui/screens/items_for_sale/fragments/my_posted_ads_fragment.dart'; | ||||
| import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; | ||||
| import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; | ||||
| import 'package:mohem_flutter_app/widgets/bottom_sheets/search_employee_bottom_sheet.dart'; | ||||
| import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import 'package:sizer/sizer.dart'; | ||||
| 
 | ||||
| class ChatHomeScreen extends StatefulWidget { | ||||
|   const ChatHomeScreen({Key? key}) : super(key: key); | ||||
| class ChatHome extends StatefulWidget { | ||||
|   const ChatHome({Key? key}) : super(key: key); | ||||
| 
 | ||||
|   @override | ||||
|   State<ChatHomeScreen> createState() => _ChatHomeScreenState(); | ||||
|   State<ChatHome> createState() => _ChatHomeState(); | ||||
| } | ||||
| 
 | ||||
| class _ChatHomeScreenState extends State<ChatHomeScreen> { | ||||
|   TextEditingController search = TextEditingController(); | ||||
|   late ChatProviderModel data; | ||||
| 
 | ||||
|   @override | ||||
|   void initState() { | ||||
|     super.initState(); | ||||
|     data = Provider.of<ChatProviderModel>(context, listen: false); | ||||
|     data.getUserAutoLoginToken().whenComplete(() { | ||||
|       data.getUserRecentChats(); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   void dispose() { | ||||
|     super.dispose(); | ||||
|   } | ||||
| class _ChatHomeState extends State<ChatHome> { | ||||
|   int tabIndex = 0; | ||||
|   PageController controller = PageController(); | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Scaffold( | ||||
|       backgroundColor: Colors.white, | ||||
|       appBar: AppBarWidget(context, title: LocaleKeys.mychats.tr(), showHomeButton: false), | ||||
|       body: Consumer<ChatProviderModel>(builder: (BuildContext context, ChatProviderModel m, Widget? child) { | ||||
|         return m.isLoading | ||||
|             ? ChatHomeShimmer() | ||||
|             : ListView( | ||||
|                 shrinkWrap: true, | ||||
|                 physics: const AlwaysScrollableScrollPhysics(), | ||||
|                 children: [ | ||||
|                   Padding( | ||||
|                     padding: const EdgeInsets.symmetric(vertical: 0, horizontal: 20), | ||||
|                     child: TextField( | ||||
|                       onChanged: (String val) { | ||||
|                         m.filter(val); | ||||
|                       }, | ||||
|                       decoration: InputDecoration( | ||||
|                         border: InputBorder.none, | ||||
|                         focusedBorder: InputBorder.none, | ||||
|                         enabledBorder: OutlineInputBorder( | ||||
|                           borderRadius: BorderRadius.circular(5), | ||||
|                           borderSide: const BorderSide( | ||||
|                             color: Color(0xFFE5E5E5), | ||||
|                           ), | ||||
|                         ), | ||||
|                         errorBorder: InputBorder.none, | ||||
|                         disabledBorder: InputBorder.none, | ||||
|                         contentPadding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), | ||||
|                         hintText: "Search from chat", | ||||
|                         hintStyle: const TextStyle(color: MyColors.lightTextColor, fontStyle: FontStyle.italic), | ||||
|                         filled: true, | ||||
|                         fillColor: const Color(0xFFF7F7F7), | ||||
|                       ), | ||||
|                     ), | ||||
|                   ), | ||||
|                   if (m.searchedChats != null) | ||||
|                     ListView.separated( | ||||
|                       itemCount: m.searchedChats!.length, | ||||
|                       padding: const EdgeInsets.only(top: 20), | ||||
|                       shrinkWrap: true, | ||||
|                       physics: const NeverScrollableScrollPhysics(), | ||||
|                       itemBuilder: (BuildContext context, int index) { | ||||
|                         return SizedBox( | ||||
|                           height: 55, | ||||
|                           child: ListTile( | ||||
|                             leading: Stack( | ||||
|                               children: [ | ||||
|                                 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, | ||||
|                                       borderRadius: const BorderRadius.all( | ||||
|                                         Radius.circular(10), | ||||
|                                       ), | ||||
|                                     ), | ||||
|                                   ), | ||||
|                                 ) | ||||
|                               ], | ||||
|                             ), | ||||
|                             title: (m.searchedChats![index].userName ?? "").toText14(color: MyColors.darkTextColor), | ||||
|                             // subtitle: (m.searchedChats![index].isTyping == true ? "Typing ..." : "").toText11(color: MyColors.normalTextColor), | ||||
|                             trailing: SizedBox( | ||||
|                               width: 60, | ||||
|                               child: Row( | ||||
|                                 crossAxisAlignment: CrossAxisAlignment.center, | ||||
|                                 mainAxisAlignment: MainAxisAlignment.end, | ||||
|                                 mainAxisSize: MainAxisSize.max, | ||||
|                                 children: <Widget>[ | ||||
|                                   if (m.searchedChats![index].unreadMessageCount! > 0) | ||||
|                                     Flexible( | ||||
|                                       child: Container( | ||||
|                                         padding: EdgeInsets.zero, | ||||
|                                         alignment: Alignment.centerRight, | ||||
|                                         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, | ||||
|                                       ), | ||||
|                                     ), | ||||
|                                   Flexible( | ||||
|                                     child: IconButton( | ||||
|                                       alignment: Alignment.centerRight, | ||||
|                                       padding: EdgeInsets.zero, | ||||
|                                       icon: Icon(m.searchedChats![index].isFav! ? Icons.star : Icons.star_border), | ||||
|                                       color: m.searchedChats![index].isFav! ? MyColors.yellowColor : MyColors.grey35Color, | ||||
|                                       onPressed: () { | ||||
|                                         if (m.searchedChats![index].isFav!) m.unFavoriteUser(userID: AppState().chatDetails!.response!.id!, targetUserID: m.searchedChats![index].id!); | ||||
|                                         if (!m.searchedChats![index].isFav!) m.favoriteUser(userID: AppState().chatDetails!.response!.id!, targetUserID: m.searchedChats![index].id!); | ||||
|                                       }, | ||||
|                                     ), | ||||
|                                   ) | ||||
|                                 ], | ||||
|                               ), | ||||
|                             ), | ||||
|                             minVerticalPadding: 0, | ||||
|                             onTap: () { | ||||
|                               Navigator.pushNamed( | ||||
|                                 context, | ||||
|                                 AppRoutes.chatDetailed, | ||||
|                                 arguments: {"targetUser": m.searchedChats![index]}, | ||||
|                               ).then((value) { | ||||
|                                 m.clearSelections(); | ||||
|                               }); | ||||
|                             }, | ||||
|                             onLongPress: () {}, | ||||
|                           ), | ||||
|                         ); | ||||
|                       }, | ||||
|                       separatorBuilder: (BuildContext context, int index) => const Padding( | ||||
|                         padding: EdgeInsets.only(right: 10, left: 70), | ||||
|                         child: Divider( | ||||
|                           color: Color(0xFFE5E5E5), | ||||
|                         ), | ||||
|                       ), | ||||
|                     ), | ||||
|       backgroundColor: MyColors.white, | ||||
|       appBar: AppBarWidget( | ||||
|         context, | ||||
|         title: LocaleKeys.chat.tr(), | ||||
|         showHomeButton: true, | ||||
|       ), | ||||
|       body: Column( | ||||
|         children: [ | ||||
|           Container( | ||||
|             padding: const EdgeInsets.only(left: 21, right: 21, top: 16, bottom: 16), | ||||
|             decoration: const BoxDecoration( | ||||
|               borderRadius: BorderRadius.only( | ||||
|                 bottomLeft: Radius.circular(25), | ||||
|                 bottomRight: Radius.circular(25), | ||||
|               ), | ||||
|               gradient: LinearGradient( | ||||
|                 transform: GradientRotation(.83), | ||||
|                 begin: Alignment.topRight, | ||||
|                 end: Alignment.bottomLeft, | ||||
|                 colors: [ | ||||
|                   MyColors.gradiantEndColor, | ||||
|                   MyColors.gradiantStartColor, | ||||
|                 ], | ||||
|               ); | ||||
|       }), | ||||
|       floatingActionButton: FloatingActionButton( | ||||
|         child: Container( | ||||
|           width: 60, | ||||
|           height: 60, | ||||
|           decoration: const BoxDecoration( | ||||
|             shape: BoxShape.circle, | ||||
|             gradient: LinearGradient( | ||||
|               transform: GradientRotation(.46), | ||||
|               begin: Alignment.topRight, | ||||
|               end: Alignment.bottomLeft, | ||||
|               colors: [ | ||||
|                 MyColors.gradiantEndColor, | ||||
|                 MyColors.gradiantStartColor, | ||||
|               ), | ||||
|             ), | ||||
|             child: Row( | ||||
|               children: [ | ||||
|                 myTab(LocaleKeys.mychats.tr(), 0), | ||||
|                 myTab( | ||||
|                      LocaleKeys.favorite.tr(), | ||||
|                     1) | ||||
|               ], | ||||
|             ), | ||||
|           ), | ||||
|           child: const Icon( | ||||
|             Icons.add, | ||||
|             size: 30, | ||||
|             color: MyColors.white, | ||||
|           ), | ||||
|         ), | ||||
|         onPressed: () async { | ||||
|           showMyBottomSheet( | ||||
|             context, | ||||
|             callBackFunc: () {}, | ||||
|             child: SearchEmployeeBottomSheet( | ||||
|               title: LocaleKeys.searchForEmployee.tr(), | ||||
|               apiMode: LocaleKeys.delegate.tr(), | ||||
|               fromChat: true, | ||||
|               onSelectEmployee: (_selectedEmployee) { | ||||
|                 setState(() {}); | ||||
|               }, | ||||
|             ), | ||||
|           ); | ||||
|         }, | ||||
|           PageView( | ||||
|             controller: controller, | ||||
|             physics: const NeverScrollableScrollPhysics(), | ||||
|             onPageChanged: (int pageIndex) { | ||||
|               setState(() { | ||||
|                 tabIndex = pageIndex; | ||||
|               }); | ||||
|             }, | ||||
|             children: [ChatHomeScreen(), ChatFavoriteUsersScreen()], | ||||
|           ).expanded, | ||||
|         ], | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   Widget myTab(String title, int index) { | ||||
|     bool isSelected = (index == tabIndex); | ||||
|     return Column( | ||||
|       mainAxisSize: MainAxisSize.min, | ||||
|       crossAxisAlignment: CrossAxisAlignment.center, | ||||
|       children: [ | ||||
|         title.toText12(color: isSelected ? MyColors.white : MyColors.white.withOpacity(.74), isCenter: true), | ||||
|         4.height, | ||||
|         Container( | ||||
|           height: 8, | ||||
|           width: 8, | ||||
|           decoration: BoxDecoration( | ||||
|             shape: BoxShape.circle, | ||||
|             color: isSelected ? MyColors.white : Colors.transparent, | ||||
|           ), | ||||
|         ).onPress(() { | ||||
|           setState(() { | ||||
|             // showFabOptions = true; | ||||
|           }); | ||||
|         }) | ||||
|       ], | ||||
|     ).onPress(() { | ||||
|       controller.jumpToPage(index); | ||||
|     }).expanded; | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -0,0 +1,226 @@ | ||||
| import 'package:easy_localization/easy_localization.dart'; | ||||
| import 'package:flutter/cupertino.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:flutter_svg/flutter_svg.dart'; | ||||
| import 'package:mohem_flutter_app/api/chat/chat_provider_model.dart'; | ||||
| import 'package:mohem_flutter_app/app_state/app_state.dart'; | ||||
| import 'package:mohem_flutter_app/classes/colors.dart'; | ||||
| import 'package:mohem_flutter_app/config/routes.dart'; | ||||
| import 'package:mohem_flutter_app/extensions/string_extensions.dart'; | ||||
| import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; | ||||
| import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; | ||||
| import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; | ||||
| import 'package:mohem_flutter_app/widgets/bottom_sheets/search_employee_bottom_sheet.dart'; | ||||
| import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| 
 | ||||
| class ChatHomeScreen extends StatefulWidget { | ||||
|   const ChatHomeScreen({Key? key}) : super(key: key); | ||||
| 
 | ||||
|   @override | ||||
|   State<ChatHomeScreen> createState() => _ChatHomeScreenState(); | ||||
| } | ||||
| 
 | ||||
| class _ChatHomeScreenState extends State<ChatHomeScreen> { | ||||
|   TextEditingController search = TextEditingController(); | ||||
|   late ChatProviderModel data; | ||||
| 
 | ||||
|   @override | ||||
|   void initState() { | ||||
|     super.initState(); | ||||
|     data = Provider.of<ChatProviderModel>(context, listen: false); | ||||
|     data.getUserAutoLoginToken().whenComplete(() { | ||||
|       data.getUserRecentChats(); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   void dispose() { | ||||
|     super.dispose(); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Scaffold( | ||||
|       backgroundColor: MyColors.white, | ||||
|       body: Consumer<ChatProviderModel>(builder: (BuildContext context, ChatProviderModel m, Widget? child) { | ||||
|         return m.isLoading | ||||
|             ? ChatHomeShimmer() | ||||
|             : ListView( | ||||
|                 shrinkWrap: true, | ||||
|                 physics: const AlwaysScrollableScrollPhysics(), | ||||
|                 children: [ | ||||
|                   Padding( | ||||
|                     padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 20), | ||||
|                     child: TextField( | ||||
|                       onChanged: (String val) { | ||||
|                         m.filter(val); | ||||
|                       }, | ||||
|                       decoration: InputDecoration( | ||||
|                         border: OutlineInputBorder( | ||||
|                           borderRadius: BorderRadius.circular(5), | ||||
|                           borderSide: const BorderSide( | ||||
|                             color: Color(0xFFE5E5E5), | ||||
|                           ), | ||||
|                         ), | ||||
|                         focusedBorder: OutlineInputBorder( | ||||
|                           borderRadius: BorderRadius.circular(5), | ||||
|                           borderSide: const BorderSide( | ||||
|                             color: Color(0xFFE5E5E5), | ||||
|                           ), | ||||
|                         ), | ||||
|                         enabledBorder: OutlineInputBorder( | ||||
|                           borderRadius: BorderRadius.circular(5), | ||||
|                           borderSide: const BorderSide( | ||||
|                             color: Color(0xFFE5E5E5), | ||||
|                           ), | ||||
|                         ), | ||||
|                         contentPadding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), | ||||
|                         hintText: LocaleKeys.searchfromchat.tr(), | ||||
|                         hintStyle: const TextStyle(color: MyColors.lightTextColor, fontStyle: FontStyle.italic), | ||||
|                         filled: true, | ||||
|                         fillColor: const Color(0xFFF7F7F7), | ||||
|                       ), | ||||
|                     ), | ||||
|                   ), | ||||
|                   if (m.searchedChats != null) | ||||
|                     ListView.separated( | ||||
|                       itemCount: m.searchedChats!.length, | ||||
|                       padding: const EdgeInsets.only(bottom: 80), | ||||
|                       shrinkWrap: true, | ||||
|                       physics: const NeverScrollableScrollPhysics(), | ||||
|                       itemBuilder: (BuildContext context, int index) { | ||||
|                         return SizedBox( | ||||
|                           height: 55, | ||||
|                           child: ListTile( | ||||
|                             leading: Stack( | ||||
|                               children: [ | ||||
|                                 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, | ||||
|                                       borderRadius: const BorderRadius.all( | ||||
|                                         Radius.circular(10), | ||||
|                                       ), | ||||
|                                     ), | ||||
|                                   ), | ||||
|                                 ) | ||||
|                               ], | ||||
|                             ), | ||||
|                             title: (m.searchedChats![index].userName ?? "").toText14(color: MyColors.darkTextColor), | ||||
|                             // subtitle: (m.searchedChats![index].isTyping == true ? "Typing ..." : "").toText11(color: MyColors.normalTextColor), | ||||
|                             trailing: SizedBox( | ||||
|                               width: 60, | ||||
|                               child: Row( | ||||
|                                 crossAxisAlignment: CrossAxisAlignment.center, | ||||
|                                 mainAxisAlignment: MainAxisAlignment.end, | ||||
|                                 mainAxisSize: MainAxisSize.max, | ||||
|                                 children: <Widget>[ | ||||
|                                   if (m.searchedChats![index].unreadMessageCount! > 0) | ||||
|                                     Flexible( | ||||
|                                       child: Container( | ||||
|                                         padding: EdgeInsets.zero, | ||||
|                                         alignment: Alignment.centerRight, | ||||
|                                         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, | ||||
|                                       ), | ||||
|                                     ), | ||||
|                                   Flexible( | ||||
|                                     child: IconButton( | ||||
|                                       alignment: Alignment.centerRight, | ||||
|                                       padding: EdgeInsets.zero, | ||||
|                                       icon: Icon(m.searchedChats![index].isFav! ? Icons.star : Icons.star_border), | ||||
|                                       color: m.searchedChats![index].isFav! ? MyColors.yellowColor : MyColors.grey35Color, | ||||
|                                       onPressed: () { | ||||
|                                         if (m.searchedChats![index].isFav!) m.unFavoriteUser(userID: AppState().chatDetails!.response!.id!, targetUserID: m.searchedChats![index].id!); | ||||
|                                         if (!m.searchedChats![index].isFav!) m.favoriteUser(userID: AppState().chatDetails!.response!.id!, targetUserID: m.searchedChats![index].id!); | ||||
|                                       }, | ||||
|                                     ), | ||||
|                                   ) | ||||
|                                 ], | ||||
|                               ), | ||||
|                             ), | ||||
|                             minVerticalPadding: 0, | ||||
|                             onTap: () { | ||||
|                               Navigator.pushNamed( | ||||
|                                 context, | ||||
|                                 AppRoutes.chatDetailed, | ||||
|                                 arguments: {"targetUser": m.searchedChats![index]}, | ||||
|                               ).then((value) { | ||||
|                                 m.clearSelections(); | ||||
|                               }); | ||||
|                             }, | ||||
|                             onLongPress: () {}, | ||||
|                           ), | ||||
|                         ); | ||||
|                       }, | ||||
|                       separatorBuilder: (BuildContext context, int index) => const Padding( | ||||
|                         padding: EdgeInsets.only(right: 10, left: 70), | ||||
|                         child: Divider( | ||||
|                           color: Color(0xFFE5E5E5), | ||||
|                         ), | ||||
|                       ), | ||||
|                     ), | ||||
|                 ], | ||||
|               ); | ||||
|       }), | ||||
|       floatingActionButton: FloatingActionButton( | ||||
|         child: Container( | ||||
|           width: 60, | ||||
|           height: 60, | ||||
|           decoration: const BoxDecoration( | ||||
|             shape: BoxShape.circle, | ||||
|             gradient: LinearGradient( | ||||
|               transform: GradientRotation(.46), | ||||
|               begin: Alignment.topRight, | ||||
|               end: Alignment.bottomLeft, | ||||
|               colors: [ | ||||
|                 MyColors.gradiantEndColor, | ||||
|                 MyColors.gradiantStartColor, | ||||
|               ], | ||||
|             ), | ||||
|           ), | ||||
|           child: const Icon( | ||||
|             Icons.add, | ||||
|             size: 30, | ||||
|             color: MyColors.white, | ||||
|           ), | ||||
|         ), | ||||
|         onPressed: () async { | ||||
|           showMyBottomSheet( | ||||
|             context, | ||||
|             callBackFunc: () {}, | ||||
|             child: SearchEmployeeBottomSheet( | ||||
|               title: LocaleKeys.searchForEmployee.tr(), | ||||
|               apiMode: LocaleKeys.delegate.tr(), | ||||
|               fromChat: true, | ||||
|               onSelectEmployee: (_selectedEmployee) { | ||||
|                 setState(() {}); | ||||
|               }, | ||||
|             ), | ||||
|           ); | ||||
|         }, | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,102 @@ | ||||
| import 'package:flutter/cupertino.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:flutter_svg/flutter_svg.dart'; | ||||
| import 'package:mohem_flutter_app/api/chat/chat_provider_model.dart'; | ||||
| import 'package:mohem_flutter_app/app_state/app_state.dart'; | ||||
| import 'package:mohem_flutter_app/classes/colors.dart'; | ||||
| import 'package:mohem_flutter_app/classes/utils.dart'; | ||||
| import 'package:mohem_flutter_app/config/routes.dart'; | ||||
| import 'package:mohem_flutter_app/extensions/string_extensions.dart'; | ||||
| import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; | ||||
| import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| 
 | ||||
| class ChatFavoriteUsersScreen extends StatelessWidget { | ||||
|   const ChatFavoriteUsersScreen({Key? key}) : super(key: key); | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     // TODO: implement build | ||||
|     return Scaffold( | ||||
|       backgroundColor: MyColors.white, | ||||
|       body: Consumer<ChatProviderModel>(builder: (BuildContext context, ChatProviderModel m, Widget? child) { | ||||
|         return m.isLoading | ||||
|             ? ChatHomeShimmer() | ||||
|             : ListView( | ||||
|                 shrinkWrap: true, | ||||
|                 physics: const AlwaysScrollableScrollPhysics(), | ||||
|                 padding: const EdgeInsets.only(top: 20), | ||||
|                 children: [ | ||||
|                   if (m.favUsersList != null && m.favUsersList.isNotEmpty) | ||||
|                     ListView.separated( | ||||
|                       itemCount: m.favUsersList!.length, | ||||
|                       padding: EdgeInsets.zero, | ||||
|                       shrinkWrap: true, | ||||
|                       physics: const NeverScrollableScrollPhysics(), | ||||
|                       itemBuilder: (BuildContext context, int index) { | ||||
|                         return SizedBox( | ||||
|                           height: 55, | ||||
|                           child: ListTile( | ||||
|                             leading: Stack( | ||||
|                               children: [ | ||||
|                                 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.favUsersList![index].userStatus == 1 ? MyColors.green2DColor : Colors.red, | ||||
|                                       borderRadius: const BorderRadius.all( | ||||
|                                         Radius.circular(10), | ||||
|                                       ), | ||||
|                                     ), | ||||
|                                   ), | ||||
|                                 ) | ||||
|                               ], | ||||
|                             ), | ||||
|                             title: (m.favUsersList![index].userName ?? "").toText14(color: MyColors.darkTextColor), | ||||
|                             // subtitle: (m.searchedChats![index].isTyping == true ? "Typing ..." : "").toText11(color: MyColors.normalTextColor), | ||||
|                             trailing: IconButton( | ||||
|                               alignment: Alignment.centerRight, | ||||
|                               padding: EdgeInsets.zero, | ||||
|                               icon: Icon(m.favUsersList![index].isFav! ? Icons.star : Icons.star_border), | ||||
|                               color: m.favUsersList![index].isFav! ? MyColors.yellowColor : MyColors.grey35Color, | ||||
|                               onPressed: () { | ||||
|                                 if (m.favUsersList![index].isFav!) m.unFavoriteUser(userID: AppState().chatDetails!.response!.id!, targetUserID: m.favUsersList![index].id!); | ||||
|                               }, | ||||
|                             ), | ||||
|                             minVerticalPadding: 0, | ||||
|                             onTap: () { | ||||
|                               Navigator.pushNamed( | ||||
|                                 context, | ||||
|                                 AppRoutes.chatDetailed, | ||||
|                                 arguments: {"targetUser": m.favUsersList![index]}, | ||||
|                               ).then((value) { | ||||
|                                 m.clearSelections(); | ||||
|                               }); | ||||
|                             }, | ||||
|                             onLongPress: () {}, | ||||
|                           ), | ||||
|                         ); | ||||
|                       }, | ||||
|                       separatorBuilder: (BuildContext context, int index) => const Padding( | ||||
|                         padding: EdgeInsets.only(right: 10, left: 70), | ||||
|                         child: Divider( | ||||
|                           color: Color(0xFFE5E5E5), | ||||
|                         ), | ||||
|                       ), | ||||
|                     ) | ||||
|                   else | ||||
|                     Utils.getNoDataWidget(context).expanded | ||||
|                 ], | ||||
|               ); | ||||
|       }), | ||||
|     ); | ||||
|   } | ||||
| } | ||||
					Loading…
					
					
				
		Reference in New Issue