From 0f13ab65d67473fe808482bde87c105c1b65175d Mon Sep 17 00:00:00 2001 From: "Aamir.Muhammad" Date: Mon, 5 Dec 2022 16:02:21 +0300 Subject: [PATCH] Chat Fixes & User Chat Counter --- lib/provider/dashboard_provider_model.dart | 26 +++---- lib/ui/chat/chat_detailed_screen.dart | 2 +- lib/ui/chat/chat_full_image_preview.dart | 6 +- lib/ui/chat/chat_home_screen.dart | 9 ++- lib/ui/chat/favorite_users_screen.dart | 5 +- lib/widgets/app_bar_widget.dart | 7 -- .../shimmer/dashboard_shimmer_widget.dart | 76 ++++++++++--------- 7 files changed, 64 insertions(+), 67 deletions(-) diff --git a/lib/provider/dashboard_provider_model.dart b/lib/provider/dashboard_provider_model.dart index 461196f..5d6a53e 100644 --- a/lib/provider/dashboard_provider_model.dart +++ b/lib/provider/dashboard_provider_model.dart @@ -307,19 +307,19 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { Future getHubConnection() async { HubConnection hub; - try { - HttpConnectionOptions httpOp = HttpConnectionOptions(skipNegotiation: false, logMessageContent: true); - hub = HubConnectionBuilder() - .withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${AppState().chatDetails!.response!.id}&source=Web&access_token=${AppState().chatDetails!.response!.token}", options: httpOp) - .withAutomaticReconnect(retryDelays: [2000, 5000, 10000, 20000]).build(); - isChatHubLoding = false; - return hub; - } catch (e) { - getUserAutoLoginToken().whenComplete(() { - getHubConnection(); - }); - throw e; - } + // try { + HttpConnectionOptions httpOp = HttpConnectionOptions(skipNegotiation: false, logMessageContent: true); + hub = HubConnectionBuilder() + .withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${AppState().chatDetails!.response!.id}&source=Web&access_token=${AppState().chatDetails!.response!.token}", options: httpOp) + .withAutomaticReconnect(retryDelays: [2000, 5000, 10000, 20000]).build(); + isChatHubLoding = false; + return hub; + // } catch (e) { + // getUserAutoLoginToken().whenComplete(() { + // getHubConnection(); + // }); + // throw e; + // } } void notify() { diff --git a/lib/ui/chat/chat_detailed_screen.dart b/lib/ui/chat/chat_detailed_screen.dart index 345884f..905bffa 100644 --- a/lib/ui/chat/chat_detailed_screen.dart +++ b/lib/ui/chat/chat_detailed_screen.dart @@ -90,7 +90,7 @@ class _ChatDetailScreenState extends State { body: Consumer( builder: (BuildContext context, ChatProviderModel m, Widget? child) { return (m.isLoading - ? ChatHomeShimmer() + ? ChatHomeShimmer(isDetailedScreen: true,) : Column( children: [ SmartRefresher( diff --git a/lib/ui/chat/chat_full_image_preview.dart b/lib/ui/chat/chat_full_image_preview.dart index c731c25..6c8073f 100644 --- a/lib/ui/chat/chat_full_image_preview.dart +++ b/lib/ui/chat/chat_full_image_preview.dart @@ -21,9 +21,9 @@ class ChatImagePreviewScreen extends StatelessWidget { children: [ Image.memory( img, - fit: BoxFit.cover, - height: 400, - width: double.infinity, + fit: BoxFit.fill, + height:500, + width: 500, ).paddingAll(15), Positioned( right: 0, diff --git a/lib/ui/chat/chat_home_screen.dart b/lib/ui/chat/chat_home_screen.dart index 73c084a..641c13d 100644 --- a/lib/ui/chat/chat_home_screen.dart +++ b/lib/ui/chat/chat_home_screen.dart @@ -21,6 +21,8 @@ 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 createState() => _ChatHomeScreenState(); } @@ -48,7 +50,7 @@ class _ChatHomeScreenState extends State { body: Consumer( builder: (BuildContext context, ChatProviderModel m, Widget? child) { return m.isLoading - ? ChatHomeShimmer() + ? ChatHomeShimmer(isDetailedScreen: false,) : Column( children: [ TextField( @@ -84,7 +86,7 @@ class _ChatHomeScreenState extends State { itemCount: m.searchedChats!.length, shrinkWrap: true, physics: const ClampingScrollPhysics(), - padding: EdgeInsets.only(bottom: 80.0), + padding: const EdgeInsets.only(bottom: 80.0), itemBuilder: (BuildContext context, int index) { return SizedBox( height: 55, @@ -96,8 +98,7 @@ class _ChatHomeScreenState extends State { const SizedBox( height: 48, width: 48, - child: Center(child: CircularProgressIndicator()), - ), + ).toShimmer().circle(30), if (m.searchedChats![index].isImageLoaded! && m.searchedChats![index].image != null && m.searchedChats![index].image.isNotEmpty) CircularAvatar( radius: 20, diff --git a/lib/ui/chat/favorite_users_screen.dart b/lib/ui/chat/favorite_users_screen.dart index 8bfcc4a..6034151 100644 --- a/lib/ui/chat/favorite_users_screen.dart +++ b/lib/ui/chat/favorite_users_screen.dart @@ -23,7 +23,7 @@ class ChatFavoriteUsersScreen extends StatelessWidget { body: Consumer( builder: (BuildContext context, ChatProviderModel m, Widget? child) { if (m.isLoading) { - return ChatHomeShimmer(); + return ChatHomeShimmer(isDetailedScreen: false,); } else { return m.favUsersList != null && m.favUsersList.isNotEmpty ? ListView.separated( @@ -41,8 +41,7 @@ class ChatFavoriteUsersScreen extends StatelessWidget { const SizedBox( height: 48, width: 48, - child: Center(child: CircularProgressIndicator()), - ), + ).toShimmer().circle(30), if (m.favUsersList![index].isImageLoaded! && m.favUsersList![index].image != null && m.favUsersList![index].image.isNotEmpty) CircularAvatar( radius: 20, diff --git a/lib/widgets/app_bar_widget.dart b/lib/widgets/app_bar_widget.dart index d18d7e6..29c94d2 100644 --- a/lib/widgets/app_bar_widget.dart +++ b/lib/widgets/app_bar_widget.dart @@ -32,14 +32,7 @@ AppBar AppBarWidget(BuildContext context, width: 40, isImageBase64: true, ), - if (image == null) - SvgPicture.asset( - "assets/images/user.svg", - height: 40, - width: 40, - ), if (image != null) 14.width, - if (image == null) 14.width, title.toText24(color: MyColors.darkTextColor, isBold: true).expanded, ], ), diff --git a/lib/widgets/shimmer/dashboard_shimmer_widget.dart b/lib/widgets/shimmer/dashboard_shimmer_widget.dart index 6fe5a03..fc243f0 100644 --- a/lib/widgets/shimmer/dashboard_shimmer_widget.dart +++ b/lib/widgets/shimmer/dashboard_shimmer_widget.dart @@ -188,7 +188,6 @@ class ServicesMenuShimmer extends StatelessWidget { } } - class MarathonBannerShimmer extends StatelessWidget { const MarathonBannerShimmer({Key? key}) : super(key: key); @@ -236,6 +235,11 @@ class MarathonBannerShimmer extends StatelessWidget { } class ChatHomeShimmer extends StatelessWidget { + bool isDetailedScreen; + + ChatHomeShimmer({Key? key, required this.isDetailedScreen}) : super(key: key); + + @override @override Widget build(BuildContext context) { return Container( @@ -254,42 +258,42 @@ class ChatHomeShimmer extends StatelessWidget { child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - width: 48.0, - height: 48.0, - decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(40))), - ), - const Padding( - padding: EdgeInsets.symmetric(horizontal: 8.0), - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: double.infinity, - height: 8.0, - color: Colors.white, - ), - const Padding( - padding: EdgeInsets.symmetric(vertical: 2.0), - ), - Container( - width: double.infinity, - height: 8.0, - color: Colors.white, - ), - const Padding( - padding: EdgeInsets.symmetric(vertical: 2.0), - ), - Container( - width: 40.0, - height: 8.0, - color: Colors.white, - ), - ], + if (!isDetailedScreen) + Container( + width: 48.0, + height: 48.0, + decoration: const BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(40))), + ), + if (!isDetailedScreen) + const Padding( + padding: EdgeInsets.symmetric(horizontal: 8.0), ), - ) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: double.infinity, + height: 8.0, + color: Colors.white, + ), + const Padding( + padding: EdgeInsets.symmetric(vertical: 2.0), + ), + Container( + width: double.infinity, + height: 8.0, + color: Colors.white, + ), + const Padding( + padding: EdgeInsets.symmetric(vertical: 2.0), + ), + Container( + width: 40.0, + height: 8.0, + color: Colors.white, + ), + ], + ).expanded ], ), ),