diff --git a/lib/Common/CommonWidget.dart b/lib/Common/CommonWidget.dart index c17bee3..6d6c8d2 100644 --- a/lib/Common/CommonWidget.dart +++ b/lib/Common/CommonWidget.dart @@ -22,7 +22,7 @@ class TextInputField extends StatefulWidget { class _TextInputFieldState extends State { @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: double.infinity, height: 46.h, child: TextFormField( @@ -274,7 +274,7 @@ Widget stackContainersGroups({ const maxImagesToShow = 3; // Calculate the number of images to show and the remaining count - final remainingCount = containerImages.length - maxImagesToShow; + // final remainingCount = containerImages.length - maxImagesToShow; final imagesToShow = containerImages.take(maxImagesToShow).toList(); return Row( @@ -304,7 +304,7 @@ Widget stackContainersGroups({ ), ), ) - : Container( + : SizedBox( height: 30.h, width: 30.w, ), diff --git a/lib/Common/api_urls.dart b/lib/Common/api_urls.dart index 6bbed48..c62be9c 100644 --- a/lib/Common/api_urls.dart +++ b/lib/Common/api_urls.dart @@ -99,6 +99,8 @@ class ApiUrls { static const getInvitecommunity = "${baseUrl}fetch-all-invite"; + static const postnewinterest = "${baseUrl}store-tags"; + static const postcancelrequest = "${baseUrl}cancel-request-of-community"; static const postacceptinvite = "${baseUrl}accept-invite-to-join-community"; diff --git a/lib/Common/controller/NormalPostCard.dart b/lib/Common/controller/NormalPostCard.dart new file mode 100644 index 0000000..6096b92 --- /dev/null +++ b/lib/Common/controller/NormalPostCard.dart @@ -0,0 +1,662 @@ +import 'dart:developer'; + +import 'package:cached_network_image/cached_network_image.dart'; +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/CommonWidget.dart'; +import 'package:regroup/Common/base_manager.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/postmethod.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/view_model/CountersHelper.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/view_model/communitypostmethod.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:regroup/sidemenu/view_model/postmethod.dart'; + +class NormalCardTile extends StatefulWidget { + List tags; + String? createAt; + CommonDatumObjModelData commonObj; + String forWhichTab; + List reactions; + Map selectedReactions; + bool? coachbool; + + int currentIndex; + NormalCardTile({ + Key? key, + required this.tags, + this.createAt, + required this.forWhichTab, + required this.commonObj, + required this.reactions, + required this.selectedReactions, + required this.currentIndex, + this.coachbool + }) : super(key: key); + + @override + _NormalCardTileState createState() => _NormalCardTileState(); +} + +class _NormalCardTileState extends State { + + RxString mainImage = 'assets/images/png/uiw_like-o.png'.obs; + final CountersHelper countersHelper = Get.find(); + int saveCount = 0; + _handleReactionChange(Reaction? reaction) async { + if (widget.selectedReactions[widget.commonObj.id] != null && + reaction?.value == + widget.selectedReactions[widget.commonObj.id]!.id.toString() || + reaction?.value == null) { + // User tapped on the currently selected reaction, so remove it + + //api call for dislike + + await LikeUploaddata( + widget.selectedReactions[widget.commonObj.id]?.id, + widget.commonObj.id!, + ); + setState(() { + widget.selectedReactions[widget.commonObj.id!] = null; + //decrement gloally + countersHelper.likesCounterPopular[widget.currentIndex]--; + log("global value ${countersHelper.likesCounterPopular[widget.currentIndex]}"); + }); + } else { + // User selected a new reaction + var newSelectedReaction = widget.reactions.firstWhere( + (r) => r.id.toString() == reaction?.value, + orElse: () => widget.reactions.first, // Default reaction if not found + ); + await _handleReactionChangeApiCall( + newSelectedReaction, widget.commonObj.id!); + } + } + + Future _handleReactionChangeApiCall( + ReactionData? reaction, int postId) async { + setState(() { + widget.selectedReactions[postId] = + reaction; // Set the selected reaction for this post + + if (countersHelper.likesCounterPopular[widget.currentIndex] <= + widget.commonObj.totalReactionCount!) { + countersHelper.likesCounterPopular[widget.currentIndex]++; + } + }); + + await LikeUploaddata( + reaction?.id, + postId, + ); + } + + LikeUploaddata(int? likeIconId, int? postid) async { + Map updata = { + "manage_posts_xid": postid, + "like_icons_xid": likeIconId ?? '', + }; + final data = await CommunitypostMethod().postLikepost(updata); + if (data.status == ResponseStatus.SUCCESS) { + // return utils.showToast(data.message); + } else { + return utils.showToast(data.message); + } + } + + void updateImage(String reaction) { + switch (reaction) { + case 'like': + mainImage.value = 'assets/images/png/f7_hand-thumbsup.png'; + break; + case 'heart': + mainImage.value = 'assets/images/png/heart 2.png'; + break; + case 'party': + mainImage.value = 'assets/images/png/party-popper 2.png'; + break; + default: + // Handle any other cases or do nothing + break; + } + } + + saveunsavepost(int popularpostid) async { + // utils.loader(); + Map updata = { + "manage_posts_xid": popularpostid, + }; + final data = await Communitypostmethod().postUserSave(updata); + if (data.status == ResponseStatus.SUCCESS) { + if (countersHelper.saveButtonPopular[widget.currentIndex] == false) { + countersHelper.savePostCounterPopular[widget.currentIndex]++; + } else { + countersHelper.savePostCounterPopular[widget.currentIndex]--; + } + countersHelper.saveButtonPopular[widget.currentIndex] = + !countersHelper.saveButtonPopular[widget.currentIndex]; + return utils.showToast(data.message); + } else { + return utils.showToast(data.message); + } + } + + pinunpinUser(int userid) async { + Map updata = { + "pin_iam_principal_xid": userid, + }; + final data = await SidebarTags().postUserpin(updata); + if (data.status == ResponseStatus.SUCCESS) { + countersHelper.pinButtonPopular[widget.currentIndex] = + !countersHelper.pinButtonPopular[widget.currentIndex]; + countersHelper.updateFeedsPage.value = + !countersHelper.updateFeedsPage.value; + return utils.showToast(data.message); + } else { + return utils.showToast(data.message); + } + } + + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + var imgUrl = widget.commonObj.image! + .split( + "https://regroup.betadelivery.com/storage/app/public/uploads/post_image/") + .last; + return commonGlassUI( + width: double.infinity, + height: 765.h, + mainOpacity: 1, + borderRadius: BorderRadius.circular(1), + customWidget: Column( + children: [ + sizedBoxHeight(25.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CircleAvatar( + backgroundImage: widget + .commonObj.iamPrincipal?.profilePhoto != + null + ? NetworkImage( + widget.commonObj.iamPrincipal!.profilePhoto!) + as ImageProvider + : const AssetImage('assets/images/default_profile.png') + as ImageProvider, + radius: 25.r, + ), + sizedBoxWidth(12.w), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + text16w400_FCFCFC( + widget.commonObj.iamPrincipal!.fullName ?? + "Regroup"), + sizedBoxWidth(10.w), + widget.coachbool == true + ? Container( + width: 75.w, + height: 25.h, + decoration: BoxDecoration( + border: Border.all( + color: const Color(0xFFD90B2E), + width: 1.w, + ), + borderRadius: BorderRadius.circular(5.r), + ), + child: + Center(child: text12w400_FCFCFC("Coach")), + ) + : const SizedBox(), + ], + ), + sizedBoxHeight(5.h), + Row( + children: [ + Image.asset( + 'assets/images/png/community 1 (traced).png', + height: 14.w, + width: 14.w, + ), + sizedBoxWidth(7.w), + text12w400_FCFCFC( + widget.commonObj.community!.communityName ?? ""), + sizedBoxWidth(7.w), + Icon( + Icons.circle, + color: const Color(0xFFFCFCFC), + size: 4.sp, + ), + sizedBoxWidth(6.w), + text12w400_FCFCFC(widget.createAt!), + ], + ) + ], + ), + const Spacer(), + PopupMenuButton( + surfaceTintColor: const Color(0xFF222935), + constraints: BoxConstraints.tightFor(width: 176.w), + offset: const Offset(0, 50), + color: const Color(0xFF222935), + tooltip: "", + itemBuilder: (BuildContext context) => [ + PopupMenuItem( + onTap: () {}, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 12.w), + child: Row( + children: [ + Text( + 'Report Post', + style: TextStyle( + fontSize: 16.sp, + color: Colors.white, + fontWeight: FontWeight.w800, + fontFamily: "Nunito Sans", + ), + ), + const Spacer(), + Image.asset( + "assets/images/png/Vector (5).png", + height: 15.h, + width: 15.w, + ) + ], + ), + ), + ), + const PopupMenuDivider(), + PopupMenuItem( + onTap: () {}, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 12.w), + child: Row( + children: [ + Text( + 'Share post', + style: TextStyle( + fontSize: 16.sp, + color: Colors.white, + fontWeight: FontWeight.w800, + fontFamily: "Nunito Sans", + ), + ), + const Spacer(), + Image.asset( + "assets/images/png/share.png", + height: 20.h, + width: 20.w, + ) + ], + ), + ), + ), + const PopupMenuDivider(), + PopupMenuItem( + onTap: () { + pinunpinUser(widget.commonObj.iamPrincipal!.id!); + }, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 12.w), + child: Row( + children: [ + countersHelper.pinButtonPopular[widget.currentIndex] + ? Text( + 'Unpin', + style: TextStyle( + fontSize: 16.sp, + color: Colors.white, + fontWeight: FontWeight.w800, + fontFamily: "Nunito Sans", + ), + ) + : Text( + 'Pin', + style: TextStyle( + fontSize: 16.sp, + color: Colors.white, + fontWeight: FontWeight.w800, + fontFamily: "Nunito Sans", + ), + ), + const Spacer(), + countersHelper + .pinButtonPopular[widget.currentIndex] + ? Image.asset( + "assets/images/png/PinnedIcon.png", + height: 25.h, + width: 25.w, + ) + : Image.asset( + "assets/images/png/f7_pin-fill (2).png", + height: 25.h, + width: 25.w, + ) + ], + ), + ), + ), + ], + child: Image.asset( + 'assets/images/png/Group 1000004071.png', + width: 16.w, + height: 18.h, + ), + ), + sizedBoxWidth(5.w) + ], + ), + ), + sizedBoxHeight(20.h), + GestureDetector( + onTap: () async { + bool result = await Get.toNamed(RouteName.postdetailsScreen, + arguments: { + 'postId': widget.commonObj.id, + 'tagsList': widget.tags, + 'created_at': widget.createAt, + 'commonObj': widget.commonObj, + 'fromWhichTab': widget.forWhichTab, + 'reactions': widget.reactions, + 'selectedReactions': widget.selectedReactions, + 'currentIndex': widget.currentIndex + }); + if (result) { + setState(() {}); + } + }, + child: SizedBox( + height: 360, + width: double.infinity, + child: CachedNetworkImage( + cacheKey: imgUrl, + imageUrl: widget.commonObj.image!, + fit: BoxFit.cover, + placeholder: (context, url) => const Center( + child: + CircularProgressIndicator()), // Optional: shows a loading indicator while the image is loading + errorWidget: (context, url, error) => const Center( + child: Icon(Icons + .error)), // Optional: shows an error icon if the image fails to load + ), + )), + sizedBoxHeight(20.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Column(children: [ + SizedBox( + height: 30.h, + child: ListView.builder( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + itemCount: widget.tags.length, + itemBuilder: (context, index) { + var manageTag = widget.tags[index]; + return Padding( + padding: EdgeInsets.only(right: 12.w), + child: GestureDetector( + onTap: () { + Get.toNamed(RouteName.tagdetailscreen, arguments: { + 'tagid': manageTag.id, + 'tagname': manageTag.name, + 'ispinnedtag': manageTag.isPinned, + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + commonContainer( + width: 130.w, + height: 30.h, + borderRadius: BorderRadius.circular(30.r), + borderColor: const Color(0xFFD90B2E), + opacity1: 0.04, + opacity2: 0.05, + customWidget: Padding( + padding: + EdgeInsets.symmetric(horizontal: 10.w), + child: Center( + child: text14w400_FCFCFC( + '#${manageTag.name}', + ), + ), + ), + ), + ], + ), + ), + ); + }, + ), + ), + sizedBoxHeight(20.h), + SizedBox( + height: 80.h, + width: double.infinity, + child: SingleChildScrollView( + child: text16w400_FCFCFC(widget.commonObj.caption ?? "")), + ), + sizedBoxHeight(20.h), + Row(children: [ + Obx( + () => InkWell( + onTap: () { + Get.toNamed(RouteName.reactionview, arguments: { + 'postId': widget.commonObj.id, + }); + }, + child: stackReaction( + number: countersHelper + .likesCounterPopular[widget.currentIndex] + .toString(), + containerImages: [ + 'assets/images/png/f7_hand-thumbsup.png', + 'assets/images/png/heart 2.png', + 'assets/images/png/party-popper 2.png' + ]), + ), + ), + const Spacer(), + commonContainer( + width: 30.w, + height: 30.h, + borderColor: const Color(0xFF434A53), + borderwidth: 0.43, + opacity1: 0.2, + opacity2: 0.2, + boxShape: BoxShape.circle, + customWidget: Center( + child: Image.asset( + 'assets/images/png/Frame 1000004088.png', + height: 13.h, + width: 13.w, + ), + ), + ), + sizedBoxWidth(12.w), + text14w400_FCFCFC( + widget.commonObj.totalCommentCount.toString()), + sizedBoxWidth(20.w), + commonContainer( + width: 30.w, + height: 30.h, + borderColor: const Color(0xFF434A53), + borderwidth: 0.43, + opacity1: 0.2, + opacity2: 0.2, + boxShape: BoxShape.circle, + customWidget: Center( + child: Image.asset( + 'assets/images/png/Vector (1).png', + height: 12.h, + width: 12.w, + ), + ), + ), + sizedBoxWidth(12.w), + Obx( + () => text14w400_FCFCFC(countersHelper + .savePostCounterPopular[widget.currentIndex] + .toString()), + ), + ]), + sizedBoxHeight(12.h), + commonDivider(), + sizedBoxHeight(12.h), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ReactionButton( + onReactionChanged: (reaction) async { + _handleReactionChange(reaction); + }, + reactions: widget.reactions + .map((reaction) => Reaction( + value: reaction.id.toString(), + previewIcon: Image.network(reaction.image, + width: 24, + height: 24, + fit: BoxFit.cover), + icon: Image.network(reaction.image, + width: 24, + height: 24, + fit: BoxFit.cover), + )) + .toList(), + selectedReaction: widget + .selectedReactions[widget.commonObj.id] != + null + ? Reaction( + value: widget + .selectedReactions[widget.commonObj.id]! + .id + .toString(), + icon: Image.network( + widget + .selectedReactions[widget.commonObj.id]! + .image, + width: 24, + height: 24, + fit: BoxFit.cover, + ), + ) + : null, + boxColor: Colors.white, + boxElevation: 9, + boxRadius: 30, + itemsSpacing: 20, + itemScale: 0.3, + itemSize: const Size(30, 30), + boxPadding: const EdgeInsets.all(8), + boxAnimationDuration: + const Duration(milliseconds: 200), + itemAnimationDuration: + const Duration(milliseconds: 500), + hoverDuration: const Duration(milliseconds: 700), + child: widget + .selectedReactions[widget.commonObj.id] != + null + ? Image.network( + widget.selectedReactions[widget.commonObj.id]! + .image, + width: 24, + height: 24, + fit: BoxFit.cover, + ) + : Image.asset( + 'assets/images/png/uiw_like-o.png', + width: 24, + height: 24, + fit: BoxFit.cover, + ), + ), + sizedBoxHeight(8.h), + text11w400_FCFCFC('Like'), + ], + ), + GestureDetector( + onTap: () async { + bool result = await Get.toNamed( + RouteName.postdetailsScreen, + arguments: { + 'postId': widget.commonObj.id, + 'tagsList': widget.tags, + 'created_at': widget.createAt, + 'commonObj': widget.commonObj, + 'fromWhichTab': widget.forWhichTab, + 'reactions': widget.reactions, + 'selectedReactions': widget.selectedReactions, + 'currentIndex': widget.currentIndex + }); + if (result) { + setState(() {}); + } + }, + child: Column( + children: [ + Image.asset( + 'assets/images/png/Frame 1000004088.png', + height: 19.h, + width: 19.w, + ), + sizedBoxHeight(8.h), + text11w400_FCFCFC('Comment') + ], + ), + ), + Obx( + () => Column( + //here + children: [ + GestureDetector( + onTap: () async => + await saveunsavepost(widget.commonObj.id!), + child: countersHelper + .saveButtonPopular[widget.currentIndex] + ? Image.asset( + 'assets/images/png/postSaved.png', + height: 19.h, + width: 19.w, + ) + : Image.asset( + 'assets/images/png/Frame 1000004089.png', + height: 19.h, + width: 19.w, + ), + ), + sizedBoxHeight(8.h), + text11w400_FCFCFC('Save') + ], + ), + ), + ], + ), + sizedBoxHeight(12.h), + commonDivider(), + sizedBoxHeight(12.h), + ]), + ), + ], + )); + } +} diff --git a/lib/Common/controller/data/network/network_api.dart b/lib/Common/controller/data/network/network_api.dart index 663e624..ba3b12d 100644 --- a/lib/Common/controller/data/network/network_api.dart +++ b/lib/Common/controller/data/network/network_api.dart @@ -47,15 +47,13 @@ class NetworkApiServices { : Options( headers: { 'authorization': basicAuth, - 'access-token': - token + 'access-token': token }, ), ); - } - on Exception catch (e) { + } on Exception catch (e) { // log(e.toString()); - if (e is DioException) { + if (e is DioException) { log(e.response.toString()); if (e.response == null) { return ResponseData( @@ -75,7 +73,6 @@ class NetworkApiServices { ResponseStatus.FAILED, ); } - } if (e.response!.statusCode == 403) { if (e.response!.data['message'] is List) { @@ -212,9 +209,7 @@ class NetworkApiServices { }, ) : Options( - headers: {'authorization': basicAuth, 'access-token': - token - }, + headers: {'authorization': basicAuth, 'access-token': token}, ), ); log(response.toString()); @@ -250,6 +245,10 @@ class NetworkApiServices { return ResponseData( e.response!.data['message'][0]!, ResponseStatus.FAILED, data: e.response!.data); + } else if (e.response!.data['message']['name'] is List) { + return ResponseData( + e.response!.data['message']['name'][0]!, ResponseStatus.FAILED, + data: e.response!.data); } else { return ResponseData( e.response!.data['message'], ResponseStatus.FAILED, diff --git a/lib/Feed Module/Main_Screens/ProfileTab/TimeLine/AddTimeline.dart b/lib/Feed Module/Main_Screens/ProfileTab/TimeLine/AddTimeline.dart index 6377ff6..3246c48 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/TimeLine/AddTimeline.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/TimeLine/AddTimeline.dart @@ -22,7 +22,6 @@ import 'package:regroup/resources/routes/route_name.dart'; import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart'; import 'package:intl/intl.dart'; import 'package:async/src/future_group.dart'; -import 'package:shared_preferences/shared_preferences.dart'; class AddTimeline extends StatefulWidget { const AddTimeline({super.key}); diff --git a/lib/Main_Screens/Community/ViewModel/getmethod.dart b/lib/Main_Screens/Community/ViewModel/getmethod.dart index 2a72663..9804178 100644 --- a/lib/Main_Screens/Community/ViewModel/getmethod.dart +++ b/lib/Main_Screens/Community/ViewModel/getmethod.dart @@ -1,4 +1,4 @@ -import 'dart:developer'; + import 'package:regroup/Common/api_urls.dart'; import 'package:regroup/Common/base_manager.dart'; diff --git a/lib/Main_Screens/Community_HomePage/Community.dart b/lib/Main_Screens/Community_HomePage/Community.dart index f2360a8..75dcd10 100644 --- a/lib/Main_Screens/Community_HomePage/Community.dart +++ b/lib/Main_Screens/Community_HomePage/Community.dart @@ -3,17 +3,14 @@ import 'dart:developer'; import 'package:async/src/future_group.dart'; -import 'package:cached_network_image/cached_network_image.dart'; 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/CommonBottomNavigationBar.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/Common/controller/MainScreen.dart'; import 'package:regroup/Main_Screens/Community/Model/CommonDatumObjModel.dart'; import 'package:regroup/Main_Screens/Community/Model/FeedPostModel.dart' @@ -25,17 +22,13 @@ import 'package:regroup/Main_Screens/Community/ViewModel/FeedPost.dart'; import 'package:regroup/Main_Screens/Community/ViewModel/LatestPost.dart'; import 'package:regroup/Main_Screens/Community/ViewModel/PopularPost.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/PostDetailScreen/View/ReactionView.dart'; -import 'package:regroup/Main_Screens/Community_HomePage/view_model/communitypostmethod.dart'; import 'package:regroup/Utils/Common/ShimmerCommon.dart'; // import 'package:regroup/Feed%20Module/sidemenu/sidemenu.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:regroup/sidemenu/sidemenu.dart'; -import 'package:regroup/sidemenu/view_model/postmethod.dart'; import 'view_model/CountersHelper.dart'; @@ -387,7 +380,7 @@ class _FeedTabState extends State { children: [ NormalCardTile( tags: _sortTags(index), - create_at: timeAgo ?? '1 hour', + createAt: timeAgo ?? '1 hour', commonObj: commonobjmodel!.data[index], forWhichTab: 'feed', @@ -475,7 +468,7 @@ class _FeedTabState extends State { children: [ NormalCardTile( tags: _sortTags(index), - create_at: timeAgo ?? '1 hour', + createAt: timeAgo ?? '1 hour', commonObj: commonobjmodel!.data[index], forWhichTab: 'feed', @@ -503,624 +496,8 @@ class _FeedTabState extends State { } // ignore: must_be_immutable -class NormalCardTile extends StatefulWidget { - List tags; - String? create_at; - CommonDatumObjModelData commonObj; - String forWhichTab; - List reactions; - Map selectedReactions; - int currentIndex; - NormalCardTile({ - Key? key, - required this.tags, - this.create_at, - required this.forWhichTab, - required this.commonObj, - required this.reactions, - required this.selectedReactions, - required this.currentIndex, - }) : super(key: key); - @override - _NormalCardTileState createState() => _NormalCardTileState(); -} - -class _NormalCardTileState extends State { - RxString mainImage = 'assets/images/png/uiw_like-o.png'.obs; - final CountersHelper countersHelper = Get.find(); - int saveCount = 0; - _handleReactionChange(Reaction? reaction) async { - if (widget.selectedReactions[widget.commonObj.id] != null && - reaction?.value == - widget.selectedReactions[widget.commonObj.id]!.id.toString() || - reaction?.value == null) { - // User tapped on the currently selected reaction, so remove it - - //api call for dislike - - await LikeUploaddata( - widget.selectedReactions[widget.commonObj.id]?.id, - widget.commonObj.id!, - ); - setState(() { - widget.selectedReactions[widget.commonObj.id!] = null; - //decrement gloally - countersHelper.likesCounterPopular[widget.currentIndex]--; - log("global value ${countersHelper.likesCounterPopular[widget.currentIndex]}"); - }); - } else { - // User selected a new reaction - var newSelectedReaction = widget.reactions.firstWhere( - (r) => r.id.toString() == reaction?.value, - orElse: () => widget.reactions.first, // Default reaction if not found - ); - await _handleReactionChangeApiCall( - newSelectedReaction, widget.commonObj.id!); - } - } - - Future _handleReactionChangeApiCall( - ReactionData? reaction, int postId) async { - setState(() { - widget.selectedReactions[postId] = - reaction; // Set the selected reaction for this post - - if (countersHelper.likesCounterPopular[widget.currentIndex] <= - widget.commonObj.totalReactionCount!) { - countersHelper.likesCounterPopular[widget.currentIndex]++; - } - }); - - await LikeUploaddata( - reaction?.id, - postId, - ); - } - - LikeUploaddata(int? likeIconId, int? postid) async { - Map updata = { - "manage_posts_xid": postid, - "like_icons_xid": likeIconId ?? '', - }; - final data = await CommunitypostMethod().postLikepost(updata); - if (data.status == ResponseStatus.SUCCESS) { - // return utils.showToast(data.message); - } else { - return utils.showToast(data.message); - } - } - - void updateImage(String reaction) { - switch (reaction) { - case 'like': - mainImage.value = 'assets/images/png/f7_hand-thumbsup.png'; - break; - case 'heart': - mainImage.value = 'assets/images/png/heart 2.png'; - break; - case 'party': - mainImage.value = 'assets/images/png/party-popper 2.png'; - break; - default: - // Handle any other cases or do nothing - break; - } - } - - saveunsavepost(int popularpostid) async { - // utils.loader(); - Map updata = { - "manage_posts_xid": popularpostid, - }; - final data = await Communitypostmethod().postUserSave(updata); - if (data.status == ResponseStatus.SUCCESS) { - if (countersHelper.saveButtonPopular[widget.currentIndex] == false) { - countersHelper.savePostCounterPopular[widget.currentIndex]++; - } else { - countersHelper.savePostCounterPopular[widget.currentIndex]--; - } - countersHelper.saveButtonPopular[widget.currentIndex] = - !countersHelper.saveButtonPopular[widget.currentIndex]; - return utils.showToast(data.message); - } else { - return utils.showToast(data.message); - } - } - - pinunpinUser(int userid) async { - Map updata = { - "pin_iam_principal_xid": userid, - }; - final data = await SidebarTags().postUserpin(updata); - if (data.status == ResponseStatus.SUCCESS) { - countersHelper.pinButtonPopular[widget.currentIndex] = - !countersHelper.pinButtonPopular[widget.currentIndex]; - countersHelper.updateFeedsPage.value = - !countersHelper.updateFeedsPage.value; - return utils.showToast(data.message); - } else { - return utils.showToast(data.message); - } - } - - @override - void initState() { - super.initState(); - } - - @override - Widget build(BuildContext context) { - var imgUrl = widget.commonObj.image! - .split( - "https://regroup.betadelivery.com/storage/app/public/uploads/post_image/") - .last; - return commonGlassUI( - width: double.infinity, - height: 765.h, - mainOpacity: 1, - borderRadius: BorderRadius.circular(1), - customWidget: Column( - children: [ - sizedBoxHeight(25.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CircleAvatar( - backgroundImage: widget - .commonObj.iamPrincipal?.profilePhoto != - null - ? NetworkImage( - widget.commonObj.iamPrincipal!.profilePhoto!) - as ImageProvider - : const AssetImage('assets/images/default_profile.png') - as ImageProvider, - radius: 25.r, - ), - sizedBoxWidth(12.w), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC( - widget.commonObj.iamPrincipal!.fullName ?? "Regroup"), - sizedBoxHeight(5.h), - Row( - children: [ - Image.asset( - 'assets/images/png/community 1 (traced).png', - height: 14.w, - width: 14.w, - ), - sizedBoxWidth(7.w), - text12w400_FCFCFC( - widget.commonObj.community!.communityName ?? ""), - sizedBoxWidth(7.w), - Icon( - Icons.circle, - color: const Color(0xFFFCFCFC), - size: 4.sp, - ), - sizedBoxWidth(6.w), - text12w400_FCFCFC(widget.create_at!), - ], - ) - ], - ), - const Spacer(), - PopupMenuButton( - surfaceTintColor: const Color(0xFF222935), - constraints: BoxConstraints.tightFor(width: 176.w), - offset: const Offset(0, 50), - color: const Color(0xFF222935), - tooltip: "", - itemBuilder: (BuildContext context) => [ - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - Text( - 'Report Post', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/Vector (5).png", - height: 15.h, - width: 15.w, - ) - ], - ), - ), - ), - const PopupMenuDivider(), - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - Text( - 'Share post', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/share.png", - height: 20.h, - width: 20.w, - ) - ], - ), - ), - ), - const PopupMenuDivider(), - PopupMenuItem( - onTap: () { - pinunpinUser(widget.commonObj.iamPrincipal!.id!); - }, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - countersHelper - .pinButtonPopular[widget.currentIndex] - ? Text( - 'Unpin', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ) - : Text( - 'Pin', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ), - const Spacer(), - countersHelper - .pinButtonPopular[widget.currentIndex] - ? Image.asset( - "assets/images/png/PinnedIcon.png", - height: 25.h, - width: 25.w, - ) - : Image.asset( - "assets/images/png/f7_pin-fill (2).png", - height: 25.h, - width: 25.w, - ) - ], - ), - ), - ), - ], - child: Image.asset( - 'assets/images/png/Group 1000004071.png', - width: 16.w, - height: 18.h, - ), - ), - sizedBoxWidth(5.w) - ], - ), - ), - sizedBoxHeight(20.h), - GestureDetector( - onTap: () async { - bool result = await Get.toNamed(RouteName.postdetailsScreen, - arguments: { - 'postId': widget.commonObj.id, - 'tagsList': widget.tags, - 'created_at': widget.create_at, - 'commonObj': widget.commonObj, - 'fromWhichTab': widget.forWhichTab, - 'reactions': widget.reactions, - 'selectedReactions': widget.selectedReactions, - 'currentIndex': widget.currentIndex - }); - if (result) { - setState(() {}); - } - }, - child: SizedBox( - height: 360, - width: double.infinity, - child: CachedNetworkImage( - cacheKey: imgUrl, - imageUrl: widget.commonObj.image!, - fit: BoxFit.cover, - placeholder: (context, url) => const Center( - child: - CircularProgressIndicator()), // Optional: shows a loading indicator while the image is loading - errorWidget: (context, url, error) => const Center( - child: Icon(Icons - .error)), // Optional: shows an error icon if the image fails to load - ), - )), - sizedBoxHeight(20.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Column(children: [ - SizedBox( - height: 30.h, - child: ListView.builder( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - itemCount: widget.tags.length, - itemBuilder: (context, index) { - var manageTag = widget.tags[index]; - return Padding( - padding: EdgeInsets.only(right: 12.w), - child: GestureDetector( - onTap: () { - Get.toNamed(RouteName.tagdetailscreen, arguments: { - 'tagid': manageTag.id, - 'tagname': manageTag.name, - 'ispinnedtag': manageTag.isPinned, - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - commonContainer( - width: 130.w, - height: 30.h, - borderRadius: BorderRadius.circular(30.r), - borderColor: const Color(0xFFD90B2E), - opacity1: 0.04, - opacity2: 0.05, - customWidget: Padding( - padding: - EdgeInsets.symmetric(horizontal: 10.w), - child: Center( - child: text14w400_FCFCFC( - '#${manageTag.name}', - ), - ), - ), - ), - ], - ), - ), - ); - }, - ), - ), - sizedBoxHeight(20.h), - SizedBox( - height: 80.h, - width: double.infinity, - child: SingleChildScrollView( - child: text16w400_FCFCFC(widget.commonObj.caption ?? "")), - ), - sizedBoxHeight(20.h), - Row(children: [ - Obx( - () => InkWell( - onTap: () { - Get.toNamed(RouteName.reactionview, arguments: { - 'postId': widget.commonObj.id, - }); - }, - child: stackReaction( - number: countersHelper - .likesCounterPopular[widget.currentIndex] - .toString(), - containerImages: [ - 'assets/images/png/f7_hand-thumbsup.png', - 'assets/images/png/heart 2.png', - 'assets/images/png/party-popper 2.png' - ]), - ), - ), - const Spacer(), - commonContainer( - width: 30.w, - height: 30.h, - borderColor: const Color(0xFF434A53), - borderwidth: 0.43, - opacity1: 0.2, - opacity2: 0.2, - boxShape: BoxShape.circle, - customWidget: Center( - child: Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 13.h, - width: 13.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC( - widget.commonObj.totalCommentCount.toString()), - sizedBoxWidth(20.w), - commonContainer( - width: 30.w, - height: 30.h, - borderColor: const Color(0xFF434A53), - borderwidth: 0.43, - opacity1: 0.2, - opacity2: 0.2, - boxShape: BoxShape.circle, - customWidget: Center( - child: Image.asset( - 'assets/images/png/Vector (1).png', - height: 12.h, - width: 12.w, - ), - ), - ), - sizedBoxWidth(12.w), - Obx( - () => text14w400_FCFCFC(countersHelper - .savePostCounterPopular[widget.currentIndex] - .toString()), - ), - ]), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - ReactionButton( - onReactionChanged: (reaction) async { - _handleReactionChange(reaction); - }, - reactions: widget.reactions - .map((reaction) => Reaction( - value: reaction.id.toString(), - previewIcon: Image.network(reaction.image, - width: 24, - height: 24, - fit: BoxFit.cover), - icon: Image.network(reaction.image, - width: 24, - height: 24, - fit: BoxFit.cover), - )) - .toList(), - selectedReaction: widget - .selectedReactions[widget.commonObj.id] != - null - ? Reaction( - value: widget - .selectedReactions[widget.commonObj.id]! - .id - .toString(), - icon: Image.network( - widget - .selectedReactions[widget.commonObj.id]! - .image, - width: 24, - height: 24, - fit: BoxFit.cover, - ), - ) - : null, - boxColor: Colors.white, - boxElevation: 9, - boxRadius: 30, - itemsSpacing: 20, - itemScale: 0.3, - itemSize: const Size(30, 30), - boxPadding: const EdgeInsets.all(8), - boxAnimationDuration: - const Duration(milliseconds: 200), - itemAnimationDuration: - const Duration(milliseconds: 500), - hoverDuration: const Duration(milliseconds: 700), - child: widget - .selectedReactions[widget.commonObj.id] != - null - ? Image.network( - widget.selectedReactions[widget.commonObj.id]! - .image, - width: 24, - height: 24, - fit: BoxFit.cover, - ) - : Image.asset( - 'assets/images/png/uiw_like-o.png', - width: 24, - height: 24, - fit: BoxFit.cover, - ), - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Like'), - ], - ), - GestureDetector( - onTap: () async { - bool result = await Get.toNamed( - RouteName.postdetailsScreen, - arguments: { - 'postId': widget.commonObj.id, - 'tagsList': widget.tags, - 'created_at': widget.create_at, - 'commonObj': widget.commonObj, - 'fromWhichTab': widget.forWhichTab, - 'reactions': widget.reactions, - 'selectedReactions': widget.selectedReactions, - 'currentIndex': widget.currentIndex - }); - if (result) { - setState(() {}); - } - }, - child: Column( - children: [ - Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Comment') - ], - ), - ), - Obx( - () => Column( - //here - children: [ - GestureDetector( - onTap: () async => - await saveunsavepost(widget.commonObj.id!), - child: countersHelper - .saveButtonPopular[widget.currentIndex] - ? Image.asset( - 'assets/images/png/postSaved.png', - height: 19.h, - width: 19.w, - ) - : Image.asset( - 'assets/images/png/Frame 1000004089.png', - height: 19.h, - width: 19.w, - ), - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Save') - ], - ), - ), - ], - ), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - ]), - ), - ], - )); - } -} Widget containertile({required String text}) { return commonGlassContainer( @@ -1334,7 +711,7 @@ class _PopularTabState extends State { children: [ NormalCardTile( tags: _sortTags(index), - create_at: timeAgo ?? '1 hour', + createAt: timeAgo ?? '1 hour', commonObj: commonobjmodel!.data[index], forWhichTab: 'popular', reactions: _reactions, @@ -1548,7 +925,7 @@ class _LatestTabState extends State { children: [ NormalCardTile( tags: _sortTags(index), - create_at: timeAgo ?? '1 hour', + createAt: timeAgo ?? '1 hour', commonObj: commonobjmodel!.data[index], forWhichTab: 'latest', reactions: _reactions, diff --git a/lib/Main_Screens/Community_HomePage/Model/tagpopulardetailsModel.dart b/lib/Main_Screens/Community_HomePage/Model/tagpopulardetailsModel.dart index d681df1..664d9ee 100644 --- a/lib/Main_Screens/Community_HomePage/Model/tagpopulardetailsModel.dart +++ b/lib/Main_Screens/Community_HomePage/Model/tagpopulardetailsModel.dart @@ -34,6 +34,7 @@ class Datum { required this.postIn, required this.caption, required this.image, + required this.manageTagsXids, required this.postAs, required this.ctaTitle, required this.ctaLink, @@ -61,6 +62,8 @@ class Datum { final int? postIn; final String? caption; final String? image; + final String? manageTagsXids; + final String? postAs; final String? ctaTitle; final String? ctaLink; @@ -89,6 +92,7 @@ class Datum { postIn: json["post_in"], caption: json["caption"], image: json["image"], + manageTagsXids: json["manage_tags_xids"], postAs: json["post_as"], ctaTitle: json["cta_title"], ctaLink: json["cta_link"], diff --git a/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart b/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart index c6115b2..98376ff 100644 --- a/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart +++ b/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart @@ -1,20 +1,15 @@ -import 'dart:developer'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/gestures.dart'; + import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:get/get_state_manager/get_state_manager.dart'; import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Common/controller/NormalPostCard.dart'; import 'package:regroup/Global.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_HomePage/Community.dart'; import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/CommentsHelper.dart'; import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/CommentsRepository.dart'; import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/PostDetailApi.dart'; @@ -36,7 +31,7 @@ class PostDetailsScreen extends StatefulWidget { class _PostDetailsScreenState extends State { int? followunfollowid; - FollowUnfollowUploadata() async { + followUnfollowUploadata() async { // utils.loader(); Map newupdata = { "following_iam_principal_xid": followunfollowid, @@ -238,7 +233,7 @@ class _PostDetailsScreenState extends State { NormalCardTile( tags: tags!, - create_at: create_at!, + createAt: create_at!, commonObj: commonObj!, forWhichTab: formWhichTab!, reactions: reactions!, diff --git a/lib/Main_Screens/Community_HomePage/PostScreen.dart b/lib/Main_Screens/Community_HomePage/PostScreen.dart index 6976fbf..344c561 100644 --- a/lib/Main_Screens/Community_HomePage/PostScreen.dart +++ b/lib/Main_Screens/Community_HomePage/PostScreen.dart @@ -9,7 +9,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart' hide MultipartFile, FormData; -import 'package:regroup/Common/CommonButton.dart'; import 'package:regroup/Common/CommonGlassmorphism.dart'; import 'package:regroup/Common/base_manager.dart'; @@ -236,15 +235,15 @@ class _PostScreenState extends State { context: context, builder: (BuildContext context) { return AlertDialog( - backgroundColor: Color(0xFF222935).withOpacity(0.9), - title: Text( + backgroundColor: const Color(0xFF222935).withOpacity(0.9), + title: const Text( "Add Tag", style: TextStyle(color: Colors.white), ), content: TextField( - style: TextStyle(color: Colors.white), + style: const TextStyle(color: Colors.white), controller: _tagController, - decoration: InputDecoration( + decoration: const InputDecoration( labelText: "Tag", labelStyle: TextStyle(color: AppColors.white), disabledBorder: UnderlineInputBorder( @@ -261,14 +260,14 @@ class _PostScreenState extends State { onPressed: () { Navigator.of(context).pop(); }, - child: Text("Cancel", style: TextStyle(color: AppColors.white)), + child: const Text("Cancel", style: TextStyle(color: AppColors.white)), ), TextButton( onPressed: () async { tagUploadata(); Navigator.of(context).pop(); }, - child: Text("Submit", style: TextStyle(color: AppColors.white)), + child: const Text("Submit", style: TextStyle(color: AppColors.white)), ), ], ); @@ -289,10 +288,10 @@ class _PostScreenState extends State { label: Text('#${tag.name}', style: const TextStyle(color: Colors.white)), backgroundColor: const Color(0xFFD90B2E).withOpacity(0.9), - side: BorderSide(color: Colors.black), + side: const BorderSide(color: Colors.black), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(30.r), - side: BorderSide(width: 1, color: Colors.white)), + side: const BorderSide(width: 1, color: Colors.white)), onDeleted: () { setState(() { selectedpopularid.remove(tag.id); @@ -612,10 +611,10 @@ class _PostScreenState extends State { ), ], ) - : SizedBox(), + : const SizedBox(), sizedBoxHeight(25.h), globalAccountType == '1' - ? SizedBox() + ? const SizedBox() : Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -735,8 +734,8 @@ class _PostScreenState extends State { context: context, builder: (BuildContext context) { return AlertDialog( - insetPadding: EdgeInsets.symmetric(vertical: 10, horizontal: 15), - contentPadding: EdgeInsets.fromLTRB(24, 8, 24, 24), + insetPadding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15), + contentPadding: const EdgeInsets.fromLTRB(24, 8, 24, 24), shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(14.r))), backgroundColor: const Color(0xFF222935), @@ -1262,10 +1261,10 @@ class _CustomDropDownPopularTagState extends State { label: Text('#${tag.name!}', style: const TextStyle(color: Colors.white)), backgroundColor: const Color(0xFFD90B2E).withOpacity(0.9), - side: BorderSide(color: Colors.black), + side: const BorderSide(color: Colors.black), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(30.r), - side: BorderSide(width: 1, color: Colors.white)), + side: const BorderSide(width: 1, color: Colors.white)), onDeleted: () { selectedTags.remove(tag); widget.onItemSelected(selectedTags.toList()); diff --git a/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart b/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart index b384a73..74b2314 100644 --- a/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart +++ b/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart @@ -9,13 +9,17 @@ 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'; @@ -551,180 +555,127 @@ class PopularTab extends StatefulWidget { } class _PopularTabState extends State { - FutureGroup futureGroup = FutureGroup(); + late Future futureGroup; + List _reactions = []; + final Map _selectedReactions = {}; + final CountersHelper countersHelper = Get.find(); + int? likeIconIdnew; @override void initState() { - futureGroup - .add(Communitygetmethod().getPopularTagsdata(widget.id).then((value) { - _initializeData(); - })); - futureGroup.close(); + futureGroup = Communitygetmethod().getPopularTagsdata(widget.id); + super.initState(); } - List _reactions = []; - Map _selectedReactions = {}; - - Future _initializeData() async { - await _fetchIcons(); - // _initializeSelectedReaction(); - for (var post in tagpopulardetailobj!.data) { - if (post.likeIcon != null) { - likeIconIdnew = post.likeIcon!.likeIconsXid; // This is safe now - print('like selectedid is ${likeIconIdnew.toString()}'); - } else { - likeIconIdnew = 0; // Or handle it as needed - print('like id is ${likeIconIdnew.toString()}'); - } - _initializeSelectedReaction(post.id!); // Pass the post ID - } - } - Future _fetchIcons() async { - var response = await Communityallgetmethod().getLikeicons(); - if (response.status == ResponseStatus.SUCCESS) { - var responseData = response.data as Map; - FetchlikeIconsModel fetchlikeIconsModel = - FetchlikeIconsModel.fromJson(responseData); + _reactions = fetchlikeIconsModel!.data ?? []; + for (var post in commonobjmodel!.data) { + //Check if post as a like icon + if (post.likeIcon?.likeIcon?.id != null) { + likeIconIdnew = post.likeIcon!.likeIconsXid; - setState(() { - _reactions = fetchlikeIconsModel.data - ?.map((data) => ReactionData( - id: data.id!, - image: data.image!, - )) - .toList() ?? - []; - for (var post in tagpopulardetailobj!.data) { - _initializeSelectedReaction(post.id!); - } - }); - } - } + final selectedReaction = _reactions.firstWhere( + (r) => r.id == likeIconIdnew, + orElse: () => _reactions.first, + ); - int? likeIconIdnew; - - void _initializeSelectedReaction(int postId) { - // Check if there's a stored likeIconId for this post - if (likeIconIdnew != null && likeIconIdnew != 0 && _reactions.isNotEmpty) { - final selectedReaction = _reactions.firstWhere( - (r) => r.id == likeIconIdnew, - orElse: () => _reactions.first, - ); - - setState(() { - _selectedReactions[postId] = + _selectedReactions[post.id!] = selectedReaction; // Set selected reaction for this post - print( - 'Selected reaction for post $postId is ${_selectedReactions[postId].toString()}'); - log(_selectedReactions[postId].toString()); - }); - } else { - setState(() { - _selectedReactions[postId] = null; // No reaction selected - print('No reaction selected for post $postId'); - }); - } - } - - Future _handleReactionChange(ReactionData? reaction, int postId) async { - // Check if the postId is valid - if (postId == null) return; - - setState(() { - if (reaction == null) { - _selectedReactions[postId] = - null; // Mark reaction as removed for this post } else { - _selectedReactions[postId] = - reaction; // Set the selected reaction for this post + _selectedReactions[post.id!] = null; // No reaction selected + // print('No reaction selected for post $postId'); } - }); - - try { - await LikeUploaddata( - reaction?.id, - postId, - ); - } catch (error) { - print('Error updating reaction: $error'); - setState(() { - _selectedReactions[postId] = - reaction; // Restore previous reaction if needed - }); } } - LikeUploaddata(int? likeIconId, int? postid) async { - // utils.loader(); - Map updata = { - "manage_posts_xid": postid, - "like_icons_xid": likeIconId ?? '', - }; - final data = await CommunitypostMethod().postLikepost(updata); - if (data.status == ResponseStatus.SUCCESS) { - // Get.back(); - print("like done"); - return utils.showToast(data.message); - } else { - // Get.back(); - print("like not done"); - return utils.showToast(data.message); + bool _isDataInitialized = true; + + Future setValues() async { + if (_isDataInitialized) { + _setModel(); + countersHelper.setListstagPopular(); + await _fetchIcons(); + + _isDataInitialized = false; } } - saveunsavepost(int postid) async { - // utils.loader(); - Map updata = { - "manage_posts_xid": postid, - }; - final data = await Communitypostmethod().postUserSave(updata); - if (data.status == ResponseStatus.SUCCESS) { - Communitygetmethod().getTagsdata(widget.id).then((value) { - _initializeData(); - setState(() {}); - }); + _sortTags(index) { + var tags = commonobjmodel!.data[index].attachTags + .where((tag) => tag.manageTag?.name?.isNotEmpty ?? false) + .map((tag) => tag.manageTag!) + .toList(); - return utils.showToast(data.message); - } else { - // Get.back(); - return utils.showToast(data.message); - } + return tags; } - pinunpinUser(int userid) async { - // utils.loader(); - Map updata = { - "pin_iam_principal_xid": userid, - }; - final data = await SidebarTags().postUserpin(updata); - if (data.status == ResponseStatus.SUCCESS) { - // Get.back(); - Communitygetmethod().getTagsdata(widget.id).then((value) { - _initializeData(); - setState(() {}); - }); - return utils.showToast(data.message); - } else { - // Get.back(); - return utils.showToast(data.message); - } + _setModel() { + commonobjmodel = null; + commonobjmodel = CommonDatumObjModel( + status: tagpopulardetailobj!.status, + statusCode: tagpopulardetailobj!.statusCode, + message: tagpopulardetailobj!.message, + data: tagpopulardetailobj!.data + .map((e) => CommonDatumObjModelData( + id: e.id, + likecount: e.likecount, + isISaved: e.isISaved, + tagsXid: e.tagsXid, + isILiked: e.isILiked, + totalComment: e.totalComment, + totalSave: e.totalSave, + iamPrincipalXid: e.iamPrincipalXid, + postIn: e.postIn, + caption: e.caption, + image: e.image, + manageTagsXids: e.manageTagsXids, + postAs: e.postAs, + ctaTitle: e.ctaTitle, + ctaLink: e.ctaLink, + createdAt: e.createdAt, + likeIcon: LikeIcon1( + likeIcon: LikeIconClass1( + id: e.likeIcon?.likeIcon?.id, + image: e.likeIcon?.likeIcon?.image), + likeIconsXid: e.likeIcon?.likeIconsXid, + ), + totalViewCount: e.totalViewCount, + totalReactionCount: e.totalReactionCount, + totalCommentCount: e.totalCommentCount, + totalImpressionCount: e.totalImpressionCount, + totalPopularScore: e.totalPopularScore, + totalHoursAgo: e.totalHoursAgo, + iamPrincipal: IamPrincipal( + id: e.iamPrincipal!.id, + isUserPinned: e.iamPrincipal!.isUserPinned, + principalTypeXid: e.iamPrincipal!.principalTypeXid, + userName: e.iamPrincipal!.userName, + fullName: e.iamPrincipal!.fullName, + profilePhoto: e.iamPrincipal!.profilePhoto), + community: Community( + id: e.community!.id, + communityProfilePhoto: e.community!.communityProfilePhoto, + communityName: e.community!.communityName), + attachTags: e.attachTags + .map((e) => AttachTag1( + managePostXid: e.managePostXid, + manageTagXid: e.manageTagXid, + manageTag: ManageTagPopular( + id: e.manageTag?.id, + isPinned: e.manageTag?.isPinned, + name: e.manageTag?.name))) + .toList())) + .toList()); } @override Widget build(BuildContext context) { return FutureBuilder( - future: futureGroup.future, + future: futureGroup, builder: (ctx, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { - return - // ShimmerCommon(); - const Center( - child: CircularProgressIndicator( - color: Colors.blue, - ), - ); + return const Center(child: ShimmerCommon()); } if (snapshot.hasError) { @@ -738,1472 +689,66 @@ class _PopularTabState extends State { if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { - print("Data fetched-->"); - return tagpopulardetailobj!.data.isEmpty - ? _buildNoDataBody(context) - : Column( - children: [ - sizedBoxHeight(16.h), - Expanded( - child: ListView.builder( - shrinkWrap: true, - itemCount: tagpopulardetailobj!.data.length, - itemBuilder: (context, index) { - var timeAgo = ConvertServerDateToUserDate() - .convertServerDateToReadableFormate( - tagpopulardetailobj!.data[index].createdAt - .toString()); - var postId = tagpopulardetailobj!.data[index].id; - var selectedReaction = _selectedReactions[postId]; - if (index == 1) { + setValues(); + return Stack(clipBehavior: Clip.none, children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill), + ), + ), + tagpopulardetailobj!.data.isEmpty + ? Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Center( + child: Column( + children: [ + Text( + "No Posts Available", + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.w600), + ) + ], + ), + ), + ]) + : Column( + children: [ + sizedBoxHeight(20.h), + Expanded( + child: ListView.builder( + shrinkWrap: true, + itemCount: commonobjmodel!.data.length, + itemBuilder: (context, index) { + var timeAgo = ConvertServerDateToUserDate() + .convertServerDateToReadableFormate( + tagpopulardetailobj!.data[index].createdAt + .toString()); + return Column( children: [ - commonGlassUIBlue( - width: double.infinity, - height: 780.h, - borderRadius: BorderRadius.circular(1), - customWidget: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - sizedBoxHeight(25.h), - Padding( - padding: - EdgeInsets.only(left: 16.w), - child: text16w700_FCFCFC( - "#Announcement"), - ), - sizedBoxHeight(25.h), - Padding( - padding: EdgeInsets.symmetric( - horizontal: 16.w), - child: Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - CircleAvatar( - foregroundImage: NetworkImage( - tagpopulardetailobj! - .data[index] - .iamPrincipal! - .profilePhoto ?? - ''), - radius: 25.r, - ), - sizedBoxWidth(12.w), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC( - tagpopulardetailobj! - .data[index] - .iamPrincipal! - .fullName ?? - ''), - sizedBoxHeight(5.h), - Row( - children: [ - Image.asset( - 'assets/images/png/community 1 (traced).png', - height: 14.w, - width: 14.w, - ), - sizedBoxWidth(7.w), - text12w400_FCFCFC( - tagpopulardetailobj! - .data[index] - .community! - .communityName ?? - '', - ), - sizedBoxWidth(7.w), - Icon( - Icons.circle, - color: const Color( - 0xFFFCFCFC), - size: 4.sp, - ), - sizedBoxWidth(6.w), - text12w400_FCFCFC( - timeAgo), - ], - ) - ], - ), - const Spacer(), - PopupMenuButton( - surfaceTintColor: - const Color(0xFF222935), - constraints: - BoxConstraints.tightFor( - width: 176.w), - offset: const Offset(0, 50), - color: - const Color(0xFF222935), - tooltip: "", - itemBuilder: - (BuildContext context) => - [ - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets - .symmetric( - horizontal: - 12.w), - child: Row( - children: [ - Text( - 'Report Post', - style: TextStyle( - fontSize: 16.sp, - color: Colors - .white, - fontWeight: - FontWeight - .w800, - fontFamily: - "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/Vector (5).png", - height: 15.h, - width: 15.w, - ) - ], - ), - ), - ), - const PopupMenuDivider(), - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets - .symmetric( - horizontal: - 12.w), - child: Row( - children: [ - Text( - 'Share post', - style: TextStyle( - fontSize: 16.sp, - color: Colors - .white, - fontWeight: - FontWeight - .w800, - fontFamily: - "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/share.png", - height: 20.h, - width: 20.w, - ) - ], - ), - ), - ), - // const PopupMenuDivider(), - // PopupMenuItem( - // onTap: () async { - // int pinPospostid = - // tagpopulardetailobj! - // .data[index] - // .id!; - // await pinunpinUser( - // pinPospostid); - // }, - // child: Padding( - // padding: EdgeInsets - // .symmetric( - // horizontal: - // 12.w), - // child: Row( - // children: [ - // Text( - // tagpopulardetailobj! - // .data[ - // index] - // .iamPrincipal! - // .isUserPinned == - // true - // ? 'Unpin' - // : 'Pin', - // style: TextStyle( - // fontSize: 16.sp, - // color: Colors - // .white, - // fontWeight: - // FontWeight - // .w800, - // fontFamily: - // "Nunito Sans", - // ), - // ), - // const Spacer(), - // Image.asset( - // "assets/images/png/f7_pin-fill (2).png", - // height: 25.h, - // width: 25.w, - // ) - // ], - // ), - // ), - // ), - ], - child: Image.asset( - 'assets/images/png/Group 1000004071.png', - width: 16.w, - height: 18.h, - ), - ), - sizedBoxWidth(5.w) - ], - ), - ), - sizedBoxHeight(20.h), - GestureDetector( - onTap: () { - Get.toNamed( - RouteName.postdetailsScreen); - }, - child: Container( - height: 390.h, - decoration: BoxDecoration( - image: DecorationImage( - image: NetworkImage( - tagpopulardetailobj! - .data[index] - .image ?? - ''), - fit: BoxFit.cover)), - ), - ), - sizedBoxHeight(20.h), - Padding( - padding: EdgeInsets.symmetric( - horizontal: 16.w), - child: Column(children: [ - // SizedBox( - // height: 30.h, - // child: ListView.builder( - // scrollDirection: Axis.horizontal, - // shrinkWrap: true, - // itemCount: tagpopulardetailobj! - // .data[index].attachTags.length, - // itemBuilder: (context, tagIndex) { - // print( - // 'tags id are ${tagpopulardetailobj!.data[index].attachTags[tagIndex].manageTag!.id}'); - // print( - // 'tags name are ${tagpopulardetailobj!.data[index].attachTags[tagIndex].manageTag!.name}'); - // return Padding( - // padding: EdgeInsets.only( - // right: 12.w), - // child: GestureDetector( - // onTap: () { - // print('anonymous tag tapped'); - // Get.toNamed( - // RouteName.tagdetailscreen, - // arguments: { - // 'tagid': - // tagpopulardetailobj! - // .data[index] - // .attachTags[ - // tagIndex] - // .manageTag!.id, - // 'tagname': - // tagpopulardetailobj! - // .data[index] - // .attachTags[ - // tagIndex] - // .manageTag!.name, - // }); - // }, - // child: - // // containertile2( - // // text: (tagpopulardetailobj! - // // .data[index] - // // .tagNames[index]) - // // ) - // commonContainer( - // width: 130.w, - // height: 30.h, - // borderRadius: - // BorderRadius - // .circular( - // 30.r), - // borderColor: - // const Color( - // 0xFFD90B2E), - // opacity1: 0.04, - // opacity2: 0.05, - // customWidget: - // Padding( - // padding: EdgeInsets - // .symmetric( - // horizontal: - // 10.w), - // child: Center( - // child: text14w400_FCFCFC(tagpopulardetailobj! - // .data[ - // index] - // .attachTags[ - // tagIndex].manageTag! - // .name!)), - // )), - // ), - // ); - // }, - // ), - // ), - SizedBox( - height: 30.h, - width: double.infinity, - child: ListView.builder( - scrollDirection: - Axis.horizontal, - shrinkWrap: true, - // Filter the tags to include only those with a non-null and non-empty name - itemCount: tagpopulardetailobj! - .data[index].attachTags - .where((tag) => - tag.manageTag?.name - ?.isNotEmpty ?? - false) - .length, - itemBuilder: - (context, tagIndex) { - // Filtered list of tags - var filteredTags = - tagpopulardetailobj! - .data[index] - .attachTags - .where((tag) => - tag - .manageTag - ?.name - ?.isNotEmpty ?? - false) - .toList(); - - // Safely get the manageTag object - var manageTag = - filteredTags[tagIndex] - .manageTag; - - // Get the tag name, ensuring it's not null or empty - String tagName = - manageTag?.name ?? ''; - - return Padding( - padding: EdgeInsets.only( - right: 12.w, - left: 12.w), - child: GestureDetector( - onTap: () { - print( - 'anonymous tapped'); - Get.back(); - Get.toNamed( - RouteName - .tagdetailscreen, - arguments: { - 'tagid': tagpopulardetailobj! - .data[index] - .attachTags[ - tagIndex] - .manageTag! - .id, - // filteredTags[ - // tagIndex] - // .manageTagXid, - 'tagname': - tagName, - }); - }, - child: Row( - mainAxisAlignment: - MainAxisAlignment - .start, - children: [ - commonContainer( - width: 130.w, - height: 30.h, - borderRadius: - BorderRadius - .circular( - 30.r), - borderColor: - const Color( - 0xFFD90B2E), - opacity1: 0.04, - opacity2: 0.05, - customWidget: - Padding( - padding: EdgeInsets - .symmetric( - horizontal: - 10.w), - child: Center( - child: text14w400_FCFCFC( - '#${tagName}'), - ), - ), - ), - ], - ), - ), - ); - }, - ), - ), - sizedBoxHeight(20.h), - SizedBox( - width: double.infinity, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC( - tagpopulardetailobj! - .data[index] - .caption ?? - ''), - ], - ), - ), - Row(children: [ - InkWell( - onTap: () {}, - child: stackReaction( - number: - tagpopulardetailobj! - .data[index] - .likecount - .toString(), - containerImages: [ - 'assets/images/png/f7_hand-thumbsup.png', - 'assets/images/png/heart 2.png', - 'assets/images/png/party-popper 2.png' - ]), - ), - const Spacer(), - commonContainer( - width: 30.w, - height: 30.h, - borderColor: - const Color(0xFF434A53), - borderwidth: 0.43, - opacity1: 0.2, - opacity2: 0.2, - boxShape: BoxShape.circle, - customWidget: Center( - child: Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 13.h, - width: 13.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC( - tagpopulardetailobj! - .data[index] - .totalComment - .toString()), - sizedBoxWidth(20.w), - commonContainer( - width: 30.w, - height: 30.h, - borderColor: - const Color(0xFF434A53), - borderwidth: 0.43, - opacity1: 0.2, - opacity2: 0.2, - boxShape: BoxShape.circle, - customWidget: Center( - child: Image.asset( - 'assets/images/png/Vector (1).png', - height: 12.h, - width: 12.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC( - tagpopulardetailobj! - .data[index].totalSave - .toString()), - ]), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - children: [ - Column( - mainAxisAlignment: - MainAxisAlignment - .center, - children: [ - Column( - children: [ - ReactionButton< - String>( - onReactionChanged: - (reaction) async { - if (selectedReaction != - null && - reaction?.value == - selectedReaction - .id - .toString()) { - // User tapped on the currently selected reaction, so remove it - await _handleReactionChange( - selectedReaction, - tagpopulardetailobj! - .data[ - index] - .id!); - } else { - // User selected a new reaction - var newSelectedReaction = - _reactions - .firstWhere( - (r) => - r.id.toString() == - reaction - ?.value, - orElse: () => - _reactions - .first, // Default reaction if not found - ); - await _handleReactionChange( - newSelectedReaction, - tagpopulardetailobj! - .data[ - index] - .id!); - } - debugPrint( - 'Selected value: ${reaction?.value}'); - }, - reactions: - _reactions - .map((reaction) => - Reaction< - String>( - value: reaction - .id - .toString(), - previewIcon: Image.network( - reaction.image, - width: 24, - height: 24, - fit: BoxFit.cover), - icon: Image.network( - reaction.image, - width: 24, - height: 24, - fit: BoxFit.cover), - )) - .toList(), - selectedReaction: - selectedReaction != - null - ? Reaction< - String>( - value: selectedReaction - .id - .toString(), - icon: Image - .network( - selectedReaction - .image, - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ) - : Reaction< - String>( - value: - '', - icon: Image - .asset( - 'assets/images/png/uiw_like-o.png', - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ), - boxColor: - Colors.white, - boxElevation: 9, - boxRadius: 30, - itemsSpacing: 8, - itemScale: 0.4, - itemSize: - const Size( - 30, 30), - boxPadding: - const EdgeInsets - .all(8), - boxAnimationDuration: - const Duration( - milliseconds: - 200), - itemAnimationDuration: - const Duration( - milliseconds: - 500), - hoverDuration: - const Duration( - milliseconds: - 700), - child: - selectedReaction != - null - ? Image - .network( - selectedReaction - .image, - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ) - : Image - .asset( - 'assets/images/png/uiw_like-o.png', - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ), - sizedBoxHeight(2.h), - text11w400_FCFCFC( - 'Like'), - ], - ) - ], - ), - GestureDetector( - onTap: () {}, - child: Column( - children: [ - Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC( - 'Comment') - ], - ), - ), - Column( - children: [ - GestureDetector( - onTap: () async { - int postid = - tagpopulardetailobj! - .data[index] - .id!; - await saveunsavepost( - postid); - }, - child: tagpopulardetailobj! - .data[index] - .isISaved == - true - ? Image.asset( - 'assets/images/png/postSaved.png', - height: 19.h, - width: 19.w, - ) - : Image.asset( - 'assets/images/png/Frame 1000004089.png', - height: 19.h, - width: 19.w, - ), - ), - // Image.asset( - // 'assets/images/png/Frame 1000004089.png', - // height: 19.h, - // width: 19.w, - // ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Save') - ], - ) - ], - ), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - ]), - ), - ], - )), - sizedBoxHeight(20.h), - ], - ); - } else { - return Column( - children: [ - commonGlassUI( - width: double.infinity, - height: 760.h, - mainOpacity: 1, - borderRadius: BorderRadius.circular(1), - customWidget: Column( - children: [ - sizedBoxHeight(25.h), - Padding( - padding: EdgeInsets.symmetric( - horizontal: 16.w), - child: Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - CircleAvatar( - foregroundImage: NetworkImage( - tagpopulardetailobj! - .data[index] - .iamPrincipal! - .profilePhoto ?? - ''), - radius: 25.r, - ), - sizedBoxWidth(12.w), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC( - tagpopulardetailobj! - .data[index] - .iamPrincipal! - .fullName ?? - ''), - sizedBoxHeight(5.h), - Row( - children: [ - Image.asset( - 'assets/images/png/community 1 (traced).png', - height: 14.w, - width: 14.w, - ), - sizedBoxWidth(7.w), - text12w400_FCFCFC( - tagpopulardetailobj! - .data[index] - .community! - .communityName - .toString()), - sizedBoxWidth(7.w), - Icon( - Icons.circle, - color: const Color( - 0xFFFCFCFC), - size: 4.sp, - ), - sizedBoxWidth(6.w), - text12w400_FCFCFC( - timeAgo!), - ], - ) - ], - ), - const Spacer(), - PopupMenuButton( - surfaceTintColor: - const Color(0xFF222935), - constraints: - BoxConstraints.tightFor( - width: 176.w), - offset: const Offset(0, 50), - color: - const Color(0xFF222935), - tooltip: "", - itemBuilder: - (BuildContext context) => - [ - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets - .symmetric( - horizontal: - 12.w), - child: Row( - children: [ - Text( - 'Report Post', - style: TextStyle( - fontSize: 16.sp, - color: Colors - .white, - fontWeight: - FontWeight - .w800, - fontFamily: - "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/Vector (5).png", - height: 15.h, - width: 15.w, - ) - ], - ), - ), - ), - const PopupMenuDivider(), - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets - .symmetric( - horizontal: - 12.w), - child: Row( - children: [ - Text( - 'Share post', - style: TextStyle( - fontSize: 16.sp, - color: Colors - .white, - fontWeight: - FontWeight - .w800, - fontFamily: - "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/share.png", - height: 20.h, - width: 20.w, - ) - ], - ), - ), - ), - const PopupMenuDivider(), - PopupMenuItem( - onTap: () async { - int pinPospostid = - tagpopulardetailobj! - .data[index] - .iamPrincipal! - .id!; - await pinunpinUser( - pinPospostid); - }, - child: Padding( - padding: EdgeInsets - .symmetric( - horizontal: - 12.w), - child: Row( - children: [ - Text( - tagpopulardetailobj! - .data[ - index] - .iamPrincipal! - .isUserPinned == - true - ? 'Unpin' - : 'Pin', - style: TextStyle( - fontSize: 16.sp, - color: Colors - .white, - fontWeight: - FontWeight - .w800, - fontFamily: - "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/f7_pin-fill (2).png", - height: 25.h, - width: 25.w, - ) - ], - ), - ), - ), - ], - child: Image.asset( - 'assets/images/png/Group 1000004071.png', - width: 16.w, - height: 18.h, - ), - ), - sizedBoxWidth(5.w) - ], - ), - ), - sizedBoxHeight(20.h), - GestureDetector( - onTap: () { - Get.toNamed( - RouteName.postdetailsScreen); - }, - child: Container( - height: 360, - width: double.infinity, - decoration: BoxDecoration( - image: DecorationImage( - fit: BoxFit.cover, - image: NetworkImage( - tagpopulardetailobj! - .data[index] - .image ?? - '', - ), - ), - ), - ), - ), - sizedBoxHeight(20.h), - Padding( - padding: EdgeInsets.symmetric( - horizontal: 16.w), - child: Column(children: [ - // SizedBox( - // height: 30.h, - // child: ListView.builder( - // scrollDirection: Axis.horizontal, - // shrinkWrap: true, - // itemCount: tagpopulardetailobj! - // .data[index].attachTags.length, - // itemBuilder: (context, tagIndex) { - // print( - // 'tags id are ${tagpopulardetailobj!.data[index].attachTags[tagIndex].manageTag!.id}'); - // print( - // 'tags name are ${tagpopulardetailobj!.data[index].attachTags[tagIndex].manageTag!.name}'); - // return Padding( - // padding: EdgeInsets.only( - // right: 12.w), - // child: GestureDetector( - // onTap: () { - // print('tag tapped'); - // Get.toNamed( - // RouteName.tagdetailscreen, - // arguments: { - // 'tagid': - // tagpopulardetailobj! - // .data[index] - // .attachTags[ - // tagIndex].manageTag! - // .id, - // 'tagname': - // tagpopulardetailobj! - // .data[index] - // .attachTags[ - // tagIndex].manageTag! - // .name, - // }); - // }, - // child: - // // containertile2( - // // text: (tagpopulardetailobj! - // // .data[index] - // // .tagNames[index]) - // // ) - // commonContainer( - // width: 130.w, - // height: 30.h, - // borderRadius: - // BorderRadius - // .circular( - // 30.r), - // borderColor: - // const Color( - // 0xFFD90B2E), - // opacity1: 0.04, - // opacity2: 0.05, - // customWidget: - // Padding( - // padding: EdgeInsets - // .symmetric( - // horizontal: - // 10.w), - // child: Center( - // child: text14w400_FCFCFC(tagpopulardetailobj! - // .data[ - // index] - // .attachTags[ - // tagIndex].manageTag! - // .name!)), - // )), - // ), - // ); - // }, - // ), - // ), - SizedBox( - height: 30.h, - width: double.infinity, - child: ListView.builder( - scrollDirection: - Axis.horizontal, - shrinkWrap: true, - // Filter the tags to include only those with a non-null and non-empty name - itemCount: tagpopulardetailobj! - .data[index].attachTags - .where((tag) => - tag.manageTag?.name - ?.isNotEmpty ?? - false) - .length, - itemBuilder: - (context, tagIndex) { - // Filtered list of tags - var filteredTags = - tagpopulardetailobj! - .data[index] - .attachTags - .where((tag) => - tag - .manageTag - ?.name - ?.isNotEmpty ?? - false) - .toList(); - - // Safely get the manageTag object - var manageTag = - filteredTags[tagIndex] - .manageTag; - - // Get the tag name, ensuring it's not null or empty - String tagName = - manageTag?.name ?? ''; - - return Padding( - padding: EdgeInsets.only( - right: 12.w, - left: 12.w), - child: GestureDetector( - onTap: () { - print( - 'anonymous tapped'); - Get.back(); - Get.toNamed( - RouteName - .tagdetailscreen, - arguments: { - 'tagid': tagpopulardetailobj! - .data[index] - .attachTags[ - tagIndex] - .manageTag! - .id, - - // filteredTags[ - // tagIndex] - // .manageTagXid, - 'tagname': - tagName, - 'ispinnedtag': - filteredTags[ - tagIndex] - .manageTag! - .isPinned - }); - }, - child: Row( - mainAxisAlignment: - MainAxisAlignment - .start, - children: [ - commonContainer( - width: 130.w, - height: 30.h, - borderRadius: - BorderRadius - .circular( - 30.r), - borderColor: - const Color( - 0xFFD90B2E), - opacity1: 0.04, - opacity2: 0.05, - customWidget: - Padding( - padding: EdgeInsets - .symmetric( - horizontal: - 10.w), - child: Center( - child: text14w400_FCFCFC( - '#${tagName}'), - ), - ), - ), - ], - ), - ), - ); - }, - ), - ), - sizedBoxHeight(20.h), - SizedBox( - width: double.infinity, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC( - tagpopulardetailobj! - .data[index] - .caption ?? - ''), - ], - ), - ), - Row(children: [ - InkWell( - onTap: () { - Get.toNamed( - RouteName.reactionview); - }, - child: stackReaction( - number: - tagpopulardetailobj! - .data[index] - .likecount - .toString(), - containerImages: [ - 'assets/images/png/f7_hand-thumbsup.png', - 'assets/images/png/heart 2.png', - 'assets/images/png/party-popper 2.png' - ]), - ), - const Spacer(), - commonContainer( - width: 30.w, - height: 30.h, - borderColor: - const Color(0xFF434A53), - borderwidth: 0.43, - opacity1: 0.2, - opacity2: 0.2, - boxShape: BoxShape.circle, - customWidget: Center( - child: Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 13.h, - width: 13.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC( - tagpopulardetailobj! - .data[index] - .totalComment - .toString()), - sizedBoxWidth(20.w), - commonContainer( - width: 30.w, - height: 30.h, - borderColor: - const Color(0xFF434A53), - borderwidth: 0.43, - opacity1: 0.2, - opacity2: 0.2, - boxShape: BoxShape.circle, - customWidget: Center( - child: Image.asset( - 'assets/images/png/Vector (1).png', - height: 12.h, - width: 12.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC( - tagpopulardetailobj! - .data[index].totalSave - .toString()), - ]), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - children: [ - Column( - mainAxisAlignment: - MainAxisAlignment - .center, - children: [ - Column( - children: [ - ReactionButton< - String>( - onReactionChanged: - (reaction) async { - if (selectedReaction != - null && - reaction?.value == - selectedReaction - .id - .toString()) { - // User tapped on the currently selected reaction, so remove it - await _handleReactionChange( - selectedReaction, - tagpopulardetailobj! - .data[ - index] - .id!); - } else { - // User selected a new reaction - var newSelectedReaction = - _reactions - .firstWhere( - (r) => - r.id.toString() == - reaction - ?.value, - orElse: () => - _reactions - .first, // Default reaction if not found - ); - await _handleReactionChange( - newSelectedReaction, - tagpopulardetailobj! - .data[ - index] - .id!); - } - debugPrint( - 'Selected value: ${reaction?.value}'); - }, - reactions: - _reactions - .map((reaction) => - Reaction< - String>( - value: reaction - .id - .toString(), - previewIcon: Image.network( - reaction.image, - width: 24, - height: 24, - fit: BoxFit.cover), - icon: Image.network( - reaction.image, - width: 24, - height: 24, - fit: BoxFit.cover), - )) - .toList(), - selectedReaction: - selectedReaction != - null - ? Reaction< - String>( - value: selectedReaction - .id - .toString(), - icon: Image - .network( - selectedReaction - .image, - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ) - : Reaction< - String>( - value: - '', - icon: Image - .asset( - 'assets/images/png/uiw_like-o.png', - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ), - boxColor: - Colors.white, - boxElevation: 9, - boxRadius: 30, - itemsSpacing: 8, - itemScale: 0.4, - itemSize: - const Size( - 30, 30), - boxPadding: - const EdgeInsets - .all(8), - boxAnimationDuration: - const Duration( - milliseconds: - 200), - itemAnimationDuration: - const Duration( - milliseconds: - 500), - hoverDuration: - const Duration( - milliseconds: - 700), - child: - selectedReaction != - null - ? Image - .network( - selectedReaction - .image, - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ) - : Image - .asset( - 'assets/images/png/uiw_like-o.png', - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ), - sizedBoxHeight(2.h), - text11w400_FCFCFC( - 'Like'), - ], - ) - ], - ), - GestureDetector( - onTap: () { - Get.toNamed(RouteName - .postdetailsScreen); - }, - child: Column( - children: [ - Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC( - 'Comment') - ], - ), - ), - InkWell( - onTap: () {}, - child: Column( - children: [ - GestureDetector( - onTap: () async { - int postid = - tagpopulardetailobj! - .data[index] - .id!; - await saveunsavepost( - postid); - }, - child: tagpopulardetailobj! - .data[ - index] - .isISaved == - true - ? Image.asset( - 'assets/images/png/postSaved.png', - height: 19.h, - width: 19.w, - ) - : Image.asset( - 'assets/images/png/Frame 1000004089.png', - height: 19.h, - width: 19.w, - ), - ), - // Image.asset( - // 'assets/images/png/Frame 1000004089.png', - // height: 19.h, - // width: 19.w, - // ), - sizedBoxHeight(8.h), - text11w400_FCFCFC( - 'Save') - ], - ), - ), - ], - ), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - ]), - ), - ], - )), + NormalCardTile( + tags: _sortTags(index), + createAt: timeAgo ?? '1 hour', + commonObj: commonobjmodel!.data[index], + forWhichTab: 'popular', + reactions: _reactions, + selectedReactions: _selectedReactions, + currentIndex: index, + ), sizedBoxHeight(20.h) ], ); - } - }, + }, + ), ), - ), - ], - ); + ], + ) + ]); } return Container(); }); @@ -2238,179 +783,128 @@ class LatestTab extends StatefulWidget { } class _LatestTabState extends State { - FutureGroup futureGroup = FutureGroup(); + late Future latestfuture; + List _reactions = []; + final Map _selectedReactions = {}; + final CountersHelper countersHelper = Get.find(); + int? likeIconIdnew; @override void initState() { - futureGroup.add(Communitygetmethod().getTagsdata(widget.id).then((value) { - _initializeData(); - })); - futureGroup.close(); + // tagdetailobj + latestfuture = Communitygetmethod().getTagsdata(widget.id); + super.initState(); } - List _reactions = []; - Map _selectedReactions = {}; - - Future _initializeData() async { - await _fetchIcons(); - // _initializeSelectedReaction(); - for (var post in tagpopulardetailobj!.data) { - if (post.likeIcon != null) { - likeIconIdnew = post.likeIcon!.likeIconsXid; // This is safe now - print('like selectedid is ${likeIconIdnew.toString()}'); - } else { - likeIconIdnew = 0; // Or handle it as needed - print('like id is ${likeIconIdnew.toString()}'); - } - _initializeSelectedReaction(post.id!); // Pass the post ID - } - } - Future _fetchIcons() async { - var response = await Communityallgetmethod().getLikeicons(); - if (response.status == ResponseStatus.SUCCESS) { - var responseData = response.data as Map; - FetchlikeIconsModel fetchlikeIconsModel = - FetchlikeIconsModel.fromJson(responseData); + _reactions = fetchlikeIconsModel!.data ?? []; + for (var post in commonobjmodel!.data) { + //Check if post as a like icon + if (post.likeIcon?.likeIcon?.id != null) { + likeIconIdnew = post.likeIcon!.likeIconsXid; - setState(() { - _reactions = fetchlikeIconsModel.data - ?.map((data) => ReactionData( - id: data.id!, - image: data.image!, - )) - .toList() ?? - []; - for (var post in tagdetailobj!.data) { - _initializeSelectedReaction(post.id!); - } - }); - } - } + final selectedReaction = _reactions.firstWhere( + (r) => r.id == likeIconIdnew, + orElse: () => _reactions.first, + ); - int? likeIconIdnew; - - void _initializeSelectedReaction(int postId) { - // Check if there's a stored likeIconId for this post - if (likeIconIdnew != null && likeIconIdnew != 0 && _reactions.isNotEmpty) { - final selectedReaction = _reactions.firstWhere( - (r) => r.id == likeIconIdnew, - orElse: () => _reactions.first, - ); - - setState(() { - _selectedReactions[postId] = + _selectedReactions[post.id!] = selectedReaction; // Set selected reaction for this post - print( - 'Selected reaction for post $postId is ${_selectedReactions[postId].toString()}'); - log(_selectedReactions[postId].toString()); - }); - } else { - setState(() { - _selectedReactions[postId] = null; // No reaction selected - print('No reaction selected for post $postId'); - }); - } - } - - Future _handleReactionChange(ReactionData? reaction, int postId) async { - // Check if the postId is valid - if (postId == null) return; - - setState(() { - if (reaction == null) { - _selectedReactions[postId] = - null; // Mark reaction as removed for this post } else { - _selectedReactions[postId] = - reaction; // Set the selected reaction for this post + _selectedReactions[post.id!] = null; // No reaction selected + // print('No reaction selected for post $postId'); } - }); - - try { - await LikeUploaddata( - reaction?.id, - postId, - ); - } catch (error) { - print('Error updating reaction: $error'); - setState(() { - _selectedReactions[postId] = - reaction; // Restore previous reaction if needed - }); } } - LikeUploaddata(int? likeIconId, int? postid) async { - // utils.loader(); - Map updata = { - "manage_posts_xid": postid, - "like_icons_xid": likeIconId ?? '', - }; - final data = await CommunitypostMethod().postLikepost(updata); - if (data.status == ResponseStatus.SUCCESS) { - // Get.back(); - print("like done"); - return utils.showToast(data.message); - } else { - // Get.back(); - print("like not done"); - return utils.showToast(data.message); + bool _isDataInitialized = true; + + Future setValues() async { + if (_isDataInitialized) { + _setModel(); + countersHelper.setListstagtagLatest(); + await _fetchIcons(); + + _isDataInitialized = false; } } - saveunsavepost(int postid) async { - // utils.loader(); - Map updata = { - "manage_posts_xid": postid, - }; - final data = await Communitypostmethod().postUserSave(updata); - if (data.status == ResponseStatus.SUCCESS) { - Communitygetmethod().getTagsdata(widget.id).then((value) { - _initializeData(); - setState(() {}); - }); + _sortTags(index) { + var tags = commonobjmodel!.data[index].attachTags + .where((tag) => tag.manageTag?.name?.isNotEmpty ?? false) + .map((tag) => tag.manageTag!) + .toList(); - return utils.showToast(data.message); - } else { - // Get.back(); - return utils.showToast(data.message); - } + return tags; } - pinunpinUser(int userid) async { - // utils.loader(); - Map updata = { - "pin_iam_principal_xid": userid, - }; - final data = await SidebarTags().postUserpin(updata); - if (data.status == ResponseStatus.SUCCESS) { - // Get.back(); - Communitygetmethod().getTagsdata(widget.id).then((value) { - _initializeData(); - setState(() {}); - }); - return utils.showToast(data.message); - } else { - // Get.back(); - return utils.showToast(data.message); - } + _setModel() { + commonobjmodel = null; + commonobjmodel = CommonDatumObjModel( + status: tagdetailobj!.status, + statusCode: tagdetailobj!.statusCode, + message: tagdetailobj!.message, + data: tagdetailobj!.data + .map((e) => CommonDatumObjModelData( + id: e.id, + likecount: e.likecount, + isISaved: e.isISaved, + tagsXid: e.tagsXid, + isILiked: e.isILiked, + totalComment: e.totalComment, + totalSave: e.totalSave, + iamPrincipalXid: e.iamPrincipalXid, + postIn: e.postIn, + caption: e.caption, + image: e.image, + manageTagsXids: e.manageTagsXids, + postAs: e.postAs, + ctaTitle: e.ctaTitle, + ctaLink: e.ctaLink, + createdAt: e.createdAt, + likeIcon: LikeIcon1( + likeIcon: LikeIconClass1( + id: e.likeIcon?.likeIcon?.id, + image: e.likeIcon?.likeIcon?.image), + likeIconsXid: e.likeIcon?.likeIconsXid, + ), + totalViewCount: e.totalViewCount, + totalReactionCount: e.totalReactionCount, + totalCommentCount: e.totalCommentCount, + totalImpressionCount: e.totalImpressionCount, + totalPopularScore: e.totalPopularScore, + totalHoursAgo: e.totalHoursAgo, + iamPrincipal: IamPrincipal( + id: e.iamPrincipal!.id, + isUserPinned: e.iamPrincipal!.isUserPinned, + principalTypeXid: e.iamPrincipal!.principalTypeXid, + userName: e.iamPrincipal!.userName, + fullName: e.iamPrincipal!.fullName, + profilePhoto: e.iamPrincipal!.profilePhoto), + community: Community( + id: e.community!.id, + communityProfilePhoto: e.community!.communityProfilePhoto, + communityName: e.community!.communityName), + attachTags: e.attachTags + .map((e) => AttachTag1( + managePostXid: e.managePostXid, + manageTagXid: e.manageTagXid, + manageTag: ManageTagPopular( + id: e.manageTag?.id, + isPinned: e.manageTag?.isPinned, + name: e.manageTag?.name))) + .toList())) + .toList()); } @override Widget build(BuildContext context) { return FutureBuilder( - future: futureGroup.future, + future: latestfuture, builder: (ctx, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { - return - // ShimmerCommon(); - const Center( - child: CircularProgressIndicator( - color: Colors.blue, - ), - ); + return const Center(child: ShimmerCommon()); } if (snapshot.hasError) { @@ -2424,1461 +918,66 @@ class _LatestTabState extends State { if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { - print("Data fetched-->"); - return tagdetailobj!.data.isEmpty - ? _buildNoDataBody(context) - : Column( - children: [ - sizedBoxHeight(16.h), - Expanded( - child: ListView.builder( - shrinkWrap: true, - itemCount: tagdetailobj!.data.length, - itemBuilder: (context, index) { - var timeAgo = ConvertServerDateToUserDate() - .convertServerDateToReadableFormate( - tagdetailobj!.data[index].createdAt - .toString()); - var postId = tagdetailobj!.data[index].id; - var selectedReaction = _selectedReactions[postId]; - if (index == 1) { + setValues(); + return Stack(clipBehavior: Clip.none, children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill), + ), + ), + tagdetailobj!.data.isEmpty + ? Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Center( + child: Column( + children: [ + Text( + "No Posts Available", + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.w600), + ) + ], + ), + ), + ]) + : Column( + children: [ + sizedBoxHeight(20.h), + Expanded( + child: ListView.builder( + shrinkWrap: true, + itemCount: commonobjmodel!.data.length, + itemBuilder: (context, index) { + var timeAgo = ConvertServerDateToUserDate() + .convertServerDateToReadableFormate( + tagdetailobj!.data[index].createdAt + .toString()); + return Column( children: [ - commonGlassUIBlue( - width: double.infinity, - height: 780.h, - borderRadius: BorderRadius.circular(1), - customWidget: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - sizedBoxHeight(25.h), - Padding( - padding: - EdgeInsets.only(left: 16.w), - child: text16w700_FCFCFC( - "#Announcement"), - ), - sizedBoxHeight(25.h), - Padding( - padding: EdgeInsets.symmetric( - horizontal: 16.w), - child: Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - CircleAvatar( - foregroundImage: NetworkImage( - tagdetailobj! - .data[index] - .iamPrincipal! - .profilePhoto ?? - ''), - radius: 25.r, - ), - sizedBoxWidth(12.w), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC( - tagdetailobj! - .data[index] - .iamPrincipal! - .fullName ?? - ''), - sizedBoxHeight(5.h), - Row( - children: [ - Image.asset( - 'assets/images/png/community 1 (traced).png', - height: 14.w, - width: 14.w, - ), - sizedBoxWidth(7.w), - text12w400_FCFCFC( - tagdetailobj! - .data[index] - .community! - .communityName ?? - '', - ), - sizedBoxWidth(7.w), - Icon( - Icons.circle, - color: const Color( - 0xFFFCFCFC), - size: 4.sp, - ), - sizedBoxWidth(6.w), - text12w400_FCFCFC( - timeAgo), - ], - ) - ], - ), - const Spacer(), - PopupMenuButton( - surfaceTintColor: - const Color(0xFF222935), - constraints: - BoxConstraints.tightFor( - width: 176.w), - offset: const Offset(0, 50), - color: - const Color(0xFF222935), - tooltip: "", - itemBuilder: - (BuildContext context) => - [ - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets - .symmetric( - horizontal: - 12.w), - child: Row( - children: [ - Text( - 'Report Post', - style: TextStyle( - fontSize: 16.sp, - color: Colors - .white, - fontWeight: - FontWeight - .w800, - fontFamily: - "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/Vector (5).png", - height: 15.h, - width: 15.w, - ) - ], - ), - ), - ), - const PopupMenuDivider(), - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets - .symmetric( - horizontal: - 12.w), - child: Row( - children: [ - Text( - 'Share post', - style: TextStyle( - fontSize: 16.sp, - color: Colors - .white, - fontWeight: - FontWeight - .w800, - fontFamily: - "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/share.png", - height: 20.h, - width: 20.w, - ) - ], - ), - ), - ), - // const PopupMenuDivider(), - // PopupMenuItem( - // onTap: () async { - // int pinPospostid = - // tagdetailobj! - // .data[index] - // .id!; - // await pinunpinUser( - // pinPospostid); - // }, - // child: Padding( - // padding: EdgeInsets - // .symmetric( - // horizontal: - // 12.w), - // child: Row( - // children: [ - // Text( - // tagdetailobj! - // .data[ - // index] - // .iamPrincipal! - // .isUserPinned == - // true - // ? 'Unpin' - // : 'Pin', - // style: TextStyle( - // fontSize: 16.sp, - // color: Colors - // .white, - // fontWeight: - // FontWeight - // .w800, - // fontFamily: - // "Nunito Sans", - // ), - // ), - // const Spacer(), - // Image.asset( - // "assets/images/png/f7_pin-fill (2).png", - // height: 25.h, - // width: 25.w, - // ) - // ], - // ), - // ), - // ), - ], - child: Image.asset( - 'assets/images/png/Group 1000004071.png', - width: 16.w, - height: 18.h, - ), - ), - sizedBoxWidth(5.w) - ], - ), - ), - sizedBoxHeight(20.h), - GestureDetector( - onTap: () { - Get.toNamed( - RouteName.postdetailsScreen); - }, - child: Container( - height: 390.h, - decoration: BoxDecoration( - image: DecorationImage( - image: NetworkImage( - tagdetailobj! - .data[index] - .image ?? - ''), - fit: BoxFit.cover)), - ), - ), - sizedBoxHeight(20.h), - Padding( - padding: EdgeInsets.symmetric( - horizontal: 16.w), - child: Column(children: [ - // SizedBox( - // height: 30.h, - // child: ListView.builder( - // scrollDirection: Axis.horizontal, - // shrinkWrap: true, - // itemCount: tagdetailobj! - // .data[index].attachTags.length, - // itemBuilder: (context, tagIndex) { - // print( - // 'tags id are ${tagdetailobj!.data[index].attachTags[tagIndex].manageTag!.id}'); - // print( - // 'tags name are ${tagdetailobj!.data[index].attachTags[tagIndex].manageTag!.name}'); - // return Padding( - // padding: EdgeInsets.only( - // right: 12.w), - // child: GestureDetector( - // onTap: () { - // print('anonymous tag tapped'); - // Get.toNamed( - // RouteName.tagdetailscreen, - // arguments: { - // 'tagid': - // tagdetailobj! - // .data[index] - // .attachTags[ - // tagIndex] - // .manageTag!.id, - // 'tagname': - // tagdetailobj! - // .data[index] - // .attachTags[ - // tagIndex] - // .manageTag!.name, - // }); - // }, - // child: - // // containertile2( - // // text: (tagdetailobj! - // // .data[index] - // // .tagNames[index]) - // // ) - // commonContainer( - // width: 130.w, - // height: 30.h, - // borderRadius: - // BorderRadius - // .circular( - // 30.r), - // borderColor: - // const Color( - // 0xFFD90B2E), - // opacity1: 0.04, - // opacity2: 0.05, - // customWidget: - // Padding( - // padding: EdgeInsets - // .symmetric( - // horizontal: - // 10.w), - // child: Center( - // child: text14w400_FCFCFC(tagdetailobj! - // .data[ - // index] - // .attachTags[ - // tagIndex].manageTag! - // .name!)), - // )), - // ), - // ); - // }, - // ), - // ), - SizedBox( - height: 30.h, - width: double.infinity, - child: ListView.builder( - scrollDirection: - Axis.horizontal, - shrinkWrap: true, - // Filter the tags to include only those with a non-null and non-empty name - itemCount: tagdetailobj! - .data[index].attachTags - .where((tag) => - tag.manageTag?.name - ?.isNotEmpty ?? - false) - .length, - itemBuilder: - (context, tagIndex) { - // Filtered list of tags - var filteredTags = - tagdetailobj! - .data[index] - .attachTags - .where((tag) => - tag - .manageTag - ?.name - ?.isNotEmpty ?? - false) - .toList(); - - // Safely get the manageTag object - var manageTag = - filteredTags[tagIndex] - .manageTag; - - // Get the tag name, ensuring it's not null or empty - String tagName = - manageTag?.name ?? ''; - - return Padding( - padding: EdgeInsets.only( - right: 12.w, - left: 12.w), - child: GestureDetector( - onTap: () { - print( - 'anonymous tapped'); - Get.back(); - Get.toNamed( - RouteName - .tagdetailscreen, - arguments: { - 'tagid': tagdetailobj! - .data[index] - .attachTags[ - tagIndex] - .manageTag! - .id, - // filteredTags[ - // tagIndex] - // .manageTagXid, - 'tagname': - tagName, - }); - }, - child: Row( - mainAxisAlignment: - MainAxisAlignment - .start, - children: [ - commonContainer( - width: 130.w, - height: 30.h, - borderRadius: - BorderRadius - .circular( - 30.r), - borderColor: - const Color( - 0xFFD90B2E), - opacity1: 0.04, - opacity2: 0.05, - customWidget: - Padding( - padding: EdgeInsets - .symmetric( - horizontal: - 10.w), - child: Center( - child: text14w400_FCFCFC( - '#${tagName}'), - ), - ), - ), - ], - ), - ), - ); - }, - ), - ), - sizedBoxHeight(20.h), - SizedBox( - width: double.infinity, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC( - tagdetailobj! - .data[index] - .caption ?? - ''), - ], - ), - ), - Row(children: [ - InkWell( - onTap: () {}, - child: stackReaction( - number: tagdetailobj! - .data[index].likecount - .toString(), - containerImages: [ - 'assets/images/png/f7_hand-thumbsup.png', - 'assets/images/png/heart 2.png', - 'assets/images/png/party-popper 2.png' - ]), - ), - const Spacer(), - commonContainer( - width: 30.w, - height: 30.h, - borderColor: - const Color(0xFF434A53), - borderwidth: 0.43, - opacity1: 0.2, - opacity2: 0.2, - boxShape: BoxShape.circle, - customWidget: Center( - child: Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 13.h, - width: 13.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC(tagdetailobj! - .data[index].totalComment - .toString()), - sizedBoxWidth(20.w), - commonContainer( - width: 30.w, - height: 30.h, - borderColor: - const Color(0xFF434A53), - borderwidth: 0.43, - opacity1: 0.2, - opacity2: 0.2, - boxShape: BoxShape.circle, - customWidget: Center( - child: Image.asset( - 'assets/images/png/Vector (1).png', - height: 12.h, - width: 12.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC(tagdetailobj! - .data[index].totalSave - .toString()), - ]), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - children: [ - Column( - mainAxisAlignment: - MainAxisAlignment - .center, - children: [ - Column( - children: [ - ReactionButton< - String>( - onReactionChanged: - (reaction) async { - if (selectedReaction != - null && - reaction?.value == - selectedReaction - .id - .toString()) { - // User tapped on the currently selected reaction, so remove it - await _handleReactionChange( - selectedReaction, - tagdetailobj! - .data[ - index] - .id!); - } else { - // User selected a new reaction - var newSelectedReaction = - _reactions - .firstWhere( - (r) => - r.id.toString() == - reaction - ?.value, - orElse: () => - _reactions - .first, // Default reaction if not found - ); - await _handleReactionChange( - newSelectedReaction, - tagdetailobj! - .data[ - index] - .id!); - } - debugPrint( - 'Selected value: ${reaction?.value}'); - }, - reactions: - _reactions - .map((reaction) => - Reaction< - String>( - value: reaction - .id - .toString(), - previewIcon: Image.network( - reaction.image, - width: 24, - height: 24, - fit: BoxFit.cover), - icon: Image.network( - reaction.image, - width: 24, - height: 24, - fit: BoxFit.cover), - )) - .toList(), - selectedReaction: - selectedReaction != - null - ? Reaction< - String>( - value: selectedReaction - .id - .toString(), - icon: Image - .network( - selectedReaction - .image, - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ) - : Reaction< - String>( - value: - '', - icon: Image - .asset( - 'assets/images/png/uiw_like-o.png', - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ), - boxColor: - Colors.white, - boxElevation: 9, - boxRadius: 30, - itemsSpacing: 8, - itemScale: 0.4, - itemSize: - const Size( - 30, 30), - boxPadding: - const EdgeInsets - .all(8), - boxAnimationDuration: - const Duration( - milliseconds: - 200), - itemAnimationDuration: - const Duration( - milliseconds: - 500), - hoverDuration: - const Duration( - milliseconds: - 700), - child: - selectedReaction != - null - ? Image - .network( - selectedReaction - .image, - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ) - : Image - .asset( - 'assets/images/png/uiw_like-o.png', - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ), - sizedBoxHeight(2.h), - text11w400_FCFCFC( - 'Like'), - ], - ) - ], - ), - GestureDetector( - onTap: () {}, - child: Column( - children: [ - Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC( - 'Comment') - ], - ), - ), - Column( - children: [ - GestureDetector( - onTap: () async { - int postid = - tagdetailobj! - .data[index] - .id!; - await saveunsavepost( - postid); - }, - child: tagdetailobj! - .data[index] - .isISaved == - true - ? Image.asset( - 'assets/images/png/postSaved.png', - height: 19.h, - width: 19.w, - ) - : Image.asset( - 'assets/images/png/Frame 1000004089.png', - height: 19.h, - width: 19.w, - ), - ), - // Image.asset( - // 'assets/images/png/Frame 1000004089.png', - // height: 19.h, - // width: 19.w, - // ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Save') - ], - ) - ], - ), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - ]), - ), - ], - )), - sizedBoxHeight(20.h), - ], - ); - } else { - return Column( - children: [ - commonGlassUI( - width: double.infinity, - height: 760.h, - mainOpacity: 1, - borderRadius: BorderRadius.circular(1), - customWidget: Column( - children: [ - sizedBoxHeight(25.h), - Padding( - padding: EdgeInsets.symmetric( - horizontal: 16.w), - child: Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - CircleAvatar( - foregroundImage: NetworkImage( - tagdetailobj! - .data[index] - .iamPrincipal! - .profilePhoto ?? - ''), - radius: 25.r, - ), - sizedBoxWidth(12.w), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC( - tagdetailobj! - .data[index] - .iamPrincipal! - .fullName ?? - ''), - sizedBoxHeight(5.h), - Row( - children: [ - Image.asset( - 'assets/images/png/community 1 (traced).png', - height: 14.w, - width: 14.w, - ), - sizedBoxWidth(7.w), - text12w400_FCFCFC( - tagdetailobj! - .data[index] - .community! - .communityName - .toString()), - sizedBoxWidth(7.w), - Icon( - Icons.circle, - color: const Color( - 0xFFFCFCFC), - size: 4.sp, - ), - sizedBoxWidth(6.w), - text12w400_FCFCFC( - timeAgo!), - ], - ) - ], - ), - const Spacer(), - PopupMenuButton( - surfaceTintColor: - const Color(0xFF222935), - constraints: - BoxConstraints.tightFor( - width: 176.w), - offset: const Offset(0, 50), - color: - const Color(0xFF222935), - tooltip: "", - itemBuilder: - (BuildContext context) => - [ - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets - .symmetric( - horizontal: - 12.w), - child: Row( - children: [ - Text( - 'Report Post', - style: TextStyle( - fontSize: 16.sp, - color: Colors - .white, - fontWeight: - FontWeight - .w800, - fontFamily: - "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/Vector (5).png", - height: 15.h, - width: 15.w, - ) - ], - ), - ), - ), - const PopupMenuDivider(), - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets - .symmetric( - horizontal: - 12.w), - child: Row( - children: [ - Text( - 'Share post', - style: TextStyle( - fontSize: 16.sp, - color: Colors - .white, - fontWeight: - FontWeight - .w800, - fontFamily: - "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/share.png", - height: 20.h, - width: 20.w, - ) - ], - ), - ), - ), - const PopupMenuDivider(), - PopupMenuItem( - onTap: () async { - int pinPospostid = - tagdetailobj! - .data[index] - .iamPrincipal! - .id!; - await pinunpinUser( - pinPospostid); - }, - child: Padding( - padding: EdgeInsets - .symmetric( - horizontal: - 12.w), - child: Row( - children: [ - Text( - tagdetailobj! - .data[ - index] - .iamPrincipal! - .isUserPinned == - true - ? 'Unpin' - : 'Pin', - style: TextStyle( - fontSize: 16.sp, - color: Colors - .white, - fontWeight: - FontWeight - .w800, - fontFamily: - "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/f7_pin-fill (2).png", - height: 25.h, - width: 25.w, - ) - ], - ), - ), - ), - ], - child: Image.asset( - 'assets/images/png/Group 1000004071.png', - width: 16.w, - height: 18.h, - ), - ), - sizedBoxWidth(5.w) - ], - ), - ), - sizedBoxHeight(20.h), - GestureDetector( - onTap: () { - Get.toNamed( - RouteName.postdetailsScreen); - }, - child: Container( - height: 360, - width: double.infinity, - decoration: BoxDecoration( - image: DecorationImage( - fit: BoxFit.cover, - image: NetworkImage( - tagdetailobj!.data[index] - .image ?? - '', - ), - ), - ), - ), - ), - sizedBoxHeight(20.h), - Padding( - padding: EdgeInsets.symmetric( - horizontal: 16.w), - child: Column(children: [ - // SizedBox( - // height: 30.h, - // child: ListView.builder( - // scrollDirection: Axis.horizontal, - // shrinkWrap: true, - // itemCount: tagdetailobj! - // .data[index].attachTags.length, - // itemBuilder: (context, tagIndex) { - // print( - // 'tags id are ${tagdetailobj!.data[index].attachTags[tagIndex].manageTag!.id}'); - // print( - // 'tags name are ${tagdetailobj!.data[index].attachTags[tagIndex].manageTag!.name}'); - // return Padding( - // padding: EdgeInsets.only( - // right: 12.w), - // child: GestureDetector( - // onTap: () { - // print('tag tapped'); - // Get.toNamed( - // RouteName.tagdetailscreen, - // arguments: { - // 'tagid': - // tagdetailobj! - // .data[index] - // .attachTags[ - // tagIndex].manageTag! - // .id, - // 'tagname': - // tagdetailobj! - // .data[index] - // .attachTags[ - // tagIndex].manageTag! - // .name, - // }); - // }, - // child: - // // containertile2( - // // text: (tagdetailobj! - // // .data[index] - // // .tagNames[index]) - // // ) - // commonContainer( - // width: 130.w, - // height: 30.h, - // borderRadius: - // BorderRadius - // .circular( - // 30.r), - // borderColor: - // const Color( - // 0xFFD90B2E), - // opacity1: 0.04, - // opacity2: 0.05, - // customWidget: - // Padding( - // padding: EdgeInsets - // .symmetric( - // horizontal: - // 10.w), - // child: Center( - // child: text14w400_FCFCFC(tagdetailobj! - // .data[ - // index] - // .attachTags[ - // tagIndex].manageTag! - // .name!)), - // )), - // ), - // ); - // }, - // ), - // ), - SizedBox( - height: 30.h, - width: double.infinity, - child: ListView.builder( - scrollDirection: - Axis.horizontal, - shrinkWrap: true, - // Filter the tags to include only those with a non-null and non-empty name - itemCount: tagdetailobj! - .data[index].attachTags - .where((tag) => - tag.manageTag?.name - ?.isNotEmpty ?? - false) - .length, - itemBuilder: - (context, tagIndex) { - // Filtered list of tags - var filteredTags = - tagdetailobj! - .data[index] - .attachTags - .where((tag) => - tag - .manageTag - ?.name - ?.isNotEmpty ?? - false) - .toList(); - - // Safely get the manageTag object - var manageTag = - filteredTags[tagIndex] - .manageTag; - - // Get the tag name, ensuring it's not null or empty - String tagName = - manageTag?.name ?? ''; - - return Padding( - padding: EdgeInsets.only( - right: 12.w, - left: 12.w), - child: GestureDetector( - onTap: () { - print( - 'anonymous tapped'); - Get.back(); - Get.toNamed( - RouteName - .tagdetailscreen, - arguments: { - 'tagid': tagdetailobj! - .data[index] - .attachTags[ - tagIndex] - .manageTag! - .id, - - // filteredTags[ - // tagIndex] - // .manageTagXid, - 'tagname': - tagName, - 'ispinnedtag': - filteredTags[ - tagIndex] - .manageTag! - .isPinned - }); - }, - child: Row( - mainAxisAlignment: - MainAxisAlignment - .start, - children: [ - commonContainer( - width: 130.w, - height: 30.h, - borderRadius: - BorderRadius - .circular( - 30.r), - borderColor: - const Color( - 0xFFD90B2E), - opacity1: 0.04, - opacity2: 0.05, - customWidget: - Padding( - padding: EdgeInsets - .symmetric( - horizontal: - 10.w), - child: Center( - child: text14w400_FCFCFC( - '#${tagName}'), - ), - ), - ), - ], - ), - ), - ); - }, - ), - ), - sizedBoxHeight(20.h), - SizedBox( - width: double.infinity, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC( - tagdetailobj! - .data[index] - .caption ?? - ''), - ], - ), - ), - Row(children: [ - InkWell( - onTap: () { - Get.toNamed( - RouteName.reactionview); - }, - child: stackReaction( - number: tagdetailobj! - .data[index].likecount - .toString(), - containerImages: [ - 'assets/images/png/f7_hand-thumbsup.png', - 'assets/images/png/heart 2.png', - 'assets/images/png/party-popper 2.png' - ]), - ), - const Spacer(), - commonContainer( - width: 30.w, - height: 30.h, - borderColor: - const Color(0xFF434A53), - borderwidth: 0.43, - opacity1: 0.2, - opacity2: 0.2, - boxShape: BoxShape.circle, - customWidget: Center( - child: Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 13.h, - width: 13.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC(tagdetailobj! - .data[index].totalComment - .toString()), - sizedBoxWidth(20.w), - commonContainer( - width: 30.w, - height: 30.h, - borderColor: - const Color(0xFF434A53), - borderwidth: 0.43, - opacity1: 0.2, - opacity2: 0.2, - boxShape: BoxShape.circle, - customWidget: Center( - child: Image.asset( - 'assets/images/png/Vector (1).png', - height: 12.h, - width: 12.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC(tagdetailobj! - .data[index].totalSave - .toString()), - ]), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - children: [ - Column( - mainAxisAlignment: - MainAxisAlignment - .center, - children: [ - Column( - children: [ - ReactionButton< - String>( - onReactionChanged: - (reaction) async { - if (selectedReaction != - null && - reaction?.value == - selectedReaction - .id - .toString()) { - // User tapped on the currently selected reaction, so remove it - await _handleReactionChange( - selectedReaction, - tagdetailobj! - .data[ - index] - .id!); - } else { - // User selected a new reaction - var newSelectedReaction = - _reactions - .firstWhere( - (r) => - r.id.toString() == - reaction - ?.value, - orElse: () => - _reactions - .first, // Default reaction if not found - ); - await _handleReactionChange( - newSelectedReaction, - tagdetailobj! - .data[ - index] - .id!); - } - debugPrint( - 'Selected value: ${reaction?.value}'); - }, - reactions: - _reactions - .map((reaction) => - Reaction< - String>( - value: reaction - .id - .toString(), - previewIcon: Image.network( - reaction.image, - width: 24, - height: 24, - fit: BoxFit.cover), - icon: Image.network( - reaction.image, - width: 24, - height: 24, - fit: BoxFit.cover), - )) - .toList(), - selectedReaction: - selectedReaction != - null - ? Reaction< - String>( - value: selectedReaction - .id - .toString(), - icon: Image - .network( - selectedReaction - .image, - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ) - : Reaction< - String>( - value: - '', - icon: Image - .asset( - 'assets/images/png/uiw_like-o.png', - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ), - boxColor: - Colors.white, - boxElevation: 9, - boxRadius: 30, - itemsSpacing: 8, - itemScale: 0.4, - itemSize: - const Size( - 30, 30), - boxPadding: - const EdgeInsets - .all(8), - boxAnimationDuration: - const Duration( - milliseconds: - 200), - itemAnimationDuration: - const Duration( - milliseconds: - 500), - hoverDuration: - const Duration( - milliseconds: - 700), - child: - selectedReaction != - null - ? Image - .network( - selectedReaction - .image, - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ) - : Image - .asset( - 'assets/images/png/uiw_like-o.png', - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ), - sizedBoxHeight(2.h), - text11w400_FCFCFC( - 'Like'), - ], - ) - ], - ), - GestureDetector( - onTap: () { - Get.toNamed(RouteName - .postdetailsScreen); - }, - child: Column( - children: [ - Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC( - 'Comment') - ], - ), - ), - InkWell( - onTap: () {}, - child: Column( - children: [ - GestureDetector( - onTap: () async { - int postid = - tagdetailobj! - .data[index] - .id!; - await saveunsavepost( - postid); - }, - child: tagdetailobj! - .data[ - index] - .isISaved == - true - ? Image.asset( - 'assets/images/png/postSaved.png', - height: 19.h, - width: 19.w, - ) - : Image.asset( - 'assets/images/png/Frame 1000004089.png', - height: 19.h, - width: 19.w, - ), - ), - // Image.asset( - // 'assets/images/png/Frame 1000004089.png', - // height: 19.h, - // width: 19.w, - // ), - sizedBoxHeight(8.h), - text11w400_FCFCFC( - 'Save') - ], - ), - ), - ], - ), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - ]), - ), - ], - )), + NormalCardTile( + tags: _sortTags(index), + createAt: timeAgo ?? '1 hour', + commonObj: commonobjmodel!.data[index], + forWhichTab: 'popular', + reactions: _reactions, + selectedReactions: _selectedReactions, + currentIndex: index, + ), sizedBoxHeight(20.h) ], ); - } - }, + }, + ), ), - ), - ], - ); + ], + ) + ]); } return Container(); }); diff --git a/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart b/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart index 2acca0a..0a82861 100644 --- a/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart +++ b/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart @@ -59,7 +59,7 @@ List pinButtonPopular = []; RxList commentsCounterComPosts = [].obs; RxList savePostCounterComPosts = [].obs; RxList saveButtonComPosts = [].obs; - RxList pinButtonComPosts = [].obs; + // RxList pinButtonComPosts = [].obs; setListsComPosts() { likesCounterComPosts.clear(); @@ -73,9 +73,35 @@ List pinButtonPopular = []; .add(commonobjmodel?.data[i].totalCommentCount ?? 0); savePostCounterComPosts.add(commonobjmodel?.data[i].totalSave ?? 0); saveButtonComPosts.add(commonobjmodel?.data[i].isISaved ?? false); - pinButtonComPosts - .add(commonobjmodel?.data[i].iamPrincipal?.isUserPinned ?? false); + // pinButtonComPosts + // .add(commonobjmodel?.data[i].iamPrincipal?.isUserPinned ?? false); } } + +//tagPostPopular + RxList likesCountertagPopular = [].obs; + RxList commentsCountertagPopular = [].obs; + RxList savePostCountertagPopular = [].obs; + + setListstagPopular() { + for (var i = 0; i < combinedListGlobal.length; i++) { + likesCounterLatest.add(combinedListGlobal[i].likecount ?? 0); + commentsCounterLatest.add(combinedListGlobal[i].totalCommentCount ?? 0); + savePostCounterLatest.add(combinedListGlobal[i].totalSave ?? 0); + } + } + + //tagPostLatest + RxList likesCountertagLatest = [].obs; + RxList commentsCountertagLatest = [].obs; + RxList savePostCountertagLatest = [].obs; + + setListstagtagLatest() { + for (var i = 0; i < combinedListGlobal.length; i++) { + likesCounterLatest.add(combinedListGlobal[i].likecount ?? 0); + commentsCounterLatest.add(combinedListGlobal[i].totalCommentCount ?? 0); + savePostCounterLatest.add(combinedListGlobal[i].totalSave ?? 0); + } + } } diff --git a/lib/Main_Screens/ProfileTab/Certificate/AddCertificate.dart b/lib/Main_Screens/ProfileTab/Certificate/AddCertificate.dart index 970e945..b6d10fb 100644 --- a/lib/Main_Screens/ProfileTab/Certificate/AddCertificate.dart +++ b/lib/Main_Screens/ProfileTab/Certificate/AddCertificate.dart @@ -3,7 +3,6 @@ import 'dart:io'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart' hide MultipartFile, FormData; import 'package:regroup/Common/base_manager.dart'; @@ -155,7 +154,7 @@ class _AddCertificateState extends State { text16400white("Certification name"), sizedBoxHeight(16.h), CustomTextFormField( - leadingIcon: Container( + leadingIcon: SizedBox( height: 17.h, width: 18.w, child: Center( @@ -186,7 +185,7 @@ class _AddCertificateState extends State { text16400white("Certification reason"), sizedBoxHeight(16.h), CustomTextFormField( - leadingIcon: Container( + leadingIcon: SizedBox( height: 17.h, width: 18.w, child: Center( diff --git a/lib/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart b/lib/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart index 6e497cf..3e19f97 100644 --- a/lib/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart +++ b/lib/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart @@ -17,7 +17,7 @@ class EditProfileApi { EditProfileApi(); Future> postEditProfileIndividual(var data) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); + // SharedPreferences prefs = await SharedPreferences.getInstance(); final response = await NetworkApiServices().postApi(data, ApiUrls.posteditprofile); @@ -62,7 +62,7 @@ class EditProfileApi { } Future> postEditProfileBusiness(var data) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); + // SharedPreferences prefs = await SharedPreferences.getInstance(); final response = await NetworkApiServices() .postApi(data, ApiUrls.posteditprofilebusiness); diff --git a/lib/Main_Screens/ProfileTab/Followers/Followers.dart b/lib/Main_Screens/ProfileTab/Followers/Followers.dart index 69136b0..adc2d9b 100644 --- a/lib/Main_Screens/ProfileTab/Followers/Followers.dart +++ b/lib/Main_Screens/ProfileTab/Followers/Followers.dart @@ -68,7 +68,7 @@ class _FollowersState extends State { int? blockid; int? removeid; - RemoveUploadata() async { + removeUploadata() async { utils.loader(); Map updata = { "iam_principal_xid": removeid, @@ -85,7 +85,7 @@ class _FollowersState extends State { } } - BlockUploadata() async { + blockUploadata() async { utils.loader(); Map updata = { "blocked_iam_principal_xid": blockid, @@ -334,7 +334,7 @@ class _FollowersState extends State { followersobj!.data!.removeWhere((item) => item.follower!.id == removeid); - RemoveUploadata(); + removeUploadata(); }); }, child: @@ -399,7 +399,7 @@ class _FollowersState extends State { followersobj!.data!.removeWhere((item) => item.follower!.id == blockid); - BlockUploadata(); + blockUploadata(); }); }, child: diff --git a/lib/Utils/texts.dart b/lib/Utils/texts.dart index de9d751..6836195 100644 --- a/lib/Utils/texts.dart +++ b/lib/Utils/texts.dart @@ -346,6 +346,9 @@ Widget text18w400white(String text, {TextAlign? textAlign}) { ); } + + + Widget text14w400white(String text, {TextAlign? textAlign}) { return Text( text, diff --git a/lib/resources/routes/routes.dart b/lib/resources/routes/routes.dart index 9246e61..e8be143 100644 --- a/lib/resources/routes/routes.dart +++ b/lib/resources/routes/routes.dart @@ -68,8 +68,8 @@ import 'package:regroup/onboarding/Signup/View/Business/View/busSignupScreen.dar import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/CommunitySetting.dart'; import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/EditCommunity/EditCommunity.dart'; import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageGroup.dart'; -import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageTags.dart/ManageTags.dart'; -import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageTags.dart/NewTag/NewTag.dart'; +import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageTags.dart/ManageInterest.dart'; +import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageTags.dart/View/NewTag/NewTag.dart'; import 'package:regroup/sidemenu/Community/Announcements/AnnouncementRequest.dart'; import 'package:regroup/sidemenu/Community/Announcements/ManageMembers.dart'; import 'package:regroup/sidemenu/Community/Announcements/NewAnnouncement/NewAnnounceent.dart'; diff --git a/lib/sidemenu/Community/Admin/PopupItem/Community settings/CommunitySetting.dart b/lib/sidemenu/Community/Admin/PopupItem/Community settings/CommunitySetting.dart index 0f0e2a2..5f32faf 100644 --- a/lib/sidemenu/Community/Admin/PopupItem/Community settings/CommunitySetting.dart +++ b/lib/sidemenu/Community/Admin/PopupItem/Community settings/CommunitySetting.dart @@ -16,8 +16,7 @@ class CommunitySetting extends StatefulWidget { } class _CommunitySettingState extends State { - - int communityid = Get.arguments['communityid']; + int communityid = Get.arguments['communityid']; @override Widget build(BuildContext context) { return Scaffold( @@ -39,11 +38,9 @@ class _CommunitySettingState extends State { sizedBoxHeight(30.h), GestureDetector( onTap: () { - Get.toNamed(RouteName.editcommunity, - arguments: { - 'communityid' : communityid, - } - ); + Get.toNamed(RouteName.editcommunity, arguments: { + 'communityid': communityid, + }); }, child: rowTile(text: 'Edit community info')), commonDivider(), @@ -61,9 +58,11 @@ class _CommunitySettingState extends State { commonDivider(), GestureDetector( onTap: () { - Get.toNamed(RouteName.managetags); + Get.toNamed(RouteName.managetags, arguments: { + 'communityid': communityid, + }); }, - child: rowTile(text: 'Manage tags')), + child: rowTile(text: 'Manage interest')), sizedBoxHeight(20.h), ]) ])); diff --git a/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ManageTags.dart b/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ManageInterest.dart similarity index 93% rename from lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ManageTags.dart rename to lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ManageInterest.dart index 2125226..2a23ba5 100644 --- a/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ManageTags.dart +++ b/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ManageInterest.dart @@ -19,6 +19,8 @@ class ManageTags extends StatefulWidget { } class _ManageTagsState extends State { + int communityid = Get.arguments['communityid']; + @override Widget build(BuildContext context) { return Scaffold( @@ -26,7 +28,7 @@ class _ManageTagsState extends State { backgroundColor: Color(0xFF222935), extendBody: true, appBar: CommonAppbar( - titleTxt: "Manage tags", + titleTxt: "Manage interest", ), resizeToAvoidBottomInset: false, body: Stack(children: [ @@ -45,7 +47,7 @@ class _ManageTagsState extends State { child: Column(children: [ CommonTabBar(tabs: const [ Tab( - text: 'Tags', + text: 'Interest', ), Tab( text: 'Tag requests', @@ -79,7 +81,9 @@ class _ManageTagsState extends State { ), child: FloatingActionButton( onPressed: () { - Get.toNamed(RouteName.newtag); + Get.toNamed(RouteName.newtag, arguments: { + 'communityid': communityid, + }); }, backgroundColor: Color(0xFFD90B2E), autofocus: true, @@ -102,7 +106,7 @@ Widget tagsTab() { sizedBoxHeight(25.h), Padding( padding: EdgeInsets.symmetric(horizontal: 16.w), - child: text16400white("Special Announcement Tags"), + child: text16400white("Special Announcement Interest"), ), sizedBoxHeight(15.h), ListView.builder( @@ -171,7 +175,7 @@ Widget rowTagRequestTile({ child: commonGlassUI( width: double.infinity, height: 60.h, - borderRadius: BorderRadius.circular( 10.r), + borderRadius: BorderRadius.circular(10.r), customWidget: Center( child: Padding( padding: EdgeInsets.symmetric(horizontal: 16.w), @@ -183,7 +187,7 @@ Widget rowTagRequestTile({ height: 35.h, opacity1: 0.24, opacity2: 0.24, - borderRadius: BorderRadius.circular( 100), + borderRadius: BorderRadius.circular(100), customWidget: Center( child: Icon( Icons.clear, diff --git a/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/NewTag/NewTag.dart b/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/NewTag/NewTag.dart deleted file mode 100644 index 32a983b..0000000 --- a/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/NewTag/NewTag.dart +++ /dev/null @@ -1,60 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:regroup/Utils/Common/CommonAppbar.dart'; -import 'package:regroup/Utils/Common/CustomNextButton.dart'; -import 'package:regroup/Utils/Common/CustomTextformfield.dart'; - -import 'package:regroup/Utils/Common/sized_box.dart'; -import 'package:regroup/Utils/texts.dart'; - -class NewTag extends StatefulWidget { - const NewTag({super.key}); - - @override - State createState() => _NewTagState(); -} - -class _NewTagState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - // key: _scaffoldKey1, - backgroundColor: Color(0xFF222935), - extendBody: true, - appBar: CommonAppbar( - titleTxt: "New tag", - ), - resizeToAvoidBottomInset: false, - body: Stack(children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/png/Ellipse 1496.png"), - fit: BoxFit.fill)), - ), - SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.end, - children: [ - sizedBoxHeight(30.h), - text16w400_FCFCFC("Tag name"), - sizedBoxHeight(16.h), - CustomTextFormField( - hintText: "", - validator: (val) { - if (val == null || val.isEmpty) { - return 'Enter a tag name'; - } - return null; - }, - ), - sizedBoxHeight(80.h), - CustomButton(text: "Add", onPressed: () {}) - ]), - )) - ])); - } -} diff --git a/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/View/NewTag/NewTag.dart b/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/View/NewTag/NewTag.dart new file mode 100644 index 0000000..697c3f0 --- /dev/null +++ b/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/View/NewTag/NewTag.dart @@ -0,0 +1,143 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Utils/Common/CommonAppbar.dart'; +import 'package:regroup/Utils/Common/CustomNextButton.dart'; +import 'package:regroup/Utils/Common/CustomTextformfield.dart'; + +import 'package:regroup/Utils/Common/sized_box.dart'; +import 'package:regroup/Utils/dialogs.dart'; +import 'package:regroup/Utils/texts.dart'; +import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageTags.dart/ViewModel/maanageInterestApi.dart'; + +enum Interests { tag1, tag2 } + +class NewTag extends StatefulWidget { + const NewTag({super.key}); + + @override + State createState() => _NewTagState(); +} + +class _NewTagState extends State { + int communityid = Get.arguments['communityid']; + Interests? _tags = Interests.tag1; + final interestController = TextEditingController(); + + addSuccess() async { + String isSpecialValue = _tags == Interests.tag1 ? "0" : "1"; + Map updata = { + "manage_community_xid": communityid.toString(), + "name": interestController.text, + "is_special": isSpecialValue, + }; + final data = await ManageInterestApi().postNewInterest(updata); + if (data.status == ResponseStatus.SUCCESS) { + print("success"); + Get.back(); + + return utils.showToast(data.message); + } else { + // Get.back(); + print("Failed"); + return utils.showToast(data.message); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + // key: _scaffoldKey1, + backgroundColor: const Color(0xFF222935), + extendBody: true, + appBar: const CommonAppbar( + titleTxt: "New interest", + ), + resizeToAvoidBottomInset: false, + body: Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), + ), + SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + sizedBoxHeight(30.h), + text16w400_FCFCFC("Interest name"), + sizedBoxHeight(16.h), + CustomTextFormField( + textEditingController: interestController, + hintText: "", + validator: (val) { + if (val == null || val.isEmpty) { + return 'Enter a interest name'; + } + return null; + }, + ), + sizedBoxHeight(40.h), + text16w400_FCFCFC("Nature of interest"), + sizedBoxHeight(40.h), + Row( + children: [ + Transform.scale( + scale: 1.2, + child: Radio( + fillColor: + const MaterialStatePropertyAll(Color(0xFFD90B2E)), + activeColor: const Color(0xFFD90B2E), + value: Interests.tag1, + groupValue: _tags, + onChanged: (Interests? val) { + setState(() { + _tags = val; + }); + }, + ), + ), + text18w400white("Special Announcement Tag") + ], + ), + sizedBoxHeight(10.h), + Row( + children: [ + Transform.scale( + scale: 1.2, + child: Radio( + fillColor: + const MaterialStatePropertyAll(Color(0xFFD90B2E)), + activeColor: const Color(0xFFD90B2E), + value: Interests.tag2, + groupValue: _tags, + onChanged: (Interests? val) { + setState(() { + _tags = val; + }); + }, + ), + ), + text18w400white("Standard Tag") + ], + ), + sizedBoxHeight(80.h), + CustomButton( + text: "Add", + onPressed: () { + if (interestController.text.isBlank!) { + utils.showToast("Enter your interest"); + } else { + addSuccess(); + } + }) + ]), + )) + ])); + } +} diff --git a/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ViewModel/maanageInterestApi.dart b/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ViewModel/maanageInterestApi.dart new file mode 100644 index 0000000..54ac6d2 --- /dev/null +++ b/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ViewModel/maanageInterestApi.dart @@ -0,0 +1,36 @@ +// InviteComModel ? inviteComobj; + +import 'package:regroup/Common/api_urls.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Common/controller/data/network/network_api.dart'; +import 'package:regroup/Utils/dialogs.dart'; + +class ManageInterestApi { + Future> postNewInterest(updata) async { + print("updata is $updata"); + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.postnewinterest, + ); + if (response.status == ResponseStatus.SUCCESS) { + if (response.data["status"] == "success") { + // likepostobj = LikepostModel.fromJson(response.data); + } + + return ResponseData( + response.data['message'], ResponseStatus.SUCCESS, + data: response.data); + } else if (response.status == ResponseStatus.FAILED) { + if (response.data["status"] == "error") { + utils.showToast(response.message); + } + + return ResponseData( + response.data['message'], ResponseStatus.FAILED, + data: response.data); + } else { + return ResponseData( + response.data['message'], ResponseStatus.FAILED); + } + } +} diff --git a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart index fbf32d3..2e06911 100644 --- a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart +++ b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart @@ -7,6 +7,7 @@ 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'; @@ -163,6 +164,28 @@ class _CommunityDetailsState extends State { ), ), const PopupMenuDivider(), + PopupMenuItem( + onTap: () { + Get.toNamed(RouteName.communitysetting, arguments: { + 'communityid': CommunityId, + }); + }, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 8.w), + child: Row( + children: [ + text14w400white("Edit community"), + const Spacer(), + Image.asset( + "assets/images/png/setting2.png", + height: 18.h, + width: 18.w, + ) + ], + ), + ), + ), + const PopupMenuDivider(), PopupMenuItem( onTap: () { leaveCommunity(); @@ -523,15 +546,15 @@ class _CommunityDetailsState extends State { borderwidth: 1), ), sizedBoxHeight(40.h), - Container( - height: 40.h, - width: 200.w, - decoration: BoxDecoration( - color: const Color(0xFFD90B2E), - borderRadius: BorderRadius.circular(30.r)), - child: Center( - child: text14w400white("Leave the community")), - ), + // Container( + // height: 40.h, + // width: 200.w, + // decoration: BoxDecoration( + // color: const Color(0xFFD90B2E), + // borderRadius: BorderRadius.circular(30.r)), + // child: Center( + // child: text14w400white("Leave the community")), + // ), sizedBoxHeight(50.h), ])), DefaultTabController( @@ -587,7 +610,7 @@ class _PostsTabState extends State { super.initState(); } - _fetchIcons() { + _fetchIcons() { _reactions = fetchlikeIconsModel!.data ?? []; for (var post in commonobjmodel!.data) { //Check if post as a like icon @@ -755,12 +778,13 @@ class _PostsTabState extends State { children: [ NormalCardTile( tags: _sortTags(index), - create_at: timeAgo ?? '1 hour', + createAt: timeAgo ?? '1 hour', commonObj: commonobjmodel!.data[index], forWhichTab: 'popular', reactions: _reactions, selectedReactions: _selectedReactions, currentIndex: index, + coachbool: true, ), sizedBoxHeight(20.h) ],