diff --git a/assets/images/png/postSaved.png b/assets/images/png/postSaved.png new file mode 100644 index 0000000..3cef09f Binary files /dev/null and b/assets/images/png/postSaved.png differ diff --git a/lib/Common/CommonPostUI.dart b/lib/Common/CommonPostUI.dart index 32e31e2..0d0d057 100644 --- a/lib/Common/CommonPostUI.dart +++ b/lib/Common/CommonPostUI.dart @@ -241,7 +241,7 @@ class _CommonPostUIState extends State { padding: EdgeInsets.only(right: 12.w), child: GestureDetector( onTap: () { - Get.toNamed(RouteName.cyclescreen); + Get.toNamed(RouteName.tagdetailscreen); }, child: containertile(text: containerTitle[index])), ); diff --git a/lib/Common/api_urls.dart b/lib/Common/api_urls.dart index 963350c..ae037c6 100644 --- a/lib/Common/api_urls.dart +++ b/lib/Common/api_urls.dart @@ -130,6 +130,10 @@ class ApiUrls { static const postLike = "${baseUrl}like-post"; + static const getTagsdetails = "${baseUrl}fetch-post-by-tag"; + + static const postusersave = "${baseUrl}save-post"; + } diff --git a/lib/Main_Screens/Community/Model/LatestPostModel.dart b/lib/Main_Screens/Community/Model/LatestPostModel.dart index ab3b0a5..5fe3cb6 100644 --- a/lib/Main_Screens/Community/Model/LatestPostModel.dart +++ b/lib/Main_Screens/Community/Model/LatestPostModel.dart @@ -26,6 +26,7 @@ class Datum { Datum({ required this.id, required this.likecount, + required this.isISaved, required this.tagsXid, required this.isILiked, required this.totalComment, @@ -39,14 +40,21 @@ class Datum { required this.ctaTitle, required this.ctaLink, required this.createdAt, - required this.tagNames, required this.likeIcon, + required this.totalViewCount, + required this.totalReactionCount, + required this.totalCommentCount, + required this.totalImpressionCount, + required this.totalPopularScore, + required this.totalHoursAgo, required this.iamPrincipal, required this.community, + required this.attachTags, }); final int? id; final int? likecount; + final bool? isISaved; final List tagsXid; final bool? isILiked; final int? totalComment; @@ -60,15 +68,22 @@ class Datum { final String? ctaTitle; final String? ctaLink; final DateTime? createdAt; - final List tagNames; final LikeIcon? likeIcon; + final int? totalViewCount; + final int? totalReactionCount; + final int? totalCommentCount; + final int? totalImpressionCount; + final int? totalPopularScore; + final int? totalHoursAgo; final IamPrincipal? iamPrincipal; final Community? community; + final List attachTags; factory Datum.fromJson(Map json){ return Datum( id: json["id"], likecount: json["likecount"], + isISaved: json["is_i_saved"], tagsXid: json["tags_xid"] == null ? [] : List.from(json["tags_xid"]!.map((x) => x)), isILiked: json["is_i_liked"], totalComment: json["total_comment"], @@ -82,10 +97,58 @@ class Datum { ctaTitle: json["cta_title"], ctaLink: json["cta_link"], createdAt: DateTime.tryParse(json["created_at"] ?? ""), - tagNames: json["tag_names"] == null ? [] : List.from(json["tag_names"]!.map((x) => x)), likeIcon: json["likeIcon"] == null ? null : LikeIcon.fromJson(json["likeIcon"]), + totalViewCount: json["totalViewCount"], + totalReactionCount: json["totalReactionCount"], + totalCommentCount: json["totalCommentCount"], + totalImpressionCount: json["totalImpressionCount"], + totalPopularScore: json["totalPopularScore"], + totalHoursAgo: json["totalHoursAgo"], iamPrincipal: json["iam_principal"] == null ? null : IamPrincipal.fromJson(json["iam_principal"]), community: json["community"] == null ? null : Community.fromJson(json["community"]), + attachTags: json["attach_tags"] == null ? [] : List.from(json["attach_tags"]!.map((x) => AttachTag.fromJson(x))), + ); + } + +} + +class AttachTag { + AttachTag({ + required this.managePostXid, + required this.manageTagXid, + required this.manageTag, + }); + + final int? managePostXid; + final int? manageTagXid; + final ManageTag? manageTag; + + factory AttachTag.fromJson(Map json){ + return AttachTag( + managePostXid: json["manage_post_xid"], + manageTagXid: json["manage_tag_xid"], + manageTag: json["manage_tag"] == null ? null : ManageTag.fromJson(json["manage_tag"]), + ); + } + +} + +class ManageTag { + ManageTag({ + required this.id, + required this.isPinned, + required this.name, + }); + + final int? id; + final bool? isPinned; + final String? name; + + factory ManageTag.fromJson(Map json){ + return ManageTag( + id: json["id"], + isPinned: json["is_pinned"], + name: json["name"], ); } @@ -115,6 +178,7 @@ class Community { class IamPrincipal { IamPrincipal({ required this.id, + required this.isUserPinned, required this.principalTypeXid, required this.userName, required this.fullName, @@ -122,14 +186,16 @@ class IamPrincipal { }); final int? id; + final bool? isUserPinned; final int? principalTypeXid; final String? userName; - final dynamic fullName; + final String? fullName; final String? profilePhoto; factory IamPrincipal.fromJson(Map json){ return IamPrincipal( id: json["id"], + isUserPinned: json["is_user_pinned"], principalTypeXid: json["principal_type_xid"], userName: json["user_name"], fullName: json["full_name"], diff --git a/lib/Main_Screens/Community_HomePage/Community.dart b/lib/Main_Screens/Community_HomePage/Community.dart index fa9944b..71b9309 100644 --- a/lib/Main_Screens/Community_HomePage/Community.dart +++ b/lib/Main_Screens/Community_HomePage/Community.dart @@ -20,6 +20,7 @@ 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/getmethod.dart'; import 'package:regroup/Main_Screens/Community/ViewModel/postmethod.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/view_model/communitypostmethod.dart'; // import 'package:regroup/Feed%20Module/sidemenu/sidemenu.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; import 'package:regroup/Utils/dialogs.dart'; @@ -27,6 +28,7 @@ import 'package:regroup/Utils/texts.dart'; import 'package:regroup/resources/routes/route_name.dart'; import 'package:regroup/sidemenu/sidemenu.dart'; import 'package:async/src/future_group.dart'; +import 'package:regroup/sidemenu/view_model/postmethod.dart'; class CommunityScreen extends StatefulWidget { const CommunityScreen({super.key}); @@ -552,7 +554,11 @@ Widget normalcardtile2({ padding: EdgeInsets.only(right: 12.w), child: GestureDetector( onTap: () { - Get.toNamed(RouteName.cyclescreen); + // Get.toNamed(RouteName.cyclescreen, ); + // arguments: { + // 'tagid': latestpostobj!.data[index].tagsData[index].id, + // 'tagname' : latestpostobj!.data[index].tagsData[index].name, + // } }, child: containertile2( text: ("#${containerTitle[index]}"))), @@ -1272,16 +1278,15 @@ class _LatestTabState extends State { List _reactions = []; Map _selectedReactions = {}; - Future _initializeData() async { await _fetchIcons(); // _initializeSelectedReaction(); for (var post in latestpostobj!.data) { - if (post.likeIcon != null) { - likeIconIdnew = post.likeIcon!.likeIconsXid; // This is safe now - } else { - likeIconIdnew = 0; // Or handle it as needed - } + if (post.likeIcon != null) { + likeIconIdnew = post.likeIcon!.likeIconsXid; // This is safe now + } else { + likeIconIdnew = 0; // Or handle it as needed + } _initializeSelectedReaction(post.id!); // Pass the post ID } } @@ -1379,6 +1384,44 @@ class _LatestTabState extends State { } } + saveunsavepost(int latestpostid) async { + // utils.loader(); + Map updata = { + "manage_posts_xid": latestpostid, + }; + final data = await Communitypostmethod().postUserSave(updata); + if (data.status == ResponseStatus.SUCCESS) { + LatespostApi().getLatestPostApi().then((value) { + _initializeData(); + setState(() {}); + }); + + return utils.showToast(data.message); + } else { + // Get.back(); + return utils.showToast(data.message); + } + } + + 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(); + LatespostApi().getLatestPostApi().then((value) { + _initializeData(); + setState(() {}); + }); + return utils.showToast(data.message); + } else { + // Get.back(); + return utils.showToast(data.message); + } + } + @override Widget build(BuildContext context) { return FutureBuilder( @@ -1600,36 +1643,36 @@ class _LatestTabState extends State { ), ), ), - const PopupMenuDivider(), - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: - EdgeInsets.symmetric( - horizontal: 12.w), - child: Row( - children: [ - Text( - '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, - ) - ], - ), - ), - ), + // const PopupMenuDivider(), + // PopupMenuItem( + // onTap: () {}, + // child: Padding( + // padding: + // EdgeInsets.symmetric( + // horizontal: 12.w), + // child: Row( + // children: [ + // Text( + // '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', @@ -1664,31 +1707,96 @@ class _LatestTabState extends State { child: Column(children: [ 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: latestpostobj! - .data[index].tagNames.length, - itemBuilder: (context, index) { + .data[index].attachTags + .where((tag) => + tag.manageTag?.name + ?.isNotEmpty ?? + false) + .length, + itemBuilder: (context, tagIndex) { + // Filtered list of tags + var filteredTags = + latestpostobj! + .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), + right: 12.w, left: 12.w), child: GestureDetector( - onTap: () { - // Get.toNamed(RouteName.cyclescreen); - }, - child: Row( - mainAxisAlignment: - MainAxisAlignment - .start, - children: [ - containertile2( - text: latestpostobj! - .data[index] - .tagNames[ - index]), - ], - )), + onTap: () { + Get.toNamed( + RouteName + .tagdetailscreen, + arguments: { + 'tagid': + // filteredTags[ + // tagIndex] + // .manageTagXid, + latestpostobj! + .data[index] + .attachTags[ + tagIndex] + .manageTag! + .id, + '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}'), + ), + ), + ), + ], + ), + ), ); }, ), @@ -1934,11 +2042,34 @@ class _LatestTabState extends State { ), Column( children: [ - Image.asset( - 'assets/images/png/Frame 1000004089.png', - height: 19.h, - width: 19.w, + GestureDetector( + onTap: () async { + int latestpostid = + latestpostobj! + .data[index].id!; + await saveunsavepost( + latestpostid); + }, + child: latestpostobj! + .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') ], @@ -2119,7 +2250,15 @@ class _LatestTabState extends State { ), const PopupMenuDivider(), PopupMenuItem( - onTap: () {}, + onTap: () async { + int pinPospostid = + latestpostobj! + .data[index] + .iamPrincipal! + .id!; + await pinunpinUser( + pinPospostid); + }, child: Padding( padding: EdgeInsets.symmetric( @@ -2127,7 +2266,14 @@ class _LatestTabState extends State { child: Row( children: [ Text( - 'Pin', + latestpostobj! + .data[ + index] + .iamPrincipal! + .isUserPinned == + true + ? 'Unpin' + : 'Pin', style: TextStyle( fontSize: 16.sp, color: Colors.white, @@ -2184,27 +2330,175 @@ class _LatestTabState extends State { padding: EdgeInsets.symmetric( horizontal: 16.w), child: Column(children: [ + // SizedBox( + // height: 30.h, + // child: ListView.builder( + // scrollDirection: Axis.horizontal, + // shrinkWrap: true, + // itemCount: latestpostobj! + // .data[index].attachTags.length, + // itemBuilder: (context, tagIndex) { + // print( + // 'tags id are ${latestpostobj!.data[index].attachTags[tagIndex].manageTag!.id}'); + // print( + // 'tags name are ${latestpostobj!.data[index].attachTags[tagIndex].manageTag!.name}'); + // return Padding( + // padding: EdgeInsets.only( + // right: 12.w), + // child: GestureDetector( + // onTap: () { + // Get.toNamed( + // RouteName + // .tagdetailscreen, + // arguments: { + // 'tagid': + // latestpostobj! + // .data[ + // index] + // .attachTags[ + // tagIndex].manageTag! + // .id, + // 'tagname': + // latestpostobj! + // .data[ + // index] + // .attachTags[ + // tagIndex].manageTag! + // .name, + // }); + // }, + // child: Row( + // mainAxisAlignment: + // MainAxisAlignment + // .start, + // children: [ + // // containertile2( + // // text: latestpostobj! + // // .data[index] + // // .tagsData[ + // // tagIndex] + // // .name!), + // 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(latestpostobj! + // .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: latestpostobj! - .data[index].tagNames.length, - itemBuilder: (context, index) { + .data[index].attachTags + .where((tag) => + tag.manageTag?.name + ?.isNotEmpty ?? + false) + .length, + itemBuilder: (context, tagIndex) { + // Filtered list of tags + var filteredTags = + latestpostobj! + .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), + right: 12.w, left: 12.w), child: GestureDetector( - onTap: () { - Get.toNamed(RouteName - .cyclescreen); - }, - child: containertile2( - text: (latestpostobj! - .data[index] - .tagNames[ - index]))), + onTap: () { + Get.toNamed( + RouteName + .tagdetailscreen, + arguments: { + 'tagid': + latestpostobj! + .data[index] + .attachTags[ + tagIndex] + .manageTag! + .id, + '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}'), + ), + ), + ), + ], + ), + ), ); }, ), @@ -2458,11 +2752,35 @@ class _LatestTabState extends State { onTap: () {}, child: Column( children: [ - Image.asset( - 'assets/images/png/Frame 1000004089.png', - height: 19.h, - width: 19.w, + GestureDetector( + onTap: () async { + int latestpostid = + latestpostobj! + .data[index] + .id!; + await saveunsavepost( + latestpostid); + }, + child: latestpostobj! + .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') ], diff --git a/lib/Main_Screens/Community_HomePage/CycleScreen.dart b/lib/Main_Screens/Community_HomePage/CycleScreen.dart deleted file mode 100644 index 3a862db..0000000 --- a/lib/Main_Screens/Community_HomePage/CycleScreen.dart +++ /dev/null @@ -1,489 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_reaction_button/flutter_reaction_button.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; -import 'package:regroup/Common/CommonGlassmorphism.dart'; -import 'package:regroup/Common/CommonTabBar.dart'; -import 'package:regroup/Common/CommonWidget.dart'; -import 'package:regroup/Main_Screens/Community_HomePage/Community.dart'; -import 'package:regroup/Utils/Common/CommonAppbar.dart'; -import 'package:regroup/Utils/Common/sized_box.dart'; -import 'package:regroup/Utils/texts.dart'; -import 'package:regroup/resources/routes/route_name.dart'; - -class CycleScreen extends StatefulWidget { - const CycleScreen({super.key}); - - @override - State createState() => _CycleScreenState(); -} - -class _CycleScreenState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: const Color(0xFF222935), - extendBody: true, - resizeToAvoidBottomInset: false, - appBar: CommonAppbar( - titleTxt: "Cycle", - customActionWidget: Image.asset( - "assets/images/png/sidemenu/f7_pin-fill.png", - height: 26.h, - width: 26.w, - )), - body: Stack(children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/png/Ellipse 1496.png"), - fit: BoxFit.fill)), - ), - Column(children: [ - sizedBoxHeight(10.h), - DefaultTabController( - length: 2, - // initialIndex: selectedIndex.value, - child: Column( - children: [ - const CommonTabBar(tabs: [ - Tab( - text: 'Popular', - ), - Tab( - text: 'Latest', - ), - ]), - SizedBox( - height: 670.h, - child: TabBarView( - children: [ - cyclepopularTab(), - cyclelatestTab(), - ], - ), - ), - ], - )) - ]) - ])); - } -} - -Widget cyclepopularTab() { - return SingleChildScrollView( - child: Column(children: [ - sizedBoxHeight(20.h), - normalcardtile( - profileImg: 'assets/images/png/Ellipse 52.png', - title: 'Ryan Dorwat', - mainImg: 'assets/images/png/img322.png', - containerTitle: [ - 'Football', - 'Teams player', - 'Events', - 'Marathon', - 'Events' - ]), - sizedBoxHeight(30.h), - normalcardtile( - profileImg: 'assets/images/png/Ellipse 43.png', - title: 'Edward Hackket', - mainImg: 'assets/images/png/Rectangle 24.png', - containerTitle: [ - 'Cycle', - 'Marathon', - 'Events', - 'Marathon', - 'Events' - ]), - ]), - ); -} - -Widget cyclelatestTab() { - return SingleChildScrollView( - child: Column(children: [ - sizedBoxHeight(20.h), - normalcardtile( - profileImg: 'assets/images/png/Ellipse 43.png', - title: 'Edward Hackket', - mainImg: 'assets/images/png/Rectangle 24.png', - containerTitle: [ - 'Cycle', - 'Marathon', - 'Events', - 'Marathon', - 'Events' - ]), - ]), - ); -} - -Widget normalcardtile({ - required String profileImg, - required String title, - required String mainImg, - required List containerTitle, -}) { - var mainImage = 'assets/images/png/uiw_like-o.png'.obs; - void updateImage(String reaction) { - if (reaction == 'like') { - mainImage.value = 'assets/images/png/f7_hand-thumbsup.png'; - } else if (reaction == 'heart') { - mainImage.value = 'assets/images/png/heart 2.png'; - } else if (reaction == 'party') { - mainImage.value = 'assets/images/png/party-popper 2.png'; - } - } - - return commonGlassUI( - width: double.infinity, - height: 570.h, - borderwidth: 0, - 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: AssetImage(profileImg), - radius: 25.r, - ), - sizedBoxWidth(12.w), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC(title), - 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('Active alliance network'), - sizedBoxWidth(7.w), - Icon( - Icons.circle, - color: const Color(0xFFFCFCFC), - size: 4.sp, - ), - sizedBoxWidth(6.w), - text12w400_FCFCFC('1 Hour ago'), - ], - ) - ], - ), - 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: () {}, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - Text( - '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: SizedBox( - height: 360.h, - width: double.infinity, - child: Image.asset( - mainImg, - 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: containerTitle.length, - itemBuilder: (context, index) { - return Padding( - padding: EdgeInsets.only(right: 12.w), - child: GestureDetector( - onTap: () { - Get.toNamed(RouteName.cyclescreen); - }, - child: containertile(text: containerTitle[index])), - ); - }, - ), - ), - sizedBoxHeight(20.h), - text16w400_FCFCFC( - "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s . . ."), - Row(children: [ - InkWell( - onTap: () { - Get.toNamed(RouteName.reactionview); - }, - child: stackReaction(number: '20', containerImages: [ - 'assets/images/png/f7_hand-thumbsup.png', - 'assets/images/png/heart 2.png', - 'assets/images/png/party-popper 2.png' - ]), - ), - const Spacer(), - commonGlassUI( - borderwidth: 0.43, - width: 30.w, - height: 30.h, - opacity1: 0.05, - opacity2: 0.06, - borderRadius: BorderRadius.circular( 100), - customWidget: Center( - child: Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 13.h, - width: 13.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC('20'), - sizedBoxWidth(20.w), - commonGlassUI( - borderwidth: 0.43, - width: 30.w, - height: 30.h, - borderRadius: BorderRadius.circular( 100), - opacity1: 0.05, - opacity2: 0.06, - customWidget: Center( - child: Image.asset( - 'assets/images/png/Vector (1).png', - height: 12.h, - width: 12.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC('10'), - ]), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Obx(() { - return ReactionButton( - onReactionChanged: (reaction) { - updateImage(reaction?.value ?? 'like'); - debugPrint('Selected value: ${reaction?.value}'); - }, - reactions: ?>[ - Reaction( - value: 'like', - previewIcon: _buildReactionsPreviewIcon( - 'assets/images/png/f7_hand-thumbsup.png'), - icon: _buildReactionsIcon( - 'assets/images/png/f7_hand-thumbsup.png'), - ), - Reaction( - value: 'heart', - previewIcon: _buildReactionsPreviewIcon( - 'assets/images/png/heart 2.png'), - icon: _buildReactionsIcon( - 'assets/images/png/heart 2.png'), - ), - Reaction( - value: 'party', - previewIcon: _buildReactionsPreviewIcon( - 'assets/images/png/party-popper 2.png'), - icon: _buildReactionsIcon( - 'assets/images/png/party-popper 2.png'), - ), - ], - selectedReaction: Reaction( - value: 'like', - icon: _buildReactionsIcon( - 'assets/images/png/f7_hand-thumbsup.png'), - ), - boxColor: Colors.white, - boxElevation: 9, - boxRadius: 30, - itemsSpacing: 8, - itemScale: 0.4, - itemSize: const Size(45, 45), - boxPadding: const EdgeInsets.all(8), - boxAnimationDuration: - const Duration(milliseconds: 200), - itemAnimationDuration: - const Duration(milliseconds: 500), - hoverDuration: const Duration(milliseconds: 700), - // toggle: false, - - child: _buildReactionsIcon(mainImage.value), - ); - }) - ], - ), - 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') - ], - ), - ), - Column( - children: [ - 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 _buildReactionsPreviewIcon(String assetPath) { - return Padding( - padding: const EdgeInsets.all(8.0), - child: Image.asset( - assetPath, - height: 40.h, - width: 40.w, - ), - ); -} - -Widget _buildReactionsIcon(String assetPath) { - return Column( - children: [ - Image.asset( - assetPath, - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Like') - ], - ); -} diff --git a/lib/Main_Screens/Community_HomePage/Model/tagdetailModel.dart b/lib/Main_Screens/Community_HomePage/Model/tagdetailModel.dart new file mode 100644 index 0000000..82c9c28 --- /dev/null +++ b/lib/Main_Screens/Community_HomePage/Model/tagdetailModel.dart @@ -0,0 +1,242 @@ +class TagdetailsModel { + TagdetailsModel({ + required this.status, + required this.statusCode, + required this.message, + required this.data, + }); + + final String? status; + final int? statusCode; + final String? message; + final List data; + + factory TagdetailsModel.fromJson(Map json){ + return TagdetailsModel( + status: json["status"], + statusCode: json["status_code"], + message: json["message"], + data: json["data"] == null ? [] : List.from(json["data"]!.map((x) => Datum.fromJson(x))), + ); + } + +} + +class Datum { + Datum({ + required this.id, + required this.likecount, + required this.isISaved, + required this.tagsXid, + required this.isILiked, + required this.totalComment, + required this.totalSave, + required this.iamPrincipalXid, + required this.postIn, + required this.caption, + required this.image, + required this.manageTagsXids, + required this.postAs, + required this.ctaTitle, + required this.ctaLink, + required this.createdAt, + required this.likeIcon, + required this.totalViewCount, + required this.totalReactionCount, + required this.totalCommentCount, + required this.totalImpressionCount, + required this.totalPopularScore, + required this.totalHoursAgo, + required this.iamPrincipal, + required this.community, + required this.attachTags, + }); + + final int? id; + final int? likecount; + final bool? isISaved; + final List tagsXid; + final bool? isILiked; + final int? totalComment; + final int? totalSave; + final int? iamPrincipalXid; + final int? postIn; + final String? caption; + final String? image; + final String? manageTagsXids; + final String? postAs; + final String? ctaTitle; + final String? ctaLink; + final DateTime? createdAt; + final LikeIcon? likeIcon; + final int? totalViewCount; + final int? totalReactionCount; + final int? totalCommentCount; + final int? totalImpressionCount; + final int? totalPopularScore; + final int? totalHoursAgo; + final IamPrincipal? iamPrincipal; + final Community? community; + final List attachTags; + + factory Datum.fromJson(Map json){ + return Datum( + id: json["id"], + likecount: json["likecount"], + isISaved: json["is_i_saved"], + tagsXid: json["tags_xid"] == null ? [] : List.from(json["tags_xid"]!.map((x) => x)), + isILiked: json["is_i_liked"], + totalComment: json["total_comment"], + totalSave: json["total_save"], + iamPrincipalXid: json["iam_principal_xid"], + 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"], + createdAt: DateTime.tryParse(json["created_at"] ?? ""), + likeIcon: json["likeIcon"] == null ? null : LikeIcon.fromJson(json["likeIcon"]), + totalViewCount: json["totalViewCount"], + totalReactionCount: json["totalReactionCount"], + totalCommentCount: json["totalCommentCount"], + totalImpressionCount: json["totalImpressionCount"], + totalPopularScore: json["totalPopularScore"], + totalHoursAgo: json["totalHoursAgo"], + iamPrincipal: json["iam_principal"] == null ? null : IamPrincipal.fromJson(json["iam_principal"]), + community: json["community"] == null ? null : Community.fromJson(json["community"]), + attachTags: json["attach_tags"] == null ? [] : List.from(json["attach_tags"]!.map((x) => AttachTag.fromJson(x))), + ); + } + +} + +class AttachTag { + AttachTag({ + required this.managePostXid, + required this.manageTagXid, + required this.manageTag, + }); + + final int? managePostXid; + final int? manageTagXid; + final ManageTag? manageTag; + + factory AttachTag.fromJson(Map json){ + return AttachTag( + managePostXid: json["manage_post_xid"], + manageTagXid: json["manage_tag_xid"], + manageTag: json["manage_tag"] == null ? null : ManageTag.fromJson(json["manage_tag"]), + ); + } + +} + +class ManageTag { + ManageTag({ + required this.id, + required this.isPinned, + required this.name, + }); + + final int? id; + final bool? isPinned; + final String? name; + + factory ManageTag.fromJson(Map json){ + return ManageTag( + id: json["id"], + isPinned: json["is_pinned"], + name: json["name"], + ); + } + +} + +class Community { + Community({ + required this.id, + required this.communityProfilePhoto, + required this.communityName, + }); + + final int? id; + final String? communityProfilePhoto; + final String? communityName; + + factory Community.fromJson(Map json){ + return Community( + id: json["id"], + communityProfilePhoto: json["community_profile_photo"], + communityName: json["community_name"], + ); + } + +} + +class IamPrincipal { + IamPrincipal({ + required this.id, + required this.isUserPinned, + required this.principalTypeXid, + required this.userName, + required this.fullName, + required this.profilePhoto, + }); + + final int? id; + final bool? isUserPinned; + final int? principalTypeXid; + final String? userName; + final String? fullName; + final String? profilePhoto; + + factory IamPrincipal.fromJson(Map json){ + return IamPrincipal( + id: json["id"], + isUserPinned: json["is_user_pinned"], + principalTypeXid: json["principal_type_xid"], + userName: json["user_name"], + fullName: json["full_name"], + profilePhoto: json["profile_photo"], + ); + } + +} + +class LikeIcon { + LikeIcon({ + required this.likeIconsXid, + required this.likeIcon, + }); + + final int? likeIconsXid; + final LikeIconClass? likeIcon; + + factory LikeIcon.fromJson(Map json){ + return LikeIcon( + likeIconsXid: json["like_icons_xid"], + likeIcon: json["like_icon"] == null ? null : LikeIconClass.fromJson(json["like_icon"]), + ); + } + +} + +class LikeIconClass { + LikeIconClass({ + required this.id, + required this.image, + }); + + final int? id; + final String? image; + + factory LikeIconClass.fromJson(Map json){ + return LikeIconClass( + id: json["id"], + image: json["image"], + ); + } + +} diff --git a/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart b/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart index b4eccee..a0c71dd 100644 --- a/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart +++ b/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart @@ -521,7 +521,7 @@ class _PostDetailsScreenState extends State { padding: EdgeInsets.only(right: 12.w), child: GestureDetector( onTap: () { - Get.toNamed(RouteName.cyclescreen); + Get.toNamed(RouteName.tagdetailscreen); }, child: containertile(text: containerTitle[index])), ); diff --git a/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart b/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart new file mode 100644 index 0000000..f22d8ce --- /dev/null +++ b/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart @@ -0,0 +1,2216 @@ +import 'dart:developer'; + +import 'package:flutter/material.dart'; +import 'package:flutter_reaction_button/flutter_reaction_button.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:regroup/Common/CommonGlassmorphism.dart'; +import 'package:regroup/Common/CommonTabBar.dart'; +import 'package:regroup/Common/CommonWidget.dart'; +import 'package:regroup/Common/ConvertServerDateToUserDate.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/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/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/sized_box.dart'; +import 'package:regroup/Utils/dialogs.dart'; +import 'package:regroup/Utils/texts.dart'; +import 'package:regroup/resources/routes/route_name.dart'; +import 'package:async/src/future_group.dart'; +import 'package:regroup/sidemenu/view_model/postmethod.dart'; + +class TagdetailScreen extends StatefulWidget { + const TagdetailScreen({super.key}); + + @override + State createState() => _TagdetailScreenState(); +} + +class _TagdetailScreenState extends State { + int tagsid = Get.arguments['tagid']; + String tagsname = Get.arguments['tagname']; + bool istagpin = Get.arguments['ispinnedtag']; + + @override + void initState() { + // TODO: implement initState + + super.initState(); + } + + pinunpinTag(int tagid) async { + // utils.loader(); + Map updata = { + "manage_tags_xid": tagid, + }; + final data = await SidebarTags().postUserpin(updata); + if (data.status == ResponseStatus.SUCCESS) { + // Get.back(); + setState(() { + istagpin = !istagpin; // Toggle the pin state + }); + return utils.showToast(data.message); + } else { + // Get.back(); + return utils.showToast(data.message); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: const Color(0xFF222935), + extendBody: true, + resizeToAvoidBottomInset: false, + appBar: CommonAppbar( + titleTxt: tagsname, + customActionWidget: GestureDetector( + onTap: () async { + await pinunpinTag(tagsid); + }, + child: istagpin == true + ? Image.asset( + "assets/images/png/sidemenu/f7_pin-fill.png", + height: 26.h, + width: 26.w, + ) + : Image.asset( + "assets/images/png/sidemenu/f7_pin-fill (1).png", + height: 26.h, + width: 26.w, + ), + )), + body: Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), + ), + Column(children: [ + sizedBoxHeight(10.h), + DefaultTabController( + length: 2, + // initialIndex: selectedIndex.value, + child: Column( + children: [ + const CommonTabBar(tabs: [ + Tab( + text: 'Popular', + ), + Tab( + text: 'Latest', + ), + ]), + SizedBox( + height: 670.h, + child: TabBarView( + children: [ + cyclepopularTab(), + // cyclelatestTab(), + LatestTab(id: tagsid) + ], + ), + ), + ], + )) + ]) + ])); + } +} + +Widget cyclepopularTab() { + return SingleChildScrollView( + child: Column(children: [ + sizedBoxHeight(20.h), + normalcardtile( + profileImg: 'assets/images/png/Ellipse 52.png', + title: 'Ryan Dorwat', + mainImg: 'assets/images/png/img322.png', + containerTitle: [ + 'Football', + 'Teams player', + 'Events', + 'Marathon', + 'Events' + ]), + sizedBoxHeight(30.h), + normalcardtile( + profileImg: 'assets/images/png/Ellipse 43.png', + title: 'Edward Hackket', + mainImg: 'assets/images/png/Rectangle 24.png', + containerTitle: [ + 'Cycle', + 'Marathon', + 'Events', + 'Marathon', + 'Events' + ]), + ]), + ); +} + +Widget cyclelatestTab() { + return SingleChildScrollView( + child: Column(children: [ + sizedBoxHeight(20.h), + normalcardtile( + profileImg: 'assets/images/png/Ellipse 43.png', + title: 'Edward Hackket', + mainImg: 'assets/images/png/Rectangle 24.png', + containerTitle: [ + 'Cycle', + 'Marathon', + 'Events', + 'Marathon', + 'Events' + ]), + ]), + ); +} + +Widget normalcardtile({ + required String profileImg, + required String title, + required String mainImg, + required List containerTitle, +}) { + var mainImage = 'assets/images/png/uiw_like-o.png'.obs; + void updateImage(String reaction) { + if (reaction == 'like') { + mainImage.value = 'assets/images/png/f7_hand-thumbsup.png'; + } else if (reaction == 'heart') { + mainImage.value = 'assets/images/png/heart 2.png'; + } else if (reaction == 'party') { + mainImage.value = 'assets/images/png/party-popper 2.png'; + } + } + + return commonGlassUI( + width: double.infinity, + height: 570.h, + borderwidth: 0, + 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: AssetImage(profileImg), + radius: 25.r, + ), + sizedBoxWidth(12.w), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + text16w400_FCFCFC(title), + 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('Active alliance network'), + sizedBoxWidth(7.w), + Icon( + Icons.circle, + color: const Color(0xFFFCFCFC), + size: 4.sp, + ), + sizedBoxWidth(6.w), + text12w400_FCFCFC('1 Hour ago'), + ], + ) + ], + ), + 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: () {}, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 12.w), + child: Row( + children: [ + Text( + '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: SizedBox( + height: 360.h, + width: double.infinity, + child: Image.asset( + mainImg, + 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: containerTitle.length, + itemBuilder: (context, index) { + return Padding( + padding: EdgeInsets.only(right: 12.w), + child: GestureDetector( + onTap: () { + // Get.toNamed(RouteName.tagdetailscreen); + }, + child: containertile(text: containerTitle[index])), + ); + }, + ), + ), + sizedBoxHeight(20.h), + text16w400_FCFCFC( + "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s . . ."), + Row(children: [ + InkWell( + onTap: () { + Get.toNamed(RouteName.reactionview); + }, + child: stackReaction(number: '20', containerImages: [ + 'assets/images/png/f7_hand-thumbsup.png', + 'assets/images/png/heart 2.png', + 'assets/images/png/party-popper 2.png' + ]), + ), + const Spacer(), + commonGlassUI( + borderwidth: 0.43, + width: 30.w, + height: 30.h, + opacity1: 0.05, + opacity2: 0.06, + borderRadius: BorderRadius.circular(100), + customWidget: Center( + child: Image.asset( + 'assets/images/png/Frame 1000004088.png', + height: 13.h, + width: 13.w, + ), + ), + ), + sizedBoxWidth(12.w), + text14w400_FCFCFC('20'), + sizedBoxWidth(20.w), + commonGlassUI( + borderwidth: 0.43, + width: 30.w, + height: 30.h, + borderRadius: BorderRadius.circular(100), + opacity1: 0.05, + opacity2: 0.06, + customWidget: Center( + child: Image.asset( + 'assets/images/png/Vector (1).png', + height: 12.h, + width: 12.w, + ), + ), + ), + sizedBoxWidth(12.w), + text14w400_FCFCFC('10'), + ]), + sizedBoxHeight(12.h), + commonDivider(), + sizedBoxHeight(12.h), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Obx(() { + return ReactionButton( + onReactionChanged: (reaction) { + updateImage(reaction?.value ?? 'like'); + debugPrint('Selected value: ${reaction?.value}'); + }, + reactions: ?>[ + Reaction( + value: 'like', + previewIcon: _buildReactionsPreviewIcon( + 'assets/images/png/f7_hand-thumbsup.png'), + icon: _buildReactionsIcon( + 'assets/images/png/f7_hand-thumbsup.png'), + ), + Reaction( + value: 'heart', + previewIcon: _buildReactionsPreviewIcon( + 'assets/images/png/heart 2.png'), + icon: _buildReactionsIcon( + 'assets/images/png/heart 2.png'), + ), + Reaction( + value: 'party', + previewIcon: _buildReactionsPreviewIcon( + 'assets/images/png/party-popper 2.png'), + icon: _buildReactionsIcon( + 'assets/images/png/party-popper 2.png'), + ), + ], + selectedReaction: Reaction( + value: 'like', + icon: _buildReactionsIcon( + 'assets/images/png/f7_hand-thumbsup.png'), + ), + boxColor: Colors.white, + boxElevation: 9, + boxRadius: 30, + itemsSpacing: 8, + itemScale: 0.4, + itemSize: const Size(45, 45), + boxPadding: const EdgeInsets.all(8), + boxAnimationDuration: + const Duration(milliseconds: 200), + itemAnimationDuration: + const Duration(milliseconds: 500), + hoverDuration: const Duration(milliseconds: 700), + // toggle: false, + + child: _buildReactionsIcon(mainImage.value), + ); + }) + ], + ), + 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') + ], + ), + ), + Column( + children: [ + 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 _buildReactionsPreviewIcon(String assetPath) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Image.asset( + assetPath, + height: 40.h, + width: 40.w, + ), + ); +} + +Widget _buildReactionsIcon(String assetPath) { + return Column( + children: [ + Image.asset( + assetPath, + height: 19.h, + width: 19.w, + ), + sizedBoxHeight(8.h), + text11w400_FCFCFC('Like') + ], + ); +} + +class LatestTab extends StatefulWidget { + LatestTab({super.key, required this.id}); + + int id; + + @override + State createState() => _LatestTabState(); +} + +class _LatestTabState extends State { + FutureGroup futureGroup = FutureGroup(); + + @override + void initState() { + futureGroup.add(Communitygetmethod().getTagsdata(widget.id).then((value) { + _initializeData(); + })); + futureGroup.close(); + super.initState(); + } + + List _reactions = []; + Map _selectedReactions = {}; + + Future _initializeData() async { + await _fetchIcons(); + // _initializeSelectedReaction(); + for (var post in tagdetailobj!.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); + + setState(() { + _reactions = fetchlikeIconsModel.data + ?.map((data) => ReactionData( + id: data.id!, + image: data.image!, + )) + .toList() ?? + []; + for (var post in tagdetailobj!.data) { + _initializeSelectedReaction(post.id!); + } + }); + } + } + + 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] = + 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 + } + }); + + 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); + } + } + + 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(() {}); + }); + + return utils.showToast(data.message); + } else { + // Get.back(); + return utils.showToast(data.message); + } + } + + 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); + } + } + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: futureGroup.future, + builder: (ctx, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return + // ShimmerCommon(); + const Center( + child: CircularProgressIndicator( + color: Colors.blue, + ), + ); + } + + if (snapshot.hasError) { + return Center( + child: Text( + '${snapshot.error} occurred', + style: TextStyle(fontSize: 18.spMin), + ), + ); + } + + 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) { + 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 ?? + ''))), + ), + ), + 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), + ]), + ), + ], + )), + sizedBoxHeight(20.h) + ], + ); + } + }, + ), + ), + ], + ); + } + return Container(); + }); + } + + Widget _buildNoDataBody(context) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "No Data Found", + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.w600), + ) + ], + ), + ); + } +} diff --git a/lib/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart b/lib/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart new file mode 100644 index 0000000..030b9c7 --- /dev/null +++ b/lib/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart @@ -0,0 +1,22 @@ +import 'dart:developer'; + +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/Main_Screens/Community_HomePage/Model/tagdetailModel.dart'; + +TagdetailsModel? tagdetailobj; + +class Communitygetmethod { + Future> getTagsdata(updata) async { + final response = await NetworkApiServices().getApi( + "${ApiUrls.getTagsdetails}?manage_tag_id=$updata", + ); + + if (response.status == ResponseStatus.SUCCESS) { + tagdetailobj = TagdetailsModel.fromJson(response.data); + log(tagdetailobj!.data.toString()); + } + return response; + } +} diff --git a/lib/Main_Screens/Community_HomePage/view_model/communitypostmethod.dart b/lib/Main_Screens/Community_HomePage/view_model/communitypostmethod.dart new file mode 100644 index 0000000..bce7b1f --- /dev/null +++ b/lib/Main_Screens/Community_HomePage/view_model/communitypostmethod.dart @@ -0,0 +1,18 @@ +import 'package:regroup/Common/api_urls.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Common/controller/data/network/network_api.dart'; + +class Communitypostmethod { + Communitypostmethod(); + + + Future> postUserSave(updata) async { + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.postusersave, + ); + return response; + } + + +} \ No newline at end of file diff --git a/lib/Main_Screens/ProfileTab/My Network/MyNetwork.dart b/lib/Main_Screens/ProfileTab/My Network/MyNetwork.dart index 95f96e0..19985ab 100644 --- a/lib/Main_Screens/ProfileTab/My Network/MyNetwork.dart +++ b/lib/Main_Screens/ProfileTab/My Network/MyNetwork.dart @@ -324,6 +324,7 @@ class _FollowersTabState extends State { // onTap: () {}, onTap: () async { setState(() { + removeid = followersobj! .data![index] .follower! diff --git a/lib/Main_Screens/ProfileTab/view_model/profileGetmethod.dart b/lib/Main_Screens/ProfileTab/view_model/profileGetmethod.dart index ca3898d..02c4e0e 100644 --- a/lib/Main_Screens/ProfileTab/view_model/profileGetmethod.dart +++ b/lib/Main_Screens/ProfileTab/view_model/profileGetmethod.dart @@ -121,7 +121,7 @@ class Profilegetmethod { if (response.status == ResponseStatus.SUCCESS) { certificateobj = CertificateuserModel.fromJson(response.data); log(certificateobj!.data.toString()); - } + } return response; } } diff --git a/lib/resources/routes/route_name.dart b/lib/resources/routes/route_name.dart index cbabf6d..de8df67 100644 --- a/lib/resources/routes/route_name.dart +++ b/lib/resources/routes/route_name.dart @@ -29,7 +29,7 @@ class RouteName { static const String mainscreen = '/mainscreen'; static const String sidemenu = '/sidemenu'; static const String savedposts = '/savedposts'; - static const String cyclescreen = '/cyclescreen'; + static const String tagdetailscreen = '/tagdetailscreen'; static const String postscreen = '/postscreen'; static const String reactionview = '/reactionview'; static const String postdetailsScreen = '/postdetailsScreen'; diff --git a/lib/resources/routes/routes.dart b/lib/resources/routes/routes.dart index 5bb7164..e779448 100644 --- a/lib/resources/routes/routes.dart +++ b/lib/resources/routes/routes.dart @@ -12,7 +12,7 @@ import 'package:regroup/Main_Screens/Chats/View/newchatpage.dart'; import 'package:regroup/Main_Screens/Chats/View/newgroup.dart'; import 'package:regroup/Main_Screens/Chats/View/userchat.dart'; import 'package:regroup/Main_Screens/Community_HomePage/Community.dart'; -import 'package:regroup/Main_Screens/Community_HomePage/CycleScreen.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/TagsdDetailScreen.dart'; import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart'; import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/View/ReactionView.dart'; import 'package:regroup/Main_Screens/Community_HomePage/PostScreen.dart'; @@ -165,8 +165,8 @@ class AppRoutes { page: () => const SavedPosts(), ), GetPage( - name: RouteName.cyclescreen, - page: () => const CycleScreen(), + name: RouteName.tagdetailscreen, + page: () => const TagdetailScreen(), ), GetPage( name: RouteName.postscreen, diff --git a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart index ca481be..505b58e 100644 --- a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart +++ b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart @@ -581,7 +581,7 @@ class _CommunityDetailsState extends State { padding: EdgeInsets.only(right: 12.w), child: GestureDetector( onTap: () { - Get.toNamed(RouteName.cyclescreen); + Get.toNamed(RouteName.tagdetailscreen); }, child: containertile(text: containerTitle[index])), );