diff --git a/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart b/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart index de00af8..37959a7 100644 --- a/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart +++ b/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart @@ -1,30 +1,23 @@ import 'dart:developer'; import 'package:flutter/material.dart'; -import 'package:flutter_reaction_button/flutter_reaction_button.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:regroup/Common/CommonGlassmorphism.dart'; import 'package:regroup/Common/CommonTabBar.dart'; -import 'package:regroup/Common/CommonWidget.dart'; import 'package:regroup/Common/ConvertServerDateToUserDate.dart'; import 'package:regroup/Common/base_manager.dart'; import 'package:regroup/Common/controller/NormalPostCard.dart'; import 'package:regroup/Main_Screens/Community/Model/CommonDatumObjModel.dart'; import 'package:regroup/Main_Screens/Community/Model/fetchicons.dart'; import 'package:regroup/Main_Screens/Community/ViewModel/getmethod.dart'; -import 'package:regroup/Main_Screens/Community/ViewModel/postmethod.dart'; -import 'package:regroup/Main_Screens/Community_HomePage/Community.dart'; + import 'package:regroup/Main_Screens/Community_HomePage/view_model/CountersHelper.dart'; import 'package:regroup/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart'; -import 'package:regroup/Main_Screens/Community_HomePage/view_model/communitypostmethod.dart'; import 'package:regroup/Utils/Common/CommonAppbar.dart'; import 'package:regroup/Utils/Common/ShimmerCommon.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; import 'package:regroup/Utils/dialogs.dart'; -import 'package:regroup/Utils/texts.dart'; -import 'package:regroup/resources/routes/route_name.dart'; -import 'package:async/src/future_group.dart'; + import 'package:regroup/sidemenu/view_model/postmethod.dart'; class TagdetailScreen extends StatefulWidget { @@ -130,16 +123,16 @@ class _TagdetailScreenState extends State { } class PopularTab extends StatefulWidget { - PopularTab({super.key, required this.id}); + const PopularTab({super.key, required this.id}); - int id; + final int id; @override State createState() => _PopularTabState(); } class _PopularTabState extends State { - late Future futureGroup; + List _reactions = []; final Map _selectedReactions = {}; final CountersHelper countersHelper = Get.find(); @@ -147,12 +140,12 @@ class _PopularTabState extends State { @override void initState() { - futureGroup = Communitygetmethod().getPopularTagsdata(widget.id); + super.initState(); } - Future _fetchIcons() async { + _fetchIcons() { _reactions = fetchlikeIconsModel!.data ?? []; for (var post in commonobjmodel!.data) { //Check if post as a like icon @@ -174,14 +167,9 @@ class _PopularTabState extends State { } Future setValues() async { - WidgetsBinding.instance.addPostFrameCallback((_) { - _setModel(); - countersHelper.setListsPopular(); - _fetchIcons(); - Future.delayed(const Duration(milliseconds: 500), () { - setState(() {}); - }); - }); + _setModel(); + countersHelper.setListsPopular(); + _fetchIcons(); } _sortTags(index) { @@ -252,10 +240,15 @@ class _PopularTabState extends State { .toList()); } + Future _initialize() async { + await Communitygetmethod().getPopularTagsdata(widget.id); + await setValues(); + } + @override Widget build(BuildContext context) { return FutureBuilder( - future: futureGroup, + future: _initialize(), builder: (ctx, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return const Center(child: ShimmerCommon()); @@ -270,9 +263,8 @@ class _PopularTabState extends State { ); } - if (snapshot.connectionState == ConnectionState.done && - snapshot.hasData) { - setValues(); + if (snapshot.connectionState == ConnectionState.done) { + return Stack(clipBehavior: Clip.none, children: [ Container( decoration: const BoxDecoration( @@ -357,16 +349,15 @@ class _PopularTabState extends State { } class LatestTab extends StatefulWidget { - LatestTab({super.key, required this.id}); + const LatestTab({super.key, required this.id}); - int id; + final int id; @override State createState() => _LatestTabState(); } class _LatestTabState extends State { - late Future latestfuture; List _reactions = []; final Map _selectedReactions = {}; final CountersHelper countersHelper = Get.find(); @@ -374,9 +365,6 @@ class _LatestTabState extends State { @override void initState() { - // tagdetailobj - latestfuture = Communitygetmethod().getTagsdata(widget.id); - super.initState(); } @@ -402,15 +390,9 @@ class _LatestTabState extends State { } Future setValues() async { - // WidgetsBinding.instance.addPostFrameCallback((_) {}); - WidgetsBinding.instance.addPostFrameCallback((_) { - _setModel(); - countersHelper.setListsPopular(); - _fetchIcons(); - }); - Future.delayed(const Duration(milliseconds: 500), () { - setState(() {}); - }); + _setModel(); + countersHelper.setListsPopular(); + _fetchIcons(); } _sortTags(index) { @@ -481,10 +463,15 @@ class _LatestTabState extends State { .toList()); } + Future _initialize() async { + await Communitygetmethod().getTagsdata(widget.id); + await setValues(); + } + @override Widget build(BuildContext context) { return FutureBuilder( - future: latestfuture, + future: _initialize(), builder: (ctx, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return const Center(child: ShimmerCommon()); @@ -499,9 +486,7 @@ class _LatestTabState extends State { ); } - if (snapshot.connectionState == ConnectionState.done && - snapshot.hasData) { - setValues(); + if (snapshot.connectionState == ConnectionState.done) { return Stack(clipBehavior: Clip.none, children: [ Container( decoration: const BoxDecoration( diff --git a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart index 94cb427..de95421 100644 --- a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart +++ b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart @@ -111,8 +111,9 @@ class _CommunityDetailsState extends State { color: const Color(0xFF222935), tooltip: "", itemBuilder: (BuildContext context) { - bool isMember = - comdetailobj?.data?.userLinkInCommunity?.userTypeXid?.name == "Member"; + bool isMember = comdetailobj + ?.data?.userLinkInCommunity?.userTypeXid?.name == + "Member"; // => return >[ PopupMenuItem( @@ -748,7 +749,6 @@ class PostsTab extends StatefulWidget { } class _PostsTabState extends State { - late Future postDetailfuture; List _reactions = []; final Map _selectedReactions = {}; final CountersHelper countersHelper = Get.find(); @@ -757,7 +757,6 @@ class _PostsTabState extends State { @override void initState() { CommunityId = Get.arguments["CommunityID"]; - postDetailfuture = CommunityDetail().getComPostApi(CommunityId); super.initState(); } @@ -783,14 +782,9 @@ class _PostsTabState extends State { } Future setValues() async { - WidgetsBinding.instance.addPostFrameCallback((_) { - _setModel(); - countersHelper.setListsPopular(); - _fetchIcons(); - Future.delayed(const Duration(milliseconds: 500), () { - setState(() {}); - }); - }); + _setModel(); + countersHelper.setListsPopular(); + _fetchIcons(); } _sortTags(index) { @@ -861,10 +855,15 @@ class _PostsTabState extends State { .toList()); } + Future _initialize() async { + await CommunityDetail().getComPostApi(CommunityId); + await setValues(); + } + @override Widget build(BuildContext context) { return FutureBuilder( - future: postDetailfuture, + future: _initialize(), builder: (ctx, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return const Center( @@ -883,9 +882,7 @@ class _PostsTabState extends State { ); } - if (snapshot.connectionState == ConnectionState.done && - snapshot.hasData) { - setValues(); + if (snapshot.connectionState == ConnectionState.done) { return Stack(clipBehavior: Clip.none, children: [ Container( decoration: const BoxDecoration(