diff --git a/lib/Common/api_urls.dart b/lib/Common/api_urls.dart index ae037c6..627be22 100644 --- a/lib/Common/api_urls.dart +++ b/lib/Common/api_urls.dart @@ -134,6 +134,8 @@ class ApiUrls { static const postusersave = "${baseUrl}save-post"; + static const getpopularTagsdetails = "${baseUrl}fetch-popular-post"; + } diff --git a/lib/Main_Screens/Community/Model/FeedPostModel.dart b/lib/Main_Screens/Community/Model/FeedPostModel.dart index 7315185..dbe4abd 100644 --- a/lib/Main_Screens/Community/Model/FeedPostModel.dart +++ b/lib/Main_Screens/Community/Model/FeedPostModel.dart @@ -45,168 +45,232 @@ class Data { // pinnedTagsPost: json["pinned_tags_post"] == null ? [] : List.from(json["pinned_tags_post"]!.map((x) => PinnedPost.fromJson(x))), pinnedTagsPost: json["pinned_tags_post"] == null ? [] - : List.from(json["pinned_tags_post"]! - .expand((x) => x as List) - .map((x) => PinnedPost.fromJson(x))), + : + List.from( + json["pinned_tags_post"]!.map((x) => PinnedPost.fromJson(x))), + // List.from(json["pinned_tags_post"]! + // .expand((x) => x as List) + // .map((x) => PinnedPost.fromJson(x))), ); } } class PinnedPost { - PinnedPost({ - required this.id, - required this.likecount, - 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.tagNames, - required this.likeIcon, - required this.iamPrincipal, - required this.community, - }); + PinnedPost({ + 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 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 List tagNames; - final LikeIcon? likeIcon; - final IamPrincipal? iamPrincipal; - final Community? community; + 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 PinnedPost.fromJson(Map json){ + return PinnedPost( + 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"], + ); + } - factory PinnedPost.fromJson(Map json) { - return PinnedPost( - id: json["id"], - likecount: json["likecount"], - 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"] ?? ""), - tagNames: json["tag_names"] == null - ? [] - : List.from(json["tag_names"]!.map((x) => x)), - likeIcon: - json["likeIcon"] == null ? null : LikeIcon.fromJson(json["likeIcon"]), - iamPrincipal: json["iam_principal"] == null - ? null - : IamPrincipal.fromJson(json["iam_principal"]), - community: json["community"] == null - ? null - : Community.fromJson(json["community"]), - ); - } } class Community { - Community({ - required this.id, - required this.communityProfilePhoto, - required this.communityName, - }); + Community({ + required this.id, + required this.communityProfilePhoto, + required this.communityName, + }); - final int? id; - final String? communityProfilePhoto; - final String? 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"], + ); + } - 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.principalTypeXid, - required this.userName, - required this.fullName, - required this.profilePhoto, - }); + IamPrincipal({ + required this.id, + required this.isUserPinned, + required this.principalTypeXid, + required this.userName, + required this.fullName, + required this.profilePhoto, + }); - final int? id; - final int? principalTypeXid; - final String? userName; - final String? fullName; - final String? 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"], + ); + } - factory IamPrincipal.fromJson(Map json) { - return IamPrincipal( - id: json["id"], - 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, - }); + LikeIcon({ + required this.likeIconsXid, + required this.likeIcon, + }); - final int? likeIconsXid; - final LikeIconClass? 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"]), + ); + } - 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, - }); + LikeIconClass({ + required this.id, + required this.image, + }); - final int? id; - final String? image; + final int? id; + final String? image; + + factory LikeIconClass.fromJson(Map json){ + return LikeIconClass( + id: json["id"], + image: json["image"], + ); + } - factory LikeIconClass.fromJson(Map json) { - return LikeIconClass( - id: json["id"], - image: json["image"], - ); - } } + diff --git a/lib/Main_Screens/Community_HomePage/Community.dart b/lib/Main_Screens/Community_HomePage/Community.dart index 71b9309..b8fdf5a 100644 --- a/lib/Main_Screens/Community_HomePage/Community.dart +++ b/lib/Main_Screens/Community_HomePage/Community.dart @@ -198,23 +198,195 @@ class _FeedTabState extends State { @override void initState() { feedfuture = FeedpostApi().getFeedPostApi(); + // .then((value) { + // _initializeData(); + // }); super.initState(); } List combinedList = []; - setValues() { - combinedList.addAll(feedpostobj!.data!.pinnedCommunityPost); - combinedList.addAll(feedpostobj!.data!.pinnedUserPost); - combinedList.addAll(feedpostobj!.data!.pinnedTagsPost); + // setValues() { + // combinedList.addAll(feedpostobj!.data!.pinnedCommunityPost); + // combinedList.addAll(feedpostobj!.data!.pinnedUserPost); + // combinedList.addAll(feedpostobj!.data!.pinnedTagsPost); + // // _initializeData(); - // for (var i = 0; i < feedpostobj!.data!.pinnedCommunityPost.length; i++) { + // // for (var i = 0; i < feedpostobj!.data!.pinnedCommunityPost.length; i++) { - // } - // for (var j = 0; j < feedpostobj!.data!.pinnedUserPost.length; j++) { - // } - // for (var k = 0; k < feedpostobj!.data!.pinnedTagsPost.length; k++) { - // } + // // } + // // for (var j = 0; j < feedpostobj!.data!.pinnedUserPost.length; j++) { + // // } + // // for (var k = 0; k < feedpostobj!.data!.pinnedTagsPost.length; k++) { + // // } + // } + + bool _isDataInitialized = false; + + Future setValues() async { + if (_isDataInitialized) return; // Check if data is already initialized + + try { + combinedList.addAll(feedpostobj!.data!.pinnedCommunityPost); + combinedList.addAll(feedpostobj!.data!.pinnedUserPost); + combinedList.addAll(feedpostobj!.data!.pinnedTagsPost); + + await _initializeData(); + + setState(() { + _isDataInitialized = true; + }); + } catch (e) { + // Handle any errors that occur during the fetch + print('Error fetching data: $e'); + } + } + + List _reactions = []; + Map _selectedReactions = {}; + + Future _initializeData() async { + await _fetchIcons(); + // _initializeSelectedReaction(); + for (var post in combinedList) { + 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 + } + } + + 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 combinedList) { + _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 latestpostid) async { + // utils.loader(); + Map updata = { + "manage_posts_xid": latestpostid, + }; + final data = await Communitypostmethod().postUserSave(updata); + if (data.status == ResponseStatus.SUCCESS) { + FeedpostApi().getFeedPostApi().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(); + FeedpostApi().getFeedPostApi().then((value) { + _initializeData(); + setState(() {}); + }); + return utils.showToast(data.message); + } else { + // Get.back(); + return utils.showToast(data.message); + } } @override @@ -253,19 +425,19 @@ class _FeedTabState extends State { ), ), combinedList.isEmpty - ? Expanded( - child: Center( - child: Column( - children: [ - Text( - "No Data Found", - style: TextStyle( - color: Colors.white, - fontSize: 16.sp, - fontWeight: FontWeight.w600), - ) - ], - ), + ? Center( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "No Data Found", + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.w600), + ) + ], ), ) : Column( @@ -279,69 +451,1303 @@ class _FeedTabState extends State { var timeAgo = ConvertServerDateToUserDate() .convertServerDateToReadableFormate( combinedList[index].createdAt.toString()); + var postId = combinedList[index].id; + var selectedReaction = _selectedReactions[postId]; if (index == 1) { - return announcecardtile( - profileImg: combinedList[index] - .iamPrincipal! - .profilePhoto ?? - '', - title: combinedList[index] - .iamPrincipal! - .fullName ?? - '', - mainImg: combinedList[index].image ?? '', - containerTitle: - combinedList[index].tagNames ?? [''], - create_at: timeAgo, - community_name: combinedList[index] - .community! - .communityName ?? - '', - totalcomments: combinedList[index] - .totalComment - .toString(), - description: - combinedList[index].caption ?? '', - totalSave: - combinedList[index].totalSave.toString(), + return + // announcecardtile( + // profileImg: combinedList[index] + // .iamPrincipal! + // .profilePhoto ?? + // '', + // title: combinedList[index] + // .iamPrincipal! + // .fullName ?? + // '', + // mainImg: combinedList[index].image ?? '', + // containerTitle: [], + // // combinedList[index].attachTags[index].manageTag.name ?? [''], + // create_at: timeAgo, + // community_name: combinedList[index] + // .community! + // .communityName ?? + // '', + // totalcomments: combinedList[index] + // .totalComment + // .toString(), + // description: + // combinedList[index].caption ?? '', + // totalSave: + // combinedList[index].totalSave.toString(), + // ); + + 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( + combinedList[index] + .iamPrincipal! + .profilePhoto ?? + ''), + radius: 25.r, + ), + sizedBoxWidth(12.w), + Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + text16w400_FCFCFC( + combinedList[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( + combinedList[ + 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, + ) + ], + ), + ), + ), + ], + 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( + combinedList[index] + .image ?? + '', + ), + fit: BoxFit.cover)), + ), + ), + sizedBoxHeight(20.h), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 16.w), + 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: combinedList[ + index] + .attachTags + .where((tag) => + tag.manageTag?.name + ?.isNotEmpty ?? + false) + .length, + itemBuilder: + (context, tagIndex) { + // Filtered list of tags + var filteredTags = + combinedList[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: () { + Get.toNamed( + RouteName + .tagdetailscreen, + arguments: { + 'tagid': + // filteredTags[ + // tagIndex] + // .manageTagXid, + combinedList[ + 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}'), + ), + ), + ), + ], + ), + ), + ); + }, + ), + ), + sizedBoxHeight(20.h), + SizedBox( + width: double.infinity, + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + text16w400_FCFCFC( + combinedList[index] + .caption ?? + ''), + ], + ), + ), + Row(children: [ + InkWell( + onTap: () {}, + child: stackReaction( + number: + combinedList[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( + combinedList[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( + combinedList[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, + combinedList[ + 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, + combinedList[ + 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 latestpostid = + combinedList[ + index] + .id!; + await saveunsavepost( + latestpostid); + }, + child: combinedList![ + 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: [ - normalcardtile2( - profileImg: combinedList[index] - .iamPrincipal! - .profilePhoto ?? - '', - title: combinedList[index] - .iamPrincipal! - .fullName ?? - '', - mainImg: combinedList[index].image ?? '', - containerTitle: - combinedList[index].tagNames ?? [], - description: - combinedList[index].caption ?? '', - create_at: timeAgo, - total_comments: combinedList[index] - .totalComment - .toString(), - total_likes: combinedList[index] - .likecount - .toString(), - total_save: combinedList[index] - .totalSave - .toString(), - community_name: combinedList[index] - .community! - .communityName - .toString(), - RecationId: - combinedList[index].id.toString(), - ), + 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( + combinedList[index] + .iamPrincipal! + .profilePhoto ?? + ''), + radius: 25.r, + ), + sizedBoxWidth(12.w), + Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + text16w400_FCFCFC( + combinedList[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( + combinedList[ + 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 = + combinedList[ + index] + .iamPrincipal! + .id!; + await pinunpinUser( + pinPospostid); + }, + child: Padding( + padding: EdgeInsets + .symmetric( + horizontal: + 12.w), + child: Row( + children: [ + Text( + combinedList[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( + combinedList[index] + .image ?? + '', + ), + ), + ), + ), + ), + sizedBoxHeight(20.h), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 16.w), + 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: combinedList[ + index] + .attachTags + .where((tag) => + tag.manageTag?.name + ?.isNotEmpty ?? + false) + .length, + itemBuilder: + (context, tagIndex) { + // Filtered list of tags + var filteredTags = + combinedList[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: () { + Get.toNamed( + RouteName + .tagdetailscreen, + arguments: { + 'tagid': combinedList[ + 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}'), + ), + ), + ), + ], + ), + ), + ); + }, + ), + ), + sizedBoxHeight(20.h), + SizedBox( + width: double.infinity, + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + text16w400_FCFCFC( + combinedList![index] + .caption ?? + ''), + ], + ), + ), + Row(children: [ + InkWell( + onTap: () { + Get.toNamed(RouteName + .reactionview); + }, + child: stackReaction( + number: + combinedList[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( + combinedList![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( + combinedList![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, + combinedList[ + 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, + combinedList[ + 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 latestpostid = + combinedList[ + index] + .id!; + await saveunsavepost( + latestpostid); + }, + child: combinedList[ + 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) ], ); + + // Column( + // children: [ + // // normalcardtile2( + // // profileImg: combinedList[index] + // // .iamPrincipal! + // // .profilePhoto ?? + // // '', + // // title: combinedList[index] + // // .iamPrincipal! + // // .fullName ?? + // // '', + // // mainImg: combinedList[index].image ?? '', + // // containerTitle: + // // combinedList[index].tagNames ?? [], + // // description: + // // combinedList[index].caption ?? '', + // // create_at: timeAgo, + // // total_comments: combinedList[index] + // // .totalComment + // // .toString(), + // // total_likes: combinedList[index] + // // .likecount + // // .toString(), + // // total_save: combinedList[index] + // // .totalSave + // // .toString(), + // // community_name: combinedList[index] + // // .community! + // // .communityName + // // .toString(), + // // RecationId: + // // combinedList[index].id.toString(), + // // ), + + // sizedBoxHeight(20.h) + // ], + // ); } }, ), @@ -1403,7 +2809,7 @@ class _LatestTabState extends State { } } - pinunpinUser(int userid) async { + pinunpinUser(int userid) async { // utils.loader(); Map updata = { "pin_iam_principal_xid": userid, @@ -1411,7 +2817,7 @@ class _LatestTabState extends State { final data = await SidebarTags().postUserpin(updata); if (data.status == ResponseStatus.SUCCESS) { // Get.back(); - LatespostApi().getLatestPostApi().then((value) { + LatespostApi().getLatestPostApi().then((value) { _initializeData(); setState(() {}); }); @@ -1450,7 +2856,28 @@ class _LatestTabState extends State { snapshot.hasData) { print("Data fetched-->"); - return Stack( + return + latestpostobj!.data.isEmpty + ? + Center( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "No Data Found", + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.w600), + ) + ], + ), + ) + + : + + Stack( clipBehavior: Clip.none, children: [ Container( @@ -1697,7 +3124,8 @@ class _LatestTabState extends State { image: NetworkImage( latestpostobj!.data[index] .image ?? - ''))), + ''), + fit: BoxFit.cover)), ), ), sizedBoxHeight(20.h), @@ -2250,15 +3678,15 @@ class _LatestTabState extends State { ), const PopupMenuDivider(), PopupMenuItem( - onTap: () async { - int pinPospostid = - latestpostobj! - .data[index] - .iamPrincipal! - .id!; - await pinunpinUser( - pinPospostid); - }, + onTap: () async { + int pinPospostid = + latestpostobj! + .data[index] + .iamPrincipal! + .id!; + await pinunpinUser( + pinPospostid); + }, child: Padding( padding: EdgeInsets.symmetric( @@ -2267,13 +3695,13 @@ class _LatestTabState extends State { children: [ Text( latestpostobj! - .data[ - index] - .iamPrincipal! - .isUserPinned == - true - ? 'Unpin' - : 'Pin', + .data[ + index] + .iamPrincipal! + .isUserPinned == + true + ? 'Unpin' + : 'Pin', style: TextStyle( fontSize: 16.sp, color: Colors.white, @@ -2586,7 +4014,7 @@ class _LatestTabState extends State { children: [ Column( mainAxisAlignment: - MainAxisAlignment.center, + MainAxisAlignment.center, children: [ Column( children: [ diff --git a/lib/Main_Screens/Community_HomePage/Model/tagpopulardetailsModel.dart b/lib/Main_Screens/Community_HomePage/Model/tagpopulardetailsModel.dart new file mode 100644 index 0000000..d681df1 --- /dev/null +++ b/lib/Main_Screens/Community_HomePage/Model/tagpopulardetailsModel.dart @@ -0,0 +1,239 @@ +class TagPopulardetailsModel { + TagPopulardetailsModel({ + 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 TagPopulardetailsModel.fromJson(Map json){ + return TagPopulardetailsModel( + 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.isILiked, + required this.totalComment, + required this.totalSave, + required this.iamPrincipalXid, + required this.postIn, + required this.caption, + required this.image, + required this.postAs, + required this.ctaTitle, + required this.ctaLink, + required this.createdAt, + required this.totalViewCount, + required this.totalReactionCount, + required this.totalCommentCount, + required this.totalImpressionCount, + required this.likeIcon, + required this.tagsXid, + 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 bool? isILiked; + final int? totalComment; + final int? totalSave; + final int? iamPrincipalXid; + final int? postIn; + final String? caption; + final String? image; + final String? postAs; + final String? ctaTitle; + final String? ctaLink; + final DateTime? createdAt; + final int? totalViewCount; + final int? totalReactionCount; + final int? totalCommentCount; + final int? totalImpressionCount; + final LikeIcon? likeIcon; + final List tagsXid; + 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"], + 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"], + postAs: json["post_as"], + ctaTitle: json["cta_title"], + ctaLink: json["cta_link"], + createdAt: DateTime.tryParse(json["created_at"] ?? ""), + totalViewCount: json["totalViewCount"], + totalReactionCount: json["totalReactionCount"], + totalCommentCount: json["totalCommentCount"], + totalImpressionCount: json["totalImpressionCount"], + likeIcon: json["likeIcon"] == null ? null : LikeIcon.fromJson(json["likeIcon"]), + tagsXid: json["tags_xid"] == null ? [] : List.from(json["tags_xid"]!.map((x) => x)), + 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 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"], + ); + } + +} + +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"], + ); + } + +} diff --git a/lib/Main_Screens/Community_HomePage/PostScreen.dart b/lib/Main_Screens/Community_HomePage/PostScreen.dart index 5be5c47..9de93ad 100644 --- a/lib/Main_Screens/Community_HomePage/PostScreen.dart +++ b/lib/Main_Screens/Community_HomePage/PostScreen.dart @@ -95,23 +95,40 @@ class _PostScreenState extends State { List selectedabilityid = []; int? communityid; - void getCatIdFromName(List selectedAbilities) { - selectedabilityid.clear(); // Clear existing selections - for (var name in selectedAbilities) { - for (var i = 0; i < postcommunity.length; i++) { - if (name == postcommunity[i].community!.communityName) { - selectedabilityid.add(postcommunity[i].community!.id!); - communityid = postcommunity[i].community!.id!; - // fetchPopularlist(postcommunity[i].id!); - fetchPopularTags(communityid!); - _isSecondDropdownEnabled = true; + // void getCatIdFromName(List selectedAbilities) { + // selectedabilityid.clear(); // Clear existing selections + // for (var name in selectedAbilities) { + // for (var i = 0; i < postcommunity.length; i++) { + // if (name == postcommunity[i].community!.communityName) { + // selectedabilityid.add(postcommunity[i].community!.id!); + // communityid = postcommunity[i].community!.id!; + // // fetchPopularlist(postcommunity[i].id!); + // fetchPopularTags(communityid!); + // _isSecondDropdownEnabled = true; - break; // Assuming each name is unique, we break after finding a match - } + // break; // Assuming each name is unique, we break after finding a match + // } + // } + // } + // print('Selected IDs: $selectedabilityid'); + // } + + void getCatIdFromName(List selectedAbilities) { + selectedabilityid.clear(); // Clear existing selections + for (var name in selectedAbilities) { + for (var i = 0; i < postcommunity.length; i++) { + if (name == postcommunity[i].community!.communityName) { + selectedabilityid.add(postcommunity[i].community!.id!); + communityid = postcommunity[i].community!.id!; + // Fetch tags for the selected community + fetchPopularTags(communityid!); + _isSecondDropdownEnabled = true; + break; // Assuming each name is unique, we break after finding a match } } - print('Selected IDs: $selectedabilityid'); } + print('Selected IDs: $selectedabilityid'); +} List tags = []; // Change the type to List @@ -1063,9 +1080,17 @@ class _CustomDropDownPopularTagState extends State { void initState() { super.initState(); filteredTags.value = widget.tags; - textEditingController.addListener(() { - filterTags(); - }); + textEditingController.addListener(filterTags); + } + + @override + void didUpdateWidget(CustomDropDownPopularTag oldWidget) { + super.didUpdateWidget(oldWidget); + if (widget.tags != oldWidget.tags) { + // Clear the selected tags and update the filtered tags when tags change + selectedTags.clear(); + filteredTags.value = widget.tags; + } } void _handleDropdownTap() { @@ -1131,10 +1156,6 @@ class _CustomDropDownPopularTagState extends State { ), suffixIcon: GestureDetector( onTap: _handleDropdownTap, - // () { - // onDropTap.value = !onDropTap.value; - - // }, child: SizedBox( height: 20, width: 20, @@ -1150,11 +1171,7 @@ class _CustomDropDownPopularTagState extends State { ), border: InputBorder.none, ), - onTap: _handleDropdownTap - // () { - // onDropTap.value = !onDropTap.value; - // }, - ), + onTap: _handleDropdownTap), ), ), @@ -1225,9 +1242,6 @@ class _CustomDropDownPopularTagState extends State { label: Text('#${tag.name!}', style: const TextStyle(color: Colors.white)), backgroundColor: const Color(0xFFD90B2E).withOpacity(0.9), - // Color(0xFFD90B2E).withOpacity(0.90), - - // Colors.transparent, // Make Chip background transparent side: BorderSide(color: Colors.black), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(30.r), @@ -1248,6 +1262,218 @@ class _CustomDropDownPopularTagState extends State { } } + +// class CustomDropDownPopularTag extends StatefulWidget { +// final List tags; +// final Function(List) onItemSelected; +// final bool isFirstDropdownSelected; + +// CustomDropDownPopularTag({ +// required this.tags, +// required this.onItemSelected, +// required this.isFirstDropdownSelected, +// }); + +// @override +// _CustomDropDownPopularTagState createState() => +// _CustomDropDownPopularTagState(); +// } + +// class _CustomDropDownPopularTagState extends State { +// RxBool onDropTap = false.obs; +// RxList selectedTags = [].obs; +// RxList filteredTags = [].obs; +// TextEditingController textEditingController = TextEditingController(); + +// @override +// void initState() { +// super.initState(); +// filteredTags.value = widget.tags; +// textEditingController.addListener(() { +// filterTags(); +// }); +// } + +// void _handleDropdownTap() { +// if (widget.isFirstDropdownSelected) { +// onDropTap.value = !onDropTap.value; +// } else { +// utils.showToast('Please select an item from the first dropdown.'); +// } +// } + +// void filterTags() { +// String query = textEditingController.text.toLowerCase(); +// if (query.isNotEmpty) { +// filteredTags.value = widget.tags +// .where((tag) => +// tag.name!.toLowerCase().contains(query) && +// !selectedTags.contains(tag)) +// .toList(); +// } else { +// filteredTags.value = +// widget.tags.where((tag) => !selectedTags.contains(tag)).toList(); +// } +// onDropTap.value = filteredTags.isNotEmpty; +// } + +// @override +// Widget build(BuildContext context) { +// return Obx( +// () => Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// // Dropdown Search Input +// Container( +// width: double.infinity, +// height: 50, +// padding: const EdgeInsets.symmetric(horizontal: 12), +// decoration: BoxDecoration( +// color: const Color(0xFFFFFFFF).withOpacity(0.10), +// borderRadius: onDropTap.value && filteredTags.isNotEmpty +// ? const BorderRadius.vertical( +// top: Radius.circular(30), +// ) +// : BorderRadius.circular(30), +// border: Border.all(color: const Color(0xFF434A53)), +// ), +// child: Center( +// child: TextFormField( +// controller: textEditingController, +// style: const TextStyle( +// fontSize: 16, +// color: Colors.white, +// fontFamily: 'Helvetica', +// ), +// cursorColor: Colors.red, +// obscureText: false, +// decoration: InputDecoration( +// hintText: 'Search Tags', +// hintStyle: const TextStyle( +// fontSize: 16, +// color: Colors.white, +// fontWeight: FontWeight.w400, +// fontFamily: 'Helvetica', +// ), +// suffixIcon: GestureDetector( +// onTap: _handleDropdownTap, +// // () { +// // onDropTap.value = !onDropTap.value; + +// // }, +// child: SizedBox( +// height: 20, +// width: 20, +// child: Center( +// child: Icon( +// onDropTap.value +// ? Icons.arrow_drop_up +// : Icons.arrow_drop_down, +// color: Colors.white, +// ), +// ), +// ), +// ), +// border: InputBorder.none, +// ), +// onTap: _handleDropdownTap +// // () { +// // onDropTap.value = !onDropTap.value; +// // }, +// ), +// ), +// ), + +// // Dropdown List +// if (onDropTap.value && filteredTags.isNotEmpty) +// Container( +// width: double.infinity, +// decoration: BoxDecoration( +// color: const Color(0xFFFFFFFF).withOpacity(0.10), +// borderRadius: const BorderRadius.vertical( +// bottom: Radius.circular(30), +// ), +// border: Border.all(color: const Color(0xFF434A53)), +// ), +// child: ListView.builder( +// shrinkWrap: true, +// itemCount: filteredTags.length, +// itemBuilder: (context, index) { +// return InkWell( +// onTap: () { +// Data selectedItem = filteredTags[index]; +// if (selectedTags.contains(selectedItem)) { +// selectedTags.remove(selectedItem); +// } else { +// selectedTags.add(selectedItem); +// } +// textEditingController.clear(); +// widget.onItemSelected(selectedTags.toList()); +// filterTags(); // Update the filtered list +// }, +// child: Padding( +// padding: const EdgeInsets.all(10.0), +// child: Row( +// children: [ +// Text( +// filteredTags[index].name!, +// style: const TextStyle( +// color: Colors.white, +// fontSize: 16, +// fontWeight: FontWeight.w400, +// fontFamily: 'Helvetica', +// ), +// ), +// const Spacer(), +// Text( +// 'Popularity: ${filteredTags[index].tagPopularity}', +// style: const TextStyle( +// color: Colors.white70, +// fontSize: 12, +// ), +// ), +// ], +// ), +// ), +// ); +// }, +// ), +// ), +// sizedBoxHeight(20.h), + +// // Selected Tags Displayed as Chips +// if (selectedTags.isNotEmpty) +// Wrap( +// spacing: 8.0, +// runSpacing: 4.0, +// children: selectedTags.map((tag) { +// return Chip( +// label: Text('#${tag.name!}', +// style: const TextStyle(color: Colors.white)), +// backgroundColor: const Color(0xFFD90B2E).withOpacity(0.9), +// // Color(0xFFD90B2E).withOpacity(0.90), + +// // Colors.transparent, // Make Chip background transparent +// side: BorderSide(color: Colors.black), +// shape: RoundedRectangleBorder( +// borderRadius: BorderRadius.circular(30.r), +// side: BorderSide(width: 1, color: Colors.white)), +// onDeleted: () { +// selectedTags.remove(tag); +// widget.onItemSelected(selectedTags.toList()); +// filterTags(); // Update the filtered list after removing a tag +// }, +// materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, +// padding: const EdgeInsets.symmetric(horizontal: 16), +// ); +// }).toList(), +// ), +// ], +// ), +// ); +// } +// } + class CreateData { final int id; final String name; diff --git a/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart b/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart index f22d8ce..b384a73 100644 --- a/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart +++ b/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart @@ -110,7 +110,7 @@ class _TagdetailScreenState extends State { height: 670.h, child: TabBarView( children: [ - cyclepopularTab(), + PopularTab(id: tagsid), // cyclelatestTab(), LatestTab(id: tagsid) ], @@ -541,6 +541,1693 @@ Widget _buildReactionsIcon(String assetPath) { ); } +class PopularTab extends StatefulWidget { + PopularTab({super.key, required this.id}); + + int id; + + @override + State createState() => _PopularTabState(); +} + +class _PopularTabState extends State { + FutureGroup futureGroup = FutureGroup(); + + @override + void initState() { + futureGroup + .add(Communitygetmethod().getPopularTagsdata(widget.id).then((value) { + _initializeData(); + })); + futureGroup.close(); + 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); + + setState(() { + _reactions = fetchlikeIconsModel.data + ?.map((data) => ReactionData( + id: data.id!, + image: data.image!, + )) + .toList() ?? + []; + for (var post in tagpopulardetailobj!.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 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) { + 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), + ]), + ), + ], + )), + 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), + ) + ], + ), + ); + } +} + class LatestTab extends StatefulWidget { LatestTab({super.key, required this.id}); @@ -568,7 +2255,7 @@ class _LatestTabState extends State { Future _initializeData() async { await _fetchIcons(); // _initializeSelectedReaction(); - for (var post in tagdetailobj!.data) { + for (var post in tagpopulardetailobj!.data) { if (post.likeIcon != null) { likeIconIdnew = post.likeIcon!.likeIconsXid; // This is safe now print('like selectedid is ${likeIconIdnew.toString()}'); @@ -981,7 +2668,8 @@ class _LatestTabState extends State { tagdetailobj! .data[index] .image ?? - ''))), + ''), + fit: BoxFit.cover)), ), ), sizedBoxHeight(20.h), diff --git a/lib/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart b/lib/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart index 030b9c7..b802ed0 100644 --- a/lib/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart +++ b/lib/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart @@ -4,8 +4,11 @@ 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'; +import 'package:regroup/Main_Screens/Community_HomePage/Model/tagpopulardetailsModel.dart'; TagdetailsModel? tagdetailobj; +TagPopulardetailsModel? tagpopulardetailobj; + class Communitygetmethod { Future> getTagsdata(updata) async { @@ -19,4 +22,16 @@ class Communitygetmethod { } return response; } + + Future> getPopularTagsdata(updata) async { + final response = await NetworkApiServices().getApi( + "${ApiUrls.getpopularTagsdetails}?search_post_by_tag_id=$updata", + ); + + if (response.status == ResponseStatus.SUCCESS) { + tagpopulardetailobj = TagPopulardetailsModel.fromJson(response.data); + log(tagpopulardetailobj!.data.toString()); + } + return response; + } } diff --git a/lib/sidemenu/sidemenu.dart b/lib/sidemenu/sidemenu.dart index 9a83ac2..268aa7d 100644 --- a/lib/sidemenu/sidemenu.dart +++ b/lib/sidemenu/sidemenu.dart @@ -208,415 +208,330 @@ class _SideMenuState extends State { } Widget _buildBody(context) { - return Column( + return ListView( + padding: EdgeInsets.zero, children: [ sizedBoxHeight(50.h), - Expanded( - child: ListView(physics: ScrollPhysics(), children: [ - GestureDetector( - onTap: () { - Get.toNamed(RouteName.mycommunity); - }, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Row( - children: [ - text16w400_FCFCFC("My communities"), - sizedBoxWidth(4.w), - Image.asset('assets/images/png/sidemenu/rightarrow.png') - ], + GestureDetector( + onTap: () { + Get.toNamed(RouteName.mycommunity); + }, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Row( + children: [ + text16w400_FCFCFC("My communities"), + sizedBoxWidth(4.w), + Image.asset('assets/images/png/sidemenu/rightarrow.png') + ], + ), + ), + ), + sizedBoxHeight(18.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Container( + height: 1, + margin: EdgeInsets.symmetric(vertical: 10.h), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: const Color.fromRGBO(255, 255, 255, 0.3), + width: 1.w, ), ), ), - const Spacer(), - sizedBoxHeight(18.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Container( - height: 1, - margin: EdgeInsets.symmetric(vertical: 10.h), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: const Color.fromRGBO(255, 255, 255, 0.3), - width: 1.w, - ), - ), + ), + ), + sizedBoxHeight(18.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: text16w400_FCFCFC("My pinned content"), + ), + sizedBoxHeight(18.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Container( + height: 1, + margin: EdgeInsets.symmetric(vertical: 10.h), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: const Color.fromRGBO(255, 255, 255, 0.3), + width: 1.w, ), ), ), - sizedBoxHeight(18.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: text16w400_FCFCFC("My pinned content"), - ), - const Spacer(), - sizedBoxHeight(18.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Container( - height: 1, - margin: EdgeInsets.symmetric(vertical: 10.h), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: const Color.fromRGBO(255, 255, 255, 0.3), - width: 1.w, - ), - ), - ), - ), - ), - sizedBoxHeight(18.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Row( - children: [ - text16w400_FCFCFC("interest"), - const Spacer(), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.viewalltags); - }, - child: text14w400_FCFCFC("View all")), - ], - ), - ), - sizedBoxHeight(20.h), - userpinnedobj!.data!.pinnedTag!.isEmpty - ? Center(child: text16400white("Pin tags")) - : SizedBox( - height: 200.h, - child: - // Obx( () { - // return - ListView.builder( - shrinkWrap: true, - itemCount: userpinnedobj!.data!.pinnedTag!.take(5).length, - itemBuilder: (context, index) { - final tagid = userpinnedobj! - .data!.pinnedTag![index].manageTagsXid!; + ), + ), + sizedBoxHeight(18.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Row( + children: [ + text16w400_FCFCFC("interest"), + const Spacer(), + GestureDetector( + onTap: () { + Get.toNamed(RouteName.viewalltags); + }, + child: text14w400_FCFCFC("View all")), + ], + ), + ), + sizedBoxHeight(0.h), + userpinnedobj!.data!.pinnedTag!.isEmpty + ? Center(child: text16400white("Pin tags")) + : SizedBox( + height: 200.h, + child: ListView.builder( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: userpinnedobj!.data!.pinnedTag!.take(5).length, + itemBuilder: (context, index) { + final tagid = + userpinnedobj!.data!.pinnedTag![index].manageTagsXid!; - return ListTile( - leading: commonContainer( - width: 29.w, - height: 29.h, - borderwidth: 0.9, - boxShape: BoxShape.circle, - customWidget: Center( - child: Image.asset( - 'assets/images/png/sidemenu/rowing 1 (traced).png', - width: 13.w, - height: 13.h, - ), - )), - title: userpinnedobj!.data!.pinnedTag![index].tag == - null || + return ListTile( + leading: commonContainer( + width: 29.w, + height: 29.h, + borderwidth: 0.9, + boxShape: BoxShape.circle, + customWidget: Center( + child: Image.asset( + 'assets/images/png/sidemenu/rowing 1 (traced).png', + width: 13.w, + height: 13.h, + ), + )), + title: + userpinnedobj!.data!.pinnedTag![index].tag == null || userpinnedobj!.data!.pinnedTag![index].tag! .name!.isEmpty ? text14w400_FCFCFC('') : text14w400_FCFCFC(userpinnedobj! .data!.pinnedTag![index].tag!.name!), - trailing: InkWell( - onTap: () async { - setState(() { - pinunpinTag(tagid); - userpinnedobj!.data!.pinnedTag!.removeWhere( - (item) => item.manageTagsXid == tagid); - }); - - // toggleSelectedIndex(tagid); - }, - child: - // Obx( - // () { - // return selectedIndices.contains(tagid) - // ? - // Image.asset( - // "assets/images/png/sidemenu/f7_pin-fill (1).png", - // width: 19, - // height: 19, - // ) - // : - Image.asset( - "assets/images/png/sidemenu/f7_pin-fill.png", - width: 19, - height: 19, - ), - // }, - // ), - ), - // onTap: () {}, - ); - }, - ), - // } - - // ) - ), - sizedBoxHeight(18.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Container( - height: 1, - margin: EdgeInsets.symmetric(vertical: 10.h), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: const Color.fromRGBO(255, 255, 255, 0.3), - width: 1.w, - ), - ), + trailing: InkWell( + onTap: () async { + setState(() { + pinunpinTag(tagid); + userpinnedobj!.data!.pinnedTag!.removeWhere( + (item) => item.manageTagsXid == tagid); + }); + }, + child: Image.asset( + "assets/images/png/sidemenu/f7_pin-fill.png", + width: 19, + height: 19, + ), + ), + ); + }, + ), + ), + sizedBoxHeight(18.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Container( + height: 1, + margin: EdgeInsets.symmetric(vertical: 10.h), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: const Color.fromRGBO(255, 255, 255, 0.3), + width: 1.w, ), ), ), - sizedBoxHeight(18.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Row( - children: [ - text16w400_FCFCFC("Communities"), - const Spacer(), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.viewallcommunitiespinned); - }, - child: text14w400_FCFCFC("View all")), - ], - ), - ), - sizedBoxHeight(20.h), - userpinnedobj!.data!.pinnedCommunity!.isEmpty - ? Center(child: text16400white("Pin communities")) - : SizedBox( - height: 200.h, - child: ListView.builder( - shrinkWrap: true, - itemCount: - userpinnedobj!.data!.pinnedCommunity!.take(5).length, - itemBuilder: (context, index) { - final commnityid = userpinnedobj!.data! - .pinnedCommunity![index].manageCommunitiesXid!; + ), + ), + sizedBoxHeight(18.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Row( + children: [ + text16w400_FCFCFC("Communities"), + const Spacer(), + GestureDetector( + onTap: () { + Get.toNamed(RouteName.viewallcommunitiespinned); + }, + child: text14w400_FCFCFC("View all")), + ], + ), + ), + sizedBoxHeight(0.h), + userpinnedobj!.data!.pinnedCommunity!.isEmpty + ? Center(child: text16400white("Pin communities")) + : SizedBox( + height: 200.h, + child: ListView.builder( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: + userpinnedobj!.data!.pinnedCommunity!.take(5).length, + itemBuilder: (context, index) { + final commnityid = userpinnedobj! + .data!.pinnedCommunity![index].manageCommunitiesXid!; - return ListTile( - leading: Container( - width: 29.w, - height: 29.h, - decoration: BoxDecoration( - shape: BoxShape.circle, - // color: Colors.amber, - ), - child: - userpinnedobj! - .data! - .pinnedCommunity![index] - .community! - .communityProfilePhoto == - null || - userpinnedobj! - .data! - .pinnedCommunity![index] - .community! - .communityProfilePhoto! - .isEmpty - ? CircleAvatar( - backgroundImage: AssetImage( - 'assets/images/png/sidemenu/rowing 1 (traced).png', - ), - ) - : CircleAvatar( - backgroundImage: NetworkImage( - userpinnedobj! - .data! - .pinnedCommunity![index] - .community! - .communityProfilePhoto!), - ) - - ), - title: userpinnedobj!.data!.pinnedCommunity![index] - .community == + return ListTile( + leading: Container( + width: 29.w, + height: 29.h, + decoration: BoxDecoration( + shape: BoxShape.circle, + ), + child: userpinnedobj!.data!.pinnedCommunity![index] + .community!.communityProfilePhoto == null || userpinnedobj!.data!.pinnedCommunity![index] - .community!.communityName!.isEmpty - ? text14w400_FCFCFC('') - : text14w400_FCFCFC(userpinnedobj! - .data! - .pinnedCommunity![index] - .community! - .communityName!), - trailing: InkWell( - onTap: () async { - setState(() { - pinunpinCommunities(commnityid); - userpinnedobj!.data!.pinnedCommunity! - .removeWhere((item) => - item.manageCommunitiesXid == - commnityid); - }); - - // toggleSelectedIndex(tagid); - }, - // () { - // pinunpinTag(tagid); - // // toggleSelectedIndex(tagid); - // }, - child: Image.asset( - "assets/images/png/sidemenu/f7_pin-fill.png", - width: 19, - height: 19, - ), - // Obx( - // () { - // return selectedIndicescommunity.contains(tagid) - // ? Image.asset( - // "assets/images/png/sidemenu/f7_pin-fill (1).png", - // width: 19, - // height: 19, - // ) - // : Image.asset( - // "assets/images/png/sidemenu/f7_pin-fill.png", - // width: 19, - // height: 19, - // ); - // }, - // ), - ), - ); - }, - ), - ), - sizedBoxHeight(18.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Container( - height: 1, - margin: EdgeInsets.symmetric(vertical: 10.h), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: const Color.fromRGBO(255, 255, 255, 0.3), - width: 1.w, - ), - ), + .community!.communityProfilePhoto!.isEmpty + ? CircleAvatar( + backgroundImage: AssetImage( + 'assets/images/png/sidemenu/rowing 1 (traced).png', + ), + ) + : CircleAvatar( + backgroundImage: NetworkImage(userpinnedobj! + .data! + .pinnedCommunity![index] + .community! + .communityProfilePhoto!), + )), + title: userpinnedobj!.data!.pinnedCommunity![index] + .community == + null || + userpinnedobj!.data!.pinnedCommunity![index] + .community!.communityName!.isEmpty + ? text14w400_FCFCFC('') + : text14w400_FCFCFC(userpinnedobj! + .data! + .pinnedCommunity![index] + .community! + .communityName!), + trailing: InkWell( + onTap: () async { + setState(() { + pinunpinCommunities(commnityid); + userpinnedobj!.data!.pinnedCommunity!.removeWhere( + (item) => + item.manageCommunitiesXid == commnityid); + }); + }, + child: Image.asset( + "assets/images/png/sidemenu/f7_pin-fill.png", + width: 19, + height: 19, + ), + ), + ); + }, + ), + ), + sizedBoxHeight(18.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Container( + height: 1, + margin: EdgeInsets.symmetric(vertical: 10.h), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: const Color.fromRGBO(255, 255, 255, 0.3), + width: 1.w, ), ), ), - sizedBoxHeight(18.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Row( - children: [ - text16w400_FCFCFC("Users"), - const Spacer(), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.viewalluserspinned); - }, - child: text14w400_FCFCFC("View all")), - ], - ), - ), - sizedBoxHeight(20.h), - userpinnedobj!.data!.pinnedUser!.isEmpty - ? Center(child: text16400white("Pin users")) - : SizedBox( - height: 200.h, - child: ListView.builder( - shrinkWrap: true, - itemCount: - userpinnedobj!.data!.pinnedUser!.take(5).length, - itemBuilder: (context, index) { - final userid = userpinnedobj! - .data!.pinnedUser![index].pinIamPrincipalXid!; + ), + ), + sizedBoxHeight(18.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Row( + children: [ + text16w400_FCFCFC("Users"), + const Spacer(), + GestureDetector( + onTap: () { + Get.toNamed(RouteName.viewalluserspinned); + }, + child: text14w400_FCFCFC("View all")), + ], + ), + ), + sizedBoxHeight(0.h), + userpinnedobj!.data!.pinnedUser!.isEmpty + ? Center(child: text16400white("Pin users")) + : SizedBox( + height: 200.h, + child: ListView.builder( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: userpinnedobj!.data!.pinnedUser!.take(5).length, + itemBuilder: (context, index) { + final userid = userpinnedobj! + .data!.pinnedUser![index].pinIamPrincipalXid!; - return ListTile( - leading: commonContainer( - width: 29.w, - height: 29.h, - borderwidth: 0.9, - boxShape: BoxShape.circle, - customWidget: Center( - child: userpinnedobj!.data!.pinnedUser![index] - .pinUser!.profilePhoto == - null || - userpinnedobj! - .data! - .pinnedUser![index] - .pinUser! - .profilePhoto! - .isEmpty - ? Image.asset( + return ListTile( + leading: commonContainer( + width: 29.w, + height: 29.h, + borderwidth: 0.9, + boxShape: BoxShape.circle, + customWidget: Center( + child: userpinnedobj!.data!.pinnedUser![index] + .pinUser!.profilePhoto == + null || + userpinnedobj!.data!.pinnedUser![index] + .pinUser!.profilePhoto!.isEmpty + ? Image.asset( + 'assets/images/png/sidemenu/rowing 1 (traced).png', + width: 13.w, + height: 13.h, + ) + : Image.network( + userpinnedobj!.data!.pinnedUser![index] + .pinUser!.profilePhoto!, + width: 13.w, + height: 13.h, + errorBuilder: + (context, error, stackTrace) { + return Image.asset( 'assets/images/png/sidemenu/rowing 1 (traced).png', width: 13.w, height: 13.h, - ) - : Image.network( - userpinnedobj! - .data! - .pinnedUser![index] - .pinUser! - .profilePhoto!, - width: 13.w, - height: 13.h, - errorBuilder: - (context, error, stackTrace) { - // Error handling when image fails to load - return Image.asset( - 'assets/images/png/sidemenu/rowing 1 (traced).png', - width: 13.w, - height: 13.h, - ); - }, - ))), - title: userpinnedobj!.data!.pinnedUser![index] - .pinUser!.fullName == - null || - userpinnedobj!.data!.pinnedUser![index] - .pinUser!.fullName!.isEmpty - ? text14w400_FCFCFC('') - : text14w400_FCFCFC(userpinnedobj! - .data!.pinnedUser![index].pinUser!.fullName!), - trailing: InkWell( - onTap: () async { - setState(() { - pinunpinUser(userid); - userpinnedobj!.data!.pinnedUser!.removeWhere( - (item) => - item.pinIamPrincipalXid == userid); - }); - - // toggleSelectedIndex(tagid); - }, - child: Image.asset( - "assets/images/png/sidemenu/f7_pin-fill.png", - width: 19, - height: 19, - ), - // Obx( - // () { - // return selectedIndicesuser.contains(userid) - // ? Image.asset( - // "assets/images/png/sidemenu/f7_pin-fill (1).png", - // width: 19, - // height: 19, - // ) - // : Image.asset( - // "assets/images/png/sidemenu/f7_pin-fill.png", - // width: 19, - // height: 19, - // ); - // }, - // ), - ), - ); - }, - ), - ), - sizedBoxHeight(18.h), - sizedBoxHeight(80.h), - ]), - ), + ); + }, + ))), + title: userpinnedobj!.data!.pinnedUser![index].pinUser! + .fullName == + null || + userpinnedobj!.data!.pinnedUser![index].pinUser! + .fullName!.isEmpty + ? text14w400_FCFCFC('') + : text14w400_FCFCFC(userpinnedobj! + .data!.pinnedUser![index].pinUser!.fullName!), + trailing: InkWell( + onTap: () async { + setState(() { + pinunpinUser(userid); + userpinnedobj!.data!.pinnedUser!.removeWhere( + (item) => item.pinIamPrincipalXid == userid); + }); + }, + child: Image.asset( + "assets/images/png/sidemenu/f7_pin-fill.png", + width: 19, + height: 19, + ), + ), + ); + }, + ), + ), + sizedBoxHeight(18.h), + sizedBoxHeight(80.h), ], ); }