From 49bbedda45f0575de4374b85f6ae03fab92064ef Mon Sep 17 00:00:00 2001 From: Prayas-Agrawal Date: Sun, 28 Jan 2024 23:17:26 +0530 Subject: [PATCH] FIX: Communities: Loading About & Featured Posts #47 --- lib/src/blocs/community_post_bloc.dart | 2 +- lib/src/routes/communitydetails.dart | 65 +++++++++++++++----------- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/lib/src/blocs/community_post_bloc.dart b/lib/src/blocs/community_post_bloc.dart index 9ca72ad..1202e39 100644 --- a/lib/src/blocs/community_post_bloc.dart +++ b/lib/src/blocs/community_post_bloc.dart @@ -46,7 +46,7 @@ class CommunityPostBloc { // _communitySubject.add(defCommunities); // print("refresh"); - _communitySubject.add([]); + // _communitySubject.add([]); if (id == null) { return; } diff --git a/lib/src/routes/communitydetails.dart b/lib/src/routes/communitydetails.dart index 44d180d..c16b62c 100644 --- a/lib/src/routes/communitydetails.dart +++ b/lib/src/routes/communitydetails.dart @@ -60,7 +60,6 @@ class _CommunityDetailsState extends State { }); } }); - } @override @@ -297,27 +296,27 @@ class CommunityAboutSectionState extends State { mainAxisSize: MainAxisSize.min, children: [ Container( - child: TabBar( - tabs: [ - Tab( - child: Text( - "About", - style: theme.textTheme.bodyText1, - ), + child: TabBar( + tabs: [ + Tab( + child: Text( + "About", + style: theme.textTheme.bodyText1, ), - Tab( - child: Text( - "Members", - style: theme.textTheme.bodyText1, - ), - ) - ], - onTap: (index) { - setState(() { - _selectedIndex = index; - }); - }, - ), + ), + Tab( + child: Text( + "Members", + style: theme.textTheme.bodyText1, + ), + ) + ], + onTap: (index) { + setState(() { + _selectedIndex = index; + }); + }, + ), ), IndexedStack( children: [ @@ -425,7 +424,11 @@ class CommunityAboutSectionState extends State { Widget _buildFeaturedPosts(ThemeData theme, List? posts) { if (posts == null || posts.isEmpty) { - return Container(); + return Center( + child: CircularProgressIndicatorExtended( + label: Text("Getting Featured Posts"), + ), + ); } return Column( children: [ @@ -494,8 +497,8 @@ class _CommunityPostSectionState extends State { var theme = Theme.of(context); var bloc = BlocProvider.of(context)!.bloc; var communityPostBloc = bloc.communityPostBloc; - - loading=false; + + loading = false; if (firstBuild) { communityPostBloc.query = ""; communityPostBloc.refresh(id: widget.community?.id); @@ -530,8 +533,7 @@ class _CommunityPostSectionState extends State { cpType = CPType.All; }); await communityPostBloc.refresh( - type: CPType.All, - id: widget.community?.id); + type: CPType.All, id: widget.community?.id); setState(() { loading = false; }); @@ -573,8 +575,7 @@ class _CommunityPostSectionState extends State { }); await communityPostBloc.refresh( type: CPType.PendingPosts, - id: widget.community?.id - ); + id: widget.community?.id); setState(() { loading = false; }); @@ -624,6 +625,14 @@ class _CommunityPostSectionState extends State { stream: communityPostBloc.communityposts, builder: (BuildContext context, AsyncSnapshot> snapshot) { + if (snapshot.connectionState == + ConnectionState.waiting) { + return Center( + child: CircularProgressIndicatorExtended( + label: Text("Getting the latest posts"), + ), + ); + } return Column( children: _buildPostList(snapshot, theme, communityPostBloc, community.id),