diff --git a/lib/Common/api_urls.dart b/lib/Common/api_urls.dart index 7811efc..963350c 100644 --- a/lib/Common/api_urls.dart +++ b/lib/Common/api_urls.dart @@ -125,4 +125,11 @@ class ApiUrls { static const getuserpinlist = "${baseUrl}fetch-pinned-detail"; static const postusertag = "${baseUrl}pin-unpin"; + + static const getLikeicons= "${baseUrl}fetch-like-icons"; + + static const postLike = "${baseUrl}like-post"; + + + } 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 4e8ef80..e40310e 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,22 @@ 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/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'; class CommunityScreen extends StatefulWidget { const CommunityScreen({super.key}); @@ -1218,18 +1227,135 @@ 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); + } + } + @override Widget build(BuildContext context) { return FutureBuilder( - future: latestfuture, + future: futureGroup.future, builder: (ctx, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return @@ -1276,59 +1402,1054 @@ class _LatestTabState extends State { .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(), + 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, + child: ListView.builder( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + itemCount: latestpostobj! + .data[index].tagNames.length, + itemBuilder: (context, index) { + return Padding( + padding: EdgeInsets.only( + right: 12.w), + child: GestureDetector( + onTap: () { + // Get.toNamed(RouteName.cyclescreen); + }, + child: Row( + mainAxisAlignment: + MainAxisAlignment + .start, + children: [ + containertile2( + text: latestpostobj! + .data[index] + .tagNames[ + index]), + ], + )), + ); + }, + ), + ), + 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( + 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: [ + 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(), - RecationId: - latestpostobj!.data[index].id.toString(), - ), + // 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: () {}, + 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: 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].tagNames.length, + itemBuilder: (context, index) { + return Padding( + padding: EdgeInsets.only( + right: 12.w), + child: GestureDetector( + onTap: () { + Get.toNamed(RouteName + .cyclescreen); + }, + child: containertile2( + text: (latestpostobj! + .data[index] + .tagNames[ + index]))), + ); + }, + ), + ), + 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); + }, + 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( + 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: [ + 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) ], );