diff --git a/lib/Common/api_urls.dart b/lib/Common/api_urls.dart index 722bac2..33af1f9 100644 --- a/lib/Common/api_urls.dart +++ b/lib/Common/api_urls.dart @@ -143,6 +143,8 @@ class ApiUrls { static const getTagsdetails = "${baseUrl}fetch-post-by-tag"; static const postusersave = "${baseUrl}save-post"; + static const getpostdetail = "${baseUrl}fetch-single-post"; + static const getpopularTagsdetails = "${baseUrl}fetch-popular-post"; diff --git a/lib/Main_Screens/Community_HomePage/PostDetailScreen/Model/PostDetailModel.dart b/lib/Main_Screens/Community_HomePage/PostDetailScreen/Model/PostDetailModel.dart new file mode 100644 index 0000000..39979bc --- /dev/null +++ b/lib/Main_Screens/Community_HomePage/PostDetailScreen/Model/PostDetailModel.dart @@ -0,0 +1,245 @@ +class PostDetailModel { + PostDetailModel({ + 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 PostDetailModel.fromJson(Map json){ + return PostDetailModel( + status: json["status"], + statusCode: json["status_code"], + message: json["message"], + data: json["data"] == null ? null : Data.fromJson(json["data"]), + ); + } + +} + +class Data { + Data({ + 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, + required this.isIFollow, + }); + + 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; + final bool? isIFollow; + + factory Data.fromJson(Map json){ + return Data( + 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))), + isIFollow: json["is_i_follow"], + ); + } + +} + +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 4eb2e43..b9dc7ab 100644 --- a/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart +++ b/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:comment_tree/comment_tree.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; @@ -10,13 +12,19 @@ import 'package:get/get.dart'; import 'package:get/get_state_manager/get_state_manager.dart'; import 'package:regroup/Common/CommonGlassmorphism.dart'; import 'package:regroup/Common/CommonWidget.dart'; +import 'package:regroup/Common/ConvertServerDateToUserDate.dart'; import 'package:regroup/Common/base_manager.dart'; import 'package:regroup/Global.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/PostDetailScreen/ViewModel/CommentsHelper.dart'; import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/CommentsRepository.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/PostDetailApi.dart'; import 'package:regroup/Utils/Common/CommonAppbar.dart'; import 'package:regroup/Utils/Common/CustomTextformfield.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; +import 'package:regroup/Utils/dialogs.dart'; import 'package:regroup/Utils/texts.dart'; import 'package:regroup/resources/routes/route_name.dart'; import 'package:async/async.dart'; @@ -29,6 +37,116 @@ class PostDetailsScreen extends StatefulWidget { } class _PostDetailsScreenState extends State { + List _reactions = []; + Map _selectedReactions = {}; + bool isOnceForPost = true; + + Future _initializeData() async { + if (isOnceForPost) { + await _fetchIcons(); + // _initializeSelectedReaction(); + if (postDetailObj?.data?.likeIcon != null) { + likeIconIdnew = postDetailObj?.data?.likeIcon!.likeIconsXid; + } else { + likeIconIdnew = 0; // Or handle it as needed + } + _initializeSelectedReaction(postDetailObj!.data!.id!); // Pass the post ID + + isOnceForPost = false; + } + } + + 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() ?? + []; + _initializeSelectedReaction(postDetailObj!.data!.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); + } + } + List hideReplies = []; FutureGroup futureGroup = FutureGroup(); final FocusNode _focusNode = FocusNode(); @@ -37,7 +155,10 @@ class _PostDetailsScreenState extends State { @override void initState() { + var postId = Get.arguments['PopularPostId'] ?? ''; futureGroup.add(CommentsRepository().getAllComments()); + futureGroup.add(PostDetailApi().getPostDetail(postId)); + futureGroup.close(); super.initState(); } @@ -127,6 +248,8 @@ class _PostDetailsScreenState extends State { } } +//reacttionlikelogic + @override Widget build(BuildContext context) { return KeyboardVisibilityBuilder(builder: (context, isKeyboardVisible) { @@ -155,6 +278,7 @@ class _PostDetailsScreenState extends State { ); } else if (snapshot.connectionState == ConnectionState.done) { _setViewMoreList(); + _initializeData(); return _buildBody(isKeyboardVisible); } else { return const Center(child: Text('Something went wrong')); @@ -165,6 +289,12 @@ class _PostDetailsScreenState extends State { } _buildBody(isKeyboardVisible) { + var postDetailData = postDetailObj!.data!; + var postId = postDetailData.id; + var selectedReaction = _selectedReactions[postId]; + var timeAgo = ConvertServerDateToUserDate() + .convertServerDateToReadableFormate( + postDetailData.createdAt.toString()); return Stack(children: [ Container( decoration: const BoxDecoration( @@ -175,17 +305,99 @@ class _PostDetailsScreenState extends State { SingleChildScrollView( child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - postCards( - profileImg: 'assets/images/png/Ellipse 52.png', - title: 'Ryan Dorwat', - mainImg: 'assets/images/png/Rectangle 25.png', - containerTitle: [ - 'Football', - 'Marathon', - 'Events', - 'Marathon', - 'Events' - ]), + PostCardTile( + profileImg: postDetailData.iamPrincipal!.profilePhoto ?? '', + title: postDetailData.iamPrincipal!.fullName ?? "", + mainImg: postDetailData.image ?? "", + containerTitle: [] ?? [], + description: postDetailData.caption ?? 'test', + create_at: timeAgo ?? '1 hour', + total_comments: postDetailData.totalCommentCount.toString() ?? '20', + total_likes: postDetailData.totalReactionCount.toString(), + total_save: postDetailData.totalSave.toString() ?? '10', + community_name: postDetailData.community!.communityName ?? 'text', + postId: postDetailData.id.toString(), + mainImagetap: () { + // Get.toNamed(RouteName.postdetailsScreen, + // arguments: { + // "PopularPostId": + // popularData.id.toString() + // }); + }, + onSaveIconTap: () async { + // await saveunsavepost(popularData.id!); + }, + isISaved: postDetailData.isISaved, + onReactionChangedLike: (reaction) async { + if (selectedReaction != null && + reaction?.value == selectedReaction.id.toString()) { + // User tapped on the currently selected reaction, so remove it + await _handleReactionChange(selectedReaction, postDetailData.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, postDetailData.id!); + } + debugPrint('Selected value: ${reaction?.value}'); + }, + reactionsLike: _reactions + .map((reaction) => Reaction( + value: reaction.id.toString(), + previewIcon: Image.network(reaction.image, + width: 24, height: 24, fit: BoxFit.cover), + icon: Image.network(reaction.image, + width: 24, height: 24, fit: BoxFit.cover), + )) + .toList(), + selectedReactionLike: selectedReaction != null + ? Reaction( + value: selectedReaction.id.toString(), + icon: Image.network( + selectedReaction.image, + width: 24, + height: 24, + fit: BoxFit.cover, + ), + ) + : Reaction( + value: '', + icon: Image.asset( + 'assets/images/png/uiw_like-o.png', + width: 24, + height: 24, + fit: BoxFit.cover, + ), + ), + likePopupWidget: 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, + ), + ), + + // PostCardTile( + // profileImg: 'assets/images/png/Ellipse 52.png', + // title: 'Ryan Dorwat', + // mainImg: 'assets/images/png/Rectangle 25.png', + // containerTitle: [ + // 'Football', + // 'Marathon', + // 'Events', + // 'Marathon', + // 'Events' + // ]), sizedBoxHeight(35.h), // ListView.builder( @@ -656,24 +868,71 @@ class _PostDetailsScreenState extends State { ), ]); } +} - Widget postCards({ - 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'; - } +class PostCardTile extends StatefulWidget { + final String profileImg; + final String title; + final String mainImg; + final String description; + final List containerTitle; + final String community_name; + final String total_comments; + final String total_likes; + final String total_save; + final String? create_at; + final String? postId; + final void Function()? onSaveIconTap; + final bool? isISaved; + // final dynamic commonpostobj; + final void Function(Reaction?) onReactionChangedLike; + final List?> reactionsLike; + final Reaction? selectedReactionLike; + final Widget? likePopupWidget; + final void Function()? mainImagetap; + + const PostCardTile({ + Key? key, + required this.profileImg, + required this.title, + required this.mainImg, + required this.description, + required this.containerTitle, + required this.community_name, + required this.total_comments, + required this.total_likes, + required this.total_save, + // this.commonpostobj, + required this.onReactionChangedLike, + required this.reactionsLike, + required this.selectedReactionLike, + required this.likePopupWidget, + required this.mainImagetap, + this.create_at, + this.postId, + this.onSaveIconTap, + this.isISaved, + }) : super(key: key); + + @override + _PostCardTileState createState() => _PostCardTileState(); +} + +class _PostCardTileState extends State { + RxString 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'; } + } + @override + Widget build(BuildContext context) { return commonGlassUI( width: double.infinity, height: 800.h, @@ -688,7 +947,7 @@ class _PostDetailsScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ CircleAvatar( - foregroundImage: AssetImage(profileImg), + foregroundImage: NetworkImage(widget.profileImg), radius: 25.r, ), sizedBoxWidth(12.w), @@ -698,7 +957,7 @@ class _PostDetailsScreenState extends State { children: [ Row( children: [ - text16w400_FCFCFC(title), + text16w400_FCFCFC(widget.title), const Spacer(), commonGlassUI( width: 72.w, @@ -816,7 +1075,7 @@ class _PostDetailsScreenState extends State { width: 14.w, ), sizedBoxWidth(7.w), - text12w400_FCFCFC('Active alliance network'), + text12w400_FCFCFC(widget.community_name), sizedBoxWidth(7.w), Icon( Icons.circle, @@ -824,7 +1083,7 @@ class _PostDetailsScreenState extends State { size: 4.sp, ), sizedBoxWidth(6.w), - text12w400_FCFCFC('1 Hour ago'), + text12w400_FCFCFC(widget.create_at!), ], ) ], @@ -835,17 +1094,20 @@ class _PostDetailsScreenState extends State { ), sizedBoxHeight(20.h), GestureDetector( - onTap: () { - // Get.toNamed(RouteName.postdetailsScreen); - }, - child: SizedBox( - height: 390.h, - width: double.infinity, - child: Image.asset( - mainImg, + onTap: widget.mainImagetap, + child: Container( + height: 360, + width: double.infinity, + decoration: BoxDecoration( + image: DecorationImage( fit: BoxFit.cover, + image: NetworkImage( + widget.mainImg, + ), ), - )), + ), + ), + ), sizedBoxHeight(20.h), Padding( padding: EdgeInsets.symmetric(horizontal: 16.w), @@ -855,34 +1117,58 @@ class _PostDetailsScreenState extends State { child: ListView.builder( scrollDirection: Axis.horizontal, shrinkWrap: true, - itemCount: containerTitle.length, + itemCount: widget.containerTitle.length, itemBuilder: (context, index) { return Padding( padding: EdgeInsets.only(right: 12.w), child: GestureDetector( onTap: () { - Get.toNamed(RouteName.tagdetailscreen); + // Get.toNamed(RouteName.cyclescreen, ); + // arguments: { + // 'tagid': latestpostobj!.data[index].tagsData[index].id, + // 'tagname' : latestpostobj!.data[index].tagsData[index].name, + // } }, - child: containertile(text: containerTitle[index])), + child: containertile2( + text: ("#${widget.containerTitle[index]}"))), ); }, ), ), sizedBoxHeight(20.h), - text16w400_FCFCFC( - "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s . . ."), + SizedBox( + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + text16w400_FCFCFC(widget.description), + ], + ), + ), Row(children: [ - stackReaction(number: '20', containerImages: [ - 'assets/images/png/f7_hand-thumbsup.png', - 'assets/images/png/heart 2.png', - 'assets/images/png/party-popper 2.png' - ]), + InkWell( + onTap: () { + Get.toNamed(RouteName.reactionview, arguments: { + 'postId': widget.postId, + }); + }, + child: stackReaction( + number: widget.total_likes, + 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.9, + commonContainer( width: 30.w, height: 30.h, - borderRadius: BorderRadius.circular(100.r), + 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', @@ -892,13 +1178,16 @@ class _PostDetailsScreenState extends State { ), ), sizedBoxWidth(12.w), - text14w400_FCFCFC('20'), + text14w400_FCFCFC(widget.total_comments), sizedBoxWidth(20.w), - commonGlassUI( - borderwidth: 0.9, + commonContainer( width: 30.w, height: 30.h, - borderRadius: BorderRadius.circular(100.r), + 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', @@ -908,7 +1197,7 @@ class _PostDetailsScreenState extends State { ), ), sizedBoxWidth(12.w), - text14w400_FCFCFC('10'), + text14w400_FCFCFC(widget.total_save), ]), sizedBoxHeight(12.h), commonDivider(), @@ -919,70 +1208,132 @@ class _PostDetailsScreenState extends State { 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, + ReactionButton( + onReactionChanged: widget.onReactionChangedLike, + // (reaction) async { + // if (_selectedReactions[postId] != null && + // reaction?.value == + // _selectedReactions[postId]!.id.toString()) { + // // User tapped on the currently selected reaction, so remove it + // await _handleReactionChange( + // _selectedReactions[postId], postId as int); + // } 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, postId as int); + // } + // debugPrint('Selected value: ${reaction?.value}'); + // }, + reactions: widget.reactionsLike, - child: _buildReactionsIcon(mainImage.value), - ); - }) + // _reactions + // .map((reaction) => Reaction( + // value: reaction.id.toString(), + // previewIcon: Image.network(reaction.image, + // width: 24, + // height: 24, + // fit: BoxFit.cover), + // icon: Image.network(reaction.image, + // width: 24, + // height: 24, + // fit: BoxFit.cover), + // )) + // .toList(), + selectedReaction: widget.selectedReactionLike, + + // _selectedReactions[postId] != null + // ? Reaction( + // value: + // _selectedReactions[postId]!.id.toString(), + // icon: Image.network( + // _selectedReactions[postId]!.image, + // width: 24, + // height: 24, + // fit: BoxFit.cover, + // ), + // ) + // : Reaction( + // 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: widget.likePopupWidget, + + // _selectedReactions[postId] != null + // ? Image.network( + // _selectedReactions[postId]!.image, + // width: 24, + // height: 24, + // fit: BoxFit.cover, + // ) + // : Image.asset( + // 'assets/images/png/uiw_like-o.png', + // width: 24, + // height: 24, + // fit: BoxFit.cover, + // ), + ), + sizedBoxHeight(8.h), + text11w400_FCFCFC('Like'), ], ), + GestureDetector( + onTap: () { + 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, + GestureDetector( + onTap: widget.onSaveIconTap, + child: widget.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, + ), ), sizedBoxHeight(8.h), text11w400_FCFCFC('Save') ], - ) + ), ], ), sizedBoxHeight(12.h), @@ -994,13 +1345,14 @@ class _PostDetailsScreenState extends State { )); } - Widget containertile({required String text}) { - return commonGlassUI( - borderwidth: 0.9, - width: 100.w, + Widget containertile2({required String text}) { + return 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(text)), diff --git a/lib/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/PostDetailApi.dart b/lib/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/PostDetailApi.dart new file mode 100644 index 0000000..eee7997 --- /dev/null +++ b/lib/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/PostDetailApi.dart @@ -0,0 +1,23 @@ + + +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/PostDetailScreen/Model/PostDetailModel.dart'; + +PostDetailModel? postDetailObj; + + + +class PostDetailApi { + Future> getPostDetail(updata) async { + final response = await NetworkApiServices().getApi( + "${ApiUrls.getpostdetail}?manage_post_xid=$updata", + ); + + if (response.status == ResponseStatus.SUCCESS) { + postDetailObj = PostDetailModel.fromJson(response.data); + } + return response; + } +} \ No newline at end of file