From 73188fa3daa1c044447bc0522910b5524de6b642 Mon Sep 17 00:00:00 2001 From: Dakshesh42 Date: Fri, 16 Aug 2024 11:53:03 +0530 Subject: [PATCH] community posts api integration --- lib/Common/api_urls.dart | 3 + .../Community/Model/CommonDatumObjModel.dart | 9 +- .../view_model/CountersHelper.dart | 26 + .../MyCommunity/Model/ComPostModel.dart | 200 ++++ .../MyCommunity/View/CommunityDetails.dart | 961 +++++++++++------- .../MyCommunity/view_model/ComDetails.dart | 23 +- 6 files changed, 848 insertions(+), 374 deletions(-) create mode 100644 lib/sidemenu/Community/MyCommunity/Model/ComPostModel.dart diff --git a/lib/Common/api_urls.dart b/lib/Common/api_urls.dart index 55ea4c5..abd9534 100644 --- a/lib/Common/api_urls.dart +++ b/lib/Common/api_urls.dart @@ -88,6 +88,9 @@ class ApiUrls { static const getcommunitydetail = "${baseUrl}fetch-community-all-details"; + static const getComPostdetail = "${baseUrl}fetch-community-all-posts"; + + static const getrequestedcommunity = "${baseUrl}fetch-joining-request-for-community"; diff --git a/lib/Main_Screens/Community/Model/CommonDatumObjModel.dart b/lib/Main_Screens/Community/Model/CommonDatumObjModel.dart index 98fb595..34a8164 100644 --- a/lib/Main_Screens/Community/Model/CommonDatumObjModel.dart +++ b/lib/Main_Screens/Community/Model/CommonDatumObjModel.dart @@ -49,8 +49,8 @@ class CommonDatumObjModelData { required this.totalImpressionCount, required this.totalPopularScore, required this.totalHoursAgo, - required this.iamPrincipal, - required this.community, + this.iamPrincipal, + this.community, required this.attachTags, }); @@ -101,8 +101,9 @@ class CommonDatumObjModelData { ctaTitle: json["cta_title"], ctaLink: json["cta_link"], createdAt: DateTime.tryParse(json["created_at"] ?? ""), - likeIcon: - json["likeIcon"] == null ? null : LikeIcon1.fromJson(json["likeIcon"]), + likeIcon: json["likeIcon"] == null + ? null + : LikeIcon1.fromJson(json["likeIcon"]), totalViewCount: json["totalViewCount"], totalReactionCount: json["totalReactionCount"], totalCommentCount: json["totalCommentCount"], diff --git a/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart b/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart index a142fcb..e255c82 100644 --- a/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart +++ b/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart @@ -12,6 +12,11 @@ class CountersHelper extends GetxController { RxList saveButtonPopular = [].obs; RxList pinButtonPopular = [].obs; + + + + + setListsPopular() { likesCounterPopular.clear(); commentsCounterPopular.clear(); @@ -53,7 +58,28 @@ class CountersHelper extends GetxController { } } +//ComPosts + RxList likesCounterComPosts= [].obs; + RxList commentsCounterComPosts = [].obs; + RxList savePostCounterComPosts = [].obs; + RxList saveButtonComPosts = [].obs; + RxList pinButtonComPosts = [].obs; + setListsComPosts() { + likesCounterComPosts.clear(); + commentsCounterComPosts.clear(); + savePostCounterComPosts.clear(); + saveButtonComPosts.clear(); + for (var i = 0; i < commonobjmodel!.data.length; i++) { + likesCounterComPosts.add(commonobjmodel?.data[i].likecount ?? 0); + commentsCounterComPosts + .add(commonobjmodel?.data[i].totalCommentCount ?? 0); + savePostCounterComPosts.add(commonobjmodel?.data[i].totalSave ?? 0); + saveButtonComPosts.add(commonobjmodel?.data[i].isISaved ?? false); + pinButtonComPosts + .add(commonobjmodel?.data[i].iamPrincipal?.isUserPinned ?? false); + } + } } diff --git a/lib/sidemenu/Community/MyCommunity/Model/ComPostModel.dart b/lib/sidemenu/Community/MyCommunity/Model/ComPostModel.dart new file mode 100644 index 0000000..4aa330a --- /dev/null +++ b/lib/sidemenu/Community/MyCommunity/Model/ComPostModel.dart @@ -0,0 +1,200 @@ +class ComPostModel { + ComPostModel({ + 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 ComPostModel.fromJson(Map json){ + return ComPostModel( + 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.iamPrincipalXid, + required this.postIn, + required this.caption, + required this.image, + required this.manageTagsXids, + required this.postAs, + required this.isUploadedByBussinessUser, + required this.ctaTitle, + required this.ctaLink, + required this.isActive, + required this.createdBy, + required this.modifiedBy, + required this.deletedAt, + required this.createdAt, + required this.updatedAt, + required this.likecount, + required this.isILiked, + required this.isIFollow, + required this.isISaved, + required this.likeIcon, + required this.totalComment, + required this.totalSave, + required this.tagsXid, + required this.totalViewCount, + required this.totalReactionCount, + required this.totalCommentCount, + required this.totalImpressionCount, + required this.totalPopularScore, + required this.totalHoursAgo, + required this.userDetail, + required this.attachTags, + }); + + final int? id; + final int? iamPrincipalXid; + final int? postIn; + final String? caption; + final String? image; + final String? manageTagsXids; + final String? postAs; + final int? isUploadedByBussinessUser; + final String? ctaTitle; + final String? ctaLink; + final int? isActive; + final dynamic createdBy; + final dynamic modifiedBy; + final dynamic deletedAt; + final DateTime? createdAt; + final DateTime? updatedAt; + final int? likecount; + final bool? isILiked; + final bool? isIFollow; + final bool? isISaved; + final dynamic likeIcon; + final int? totalComment; + final int? totalSave; + final List tagsXid; + final int? totalViewCount; + final int? totalReactionCount; + final int? totalCommentCount; + final int? totalImpressionCount; + final int? totalPopularScore; + final int? totalHoursAgo; + final UserDetail? userDetail; + final List attachTags; + + factory Datum.fromJson(Map json){ + return Datum( + id: json["id"], + iamPrincipalXid: json["iam_principal_xid"], + postIn: json["post_in"], + caption: json["caption"], + image: json["image"], + manageTagsXids: json["manage_tags_xids"], + postAs: json["post_as"], + isUploadedByBussinessUser: json["is_uploaded_by_bussiness_user"], + ctaTitle: json["cta_title"], + ctaLink: json["cta_link"], + isActive: json["is_active"], + createdBy: json["created_by"], + modifiedBy: json["modified_by"], + deletedAt: json["deleted_at"], + createdAt: DateTime.tryParse(json["created_at"] ?? ""), + updatedAt: DateTime.tryParse(json["updated_at"] ?? ""), + likecount: json["likecount"], + isILiked: json["is_i_liked"], + isIFollow: json["is_i_follow"], + isISaved: json["is_i_saved"], + likeIcon: json["likeIcon"], + totalComment: json["total_comment"], + totalSave: json["total_save"], + tagsXid: json["tags_xid"] == null ? [] : List.from(json["tags_xid"]!.map((x) => x)), + totalViewCount: json["totalViewCount"], + totalReactionCount: json["totalReactionCount"], + totalCommentCount: json["totalCommentCount"], + totalImpressionCount: json["totalImpressionCount"], + totalPopularScore: json["totalPopularScore"], + totalHoursAgo: json["totalHoursAgo"], + userDetail: json["user_detail"] == null ? null : UserDetail.fromJson(json["user_detail"]), + 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 UserDetail { + UserDetail({ + required this.id, + required this.principalTypeXid, + required this.userName, + required this.profilePhoto, + required this.isUserPinned, + }); + + final int? id; + final int? principalTypeXid; + final String? userName; + final String? profilePhoto; + final bool? isUserPinned; + + factory UserDetail.fromJson(Map json){ + return UserDetail( + id: json["id"], + principalTypeXid: json["principal_type_xid"], + userName: json["user_name"], + profilePhoto: json["profile_photo"], + isUserPinned: json["is_user_pinned"], + ); + } + +} diff --git a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart index 7dc7dc0..fb37019 100644 --- a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart +++ b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart @@ -7,6 +7,14 @@ 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/CommonDatumObjModel.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_HomePage/Community.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/PostDetailApi.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/view_model/CountersHelper.dart'; import 'package:regroup/Utils/Common/CommonAppbar.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; @@ -14,6 +22,8 @@ import 'package:regroup/Utils/texts.dart'; import 'package:regroup/resources/routes/route_name.dart'; import 'package:regroup/sidemenu/Community/MyCommunity/view_model/ComDetails.dart'; +var CommunityId; + class CommunityDetails extends StatefulWidget { const CommunityDetails({super.key}); @@ -23,7 +33,7 @@ class CommunityDetails extends StatefulWidget { class _CommunityDetailsState extends State { bool? additionalContent = false; - var CommunityId; + late Future myfuture; @override @@ -319,7 +329,8 @@ class _CommunityDetailsState extends State { text16w400_FCFCFC("About community"), sizedBoxHeight(16.h), text14w400_FCFCFCblur( - "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."), + comdetailobj!.data!.communityDescription ?? + ""), sizedBoxHeight(20.h), Row( children: [ @@ -340,7 +351,8 @@ class _CommunityDetailsState extends State { borderwidth: 0.5), sizedBoxWidth(12.w), text16400white( - "Elm street london, United Kingdom") + comdetailobj!.data!.communityLocation ?? + "") ], ), sizedBoxHeight(16.h), @@ -431,7 +443,8 @@ class _CommunityDetailsState extends State { width: 31.w, ), sizedBoxWidth(15.w), - text16w400white('10 groups'), + text16w400white( + '${comdetailobj!.data!.totalGroup} groups'), Spacer(), Icon( Icons.arrow_forward, @@ -470,7 +483,13 @@ class _CommunityDetailsState extends State { width: 31.w, ), sizedBoxWidth(15.w), - text16w400white('Announcements'), + Column( + children: [ + text16w400white('Announcements'), + text11w400_F91D42( + "${comdetailobj!.data!.totalAnnouncements.toString()} New Announcements Request") + ], + ), Spacer(), Container( height: 21.h, @@ -480,7 +499,10 @@ class _CommunityDetailsState extends State { borderRadius: BorderRadius.circular(30.r)), child: Center( - child: text12w400_FCFCFC("11")), + child: text12w400_FCFCFC( + comdetailobj! + .data!.totalAnnouncements + .toString())), ) ]), ], @@ -517,7 +539,7 @@ class _CommunityDetailsState extends State { height: 600.h, child: TabBarView( children: [ - poststab(), + PostsTab(), eventstab(), ], ), @@ -529,393 +551,596 @@ class _CommunityDetailsState extends State { ]); })); } +} - Widget poststab() { - return 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' - ]), - ], - ); +class PostsTab extends StatefulWidget { + const PostsTab({super.key}); + + @override + State createState() => _PostsTabState(); +} + +class _PostsTabState extends State { + late Future postDetailfuture; + List _reactions = []; + Map _selectedReactions = {}; + final CountersHelper countersHelper = Get.find(); + int? likeIconIdnew; + + @override + void initState() { + // TODO: implement initState + CommunityId = Get.arguments["CommunityID"]; + postDetailfuture = CommunityDetail().getComPostApi(CommunityId); + + super.initState(); } - Widget eventstab() { - return Column( - children: [], - ); - } + Future _fetchIcons() async { + var response = await Communityallgetmethod().getLikeicons(); + if (response.status == ResponseStatus.SUCCESS) { + var responseData = response.data as Map; + FetchlikeIconsModel fetchlikeIconsModel = + FetchlikeIconsModel.fromJson(responseData); - 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'; + _reactions = fetchlikeIconsModel.data ?? []; + for (var post in compostobj!.data) { + //Check if post as a like icon + if (post.likeIcon != null) { + likeIconIdnew = post.likeIcon!.likeIconsXid; + + final selectedReaction = _reactions.firstWhere( + (r) => r.id == likeIconIdnew, + orElse: () => _reactions.first, + ); + + _selectedReactions[post.id!] = + selectedReaction; // Set selected reaction for this post + } else { + _selectedReactions[post.id!] = null; // No reaction selected + print('No reaction selected for post $CommunityId'); + } } + setState(() {}); } + } - return 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, + bool _isDataInitialized = true; + + Future setValues() async { + if (_isDataInitialized) { + _setModel(); + countersHelper.setListsPopular(); + await _fetchIcons(); + + _isDataInitialized = false; + } + } + + _sortTags(index) { + var tags = commonobjmodel!.data[index].attachTags + .where((tag) => tag.manageTag?.name?.isNotEmpty ?? false) + .map((tag) => tag.manageTag!) + .toList(); + + return tags; + } + + _setModel() { + commonobjmodel = null; + commonobjmodel = CommonDatumObjModel( + status: compostobj!.status, + statusCode: compostobj!.statusCode, + message: compostobj!.message, + data: compostobj!.data + .map((e) => CommonDatumObjModelData( + id: e.id, + likecount: e.likecount, + isISaved: e.isISaved, + tagsXid: e.tagsXid, + isILiked: e.isILiked, + totalComment: e.totalComment, + totalSave: e.totalSave, + iamPrincipalXid: e.iamPrincipalXid, + postIn: e.postIn, + caption: e.caption, + image: e.image, + manageTagsXids: e.manageTagsXids, + postAs: e.postAs, + ctaTitle: e.ctaTitle, + ctaLink: e.ctaLink, + createdAt: e.createdAt, + likeIcon: LikeIcon1( + likeIcon: LikeIconClass1( + id: e.likeIcon?.likeIcon?.id, + image: e.likeIcon?.likeIcon?.image), + likeIconsXid: e.likeIcon?.likeIconsXid, + ), + totalViewCount: e.totalViewCount, + totalReactionCount: e.totalReactionCount, + totalCommentCount: e.totalCommentCount, + totalImpressionCount: e.totalImpressionCount, + totalPopularScore: e.totalPopularScore, + totalHoursAgo: e.totalHoursAgo, + // iamPrincipal: IamPrincipal( + // id: e.iamPrincipal!.id, + // isUserPinned: e.iamPrincipal!.isUserPinned, + // principalTypeXid: e.iamPrincipal!.principalTypeXid, + // userName: e.iamPrincipal!.userName, + // fullName: e.iamPrincipal!.fullName, + // profilePhoto: e.iamPrincipal!.profilePhoto), + // community: Community( + // id: e.community!.id, + // communityProfilePhoto: e.community!.communityProfilePhoto, + // communityName: e.community!.communityName), + attachTags: e.attachTags + .map((e) => AttachTag1( + managePostXid: e.managePostXid, + manageTagXid: e.manageTagXid, + manageTag: ManageTagPopular( + id: e.manageTag?.id, + isPinned: e.manageTag?.isPinned, + name: e.manageTag?.name))) + .toList())) + .toList()); + } + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: postDetailfuture, + builder: (ctx, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center( + child: CircularProgressIndicator( + color: Colors.blue, ), - 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: Color(0xFFFCFCFC), - size: 4.sp, - ), - sizedBoxWidth(6.w), - text12w400_FCFCFC('1 Hour ago'), - ], - ) - ], + ); + } + + if (snapshot.hasError) { + return Center( + child: Text( + '${snapshot.error} occurred', + style: TextStyle(fontSize: 18.spMin), ), - Spacer(), - PopupMenuButton( - surfaceTintColor: Color(0xFF222935), - constraints: BoxConstraints.tightFor(width: 176.w), - offset: Offset(0, 50), - color: 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", - ), - ), - Spacer(), - Image.asset( - "assets/images/png/Vector (5).png", - height: 15.h, - width: 15.w, - ) - ], - ), - ), - ), - 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", - ), - ), - Spacer(), - Image.asset( - "assets/images/png/share.png", - height: 20.h, - width: 20.w, - ) - ], - ), - ), - ), - 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", - ), - ), - 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, + ); + } + + if (snapshot.connectionState == ConnectionState.done && + snapshot.hasData) { + setValues(); + return Stack(clipBehavior: Clip.none, children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill), ), ), - sizedBoxWidth(5.w) - ], - ), - ), - sizedBoxHeight(20.h), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.postdetailsScreen); - }, - child: Container( - height: 163.h, - width: double.infinity, + compostobj!.data.isEmpty + ? Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Center( + child: Column( + children: [ + Text( + "No Posts Available", + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.w600), + ) + ], + ), + ), + ]) + : Column( + children: [ + sizedBoxHeight(20.h), + Expanded( + child: ListView.builder( + shrinkWrap: true, + itemCount: commonobjmodel!.data.length, + itemBuilder: (context, index) { + var timeAgo = ConvertServerDateToUserDate() + .convertServerDateToReadableFormate( + compostobj!.data[index].createdAt + .toString()); + + return Column( + children: [ + NormalCardTile( + tags: _sortTags(index), + create_at: timeAgo ?? '1 hour', + commonObj: commonobjmodel!.data[index], + forWhichTab: 'popular', + reactions: _reactions, + selectedReactions: _selectedReactions, + currentIndex: index, + ), + sizedBoxHeight(20.h) + ], + ); + }, + ), + ), + ], + ) + ]); + } + return Container(); + }); + } +} + +Widget eventstab() { + return Column( + children: [], + ); +} + +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 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: Color(0xFFFCFCFC), + size: 4.sp, + ), + sizedBoxWidth(6.w), + text12w400_FCFCFC('1 Hour ago'), + ], + ) + ], + ), + Spacer(), + PopupMenuButton( + surfaceTintColor: Color(0xFF222935), + constraints: BoxConstraints.tightFor(width: 176.w), + offset: Offset(0, 50), + color: 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", + ), + ), + Spacer(), + Image.asset( + "assets/images/png/Vector (5).png", + height: 15.h, + width: 15.w, + ) + ], + ), + ), + ), + 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", + ), + ), + Spacer(), + Image.asset( + "assets/images/png/share.png", + height: 20.h, + width: 20.w, + ) + ], + ), + ), + ), + 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", + ), + ), + Spacer(), + Image.asset( + "assets/images/png/f7_pin-fill (2).png", + height: 25.h, + width: 25.w, + ) + ], + ), + ), + ), + ], 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])), - ); - }, + 'assets/images/png/Group 1000004071.png', + width: 16.w, + height: 18.h, ), ), - sizedBoxHeight(20.h), - text16w400_FCFCFC( - "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s . . ."), - 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' - ]), - 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'), + sizedBoxWidth(5.w) + ], + ), + ), + sizedBoxHeight(20.h), + GestureDetector( + onTap: () { + Get.toNamed(RouteName.postdetailsScreen); + }, + child: Container( + height: 163.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: [ + stackReaction(number: '20', containerImages: [ + 'assets/images/png/f7_hand-thumbsup.png', + 'assets/images/png/heart 2.png', + 'assets/images/png/party-popper 2.png' ]), - sizedBoxHeight(30.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( + 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(30.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'), ), - boxColor: Colors.white, - boxElevation: 9, - boxRadius: 30, - itemsSpacing: 8, - itemScale: 0.4, - itemSize: Size(45, 45), - boxPadding: EdgeInsets.all(8), - boxAnimationDuration: Duration(milliseconds: 200), - itemAnimationDuration: Duration(milliseconds: 500), - hoverDuration: 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, + 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'), ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Comment') - ], - ), - ), - Column( + boxColor: Colors.white, + boxElevation: 9, + boxRadius: 30, + itemsSpacing: 8, + itemScale: 0.4, + itemSize: Size(45, 45), + boxPadding: EdgeInsets.all(8), + boxAnimationDuration: Duration(milliseconds: 200), + itemAnimationDuration: Duration(milliseconds: 500), + hoverDuration: Duration(milliseconds: 700), + // toggle: false, + + child: _buildReactionsIcon(mainImage.value), + ); + }) + ], + ), + GestureDetector( + onTap: () { + Get.toNamed(RouteName.postdetailsScreen); + }, + child: Column( children: [ Image.asset( - 'assets/images/png/Frame 1000004089.png', + 'assets/images/png/Frame 1000004088.png', height: 19.h, width: 19.w, ), sizedBoxHeight(8.h), - text11w400_FCFCFC('Save') + text11w400_FCFCFC('Comment') ], - ) - ], - ) - ]), - ), - ], - ); - } - - Widget _buildReactionsPreviewIcon(String assetPath) { - return Padding( - padding: const EdgeInsets.all(8.0), - child: Image.asset( - assetPath, - height: 40.h, - width: 40.w, + ), + ), + Column( + children: [ + Image.asset( + 'assets/images/png/Frame 1000004089.png', + height: 19.h, + width: 19.w, + ), + sizedBoxHeight(8.h), + text11w400_FCFCFC('Save') + ], + ) + ], + ) + ]), ), - ); - } - - Widget _buildReactionsIcon(String assetPath) { - return Column( - children: [ - Image.asset( - assetPath, - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Like') - ], - ); - } - - Widget containertile({required String text}) { - return commonGlassUI( - borderwidth: 1, - width: 100.w, - height: 30.h, - borderRadius: BorderRadius.circular(30.r), - borderColor: Color(0xFFD90B2E), - customWidget: Padding( - padding: EdgeInsets.symmetric(horizontal: 10.w), - child: Center(child: text14w400_FCFCFC(text)), - )); - } + ], + ); +} + +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') + ], + ); +} + +Widget containertile({required String text}) { + return commonGlassUI( + borderwidth: 1, + width: 100.w, + height: 30.h, + borderRadius: BorderRadius.circular(30.r), + borderColor: Color(0xFFD90B2E), + customWidget: Padding( + padding: EdgeInsets.symmetric(horizontal: 10.w), + child: Center(child: text14w400_FCFCFC(text)), + )); } diff --git a/lib/sidemenu/Community/MyCommunity/view_model/ComDetails.dart b/lib/sidemenu/Community/MyCommunity/view_model/ComDetails.dart index fdd3f0a..03ea356 100644 --- a/lib/sidemenu/Community/MyCommunity/view_model/ComDetails.dart +++ b/lib/sidemenu/Community/MyCommunity/view_model/ComDetails.dart @@ -2,10 +2,10 @@ 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/sidemenu/Community/MyCommunity/Model/ComDetailModel.dart'; +import 'package:regroup/sidemenu/Community/MyCommunity/Model/ComPostModel.dart'; ComDetailModel? comdetailobj; - - +ComPostModel? compostobj; class CommunityDetail { @@ -22,4 +22,23 @@ class CommunityDetail { } return response; } + + Future> getComPostApi(updata) async { + final response = await NetworkApiServices().getApi( + + "${ApiUrls.getComPostdetail}?manage_community_xid=$updata" + ); + + if (response.status == ResponseStatus.SUCCESS) { + if (response.data["status"] == "success") { + compostobj = ComPostModel.fromJson(response.data); + } + return ResponseData( + response.data['message'], ResponseStatus.SUCCESS, + data: response.data); + } else { + return ResponseData( + response.data['message'], ResponseStatus.FAILED); + } + } } \ No newline at end of file