diff --git a/assets/images/png/background.png b/assets/images/png/background.png new file mode 100644 index 0000000..3e27684 Binary files /dev/null and b/assets/images/png/background.png differ diff --git a/assets/images/png/postSaved.png b/assets/images/png/postSaved.png new file mode 100644 index 0000000..3cef09f Binary files /dev/null and b/assets/images/png/postSaved.png differ diff --git a/lib/Common/CommonPostUI.dart b/lib/Common/CommonPostUI.dart index 32e31e2..0d0d057 100644 --- a/lib/Common/CommonPostUI.dart +++ b/lib/Common/CommonPostUI.dart @@ -241,7 +241,7 @@ class _CommonPostUIState extends State { padding: EdgeInsets.only(right: 12.w), child: GestureDetector( onTap: () { - Get.toNamed(RouteName.cyclescreen); + Get.toNamed(RouteName.tagdetailscreen); }, child: containertile(text: containerTitle[index])), ); diff --git a/lib/Common/api_urls.dart b/lib/Common/api_urls.dart index 4107f36..8bd5d6c 100644 --- a/lib/Common/api_urls.dart +++ b/lib/Common/api_urls.dart @@ -126,10 +126,20 @@ class ApiUrls { static const postusertag = "${baseUrl}pin-unpin"; + //comments static const getComments = "${baseUrl}fetch-comment-with-replied-comment"; static const storeComments = "${baseUrl}store-comment"; static const storeRepliesOnComments = "${baseUrl}reply-on-comment"; static const deleteComments = "${baseUrl}delete-comment"; static const deleteRepliesComments = "${baseUrl}delete-reply-on-comment"; + + static const getLikeicons= "${baseUrl}fetch-like-icons"; + + static const postLike = "${baseUrl}like-post"; + + static const getTagsdetails = "${baseUrl}fetch-post-by-tag"; + + static const postusersave = "${baseUrl}save-post"; + } diff --git a/lib/Main_Screens/Community/Model/FeedPostModel.dart b/lib/Main_Screens/Community/Model/FeedPostModel.dart index ffb9bc5..7315185 100644 --- a/lib/Main_Screens/Community/Model/FeedPostModel.dart +++ b/lib/Main_Screens/Community/Model/FeedPostModel.dart @@ -1,197 +1,212 @@ class FeedPostModel { - FeedPostModel({ - required this.status, - required this.statusCode, - required this.message, - required this.data, - }); + FeedPostModel({ + required this.status, + required this.statusCode, + required this.message, + required this.data, + }); - final String? status; - final int? statusCode; - final String? message; - final Data? data; - - factory FeedPostModel.fromJson(Map json){ - return FeedPostModel( - status: json["status"], - statusCode: json["status_code"], - message: json["message"], - data: json["data"] == null ? null : Data.fromJson(json["data"]), - ); - } + final String? status; + final int? statusCode; + final String? message; + final Data? data; + factory FeedPostModel.fromJson(Map json) { + return FeedPostModel( + status: json["status"], + statusCode: json["status_code"], + message: json["message"], + data: json["data"] == null ? null : Data.fromJson(json["data"]), + ); + } } class Data { - Data({ - required this.pinnedCommunityPost, - required this.pinnedUserPost, - required this.pinnedTagsPost, - }); + Data({ + required this.pinnedCommunityPost, + required this.pinnedUserPost, + required this.pinnedTagsPost, + }); - final List pinnedCommunityPost; - final List pinnedUserPost; - final List pinnedTagsPost; - - factory Data.fromJson(Map json){ - return Data( - pinnedCommunityPost: json["pinned_community_post"] == null ? [] : List.from(json["pinned_community_post"]!.map((x) => PinnedPost.fromJson(x))), - pinnedUserPost: json["pinned_user_post"] == null ? [] : List.from(json["pinned_user_post"]!.map((x) => PinnedPost.fromJson(x))), - pinnedTagsPost: json["pinned_tags_post"] == null ? [] : List.from(json["pinned_tags_post"]!.map((x) => PinnedPost.fromJson(x))), - ); - } + final List pinnedCommunityPost; + final List pinnedUserPost; + final List pinnedTagsPost; + factory Data.fromJson(Map json) { + return Data( + pinnedCommunityPost: json["pinned_community_post"] == null + ? [] + : List.from(json["pinned_community_post"]! + .map((x) => PinnedPost.fromJson(x))), + pinnedUserPost: json["pinned_user_post"] == null + ? [] + : List.from( + json["pinned_user_post"]!.map((x) => PinnedPost.fromJson(x))), + // 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))), + ); + } } 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.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, + }); - 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; - - 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"]), - ); - } + 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; + 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; - - factory Community.fromJson(Map json){ - return Community( - id: json["id"], - communityProfilePhoto: json["community_profile_photo"], - communityName: json["community_name"], - ); - } + 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.principalTypeXid, - required this.userName, - required this.fullName, - required this.profilePhoto, - }); + IamPrincipal({ + required this.id, + 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; - - 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"], - ); - } + final int? id; + final int? principalTypeXid; + final String? userName; + final String? fullName; + final String? profilePhoto; + 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; - - factory LikeIcon.fromJson(Map json){ - return LikeIcon( - likeIconsXid: json["like_icons_xid"], - likeIcon: json["like_icon"] == null ? null : LikeIconClass.fromJson(json["like_icon"]), - ); - } + 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, - }); + 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"], - ); - } + final int? id; + final String? image; + factory LikeIconClass.fromJson(Map json) { + return LikeIconClass( + id: json["id"], + image: json["image"], + ); + } } diff --git a/lib/Main_Screens/Community/Model/LatestPostModel.dart b/lib/Main_Screens/Community/Model/LatestPostModel.dart index ab3b0a5..5fe3cb6 100644 --- a/lib/Main_Screens/Community/Model/LatestPostModel.dart +++ b/lib/Main_Screens/Community/Model/LatestPostModel.dart @@ -26,6 +26,7 @@ class Datum { Datum({ required this.id, required this.likecount, + required this.isISaved, required this.tagsXid, required this.isILiked, required this.totalComment, @@ -39,14 +40,21 @@ class Datum { required this.ctaTitle, required this.ctaLink, required this.createdAt, - required this.tagNames, required this.likeIcon, + required this.totalViewCount, + required this.totalReactionCount, + required this.totalCommentCount, + required this.totalImpressionCount, + required this.totalPopularScore, + required this.totalHoursAgo, required this.iamPrincipal, required this.community, + required this.attachTags, }); final int? id; final int? likecount; + final bool? isISaved; final List tagsXid; final bool? isILiked; final int? totalComment; @@ -60,15 +68,22 @@ class Datum { final String? ctaTitle; final String? ctaLink; final DateTime? createdAt; - final List tagNames; final LikeIcon? likeIcon; + final int? totalViewCount; + final int? totalReactionCount; + final int? totalCommentCount; + final int? totalImpressionCount; + final int? totalPopularScore; + final int? totalHoursAgo; final IamPrincipal? iamPrincipal; final Community? community; + final List attachTags; factory Datum.fromJson(Map json){ return Datum( id: json["id"], likecount: json["likecount"], + isISaved: json["is_i_saved"], tagsXid: json["tags_xid"] == null ? [] : List.from(json["tags_xid"]!.map((x) => x)), isILiked: json["is_i_liked"], totalComment: json["total_comment"], @@ -82,10 +97,58 @@ class Datum { ctaTitle: json["cta_title"], ctaLink: json["cta_link"], createdAt: DateTime.tryParse(json["created_at"] ?? ""), - tagNames: json["tag_names"] == null ? [] : List.from(json["tag_names"]!.map((x) => x)), likeIcon: json["likeIcon"] == null ? null : LikeIcon.fromJson(json["likeIcon"]), + totalViewCount: json["totalViewCount"], + totalReactionCount: json["totalReactionCount"], + totalCommentCount: json["totalCommentCount"], + totalImpressionCount: json["totalImpressionCount"], + totalPopularScore: json["totalPopularScore"], + totalHoursAgo: json["totalHoursAgo"], iamPrincipal: json["iam_principal"] == null ? null : IamPrincipal.fromJson(json["iam_principal"]), community: json["community"] == null ? null : Community.fromJson(json["community"]), + attachTags: json["attach_tags"] == null ? [] : List.from(json["attach_tags"]!.map((x) => AttachTag.fromJson(x))), + ); + } + +} + +class AttachTag { + AttachTag({ + required this.managePostXid, + required this.manageTagXid, + required this.manageTag, + }); + + final int? managePostXid; + final int? manageTagXid; + final ManageTag? manageTag; + + factory AttachTag.fromJson(Map json){ + return AttachTag( + managePostXid: json["manage_post_xid"], + manageTagXid: json["manage_tag_xid"], + manageTag: json["manage_tag"] == null ? null : ManageTag.fromJson(json["manage_tag"]), + ); + } + +} + +class ManageTag { + ManageTag({ + required this.id, + required this.isPinned, + required this.name, + }); + + final int? id; + final bool? isPinned; + final String? name; + + factory ManageTag.fromJson(Map json){ + return ManageTag( + id: json["id"], + isPinned: json["is_pinned"], + name: json["name"], ); } @@ -115,6 +178,7 @@ class Community { class IamPrincipal { IamPrincipal({ required this.id, + required this.isUserPinned, required this.principalTypeXid, required this.userName, required this.fullName, @@ -122,14 +186,16 @@ class IamPrincipal { }); final int? id; + final bool? isUserPinned; final int? principalTypeXid; final String? userName; - final dynamic fullName; + final String? fullName; final String? profilePhoto; factory IamPrincipal.fromJson(Map json){ return IamPrincipal( id: json["id"], + isUserPinned: json["is_user_pinned"], principalTypeXid: json["principal_type_xid"], userName: json["user_name"], fullName: json["full_name"], diff --git a/lib/Main_Screens/Community/Model/fetchicons.dart b/lib/Main_Screens/Community/Model/fetchicons.dart new file mode 100644 index 0000000..c6e2f48 --- /dev/null +++ b/lib/Main_Screens/Community/Model/fetchicons.dart @@ -0,0 +1,64 @@ +class FetchlikeIconsModel { + String? status; + int? statusCode; + String? message; + List? data; + + FetchlikeIconsModel({this.status, this.statusCode, this.message, this.data}); + + FetchlikeIconsModel.fromJson(Map json) { + status = json['status']; + statusCode = json['status_code']; + message = json['message']; + if (json['data'] != null) { + data = []; + json['data'].forEach((v) { + data!.add(new Data.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['status'] = this.status; + data['status_code'] = this.statusCode; + data['message'] = this.message; + if (this.data != null) { + data['data'] = this.data!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class Data { + int? id; + String? image; + + Data({this.id, this.image}); + + Data.fromJson(Map json) { + id = json['id']; + image = json['image']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['image'] = this.image; + return data; + } +} + +class ReactionData { + final int id; + final String image; + + ReactionData({required this.id, required this.image}); + + factory ReactionData.fromJson(Map json) { + return ReactionData( + id: json['id'], + image: json['image'], + ); + } +} diff --git a/lib/Main_Screens/Community/ViewModel/getmethod.dart b/lib/Main_Screens/Community/ViewModel/getmethod.dart new file mode 100644 index 0000000..5733b1c --- /dev/null +++ b/lib/Main_Screens/Community/ViewModel/getmethod.dart @@ -0,0 +1,24 @@ +import 'dart:developer'; + +import 'package:regroup/Common/api_urls.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Common/controller/data/network/network_api.dart'; +import 'package:regroup/Main_Screens/Community/Model/fetchicons.dart'; + +// FetchlikeIconsModel? likeiconsobj; + +class Communityallgetmethod { + + Future> getLikeicons() async { + final response = await NetworkApiServices().getApi( + ApiUrls.getLikeicons, + // optionalpar: false + ); + if (response.status == ResponseStatus.SUCCESS) { + // likeiconsobj = FetchlikeIconsModel.fromJson(response.data); + // log(likeiconsobj!.data.toString()); + } + return response; + } + +} \ No newline at end of file diff --git a/lib/Main_Screens/Community/ViewModel/postmethod.dart b/lib/Main_Screens/Community/ViewModel/postmethod.dart new file mode 100644 index 0000000..5b65cf6 --- /dev/null +++ b/lib/Main_Screens/Community/ViewModel/postmethod.dart @@ -0,0 +1,15 @@ +import 'package:regroup/Common/api_urls.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Common/controller/data/network/network_api.dart'; + +class CommunitypostMethod { +CommunitypostMethod(); + + Future> postLikepost(updata) async { + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.postLike, + ); + return response; + } +} \ No newline at end of file diff --git a/lib/Main_Screens/Community_HomePage/Community.dart b/lib/Main_Screens/Community_HomePage/Community.dart index c6ef975..765040f 100644 --- a/lib/Main_Screens/Community_HomePage/Community.dart +++ b/lib/Main_Screens/Community_HomePage/Community.dart @@ -1,5 +1,7 @@ // ignore_for_file: unused_local_variable, non_constant_identifier_names, avoid_print, file_names +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:flutter_reaction_button/flutter_reaction_button.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -9,15 +11,24 @@ import 'package:regroup/Common/CommonGlassmorphism.dart'; import 'package:regroup/Common/CommonTabBar.dart'; import 'package:regroup/Common/CommonWidget.dart'; import 'package:regroup/Common/ConvertServerDateToUserDate.dart'; +import 'package:regroup/Common/base_manager.dart'; import 'package:regroup/Common/controller/MainScreen.dart'; +import 'package:regroup/Feed%20Module/Main_Screens/Community/view_model/getApi.dart'; import 'package:regroup/Main_Screens/Community/Model/FeedPostModel.dart'; +import 'package:regroup/Main_Screens/Community/Model/fetchicons.dart'; import 'package:regroup/Main_Screens/Community/ViewModel/FeedPost.dart'; import 'package:regroup/Main_Screens/Community/ViewModel/LatestPost.dart'; +import 'package:regroup/Main_Screens/Community/ViewModel/getmethod.dart'; +import 'package:regroup/Main_Screens/Community/ViewModel/postmethod.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/view_model/communitypostmethod.dart'; // import 'package:regroup/Feed%20Module/sidemenu/sidemenu.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; +import 'package:regroup/Utils/dialogs.dart'; import 'package:regroup/Utils/texts.dart'; import 'package:regroup/resources/routes/route_name.dart'; import 'package:regroup/sidemenu/sidemenu.dart'; +import 'package:async/src/future_group.dart'; +import 'package:regroup/sidemenu/view_model/postmethod.dart'; class CommunityScreen extends StatefulWidget { const CommunityScreen({super.key}); @@ -241,75 +252,120 @@ class _FeedTabState extends State { fit: BoxFit.fill), ), ), - Column( - children: [ - sizedBoxHeight(16.h), - Expanded( - child: ListView.builder( - shrinkWrap: true, - itemCount: combinedList.length, - itemBuilder: (context, index) { - var timeAgo = ConvertServerDateToUserDate() - .convertServerDateToReadableFormate( - combinedList[index].createdAt.toString()); - 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(), - ); - } 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(), - ), - sizedBoxHeight(20.h) - ], - ); - } - }, + combinedList.isEmpty + ? + + // Expanded( + // child: Center( + // child: Column( + // children: [ + // Text( + // "No Data Found", + // style: TextStyle( + // color: Colors.white, + // fontSize: 16.sp, + // fontWeight: FontWeight.w600), + // ) + // ], + // ), + // ), + // ) + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Center( + child: Column( + children: [ + Text( + "No Data Found", + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.w600), + ) + ], + ), + ), + ]) + : Column( + children: [ + sizedBoxHeight(16.h), + Expanded( + child: ListView.builder( + shrinkWrap: true, + itemCount: combinedList.length, + itemBuilder: (context, index) { + var timeAgo = ConvertServerDateToUserDate() + .convertServerDateToReadableFormate( + combinedList[index].createdAt.toString()); + 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(), + ); + } 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(), + postId: combinedList[index].id.toString(), + ), + sizedBoxHeight(20.h) + ], + ); + } + }, + ), + ), + ], ), - ), - ], - ), ], ); } @@ -330,7 +386,7 @@ Widget normalcardtile2({ required String total_likes, required String total_save, required String? create_at, - required String? RecationId, + required String? postId, }) { var mainImage = 'assets/images/png/uiw_like-o.png'.obs; void updateImage(String reaction) { @@ -516,7 +572,11 @@ Widget normalcardtile2({ padding: EdgeInsets.only(right: 12.w), child: GestureDetector( onTap: () { - Get.toNamed(RouteName.cyclescreen); + // Get.toNamed(RouteName.cyclescreen, ); + // arguments: { + // 'tagid': latestpostobj!.data[index].tagsData[index].id, + // 'tagname' : latestpostobj!.data[index].tagsData[index].name, + // } }, child: containertile2( text: ("#${containerTitle[index]}"))), @@ -538,7 +598,7 @@ Widget normalcardtile2({ InkWell( onTap: () { Get.toNamed(RouteName.reactionview, arguments: { - 'reactionId': RecationId, + 'postId': postId, }); }, child: stackReaction(number: total_likes, containerImages: [ @@ -1189,17 +1249,18 @@ Widget popularTab() { return Column( children: [ normalcardtile2( - profileImg: popularTabData[index]["profileImg"], - title: popularTabData[index]["title"], - mainImg: popularTabData[index]["mainImg"], - containerTitle: popularTabData[index]["containerTitle"], - description: 'test', - create_at: '1 hour', - total_comments: '20', - total_likes: '20', - total_save: '10', - community_name: 'text', - RecationId: ''), + profileImg: popularTabData[index]["profileImg"], + title: popularTabData[index]["title"], + mainImg: popularTabData[index]["mainImg"], + containerTitle: popularTabData[index]["containerTitle"], + description: 'test', + create_at: '1 hour', + total_comments: '20', + total_likes: '20', + total_save: '10', + community_name: 'text', + postId: '', + ), sizedBoxHeight(20.h) ], ); @@ -1218,18 +1279,172 @@ class LatestTab extends StatefulWidget { } class _LatestTabState extends State { - late Future latestfuture; + // late Future latestfuture; + FutureGroup futureGroup = FutureGroup(); @override void initState() { - latestfuture = LatespostApi().getLatestPostApi(); + futureGroup.add(LatespostApi().getLatestPostApi().then((value) { + _initializeData(); + })); + // futureGroup.add( + // ); + // latestfuture = LatespostApi().getLatestPostApi(); + futureGroup.close(); super.initState(); } + List _reactions = []; + Map _selectedReactions = {}; + + Future _initializeData() async { + await _fetchIcons(); + // _initializeSelectedReaction(); + for (var post in latestpostobj!.data) { + if (post.likeIcon != null) { + likeIconIdnew = post.likeIcon!.likeIconsXid; // This is safe now + } else { + likeIconIdnew = 0; // Or handle it as needed + } + _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 latestpostobj!.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 latestpostid) async { + // utils.loader(); + Map updata = { + "manage_posts_xid": latestpostid, + }; + final data = await Communitypostmethod().postUserSave(updata); + if (data.status == ResponseStatus.SUCCESS) { + LatespostApi().getLatestPostApi().then((value) { + _initializeData(); + setState(() {}); + }); + + return utils.showToast(data.message); + } else { + // Get.back(); + return utils.showToast(data.message); + } + } + + pinunpinUser(int userid) async { + // utils.loader(); + Map updata = { + "pin_iam_principal_xid": userid, + }; + final data = await SidebarTags().postUserpin(updata); + if (data.status == ResponseStatus.SUCCESS) { + // Get.back(); + LatespostApi().getLatestPostApi().then((value) { + _initializeData(); + setState(() {}); + }); + return utils.showToast(data.message); + } else { + // Get.back(); + return utils.showToast(data.message); + } + } + @override Widget build(BuildContext context) { return FutureBuilder( - future: latestfuture, + future: futureGroup.future, builder: (ctx, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return @@ -1264,80 +1479,1457 @@ class _LatestTabState extends State { fit: BoxFit.fill), ), ), - Column( - children: [ - sizedBoxHeight(16.h), - Expanded( - child: ListView.builder( - shrinkWrap: true, - itemCount: latestpostobj!.data.length, - itemBuilder: (context, index) { - var timeAgo = ConvertServerDateToUserDate() - .convertServerDateToReadableFormate(latestpostobj! - .data[index].createdAt - .toString()); - if (index == 1) { - return announcecardtile( - profileImg: latestpostobj! - .data[index].iamPrincipal!.profilePhoto ?? - '', - title: latestpostobj! - .data[index].iamPrincipal!.fullName ?? - '', - mainImg: latestpostobj!.data[index].image ?? '', - containerTitle: - latestpostobj!.data[index].tagNames ?? [''], - create_at: timeAgo, - community_name: latestpostobj! - .data[index].community!.communityName ?? - '', - totalcomments: latestpostobj! - .data[index].totalComment - .toString(), - description: - latestpostobj!.data[index].caption ?? '', - totalSave: - latestpostobj!.data[index].totalSave.toString(), - ); - } else { - return Column( - children: [ - normalcardtile2( - profileImg: latestpostobj!.data[index] - .iamPrincipal!.profilePhoto ?? - '', - title: latestpostobj! - .data[index].iamPrincipal!.fullName ?? - '', - mainImg: latestpostobj!.data[index].image ?? '', - containerTitle: - latestpostobj!.data[index].tagNames ?? [''], - description: - latestpostobj!.data[index].caption ?? '', - create_at: timeAgo, - total_comments: latestpostobj! - .data[index].totalComment - .toString(), - total_likes: latestpostobj! - .data[index].likecount - .toString(), - total_save: latestpostobj!.data[index].totalSave - .toString(), - community_name: latestpostobj! - .data[index].community!.communityName - .toString(), - RecationId: - latestpostobj!.data[index].id.toString(), - ), - sizedBoxHeight(20.h) - ], - ); - } - }, + latestpostobj!.data.isEmpty + ? Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Center( + child: Column( + children: [ + Text( + "No Data Found", + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.w600), + ) + ], + ), + ), + ], + ), + ) + : Column( + children: [ + sizedBoxHeight(16.h), + Expanded( + child: ListView.builder( + shrinkWrap: true, + itemCount: latestpostobj!.data.length, + itemBuilder: (context, index) { + var timeAgo = ConvertServerDateToUserDate() + .convertServerDateToReadableFormate( + latestpostobj!.data[index].createdAt + .toString()); + var postId = latestpostobj!.data[index].id; + var selectedReaction = _selectedReactions[postId]; + if (index == 1) { + return + // announcecardtile( + // profileImg: latestpostobj! + // .data[index].iamPrincipal!.profilePhoto ?? + // '', + // title: latestpostobj! + // .data[index].iamPrincipal!.fullName ?? + // '', + // mainImg: latestpostobj!.data[index].image ?? '', + // containerTitle: + // latestpostobj!.data[index].tagNames ?? [''], + // create_at: timeAgo, + // community_name: latestpostobj! + // .data[index].community!.communityName ?? + // '', + // totalcomments: latestpostobj! + // .data[index].totalComment + // .toString(), + // description: + // latestpostobj!.data[index].caption ?? '', + // totalSave: + // latestpostobj!.data[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( + latestpostobj! + .data[index] + .iamPrincipal! + .profilePhoto ?? + ''), + radius: 25.r, + ), + sizedBoxWidth(12.w), + Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + text16w400_FCFCFC( + latestpostobj! + .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( + latestpostobj! + .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: () {}, + // child: Padding( + // padding: + // EdgeInsets.symmetric( + // horizontal: 12.w), + // child: Row( + // children: [ + // Text( + // 'Pin', + // style: TextStyle( + // fontSize: 16.sp, + // color: Colors.white, + // fontWeight: + // FontWeight.w800, + // fontFamily: + // "Nunito Sans", + // ), + // ), + // const Spacer(), + // Image.asset( + // "assets/images/png/f7_pin-fill (2).png", + // height: 25.h, + // width: 25.w, + // ) + // ], + // ), + // ), + // ), + ], + child: Image.asset( + 'assets/images/png/Group 1000004071.png', + width: 16.w, + height: 18.h, + ), + ), + sizedBoxWidth(5.w) + ], + ), + ), + sizedBoxHeight(20.h), + GestureDetector( + onTap: () { + Get.toNamed(RouteName + .postdetailsScreen); + }, + child: Container( + height: 390.h, + decoration: BoxDecoration( + image: DecorationImage( + image: NetworkImage( + latestpostobj! + .data[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: latestpostobj! + .data[index].attachTags + .where((tag) => + tag.manageTag?.name + ?.isNotEmpty ?? + false) + .length, + itemBuilder: + (context, tagIndex) { + // Filtered list of tags + var filteredTags = + latestpostobj! + .data[index] + .attachTags + .where((tag) => + tag + .manageTag + ?.name + ?.isNotEmpty ?? + false) + .toList(); + + // Safely get the manageTag object + var manageTag = + filteredTags[tagIndex] + .manageTag; + + // Get the tag name, ensuring it's not null or empty + String tagName = + manageTag?.name ?? ''; + + return Padding( + padding: + EdgeInsets.only( + right: 12.w, + left: 12.w), + child: GestureDetector( + onTap: () { + Get.toNamed( + RouteName + .tagdetailscreen, + arguments: { + 'tagid': + // filteredTags[ + // tagIndex] + // .manageTagXid, + latestpostobj! + .data[ + index] + .attachTags[ + tagIndex] + .manageTag! + .id, + 'tagname': + tagName, + 'ispinnedtag': filteredTags[ + tagIndex] + .manageTag! + .isPinned + }); + }, + child: Row( + mainAxisAlignment: + MainAxisAlignment + .start, + children: [ + commonContainer( + width: 130.w, + height: 30.h, + borderRadius: + BorderRadius + .circular( + 30.r), + borderColor: + const Color( + 0xFFD90B2E), + opacity1: 0.04, + opacity2: 0.05, + customWidget: + Padding( + padding: EdgeInsets + .symmetric( + horizontal: + 10.w), + child: Center( + child: text14w400_FCFCFC( + '#${tagName}'), + ), + ), + ), + ], + ), + ), + ); + }, + ), + ), + sizedBoxHeight(20.h), + SizedBox( + width: double.infinity, + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + text16w400_FCFCFC( + latestpostobj! + .data[index] + .caption ?? + ''), + ], + ), + ), + Row(children: [ + InkWell( + onTap: () {}, + child: stackReaction( + number: latestpostobj! + .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( + latestpostobj!.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( + latestpostobj! + .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, + latestpostobj! + .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, + latestpostobj! + .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 latestpostid = + latestpostobj! + .data[index] + .id!; + await saveunsavepost( + latestpostid); + }, + child: latestpostobj! + .data[ + index] + .isISaved == + true + ? Image.asset( + 'assets/images/png/postSaved.png', + height: 19.h, + width: 19.w, + ) + : Image.asset( + 'assets/images/png/Frame 1000004089.png', + height: 19.h, + width: 19.w, + ), + ), + // Image.asset( + // 'assets/images/png/Frame 1000004089.png', + // height: 19.h, + // width: 19.w, + // ), + sizedBoxHeight(8.h), + text11w400_FCFCFC( + 'Save') + ], + ) + ], + ), + sizedBoxHeight(12.h), + commonDivider(), + sizedBoxHeight(12.h), + ]), + ), + ], + )), + sizedBoxHeight(20.h), + ], + ); + } else { + return Column( + children: [ + // normalcardtile2( + // profileImg: latestpostobj!.data[index] + // .iamPrincipal!.profilePhoto ?? + // '', + // title: latestpostobj! + // .data[index].iamPrincipal!.fullName ?? + // '', + // mainImg: latestpostobj!.data[index].image ?? '', + // containerTitle: + // latestpostobj!.data[index].tagNames ?? [''], + // description: + // latestpostobj!.data[index].caption ?? '', + // create_at: timeAgo, + // total_comments: latestpostobj! + // .data[index].totalComment + // .toString(), + // total_likes: latestpostobj! + // .data[index].likecount + // .toString(), + // total_save: latestpostobj!.data[index].totalSave + // .toString(), + // community_name: latestpostobj! + // .data[index].community!.communityName + // .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( + latestpostobj! + .data[index] + .iamPrincipal! + .profilePhoto ?? + ''), + radius: 25.r, + ), + sizedBoxWidth(12.w), + Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + text16w400_FCFCFC( + latestpostobj! + .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( + latestpostobj! + .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 = + latestpostobj! + .data[index] + .iamPrincipal! + .id!; + await pinunpinUser( + pinPospostid); + }, + child: Padding( + padding: EdgeInsets + .symmetric( + horizontal: + 12.w), + child: Row( + children: [ + Text( + latestpostobj! + .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( + latestpostobj!.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: latestpostobj! + // .data[index].attachTags.length, + // itemBuilder: (context, tagIndex) { + // print( + // 'tags id are ${latestpostobj!.data[index].attachTags[tagIndex].manageTag!.id}'); + // print( + // 'tags name are ${latestpostobj!.data[index].attachTags[tagIndex].manageTag!.name}'); + // return Padding( + // padding: EdgeInsets.only( + // right: 12.w), + // child: GestureDetector( + // onTap: () { + // Get.toNamed( + // RouteName + // .tagdetailscreen, + // arguments: { + // 'tagid': + // latestpostobj! + // .data[ + // index] + // .attachTags[ + // tagIndex].manageTag! + // .id, + // 'tagname': + // latestpostobj! + // .data[ + // index] + // .attachTags[ + // tagIndex].manageTag! + // .name, + // }); + // }, + // child: Row( + // mainAxisAlignment: + // MainAxisAlignment + // .start, + // children: [ + // // containertile2( + // // text: latestpostobj! + // // .data[index] + // // .tagsData[ + // // tagIndex] + // // .name!), + // commonContainer( + // width: 130.w, + // height: 30.h, + // borderRadius: + // BorderRadius + // .circular( + // 30.r), + // borderColor: + // const Color( + // 0xFFD90B2E), + // opacity1: 0.04, + // opacity2: 0.05, + // customWidget: + // Padding( + // padding: EdgeInsets + // .symmetric( + // horizontal: + // 10.w), + // child: Center( + // child: text14w400_FCFCFC(latestpostobj! + // .data[ + // index] + // .attachTags[ + // tagIndex].manageTag! + // .name!)), + // )), + // ], + // )), + // ); + // }, + // ), + // ), + SizedBox( + height: 30.h, + width: double.infinity, + child: ListView.builder( + scrollDirection: + Axis.horizontal, + shrinkWrap: true, + // Filter the tags to include only those with a non-null and non-empty name + itemCount: latestpostobj! + .data[index].attachTags + .where((tag) => + tag.manageTag?.name + ?.isNotEmpty ?? + false) + .length, + itemBuilder: + (context, tagIndex) { + // Filtered list of tags + var filteredTags = + latestpostobj! + .data[index] + .attachTags + .where((tag) => + tag + .manageTag + ?.name + ?.isNotEmpty ?? + false) + .toList(); + + // Safely get the manageTag object + var manageTag = + filteredTags[tagIndex] + .manageTag; + + // Get the tag name, ensuring it's not null or empty + String tagName = + manageTag?.name ?? ''; + + return Padding( + padding: + EdgeInsets.only( + right: 12.w, + left: 12.w), + child: GestureDetector( + onTap: () { + Get.toNamed( + RouteName + .tagdetailscreen, + arguments: { + 'tagid': latestpostobj! + .data[ + index] + .attachTags[ + tagIndex] + .manageTag! + .id, + 'tagname': + tagName, + 'ispinnedtag': filteredTags[ + tagIndex] + .manageTag! + .isPinned + }); + }, + child: Row( + mainAxisAlignment: + MainAxisAlignment + .start, + children: [ + commonContainer( + width: 130.w, + height: 30.h, + borderRadius: + BorderRadius + .circular( + 30.r), + borderColor: + const Color( + 0xFFD90B2E), + opacity1: 0.04, + opacity2: 0.05, + customWidget: + Padding( + padding: EdgeInsets + .symmetric( + horizontal: + 10.w), + child: Center( + child: text14w400_FCFCFC( + '#${tagName}'), + ), + ), + ), + ], + ), + ), + ); + }, + ), + ), + sizedBoxHeight(20.h), + SizedBox( + width: double.infinity, + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + text16w400_FCFCFC( + latestpostobj! + .data[index] + .caption ?? + ''), + ], + ), + ), + Row(children: [ + InkWell( + onTap: () { + Get.toNamed( + RouteName + .reactionview, + arguments: { + 'postId': postId + .toString(), + }); + }, + child: stackReaction( + number: latestpostobj! + .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( + latestpostobj!.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( + latestpostobj! + .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, + latestpostobj! + .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, + latestpostobj! + .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 latestpostid = + latestpostobj! + .data[ + index] + .id!; + await saveunsavepost( + latestpostid); + }, + child: latestpostobj! + .data[ + index] + .isISaved == + true + ? Image.asset( + 'assets/images/png/postSaved.png', + height: + 19.h, + width: 19.w, + ) + : Image.asset( + 'assets/images/png/Frame 1000004089.png', + height: + 19.h, + width: 19.w, + ), + ), + // Image.asset( + // 'assets/images/png/Frame 1000004089.png', + // height: 19.h, + // width: 19.w, + // ), + sizedBoxHeight(8.h), + text11w400_FCFCFC( + 'Save') + ], + ), + ), + ], + ), + sizedBoxHeight(12.h), + commonDivider(), + sizedBoxHeight(12.h), + ]), + ), + ], + )), + sizedBoxHeight(20.h) + ], + ); + } + }, + ), + ), + ], ), - ), - ], - ), ], ); } diff --git a/lib/Main_Screens/Community_HomePage/CycleScreen.dart b/lib/Main_Screens/Community_HomePage/CycleScreen.dart deleted file mode 100644 index 3a862db..0000000 --- a/lib/Main_Screens/Community_HomePage/CycleScreen.dart +++ /dev/null @@ -1,489 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_reaction_button/flutter_reaction_button.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; -import 'package:regroup/Common/CommonGlassmorphism.dart'; -import 'package:regroup/Common/CommonTabBar.dart'; -import 'package:regroup/Common/CommonWidget.dart'; -import 'package:regroup/Main_Screens/Community_HomePage/Community.dart'; -import 'package:regroup/Utils/Common/CommonAppbar.dart'; -import 'package:regroup/Utils/Common/sized_box.dart'; -import 'package:regroup/Utils/texts.dart'; -import 'package:regroup/resources/routes/route_name.dart'; - -class CycleScreen extends StatefulWidget { - const CycleScreen({super.key}); - - @override - State createState() => _CycleScreenState(); -} - -class _CycleScreenState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: const Color(0xFF222935), - extendBody: true, - resizeToAvoidBottomInset: false, - appBar: CommonAppbar( - titleTxt: "Cycle", - customActionWidget: Image.asset( - "assets/images/png/sidemenu/f7_pin-fill.png", - height: 26.h, - width: 26.w, - )), - body: Stack(children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/png/Ellipse 1496.png"), - fit: BoxFit.fill)), - ), - Column(children: [ - sizedBoxHeight(10.h), - DefaultTabController( - length: 2, - // initialIndex: selectedIndex.value, - child: Column( - children: [ - const CommonTabBar(tabs: [ - Tab( - text: 'Popular', - ), - Tab( - text: 'Latest', - ), - ]), - SizedBox( - height: 670.h, - child: TabBarView( - children: [ - cyclepopularTab(), - cyclelatestTab(), - ], - ), - ), - ], - )) - ]) - ])); - } -} - -Widget cyclepopularTab() { - return SingleChildScrollView( - child: Column(children: [ - sizedBoxHeight(20.h), - normalcardtile( - profileImg: 'assets/images/png/Ellipse 52.png', - title: 'Ryan Dorwat', - mainImg: 'assets/images/png/img322.png', - containerTitle: [ - 'Football', - 'Teams player', - 'Events', - 'Marathon', - 'Events' - ]), - sizedBoxHeight(30.h), - normalcardtile( - profileImg: 'assets/images/png/Ellipse 43.png', - title: 'Edward Hackket', - mainImg: 'assets/images/png/Rectangle 24.png', - containerTitle: [ - 'Cycle', - 'Marathon', - 'Events', - 'Marathon', - 'Events' - ]), - ]), - ); -} - -Widget cyclelatestTab() { - return SingleChildScrollView( - child: Column(children: [ - sizedBoxHeight(20.h), - normalcardtile( - profileImg: 'assets/images/png/Ellipse 43.png', - title: 'Edward Hackket', - mainImg: 'assets/images/png/Rectangle 24.png', - containerTitle: [ - 'Cycle', - 'Marathon', - 'Events', - 'Marathon', - 'Events' - ]), - ]), - ); -} - -Widget normalcardtile({ - required String profileImg, - required String title, - required String mainImg, - required List containerTitle, -}) { - var mainImage = 'assets/images/png/uiw_like-o.png'.obs; - void updateImage(String reaction) { - if (reaction == 'like') { - mainImage.value = 'assets/images/png/f7_hand-thumbsup.png'; - } else if (reaction == 'heart') { - mainImage.value = 'assets/images/png/heart 2.png'; - } else if (reaction == 'party') { - mainImage.value = 'assets/images/png/party-popper 2.png'; - } - } - - return commonGlassUI( - width: double.infinity, - height: 570.h, - borderwidth: 0, - borderRadius: BorderRadius.circular( 1), - customWidget: Column( - children: [ - sizedBoxHeight(25.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CircleAvatar( - foregroundImage: AssetImage(profileImg), - radius: 25.r, - ), - sizedBoxWidth(12.w), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC(title), - sizedBoxHeight(5.h), - Row( - children: [ - Image.asset( - 'assets/images/png/community 1 (traced).png', - height: 14.w, - width: 14.w, - ), - sizedBoxWidth(7.w), - text12w400_FCFCFC('Active alliance network'), - sizedBoxWidth(7.w), - Icon( - Icons.circle, - color: const Color(0xFFFCFCFC), - size: 4.sp, - ), - sizedBoxWidth(6.w), - text12w400_FCFCFC('1 Hour ago'), - ], - ) - ], - ), - const Spacer(), - PopupMenuButton( - surfaceTintColor: const Color(0xFF222935), - constraints: BoxConstraints.tightFor(width: 176.w), - offset: const Offset(0, 50), - color: const Color(0xFF222935), - tooltip: "", - itemBuilder: (BuildContext context) => [ - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - Text( - 'Report Post', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/Vector (5).png", - height: 15.h, - width: 15.w, - ) - ], - ), - ), - ), - const PopupMenuDivider(), - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - Text( - 'Share post', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/share.png", - height: 20.h, - width: 20.w, - ) - ], - ), - ), - ), - const PopupMenuDivider(), - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - Text( - 'Pin', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/f7_pin-fill (2).png", - height: 25.h, - width: 25.w, - ) - ], - ), - ), - ), - ], - child: Image.asset( - 'assets/images/png/Group 1000004071.png', - width: 16.w, - height: 18.h, - ), - ), - sizedBoxWidth(5.w) - ], - ), - ), - sizedBoxHeight(20.h), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.postdetailsScreen); - }, - child: SizedBox( - height: 360.h, - width: double.infinity, - child: Image.asset( - mainImg, - fit: BoxFit.cover, - ), - )), - sizedBoxHeight(20.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Column(children: [ - SizedBox( - height: 30.h, - child: ListView.builder( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - itemCount: containerTitle.length, - itemBuilder: (context, index) { - return Padding( - padding: EdgeInsets.only(right: 12.w), - child: GestureDetector( - onTap: () { - Get.toNamed(RouteName.cyclescreen); - }, - child: containertile(text: containerTitle[index])), - ); - }, - ), - ), - sizedBoxHeight(20.h), - text16w400_FCFCFC( - "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s . . ."), - Row(children: [ - InkWell( - onTap: () { - Get.toNamed(RouteName.reactionview); - }, - child: stackReaction(number: '20', containerImages: [ - 'assets/images/png/f7_hand-thumbsup.png', - 'assets/images/png/heart 2.png', - 'assets/images/png/party-popper 2.png' - ]), - ), - const Spacer(), - commonGlassUI( - borderwidth: 0.43, - width: 30.w, - height: 30.h, - opacity1: 0.05, - opacity2: 0.06, - borderRadius: BorderRadius.circular( 100), - customWidget: Center( - child: Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 13.h, - width: 13.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC('20'), - sizedBoxWidth(20.w), - commonGlassUI( - borderwidth: 0.43, - width: 30.w, - height: 30.h, - borderRadius: BorderRadius.circular( 100), - opacity1: 0.05, - opacity2: 0.06, - customWidget: Center( - child: Image.asset( - 'assets/images/png/Vector (1).png', - height: 12.h, - width: 12.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC('10'), - ]), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Obx(() { - return ReactionButton( - onReactionChanged: (reaction) { - updateImage(reaction?.value ?? 'like'); - debugPrint('Selected value: ${reaction?.value}'); - }, - reactions: ?>[ - Reaction( - value: 'like', - previewIcon: _buildReactionsPreviewIcon( - 'assets/images/png/f7_hand-thumbsup.png'), - icon: _buildReactionsIcon( - 'assets/images/png/f7_hand-thumbsup.png'), - ), - Reaction( - value: 'heart', - previewIcon: _buildReactionsPreviewIcon( - 'assets/images/png/heart 2.png'), - icon: _buildReactionsIcon( - 'assets/images/png/heart 2.png'), - ), - Reaction( - value: 'party', - previewIcon: _buildReactionsPreviewIcon( - 'assets/images/png/party-popper 2.png'), - icon: _buildReactionsIcon( - 'assets/images/png/party-popper 2.png'), - ), - ], - selectedReaction: Reaction( - value: 'like', - icon: _buildReactionsIcon( - 'assets/images/png/f7_hand-thumbsup.png'), - ), - boxColor: Colors.white, - boxElevation: 9, - boxRadius: 30, - itemsSpacing: 8, - itemScale: 0.4, - itemSize: const Size(45, 45), - boxPadding: const EdgeInsets.all(8), - boxAnimationDuration: - const Duration(milliseconds: 200), - itemAnimationDuration: - const Duration(milliseconds: 500), - hoverDuration: const Duration(milliseconds: 700), - // toggle: false, - - child: _buildReactionsIcon(mainImage.value), - ); - }) - ], - ), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.postdetailsScreen); - }, - child: Column( - children: [ - Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Comment') - ], - ), - ), - Column( - children: [ - Image.asset( - 'assets/images/png/Frame 1000004089.png', - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Save') - ], - ) - ], - ), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - ]), - ), - ], - )); -} - -Widget _buildReactionsPreviewIcon(String assetPath) { - return Padding( - padding: const EdgeInsets.all(8.0), - child: Image.asset( - assetPath, - height: 40.h, - width: 40.w, - ), - ); -} - -Widget _buildReactionsIcon(String assetPath) { - return Column( - children: [ - Image.asset( - assetPath, - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Like') - ], - ); -} diff --git a/lib/Main_Screens/Community_HomePage/Model/tagdetailModel.dart b/lib/Main_Screens/Community_HomePage/Model/tagdetailModel.dart new file mode 100644 index 0000000..82c9c28 --- /dev/null +++ b/lib/Main_Screens/Community_HomePage/Model/tagdetailModel.dart @@ -0,0 +1,242 @@ +class TagdetailsModel { + TagdetailsModel({ + required this.status, + required this.statusCode, + required this.message, + required this.data, + }); + + final String? status; + final int? statusCode; + final String? message; + final List data; + + factory TagdetailsModel.fromJson(Map json){ + return TagdetailsModel( + status: json["status"], + statusCode: json["status_code"], + message: json["message"], + data: json["data"] == null ? [] : List.from(json["data"]!.map((x) => Datum.fromJson(x))), + ); + } + +} + +class Datum { + Datum({ + required this.id, + required this.likecount, + required this.isISaved, + required this.tagsXid, + required this.isILiked, + required this.totalComment, + required this.totalSave, + required this.iamPrincipalXid, + required this.postIn, + required this.caption, + required this.image, + required this.manageTagsXids, + required this.postAs, + required this.ctaTitle, + required this.ctaLink, + required this.createdAt, + required this.likeIcon, + required this.totalViewCount, + required this.totalReactionCount, + required this.totalCommentCount, + required this.totalImpressionCount, + required this.totalPopularScore, + required this.totalHoursAgo, + required this.iamPrincipal, + required this.community, + required this.attachTags, + }); + + final int? id; + final int? likecount; + final bool? isISaved; + final List tagsXid; + final bool? isILiked; + final int? totalComment; + final int? totalSave; + final int? iamPrincipalXid; + final int? postIn; + final String? caption; + final String? image; + final String? manageTagsXids; + final String? postAs; + final String? ctaTitle; + final String? ctaLink; + final DateTime? createdAt; + final LikeIcon? likeIcon; + final int? totalViewCount; + final int? totalReactionCount; + final int? totalCommentCount; + final int? totalImpressionCount; + final int? totalPopularScore; + final int? totalHoursAgo; + final IamPrincipal? iamPrincipal; + final Community? community; + final List attachTags; + + factory Datum.fromJson(Map json){ + return Datum( + id: json["id"], + likecount: json["likecount"], + isISaved: json["is_i_saved"], + tagsXid: json["tags_xid"] == null ? [] : List.from(json["tags_xid"]!.map((x) => x)), + isILiked: json["is_i_liked"], + totalComment: json["total_comment"], + totalSave: json["total_save"], + iamPrincipalXid: json["iam_principal_xid"], + postIn: json["post_in"], + caption: json["caption"], + image: json["image"], + manageTagsXids: json["manage_tags_xids"], + postAs: json["post_as"], + ctaTitle: json["cta_title"], + ctaLink: json["cta_link"], + createdAt: DateTime.tryParse(json["created_at"] ?? ""), + likeIcon: json["likeIcon"] == null ? null : LikeIcon.fromJson(json["likeIcon"]), + totalViewCount: json["totalViewCount"], + totalReactionCount: json["totalReactionCount"], + totalCommentCount: json["totalCommentCount"], + totalImpressionCount: json["totalImpressionCount"], + totalPopularScore: json["totalPopularScore"], + totalHoursAgo: json["totalHoursAgo"], + iamPrincipal: json["iam_principal"] == null ? null : IamPrincipal.fromJson(json["iam_principal"]), + community: json["community"] == null ? null : Community.fromJson(json["community"]), + attachTags: json["attach_tags"] == null ? [] : List.from(json["attach_tags"]!.map((x) => AttachTag.fromJson(x))), + ); + } + +} + +class AttachTag { + AttachTag({ + required this.managePostXid, + required this.manageTagXid, + required this.manageTag, + }); + + final int? managePostXid; + final int? manageTagXid; + final ManageTag? manageTag; + + factory AttachTag.fromJson(Map json){ + return AttachTag( + managePostXid: json["manage_post_xid"], + manageTagXid: json["manage_tag_xid"], + manageTag: json["manage_tag"] == null ? null : ManageTag.fromJson(json["manage_tag"]), + ); + } + +} + +class ManageTag { + ManageTag({ + required this.id, + required this.isPinned, + required this.name, + }); + + final int? id; + final bool? isPinned; + final String? name; + + factory ManageTag.fromJson(Map json){ + return ManageTag( + id: json["id"], + isPinned: json["is_pinned"], + name: json["name"], + ); + } + +} + +class Community { + Community({ + required this.id, + required this.communityProfilePhoto, + required this.communityName, + }); + + final int? id; + final String? communityProfilePhoto; + final String? communityName; + + factory Community.fromJson(Map json){ + return Community( + id: json["id"], + communityProfilePhoto: json["community_profile_photo"], + communityName: json["community_name"], + ); + } + +} + +class IamPrincipal { + IamPrincipal({ + required this.id, + required this.isUserPinned, + required this.principalTypeXid, + required this.userName, + required this.fullName, + required this.profilePhoto, + }); + + final int? id; + final bool? isUserPinned; + final int? principalTypeXid; + final String? userName; + final String? fullName; + final String? profilePhoto; + + factory IamPrincipal.fromJson(Map json){ + return IamPrincipal( + id: json["id"], + isUserPinned: json["is_user_pinned"], + principalTypeXid: json["principal_type_xid"], + userName: json["user_name"], + fullName: json["full_name"], + profilePhoto: json["profile_photo"], + ); + } + +} + +class LikeIcon { + LikeIcon({ + required this.likeIconsXid, + required this.likeIcon, + }); + + final int? likeIconsXid; + final LikeIconClass? likeIcon; + + factory LikeIcon.fromJson(Map json){ + return LikeIcon( + likeIconsXid: json["like_icons_xid"], + likeIcon: json["like_icon"] == null ? null : LikeIconClass.fromJson(json["like_icon"]), + ); + } + +} + +class LikeIconClass { + LikeIconClass({ + required this.id, + required this.image, + }); + + final int? id; + final String? image; + + factory LikeIconClass.fromJson(Map json){ + return LikeIconClass( + id: json["id"], + image: json["image"], + ); + } + +} diff --git a/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart b/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart index 10a3f81..4eb2e43 100644 --- a/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart +++ b/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart @@ -861,7 +861,7 @@ class _PostDetailsScreenState extends State { padding: EdgeInsets.only(right: 12.w), child: GestureDetector( onTap: () { - Get.toNamed(RouteName.cyclescreen); + Get.toNamed(RouteName.tagdetailscreen); }, child: containertile(text: containerTitle[index])), ); diff --git a/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/ReactionView.dart b/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/ReactionView.dart index b8c5ecb..0c6bbdb 100644 --- a/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/ReactionView.dart +++ b/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/ReactionView.dart @@ -9,7 +9,7 @@ import 'package:regroup/Utils/Common/CommonAppbar.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; import 'package:regroup/Utils/texts.dart'; -var recationid = Get.arguments['reactionId']; +String? postId; class ReactionView extends StatefulWidget { const ReactionView({super.key}); @@ -149,7 +149,9 @@ class _AllTabsState extends State { @override void initState() { - alltabfuture = LikePostApi().postLike({'manage_posts_xid': recationid}); + postId = Get.arguments['postId']; + + alltabfuture = LikePostApi().postLike({'manage_posts_xid': postId}); super.initState(); } @@ -224,8 +226,9 @@ class _LikeTabsState extends State { @override void initState() { - liketabfuture = LikePostApi() - .postLike({'manage_posts_xid': recationid, 'like_icons_xid': 1}); + postId = Get.arguments['postId']; + + liketabfuture = LikePostApi() .postLike({'manage_posts_xid': postId, 'like_icons_xid': 1}); super.initState(); } @@ -300,8 +303,9 @@ class _FavouriteTabsState extends State { @override void initState() { - favouritetabfuture = LikePostApi() - .postLike({'manage_posts_xid': recationid, 'like_icons_xid': 2}); + postId = Get.arguments['postId']; + + favouritetabfuture = LikePostApi() .postLike({'manage_posts_xid': postId, 'like_icons_xid': 2}); super.initState(); } @@ -376,8 +380,8 @@ class _PartyTabsState extends State { @override void initState() { - partytabfuture = LikePostApi() - .postLike({'manage_posts_xid': recationid, 'like_icons_xid': 3}); + postId = Get.arguments['postId']; + partytabfuture = LikePostApi().postLike({'manage_posts_xid': postId, 'like_icons_xid': 3}); super.initState(); } diff --git a/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart b/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart new file mode 100644 index 0000000..f22d8ce --- /dev/null +++ b/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart @@ -0,0 +1,2216 @@ +import 'dart:developer'; + +import 'package:flutter/material.dart'; +import 'package:flutter_reaction_button/flutter_reaction_button.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:regroup/Common/CommonGlassmorphism.dart'; +import 'package:regroup/Common/CommonTabBar.dart'; +import 'package:regroup/Common/CommonWidget.dart'; +import 'package:regroup/Common/ConvertServerDateToUserDate.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Main_Screens/Community/Model/fetchicons.dart'; +import 'package:regroup/Main_Screens/Community/ViewModel/getmethod.dart'; +import 'package:regroup/Main_Screens/Community/ViewModel/postmethod.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/Community.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/view_model/communitypostmethod.dart'; +import 'package:regroup/Utils/Common/CommonAppbar.dart'; +import 'package:regroup/Utils/Common/sized_box.dart'; +import 'package:regroup/Utils/dialogs.dart'; +import 'package:regroup/Utils/texts.dart'; +import 'package:regroup/resources/routes/route_name.dart'; +import 'package:async/src/future_group.dart'; +import 'package:regroup/sidemenu/view_model/postmethod.dart'; + +class TagdetailScreen extends StatefulWidget { + const TagdetailScreen({super.key}); + + @override + State createState() => _TagdetailScreenState(); +} + +class _TagdetailScreenState extends State { + int tagsid = Get.arguments['tagid']; + String tagsname = Get.arguments['tagname']; + bool istagpin = Get.arguments['ispinnedtag']; + + @override + void initState() { + // TODO: implement initState + + super.initState(); + } + + pinunpinTag(int tagid) async { + // utils.loader(); + Map updata = { + "manage_tags_xid": tagid, + }; + final data = await SidebarTags().postUserpin(updata); + if (data.status == ResponseStatus.SUCCESS) { + // Get.back(); + setState(() { + istagpin = !istagpin; // Toggle the pin state + }); + return utils.showToast(data.message); + } else { + // Get.back(); + return utils.showToast(data.message); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: const Color(0xFF222935), + extendBody: true, + resizeToAvoidBottomInset: false, + appBar: CommonAppbar( + titleTxt: tagsname, + customActionWidget: GestureDetector( + onTap: () async { + await pinunpinTag(tagsid); + }, + child: istagpin == true + ? Image.asset( + "assets/images/png/sidemenu/f7_pin-fill.png", + height: 26.h, + width: 26.w, + ) + : Image.asset( + "assets/images/png/sidemenu/f7_pin-fill (1).png", + height: 26.h, + width: 26.w, + ), + )), + body: Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), + ), + Column(children: [ + sizedBoxHeight(10.h), + DefaultTabController( + length: 2, + // initialIndex: selectedIndex.value, + child: Column( + children: [ + const CommonTabBar(tabs: [ + Tab( + text: 'Popular', + ), + Tab( + text: 'Latest', + ), + ]), + SizedBox( + height: 670.h, + child: TabBarView( + children: [ + cyclepopularTab(), + // cyclelatestTab(), + LatestTab(id: tagsid) + ], + ), + ), + ], + )) + ]) + ])); + } +} + +Widget cyclepopularTab() { + return SingleChildScrollView( + child: Column(children: [ + sizedBoxHeight(20.h), + normalcardtile( + profileImg: 'assets/images/png/Ellipse 52.png', + title: 'Ryan Dorwat', + mainImg: 'assets/images/png/img322.png', + containerTitle: [ + 'Football', + 'Teams player', + 'Events', + 'Marathon', + 'Events' + ]), + sizedBoxHeight(30.h), + normalcardtile( + profileImg: 'assets/images/png/Ellipse 43.png', + title: 'Edward Hackket', + mainImg: 'assets/images/png/Rectangle 24.png', + containerTitle: [ + 'Cycle', + 'Marathon', + 'Events', + 'Marathon', + 'Events' + ]), + ]), + ); +} + +Widget cyclelatestTab() { + return SingleChildScrollView( + child: Column(children: [ + sizedBoxHeight(20.h), + normalcardtile( + profileImg: 'assets/images/png/Ellipse 43.png', + title: 'Edward Hackket', + mainImg: 'assets/images/png/Rectangle 24.png', + containerTitle: [ + 'Cycle', + 'Marathon', + 'Events', + 'Marathon', + 'Events' + ]), + ]), + ); +} + +Widget normalcardtile({ + required String profileImg, + required String title, + required String mainImg, + required List containerTitle, +}) { + var mainImage = 'assets/images/png/uiw_like-o.png'.obs; + void updateImage(String reaction) { + if (reaction == 'like') { + mainImage.value = 'assets/images/png/f7_hand-thumbsup.png'; + } else if (reaction == 'heart') { + mainImage.value = 'assets/images/png/heart 2.png'; + } else if (reaction == 'party') { + mainImage.value = 'assets/images/png/party-popper 2.png'; + } + } + + return commonGlassUI( + width: double.infinity, + height: 570.h, + borderwidth: 0, + borderRadius: BorderRadius.circular(1), + customWidget: Column( + children: [ + sizedBoxHeight(25.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CircleAvatar( + foregroundImage: AssetImage(profileImg), + radius: 25.r, + ), + sizedBoxWidth(12.w), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + text16w400_FCFCFC(title), + sizedBoxHeight(5.h), + Row( + children: [ + Image.asset( + 'assets/images/png/community 1 (traced).png', + height: 14.w, + width: 14.w, + ), + sizedBoxWidth(7.w), + text12w400_FCFCFC('Active alliance network'), + sizedBoxWidth(7.w), + Icon( + Icons.circle, + color: const Color(0xFFFCFCFC), + size: 4.sp, + ), + sizedBoxWidth(6.w), + text12w400_FCFCFC('1 Hour ago'), + ], + ) + ], + ), + const Spacer(), + PopupMenuButton( + surfaceTintColor: const Color(0xFF222935), + constraints: BoxConstraints.tightFor(width: 176.w), + offset: const Offset(0, 50), + color: const Color(0xFF222935), + tooltip: "", + itemBuilder: (BuildContext context) => [ + PopupMenuItem( + onTap: () {}, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 12.w), + child: Row( + children: [ + Text( + 'Report Post', + style: TextStyle( + fontSize: 16.sp, + color: Colors.white, + fontWeight: FontWeight.w800, + fontFamily: "Nunito Sans", + ), + ), + const Spacer(), + Image.asset( + "assets/images/png/Vector (5).png", + height: 15.h, + width: 15.w, + ) + ], + ), + ), + ), + const PopupMenuDivider(), + PopupMenuItem( + onTap: () {}, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 12.w), + child: Row( + children: [ + Text( + 'Share post', + style: TextStyle( + fontSize: 16.sp, + color: Colors.white, + fontWeight: FontWeight.w800, + fontFamily: "Nunito Sans", + ), + ), + const Spacer(), + Image.asset( + "assets/images/png/share.png", + height: 20.h, + width: 20.w, + ) + ], + ), + ), + ), + const PopupMenuDivider(), + PopupMenuItem( + onTap: () {}, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 12.w), + child: Row( + children: [ + Text( + 'Pin', + style: TextStyle( + fontSize: 16.sp, + color: Colors.white, + fontWeight: FontWeight.w800, + fontFamily: "Nunito Sans", + ), + ), + const Spacer(), + Image.asset( + "assets/images/png/f7_pin-fill (2).png", + height: 25.h, + width: 25.w, + ) + ], + ), + ), + ), + ], + child: Image.asset( + 'assets/images/png/Group 1000004071.png', + width: 16.w, + height: 18.h, + ), + ), + sizedBoxWidth(5.w) + ], + ), + ), + sizedBoxHeight(20.h), + GestureDetector( + onTap: () { + Get.toNamed(RouteName.postdetailsScreen); + }, + child: SizedBox( + height: 360.h, + width: double.infinity, + child: Image.asset( + mainImg, + fit: BoxFit.cover, + ), + )), + sizedBoxHeight(20.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Column(children: [ + SizedBox( + height: 30.h, + child: ListView.builder( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + itemCount: containerTitle.length, + itemBuilder: (context, index) { + return Padding( + padding: EdgeInsets.only(right: 12.w), + child: GestureDetector( + onTap: () { + // Get.toNamed(RouteName.tagdetailscreen); + }, + child: containertile(text: containerTitle[index])), + ); + }, + ), + ), + sizedBoxHeight(20.h), + text16w400_FCFCFC( + "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s . . ."), + Row(children: [ + InkWell( + onTap: () { + Get.toNamed(RouteName.reactionview); + }, + child: stackReaction(number: '20', containerImages: [ + 'assets/images/png/f7_hand-thumbsup.png', + 'assets/images/png/heart 2.png', + 'assets/images/png/party-popper 2.png' + ]), + ), + const Spacer(), + commonGlassUI( + borderwidth: 0.43, + width: 30.w, + height: 30.h, + opacity1: 0.05, + opacity2: 0.06, + borderRadius: BorderRadius.circular(100), + customWidget: Center( + child: Image.asset( + 'assets/images/png/Frame 1000004088.png', + height: 13.h, + width: 13.w, + ), + ), + ), + sizedBoxWidth(12.w), + text14w400_FCFCFC('20'), + sizedBoxWidth(20.w), + commonGlassUI( + borderwidth: 0.43, + width: 30.w, + height: 30.h, + borderRadius: BorderRadius.circular(100), + opacity1: 0.05, + opacity2: 0.06, + customWidget: Center( + child: Image.asset( + 'assets/images/png/Vector (1).png', + height: 12.h, + width: 12.w, + ), + ), + ), + sizedBoxWidth(12.w), + text14w400_FCFCFC('10'), + ]), + sizedBoxHeight(12.h), + commonDivider(), + sizedBoxHeight(12.h), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Obx(() { + return ReactionButton( + onReactionChanged: (reaction) { + updateImage(reaction?.value ?? 'like'); + debugPrint('Selected value: ${reaction?.value}'); + }, + reactions: ?>[ + Reaction( + value: 'like', + previewIcon: _buildReactionsPreviewIcon( + 'assets/images/png/f7_hand-thumbsup.png'), + icon: _buildReactionsIcon( + 'assets/images/png/f7_hand-thumbsup.png'), + ), + Reaction( + value: 'heart', + previewIcon: _buildReactionsPreviewIcon( + 'assets/images/png/heart 2.png'), + icon: _buildReactionsIcon( + 'assets/images/png/heart 2.png'), + ), + Reaction( + value: 'party', + previewIcon: _buildReactionsPreviewIcon( + 'assets/images/png/party-popper 2.png'), + icon: _buildReactionsIcon( + 'assets/images/png/party-popper 2.png'), + ), + ], + selectedReaction: Reaction( + value: 'like', + icon: _buildReactionsIcon( + 'assets/images/png/f7_hand-thumbsup.png'), + ), + boxColor: Colors.white, + boxElevation: 9, + boxRadius: 30, + itemsSpacing: 8, + itemScale: 0.4, + itemSize: const Size(45, 45), + boxPadding: const EdgeInsets.all(8), + boxAnimationDuration: + const Duration(milliseconds: 200), + itemAnimationDuration: + const Duration(milliseconds: 500), + hoverDuration: const Duration(milliseconds: 700), + // toggle: false, + + child: _buildReactionsIcon(mainImage.value), + ); + }) + ], + ), + GestureDetector( + onTap: () { + Get.toNamed(RouteName.postdetailsScreen); + }, + child: Column( + children: [ + Image.asset( + 'assets/images/png/Frame 1000004088.png', + height: 19.h, + width: 19.w, + ), + sizedBoxHeight(8.h), + text11w400_FCFCFC('Comment') + ], + ), + ), + Column( + children: [ + Image.asset( + 'assets/images/png/Frame 1000004089.png', + height: 19.h, + width: 19.w, + ), + sizedBoxHeight(8.h), + text11w400_FCFCFC('Save') + ], + ) + ], + ), + sizedBoxHeight(12.h), + commonDivider(), + sizedBoxHeight(12.h), + ]), + ), + ], + )); +} + +Widget _buildReactionsPreviewIcon(String assetPath) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Image.asset( + assetPath, + height: 40.h, + width: 40.w, + ), + ); +} + +Widget _buildReactionsIcon(String assetPath) { + return Column( + children: [ + Image.asset( + assetPath, + height: 19.h, + width: 19.w, + ), + sizedBoxHeight(8.h), + text11w400_FCFCFC('Like') + ], + ); +} + +class LatestTab extends StatefulWidget { + LatestTab({super.key, required this.id}); + + int id; + + @override + State createState() => _LatestTabState(); +} + +class _LatestTabState extends State { + FutureGroup futureGroup = FutureGroup(); + + @override + void initState() { + futureGroup.add(Communitygetmethod().getTagsdata(widget.id).then((value) { + _initializeData(); + })); + futureGroup.close(); + super.initState(); + } + + List _reactions = []; + Map _selectedReactions = {}; + + Future _initializeData() async { + await _fetchIcons(); + // _initializeSelectedReaction(); + for (var post in tagdetailobj!.data) { + if (post.likeIcon != null) { + likeIconIdnew = post.likeIcon!.likeIconsXid; // This is safe now + print('like selectedid is ${likeIconIdnew.toString()}'); + } else { + likeIconIdnew = 0; // Or handle it as needed + print('like id is ${likeIconIdnew.toString()}'); + } + _initializeSelectedReaction(post.id!); // Pass the post ID + } + } + + Future _fetchIcons() async { + var response = await Communityallgetmethod().getLikeicons(); + if (response.status == ResponseStatus.SUCCESS) { + var responseData = response.data as Map; + FetchlikeIconsModel fetchlikeIconsModel = + FetchlikeIconsModel.fromJson(responseData); + + setState(() { + _reactions = fetchlikeIconsModel.data + ?.map((data) => ReactionData( + id: data.id!, + image: data.image!, + )) + .toList() ?? + []; + for (var post in tagdetailobj!.data) { + _initializeSelectedReaction(post.id!); + } + }); + } + } + + int? likeIconIdnew; + + void _initializeSelectedReaction(int postId) { + // Check if there's a stored likeIconId for this post + if (likeIconIdnew != null && likeIconIdnew != 0 && _reactions.isNotEmpty) { + final selectedReaction = _reactions.firstWhere( + (r) => r.id == likeIconIdnew, + orElse: () => _reactions.first, + ); + + setState(() { + _selectedReactions[postId] = + selectedReaction; // Set selected reaction for this post + print( + 'Selected reaction for post $postId is ${_selectedReactions[postId].toString()}'); + log(_selectedReactions[postId].toString()); + }); + } else { + setState(() { + _selectedReactions[postId] = null; // No reaction selected + print('No reaction selected for post $postId'); + }); + } + } + + Future _handleReactionChange(ReactionData? reaction, int postId) async { + // Check if the postId is valid + if (postId == null) return; + + setState(() { + if (reaction == null) { + _selectedReactions[postId] = + null; // Mark reaction as removed for this post + } else { + _selectedReactions[postId] = + reaction; // Set the selected reaction for this post + } + }); + + try { + await LikeUploaddata( + reaction?.id, + postId, + ); + } catch (error) { + print('Error updating reaction: $error'); + setState(() { + _selectedReactions[postId] = + reaction; // Restore previous reaction if needed + }); + } + } + + LikeUploaddata(int? likeIconId, int? postid) async { + // utils.loader(); + Map updata = { + "manage_posts_xid": postid, + "like_icons_xid": likeIconId ?? '', + }; + final data = await CommunitypostMethod().postLikepost(updata); + if (data.status == ResponseStatus.SUCCESS) { + // Get.back(); + print("like done"); + return utils.showToast(data.message); + } else { + // Get.back(); + print("like not done"); + return utils.showToast(data.message); + } + } + + saveunsavepost(int postid) async { + // utils.loader(); + Map updata = { + "manage_posts_xid": postid, + }; + final data = await Communitypostmethod().postUserSave(updata); + if (data.status == ResponseStatus.SUCCESS) { + Communitygetmethod().getTagsdata(widget.id).then((value) { + _initializeData(); + setState(() {}); + }); + + return utils.showToast(data.message); + } else { + // Get.back(); + return utils.showToast(data.message); + } + } + + pinunpinUser(int userid) async { + // utils.loader(); + Map updata = { + "pin_iam_principal_xid": userid, + }; + final data = await SidebarTags().postUserpin(updata); + if (data.status == ResponseStatus.SUCCESS) { + // Get.back(); + Communitygetmethod().getTagsdata(widget.id).then((value) { + _initializeData(); + setState(() {}); + }); + return utils.showToast(data.message); + } else { + // Get.back(); + return utils.showToast(data.message); + } + } + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: futureGroup.future, + builder: (ctx, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return + // ShimmerCommon(); + const Center( + child: CircularProgressIndicator( + color: Colors.blue, + ), + ); + } + + if (snapshot.hasError) { + return Center( + child: Text( + '${snapshot.error} occurred', + style: TextStyle(fontSize: 18.spMin), + ), + ); + } + + if (snapshot.connectionState == ConnectionState.done && + snapshot.hasData) { + print("Data fetched-->"); + return tagdetailobj!.data.isEmpty + ? _buildNoDataBody(context) + : Column( + children: [ + sizedBoxHeight(16.h), + Expanded( + child: ListView.builder( + shrinkWrap: true, + itemCount: tagdetailobj!.data.length, + itemBuilder: (context, index) { + var timeAgo = ConvertServerDateToUserDate() + .convertServerDateToReadableFormate( + tagdetailobj!.data[index].createdAt + .toString()); + var postId = tagdetailobj!.data[index].id; + var selectedReaction = _selectedReactions[postId]; + if (index == 1) { + return Column( + children: [ + commonGlassUIBlue( + width: double.infinity, + height: 780.h, + borderRadius: BorderRadius.circular(1), + customWidget: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + sizedBoxHeight(25.h), + Padding( + padding: + EdgeInsets.only(left: 16.w), + child: text16w700_FCFCFC( + "#Announcement"), + ), + sizedBoxHeight(25.h), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 16.w), + child: Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + CircleAvatar( + foregroundImage: NetworkImage( + tagdetailobj! + .data[index] + .iamPrincipal! + .profilePhoto ?? + ''), + radius: 25.r, + ), + sizedBoxWidth(12.w), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + text16w400_FCFCFC( + tagdetailobj! + .data[index] + .iamPrincipal! + .fullName ?? + ''), + sizedBoxHeight(5.h), + Row( + children: [ + Image.asset( + 'assets/images/png/community 1 (traced).png', + height: 14.w, + width: 14.w, + ), + sizedBoxWidth(7.w), + text12w400_FCFCFC( + tagdetailobj! + .data[index] + .community! + .communityName ?? + '', + ), + sizedBoxWidth(7.w), + Icon( + Icons.circle, + color: const Color( + 0xFFFCFCFC), + size: 4.sp, + ), + sizedBoxWidth(6.w), + text12w400_FCFCFC( + timeAgo), + ], + ) + ], + ), + const Spacer(), + PopupMenuButton( + surfaceTintColor: + const Color(0xFF222935), + constraints: + BoxConstraints.tightFor( + width: 176.w), + offset: const Offset(0, 50), + color: + const Color(0xFF222935), + tooltip: "", + itemBuilder: + (BuildContext context) => + [ + PopupMenuItem( + onTap: () {}, + child: Padding( + padding: EdgeInsets + .symmetric( + horizontal: + 12.w), + child: Row( + children: [ + Text( + 'Report Post', + style: TextStyle( + fontSize: 16.sp, + color: Colors + .white, + fontWeight: + FontWeight + .w800, + fontFamily: + "Nunito Sans", + ), + ), + const Spacer(), + Image.asset( + "assets/images/png/Vector (5).png", + height: 15.h, + width: 15.w, + ) + ], + ), + ), + ), + const PopupMenuDivider(), + PopupMenuItem( + onTap: () {}, + child: Padding( + padding: EdgeInsets + .symmetric( + horizontal: + 12.w), + child: Row( + children: [ + Text( + 'Share post', + style: TextStyle( + fontSize: 16.sp, + color: Colors + .white, + fontWeight: + FontWeight + .w800, + fontFamily: + "Nunito Sans", + ), + ), + const Spacer(), + Image.asset( + "assets/images/png/share.png", + height: 20.h, + width: 20.w, + ) + ], + ), + ), + ), + // const PopupMenuDivider(), + // PopupMenuItem( + // onTap: () async { + // int pinPospostid = + // tagdetailobj! + // .data[index] + // .id!; + // await pinunpinUser( + // pinPospostid); + // }, + // child: Padding( + // padding: EdgeInsets + // .symmetric( + // horizontal: + // 12.w), + // child: Row( + // children: [ + // Text( + // tagdetailobj! + // .data[ + // index] + // .iamPrincipal! + // .isUserPinned == + // true + // ? 'Unpin' + // : 'Pin', + // style: TextStyle( + // fontSize: 16.sp, + // color: Colors + // .white, + // fontWeight: + // FontWeight + // .w800, + // fontFamily: + // "Nunito Sans", + // ), + // ), + // const Spacer(), + // Image.asset( + // "assets/images/png/f7_pin-fill (2).png", + // height: 25.h, + // width: 25.w, + // ) + // ], + // ), + // ), + // ), + ], + child: Image.asset( + 'assets/images/png/Group 1000004071.png', + width: 16.w, + height: 18.h, + ), + ), + sizedBoxWidth(5.w) + ], + ), + ), + sizedBoxHeight(20.h), + GestureDetector( + onTap: () { + Get.toNamed( + RouteName.postdetailsScreen); + }, + child: Container( + height: 390.h, + decoration: BoxDecoration( + image: DecorationImage( + image: NetworkImage( + tagdetailobj! + .data[index] + .image ?? + ''))), + ), + ), + sizedBoxHeight(20.h), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 16.w), + child: Column(children: [ + // SizedBox( + // height: 30.h, + // child: ListView.builder( + // scrollDirection: Axis.horizontal, + // shrinkWrap: true, + // itemCount: tagdetailobj! + // .data[index].attachTags.length, + // itemBuilder: (context, tagIndex) { + // print( + // 'tags id are ${tagdetailobj!.data[index].attachTags[tagIndex].manageTag!.id}'); + // print( + // 'tags name are ${tagdetailobj!.data[index].attachTags[tagIndex].manageTag!.name}'); + // return Padding( + // padding: EdgeInsets.only( + // right: 12.w), + // child: GestureDetector( + // onTap: () { + // print('anonymous tag tapped'); + // Get.toNamed( + // RouteName.tagdetailscreen, + // arguments: { + // 'tagid': + // tagdetailobj! + // .data[index] + // .attachTags[ + // tagIndex] + // .manageTag!.id, + // 'tagname': + // tagdetailobj! + // .data[index] + // .attachTags[ + // tagIndex] + // .manageTag!.name, + // }); + // }, + // child: + // // containertile2( + // // text: (tagdetailobj! + // // .data[index] + // // .tagNames[index]) + // // ) + // commonContainer( + // width: 130.w, + // height: 30.h, + // borderRadius: + // BorderRadius + // .circular( + // 30.r), + // borderColor: + // const Color( + // 0xFFD90B2E), + // opacity1: 0.04, + // opacity2: 0.05, + // customWidget: + // Padding( + // padding: EdgeInsets + // .symmetric( + // horizontal: + // 10.w), + // child: Center( + // child: text14w400_FCFCFC(tagdetailobj! + // .data[ + // index] + // .attachTags[ + // tagIndex].manageTag! + // .name!)), + // )), + // ), + // ); + // }, + // ), + // ), + SizedBox( + height: 30.h, + width: double.infinity, + child: ListView.builder( + scrollDirection: + Axis.horizontal, + shrinkWrap: true, + // Filter the tags to include only those with a non-null and non-empty name + itemCount: tagdetailobj! + .data[index].attachTags + .where((tag) => + tag.manageTag?.name + ?.isNotEmpty ?? + false) + .length, + itemBuilder: + (context, tagIndex) { + // Filtered list of tags + var filteredTags = + tagdetailobj! + .data[index] + .attachTags + .where((tag) => + tag + .manageTag + ?.name + ?.isNotEmpty ?? + false) + .toList(); + + // Safely get the manageTag object + var manageTag = + filteredTags[tagIndex] + .manageTag; + + // Get the tag name, ensuring it's not null or empty + String tagName = + manageTag?.name ?? ''; + + return Padding( + padding: EdgeInsets.only( + right: 12.w, + left: 12.w), + child: GestureDetector( + onTap: () { + print( + 'anonymous tapped'); + Get.back(); + Get.toNamed( + RouteName + .tagdetailscreen, + arguments: { + 'tagid': tagdetailobj! + .data[index] + .attachTags[ + tagIndex] + .manageTag! + .id, + // filteredTags[ + // tagIndex] + // .manageTagXid, + 'tagname': + tagName, + }); + }, + child: Row( + mainAxisAlignment: + MainAxisAlignment + .start, + children: [ + commonContainer( + width: 130.w, + height: 30.h, + borderRadius: + BorderRadius + .circular( + 30.r), + borderColor: + const Color( + 0xFFD90B2E), + opacity1: 0.04, + opacity2: 0.05, + customWidget: + Padding( + padding: EdgeInsets + .symmetric( + horizontal: + 10.w), + child: Center( + child: text14w400_FCFCFC( + '#${tagName}'), + ), + ), + ), + ], + ), + ), + ); + }, + ), + ), + sizedBoxHeight(20.h), + SizedBox( + width: double.infinity, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + text16w400_FCFCFC( + tagdetailobj! + .data[index] + .caption ?? + ''), + ], + ), + ), + Row(children: [ + InkWell( + onTap: () {}, + child: stackReaction( + number: tagdetailobj! + .data[index].likecount + .toString(), + containerImages: [ + 'assets/images/png/f7_hand-thumbsup.png', + 'assets/images/png/heart 2.png', + 'assets/images/png/party-popper 2.png' + ]), + ), + const Spacer(), + commonContainer( + width: 30.w, + height: 30.h, + borderColor: + const Color(0xFF434A53), + borderwidth: 0.43, + opacity1: 0.2, + opacity2: 0.2, + boxShape: BoxShape.circle, + customWidget: Center( + child: Image.asset( + 'assets/images/png/Frame 1000004088.png', + height: 13.h, + width: 13.w, + ), + ), + ), + sizedBoxWidth(12.w), + text14w400_FCFCFC(tagdetailobj! + .data[index].totalComment + .toString()), + sizedBoxWidth(20.w), + commonContainer( + width: 30.w, + height: 30.h, + borderColor: + const Color(0xFF434A53), + borderwidth: 0.43, + opacity1: 0.2, + opacity2: 0.2, + boxShape: BoxShape.circle, + customWidget: Center( + child: Image.asset( + 'assets/images/png/Vector (1).png', + height: 12.h, + width: 12.w, + ), + ), + ), + sizedBoxWidth(12.w), + text14w400_FCFCFC(tagdetailobj! + .data[index].totalSave + .toString()), + ]), + sizedBoxHeight(12.h), + commonDivider(), + sizedBoxHeight(12.h), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + children: [ + Column( + mainAxisAlignment: + MainAxisAlignment + .center, + children: [ + Column( + children: [ + ReactionButton< + String>( + onReactionChanged: + (reaction) async { + if (selectedReaction != + null && + reaction?.value == + selectedReaction + .id + .toString()) { + // User tapped on the currently selected reaction, so remove it + await _handleReactionChange( + selectedReaction, + tagdetailobj! + .data[ + index] + .id!); + } else { + // User selected a new reaction + var newSelectedReaction = + _reactions + .firstWhere( + (r) => + r.id.toString() == + reaction + ?.value, + orElse: () => + _reactions + .first, // Default reaction if not found + ); + await _handleReactionChange( + newSelectedReaction, + tagdetailobj! + .data[ + index] + .id!); + } + debugPrint( + 'Selected value: ${reaction?.value}'); + }, + reactions: + _reactions + .map((reaction) => + Reaction< + String>( + value: reaction + .id + .toString(), + previewIcon: Image.network( + reaction.image, + width: 24, + height: 24, + fit: BoxFit.cover), + icon: Image.network( + reaction.image, + width: 24, + height: 24, + fit: BoxFit.cover), + )) + .toList(), + selectedReaction: + selectedReaction != + null + ? Reaction< + String>( + value: selectedReaction + .id + .toString(), + icon: Image + .network( + selectedReaction + .image, + width: + 24, + height: + 24, + fit: BoxFit + .cover, + ), + ) + : Reaction< + String>( + value: + '', + icon: Image + .asset( + 'assets/images/png/uiw_like-o.png', + width: + 24, + height: + 24, + fit: BoxFit + .cover, + ), + ), + boxColor: + Colors.white, + boxElevation: 9, + boxRadius: 30, + itemsSpacing: 8, + itemScale: 0.4, + itemSize: + const Size( + 30, 30), + boxPadding: + const EdgeInsets + .all(8), + boxAnimationDuration: + const Duration( + milliseconds: + 200), + itemAnimationDuration: + const Duration( + milliseconds: + 500), + hoverDuration: + const Duration( + milliseconds: + 700), + child: + selectedReaction != + null + ? Image + .network( + selectedReaction + .image, + width: + 24, + height: + 24, + fit: BoxFit + .cover, + ) + : Image + .asset( + 'assets/images/png/uiw_like-o.png', + width: + 24, + height: + 24, + fit: BoxFit + .cover, + ), + ), + sizedBoxHeight(2.h), + text11w400_FCFCFC( + 'Like'), + ], + ) + ], + ), + GestureDetector( + onTap: () {}, + child: Column( + children: [ + Image.asset( + 'assets/images/png/Frame 1000004088.png', + height: 19.h, + width: 19.w, + ), + sizedBoxHeight(8.h), + text11w400_FCFCFC( + 'Comment') + ], + ), + ), + Column( + children: [ + GestureDetector( + onTap: () async { + int postid = + tagdetailobj! + .data[index] + .id!; + await saveunsavepost( + postid); + }, + child: tagdetailobj! + .data[index] + .isISaved == + true + ? Image.asset( + 'assets/images/png/postSaved.png', + height: 19.h, + width: 19.w, + ) + : Image.asset( + 'assets/images/png/Frame 1000004089.png', + height: 19.h, + width: 19.w, + ), + ), + // Image.asset( + // 'assets/images/png/Frame 1000004089.png', + // height: 19.h, + // width: 19.w, + // ), + sizedBoxHeight(8.h), + text11w400_FCFCFC('Save') + ], + ) + ], + ), + sizedBoxHeight(12.h), + commonDivider(), + sizedBoxHeight(12.h), + ]), + ), + ], + )), + sizedBoxHeight(20.h), + ], + ); + } else { + return Column( + children: [ + commonGlassUI( + width: double.infinity, + height: 760.h, + mainOpacity: 1, + borderRadius: BorderRadius.circular(1), + customWidget: Column( + children: [ + sizedBoxHeight(25.h), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 16.w), + child: Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + CircleAvatar( + foregroundImage: NetworkImage( + tagdetailobj! + .data[index] + .iamPrincipal! + .profilePhoto ?? + ''), + radius: 25.r, + ), + sizedBoxWidth(12.w), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + text16w400_FCFCFC( + tagdetailobj! + .data[index] + .iamPrincipal! + .fullName ?? + ''), + sizedBoxHeight(5.h), + Row( + children: [ + Image.asset( + 'assets/images/png/community 1 (traced).png', + height: 14.w, + width: 14.w, + ), + sizedBoxWidth(7.w), + text12w400_FCFCFC( + tagdetailobj! + .data[index] + .community! + .communityName + .toString()), + sizedBoxWidth(7.w), + Icon( + Icons.circle, + color: const Color( + 0xFFFCFCFC), + size: 4.sp, + ), + sizedBoxWidth(6.w), + text12w400_FCFCFC( + timeAgo!), + ], + ) + ], + ), + const Spacer(), + PopupMenuButton( + surfaceTintColor: + const Color(0xFF222935), + constraints: + BoxConstraints.tightFor( + width: 176.w), + offset: const Offset(0, 50), + color: + const Color(0xFF222935), + tooltip: "", + itemBuilder: + (BuildContext context) => + [ + PopupMenuItem( + onTap: () {}, + child: Padding( + padding: EdgeInsets + .symmetric( + horizontal: + 12.w), + child: Row( + children: [ + Text( + 'Report Post', + style: TextStyle( + fontSize: 16.sp, + color: Colors + .white, + fontWeight: + FontWeight + .w800, + fontFamily: + "Nunito Sans", + ), + ), + const Spacer(), + Image.asset( + "assets/images/png/Vector (5).png", + height: 15.h, + width: 15.w, + ) + ], + ), + ), + ), + const PopupMenuDivider(), + PopupMenuItem( + onTap: () {}, + child: Padding( + padding: EdgeInsets + .symmetric( + horizontal: + 12.w), + child: Row( + children: [ + Text( + 'Share post', + style: TextStyle( + fontSize: 16.sp, + color: Colors + .white, + fontWeight: + FontWeight + .w800, + fontFamily: + "Nunito Sans", + ), + ), + const Spacer(), + Image.asset( + "assets/images/png/share.png", + height: 20.h, + width: 20.w, + ) + ], + ), + ), + ), + const PopupMenuDivider(), + PopupMenuItem( + onTap: () async { + int pinPospostid = + tagdetailobj! + .data[index] + .iamPrincipal! + .id!; + await pinunpinUser( + pinPospostid); + }, + child: Padding( + padding: EdgeInsets + .symmetric( + horizontal: + 12.w), + child: Row( + children: [ + Text( + tagdetailobj! + .data[ + index] + .iamPrincipal! + .isUserPinned == + true + ? 'Unpin' + : 'Pin', + style: TextStyle( + fontSize: 16.sp, + color: Colors + .white, + fontWeight: + FontWeight + .w800, + fontFamily: + "Nunito Sans", + ), + ), + const Spacer(), + Image.asset( + "assets/images/png/f7_pin-fill (2).png", + height: 25.h, + width: 25.w, + ) + ], + ), + ), + ), + ], + child: Image.asset( + 'assets/images/png/Group 1000004071.png', + width: 16.w, + height: 18.h, + ), + ), + sizedBoxWidth(5.w) + ], + ), + ), + sizedBoxHeight(20.h), + GestureDetector( + onTap: () { + Get.toNamed( + RouteName.postdetailsScreen); + }, + child: Container( + height: 360, + width: double.infinity, + decoration: BoxDecoration( + image: DecorationImage( + fit: BoxFit.cover, + image: NetworkImage( + tagdetailobj!.data[index] + .image ?? + '', + ), + ), + ), + ), + ), + sizedBoxHeight(20.h), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 16.w), + child: Column(children: [ + // SizedBox( + // height: 30.h, + // child: ListView.builder( + // scrollDirection: Axis.horizontal, + // shrinkWrap: true, + // itemCount: tagdetailobj! + // .data[index].attachTags.length, + // itemBuilder: (context, tagIndex) { + // print( + // 'tags id are ${tagdetailobj!.data[index].attachTags[tagIndex].manageTag!.id}'); + // print( + // 'tags name are ${tagdetailobj!.data[index].attachTags[tagIndex].manageTag!.name}'); + // return Padding( + // padding: EdgeInsets.only( + // right: 12.w), + // child: GestureDetector( + // onTap: () { + // print('tag tapped'); + // Get.toNamed( + // RouteName.tagdetailscreen, + // arguments: { + // 'tagid': + // tagdetailobj! + // .data[index] + // .attachTags[ + // tagIndex].manageTag! + // .id, + // 'tagname': + // tagdetailobj! + // .data[index] + // .attachTags[ + // tagIndex].manageTag! + // .name, + // }); + // }, + // child: + // // containertile2( + // // text: (tagdetailobj! + // // .data[index] + // // .tagNames[index]) + // // ) + // commonContainer( + // width: 130.w, + // height: 30.h, + // borderRadius: + // BorderRadius + // .circular( + // 30.r), + // borderColor: + // const Color( + // 0xFFD90B2E), + // opacity1: 0.04, + // opacity2: 0.05, + // customWidget: + // Padding( + // padding: EdgeInsets + // .symmetric( + // horizontal: + // 10.w), + // child: Center( + // child: text14w400_FCFCFC(tagdetailobj! + // .data[ + // index] + // .attachTags[ + // tagIndex].manageTag! + // .name!)), + // )), + // ), + // ); + // }, + // ), + // ), + SizedBox( + height: 30.h, + width: double.infinity, + child: ListView.builder( + scrollDirection: + Axis.horizontal, + shrinkWrap: true, + // Filter the tags to include only those with a non-null and non-empty name + itemCount: tagdetailobj! + .data[index].attachTags + .where((tag) => + tag.manageTag?.name + ?.isNotEmpty ?? + false) + .length, + itemBuilder: + (context, tagIndex) { + // Filtered list of tags + var filteredTags = + tagdetailobj! + .data[index] + .attachTags + .where((tag) => + tag + .manageTag + ?.name + ?.isNotEmpty ?? + false) + .toList(); + + // Safely get the manageTag object + var manageTag = + filteredTags[tagIndex] + .manageTag; + + // Get the tag name, ensuring it's not null or empty + String tagName = + manageTag?.name ?? ''; + + return Padding( + padding: EdgeInsets.only( + right: 12.w, + left: 12.w), + child: GestureDetector( + onTap: () { + print( + 'anonymous tapped'); + Get.back(); + Get.toNamed( + RouteName + .tagdetailscreen, + arguments: { + 'tagid': tagdetailobj! + .data[index] + .attachTags[ + tagIndex] + .manageTag! + .id, + + // filteredTags[ + // tagIndex] + // .manageTagXid, + 'tagname': + tagName, + 'ispinnedtag': + filteredTags[ + tagIndex] + .manageTag! + .isPinned + }); + }, + child: Row( + mainAxisAlignment: + MainAxisAlignment + .start, + children: [ + commonContainer( + width: 130.w, + height: 30.h, + borderRadius: + BorderRadius + .circular( + 30.r), + borderColor: + const Color( + 0xFFD90B2E), + opacity1: 0.04, + opacity2: 0.05, + customWidget: + Padding( + padding: EdgeInsets + .symmetric( + horizontal: + 10.w), + child: Center( + child: text14w400_FCFCFC( + '#${tagName}'), + ), + ), + ), + ], + ), + ), + ); + }, + ), + ), + sizedBoxHeight(20.h), + SizedBox( + width: double.infinity, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + text16w400_FCFCFC( + tagdetailobj! + .data[index] + .caption ?? + ''), + ], + ), + ), + Row(children: [ + InkWell( + onTap: () { + Get.toNamed( + RouteName.reactionview); + }, + child: stackReaction( + number: tagdetailobj! + .data[index].likecount + .toString(), + containerImages: [ + 'assets/images/png/f7_hand-thumbsup.png', + 'assets/images/png/heart 2.png', + 'assets/images/png/party-popper 2.png' + ]), + ), + const Spacer(), + commonContainer( + width: 30.w, + height: 30.h, + borderColor: + const Color(0xFF434A53), + borderwidth: 0.43, + opacity1: 0.2, + opacity2: 0.2, + boxShape: BoxShape.circle, + customWidget: Center( + child: Image.asset( + 'assets/images/png/Frame 1000004088.png', + height: 13.h, + width: 13.w, + ), + ), + ), + sizedBoxWidth(12.w), + text14w400_FCFCFC(tagdetailobj! + .data[index].totalComment + .toString()), + sizedBoxWidth(20.w), + commonContainer( + width: 30.w, + height: 30.h, + borderColor: + const Color(0xFF434A53), + borderwidth: 0.43, + opacity1: 0.2, + opacity2: 0.2, + boxShape: BoxShape.circle, + customWidget: Center( + child: Image.asset( + 'assets/images/png/Vector (1).png', + height: 12.h, + width: 12.w, + ), + ), + ), + sizedBoxWidth(12.w), + text14w400_FCFCFC(tagdetailobj! + .data[index].totalSave + .toString()), + ]), + sizedBoxHeight(12.h), + commonDivider(), + sizedBoxHeight(12.h), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + children: [ + Column( + mainAxisAlignment: + MainAxisAlignment + .center, + children: [ + Column( + children: [ + ReactionButton< + String>( + onReactionChanged: + (reaction) async { + if (selectedReaction != + null && + reaction?.value == + selectedReaction + .id + .toString()) { + // User tapped on the currently selected reaction, so remove it + await _handleReactionChange( + selectedReaction, + tagdetailobj! + .data[ + index] + .id!); + } else { + // User selected a new reaction + var newSelectedReaction = + _reactions + .firstWhere( + (r) => + r.id.toString() == + reaction + ?.value, + orElse: () => + _reactions + .first, // Default reaction if not found + ); + await _handleReactionChange( + newSelectedReaction, + tagdetailobj! + .data[ + index] + .id!); + } + debugPrint( + 'Selected value: ${reaction?.value}'); + }, + reactions: + _reactions + .map((reaction) => + Reaction< + String>( + value: reaction + .id + .toString(), + previewIcon: Image.network( + reaction.image, + width: 24, + height: 24, + fit: BoxFit.cover), + icon: Image.network( + reaction.image, + width: 24, + height: 24, + fit: BoxFit.cover), + )) + .toList(), + selectedReaction: + selectedReaction != + null + ? Reaction< + String>( + value: selectedReaction + .id + .toString(), + icon: Image + .network( + selectedReaction + .image, + width: + 24, + height: + 24, + fit: BoxFit + .cover, + ), + ) + : Reaction< + String>( + value: + '', + icon: Image + .asset( + 'assets/images/png/uiw_like-o.png', + width: + 24, + height: + 24, + fit: BoxFit + .cover, + ), + ), + boxColor: + Colors.white, + boxElevation: 9, + boxRadius: 30, + itemsSpacing: 8, + itemScale: 0.4, + itemSize: + const Size( + 30, 30), + boxPadding: + const EdgeInsets + .all(8), + boxAnimationDuration: + const Duration( + milliseconds: + 200), + itemAnimationDuration: + const Duration( + milliseconds: + 500), + hoverDuration: + const Duration( + milliseconds: + 700), + child: + selectedReaction != + null + ? Image + .network( + selectedReaction + .image, + width: + 24, + height: + 24, + fit: BoxFit + .cover, + ) + : Image + .asset( + 'assets/images/png/uiw_like-o.png', + width: + 24, + height: + 24, + fit: BoxFit + .cover, + ), + ), + sizedBoxHeight(2.h), + text11w400_FCFCFC( + 'Like'), + ], + ) + ], + ), + GestureDetector( + onTap: () { + Get.toNamed(RouteName + .postdetailsScreen); + }, + child: Column( + children: [ + Image.asset( + 'assets/images/png/Frame 1000004088.png', + height: 19.h, + width: 19.w, + ), + sizedBoxHeight(8.h), + text11w400_FCFCFC( + 'Comment') + ], + ), + ), + InkWell( + onTap: () {}, + child: Column( + children: [ + GestureDetector( + onTap: () async { + int postid = + tagdetailobj! + .data[index] + .id!; + await saveunsavepost( + postid); + }, + child: tagdetailobj! + .data[ + index] + .isISaved == + true + ? Image.asset( + 'assets/images/png/postSaved.png', + height: 19.h, + width: 19.w, + ) + : Image.asset( + 'assets/images/png/Frame 1000004089.png', + height: 19.h, + width: 19.w, + ), + ), + // Image.asset( + // 'assets/images/png/Frame 1000004089.png', + // height: 19.h, + // width: 19.w, + // ), + sizedBoxHeight(8.h), + text11w400_FCFCFC( + 'Save') + ], + ), + ), + ], + ), + sizedBoxHeight(12.h), + commonDivider(), + sizedBoxHeight(12.h), + ]), + ), + ], + )), + sizedBoxHeight(20.h) + ], + ); + } + }, + ), + ), + ], + ); + } + return Container(); + }); + } + + Widget _buildNoDataBody(context) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "No Data Found", + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.w600), + ) + ], + ), + ); + } +} diff --git a/lib/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart b/lib/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart new file mode 100644 index 0000000..030b9c7 --- /dev/null +++ b/lib/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart @@ -0,0 +1,22 @@ +import 'dart:developer'; + +import 'package:regroup/Common/api_urls.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Common/controller/data/network/network_api.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/Model/tagdetailModel.dart'; + +TagdetailsModel? tagdetailobj; + +class Communitygetmethod { + Future> getTagsdata(updata) async { + final response = await NetworkApiServices().getApi( + "${ApiUrls.getTagsdetails}?manage_tag_id=$updata", + ); + + if (response.status == ResponseStatus.SUCCESS) { + tagdetailobj = TagdetailsModel.fromJson(response.data); + log(tagdetailobj!.data.toString()); + } + return response; + } +} diff --git a/lib/Main_Screens/Community_HomePage/view_model/communitypostmethod.dart b/lib/Main_Screens/Community_HomePage/view_model/communitypostmethod.dart new file mode 100644 index 0000000..bce7b1f --- /dev/null +++ b/lib/Main_Screens/Community_HomePage/view_model/communitypostmethod.dart @@ -0,0 +1,18 @@ +import 'package:regroup/Common/api_urls.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Common/controller/data/network/network_api.dart'; + +class Communitypostmethod { + Communitypostmethod(); + + + Future> postUserSave(updata) async { + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.postusersave, + ); + return response; + } + + +} \ No newline at end of file diff --git a/lib/Main_Screens/ProfileTab/My Network/MyNetwork.dart b/lib/Main_Screens/ProfileTab/My Network/MyNetwork.dart index 95f96e0..19985ab 100644 --- a/lib/Main_Screens/ProfileTab/My Network/MyNetwork.dart +++ b/lib/Main_Screens/ProfileTab/My Network/MyNetwork.dart @@ -324,6 +324,7 @@ class _FollowersTabState extends State { // onTap: () {}, onTap: () async { setState(() { + removeid = followersobj! .data![index] .follower! diff --git a/lib/Main_Screens/ProfileTab/view_model/profileGetmethod.dart b/lib/Main_Screens/ProfileTab/view_model/profileGetmethod.dart index ca3898d..02c4e0e 100644 --- a/lib/Main_Screens/ProfileTab/view_model/profileGetmethod.dart +++ b/lib/Main_Screens/ProfileTab/view_model/profileGetmethod.dart @@ -121,7 +121,7 @@ class Profilegetmethod { if (response.status == ResponseStatus.SUCCESS) { certificateobj = CertificateuserModel.fromJson(response.data); log(certificateobj!.data.toString()); - } + } return response; } } diff --git a/lib/onboarding/Signup/View/Business/View/busSignupScreen.dart b/lib/onboarding/Signup/View/Business/View/busSignupScreen.dart index 6f8796d..449af88 100644 --- a/lib/onboarding/Signup/View/Business/View/busSignupScreen.dart +++ b/lib/onboarding/Signup/View/Business/View/busSignupScreen.dart @@ -190,8 +190,7 @@ class _BusSignUpScreenState extends State { Container( decoration: const BoxDecoration( image: DecorationImage( - image: - AssetImage("assets/images/png/Choice screen.png"), + image: AssetImage("assets/images/png/background.png"), fit: BoxFit.fill)), ), Column( diff --git a/lib/onboarding/Signup/View/Individual/step2Selectactivity.dart b/lib/onboarding/Signup/View/Individual/step2Selectactivity.dart index 89c76e2..2d54159 100644 --- a/lib/onboarding/Signup/View/Individual/step2Selectactivity.dart +++ b/lib/onboarding/Signup/View/Individual/step2Selectactivity.dart @@ -52,6 +52,7 @@ class _SelectIndividualActivityState extends State { // If the first selected container is unselected, reset the active state _firstSelectedIndex = null; _isFirstSelectionActive = false; + _selectedIndices.clear(); } } else { if (_firstSelectedIndex == null) { diff --git a/lib/resources/routes/route_name.dart b/lib/resources/routes/route_name.dart index cbabf6d..de8df67 100644 --- a/lib/resources/routes/route_name.dart +++ b/lib/resources/routes/route_name.dart @@ -29,7 +29,7 @@ class RouteName { static const String mainscreen = '/mainscreen'; static const String sidemenu = '/sidemenu'; static const String savedposts = '/savedposts'; - static const String cyclescreen = '/cyclescreen'; + static const String tagdetailscreen = '/tagdetailscreen'; static const String postscreen = '/postscreen'; static const String reactionview = '/reactionview'; static const String postdetailsScreen = '/postdetailsScreen'; diff --git a/lib/resources/routes/routes.dart b/lib/resources/routes/routes.dart index 5bb7164..e779448 100644 --- a/lib/resources/routes/routes.dart +++ b/lib/resources/routes/routes.dart @@ -12,7 +12,7 @@ import 'package:regroup/Main_Screens/Chats/View/newchatpage.dart'; import 'package:regroup/Main_Screens/Chats/View/newgroup.dart'; import 'package:regroup/Main_Screens/Chats/View/userchat.dart'; import 'package:regroup/Main_Screens/Community_HomePage/Community.dart'; -import 'package:regroup/Main_Screens/Community_HomePage/CycleScreen.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/TagsdDetailScreen.dart'; import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart'; import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/View/ReactionView.dart'; import 'package:regroup/Main_Screens/Community_HomePage/PostScreen.dart'; @@ -165,8 +165,8 @@ class AppRoutes { page: () => const SavedPosts(), ), GetPage( - name: RouteName.cyclescreen, - page: () => const CycleScreen(), + name: RouteName.tagdetailscreen, + page: () => const TagdetailScreen(), ), GetPage( name: RouteName.postscreen, diff --git a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart index ca481be..505b58e 100644 --- a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart +++ b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart @@ -581,7 +581,7 @@ class _CommunityDetailsState extends State { padding: EdgeInsets.only(right: 12.w), child: GestureDetector( onTap: () { - Get.toNamed(RouteName.cyclescreen); + Get.toNamed(RouteName.tagdetailscreen); }, child: containertile(text: containerTitle[index])), ); diff --git a/pubspec.yaml b/pubspec.yaml index 2e748e3..4571906 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: regroup description: A new Flutter project. # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +publish_to: "none" # Remove this line if you wish to publish to pub.dev # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=2.19.6 <3.0.0' + sdk: ">=2.19.6 <3.0.0" # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions @@ -31,7 +31,6 @@ dependencies: flutter: sdk: flutter - # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 @@ -48,7 +47,7 @@ dependencies: image_cropper: ^6.0.0 image_picker: ^1.0.8 lottie: ^3.1.2 - connectivity_plus: + connectivity_plus: animations: ^2.0.11 shimmer: ^3.0.0 device_info_plus: ^9.1.2 @@ -79,15 +78,12 @@ dependencies: comment_tree: ^0.3.0 flutter_keyboard_visibility: ^6.0.0 - - dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^2.0.0 - flutter_launcher_icons: ^0.13.1 flutter_launcher_icons: @@ -102,7 +98,6 @@ flutter_launcher_icons: # The following section is specific to Flutter packages. flutter: - # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class.