Merge pull request #114 from WDI-Ideas/PriyankaH
postdetail pin api done
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:comment_tree/comment_tree.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -16,11 +15,15 @@ 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/LatestPost.dart';
|
||||
import 'package:regroup/Main_Screens/Community/ViewModel/PopularPost.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/Model/PostDetailModel.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/Main_Screens/Community_HomePage/view_model/communitypostmethod.dart';
|
||||
import 'package:regroup/Utils/Common/CommonAppbar.dart';
|
||||
import 'package:regroup/Utils/Common/CustomTextformfield.dart';
|
||||
import 'package:regroup/Utils/Common/sized_box.dart';
|
||||
@@ -28,6 +31,7 @@ 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';
|
||||
import 'package:regroup/sidemenu/view_model/postmethod.dart';
|
||||
|
||||
class PostDetailsScreen extends StatefulWidget {
|
||||
const PostDetailsScreen({super.key});
|
||||
@@ -147,6 +151,48 @@ class _PostDetailsScreenState extends State<PostDetailsScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
//savePost
|
||||
|
||||
saveunsavepost(int postid) async {
|
||||
// utils.loader();
|
||||
Map<String, dynamic> updata = {
|
||||
"manage_posts_xid": postid,
|
||||
};
|
||||
final data = await Communitypostmethod().postUserSave(updata);
|
||||
if (data.status == ResponseStatus.SUCCESS) {
|
||||
PopularpostApi().getPopularPostApi().then((value) {
|
||||
_initializeData();
|
||||
setState(() {});
|
||||
});
|
||||
|
||||
return utils.showToast(data.message);
|
||||
} else {
|
||||
// Get.back();
|
||||
return utils.showToast(data.message);
|
||||
}
|
||||
}
|
||||
|
||||
//PinUser
|
||||
|
||||
pinunpinUser(int userid) async {
|
||||
// utils.loader();
|
||||
Map<String, dynamic> 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);
|
||||
}
|
||||
}
|
||||
|
||||
List<bool> hideReplies = [];
|
||||
FutureGroup futureGroup = FutureGroup();
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
@@ -295,6 +341,10 @@ class _PostDetailsScreenState extends State<PostDetailsScreen> {
|
||||
var timeAgo = ConvertServerDateToUserDate()
|
||||
.convertServerDateToReadableFormate(
|
||||
postDetailData.createdAt.toString());
|
||||
var tags = postDetailData.attachTags
|
||||
.where((tag) => tag.manageTag?.name?.isNotEmpty ?? false)
|
||||
.map((tag) => tag.manageTag!)
|
||||
.toList();
|
||||
return Stack(children: [
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
@@ -309,7 +359,7 @@ class _PostDetailsScreenState extends State<PostDetailsScreen> {
|
||||
profileImg: postDetailData.iamPrincipal!.profilePhoto ?? '',
|
||||
title: postDetailData.iamPrincipal!.fullName ?? "",
|
||||
mainImg: postDetailData.image ?? "",
|
||||
containerTitle: [] ?? [],
|
||||
tags: tags,
|
||||
description: postDetailData.caption ?? 'test',
|
||||
create_at: timeAgo ?? '1 hour',
|
||||
total_comments: postDetailData.totalCommentCount.toString() ?? '20',
|
||||
@@ -325,9 +375,14 @@ class _PostDetailsScreenState extends State<PostDetailsScreen> {
|
||||
// });
|
||||
},
|
||||
onSaveIconTap: () async {
|
||||
// await saveunsavepost(popularData.id!);
|
||||
await saveunsavepost(postDetailData.id!);
|
||||
},
|
||||
isISaved: postDetailData.isISaved,
|
||||
PinPopupTap: () async {
|
||||
int pinPospostid = postDetailData.iamPrincipal!.id!;
|
||||
await pinunpinUser(pinPospostid);
|
||||
},
|
||||
isUserPinned: postDetailData.iamPrincipal!.isUserPinned,
|
||||
onReactionChangedLike: (reaction) async {
|
||||
if (selectedReaction != null &&
|
||||
reaction?.value == selectedReaction.id.toString()) {
|
||||
@@ -875,7 +930,7 @@ class PostCardTile extends StatefulWidget {
|
||||
final String title;
|
||||
final String mainImg;
|
||||
final String description;
|
||||
final List<String> containerTitle;
|
||||
final List<ManageTag> tags;
|
||||
final String community_name;
|
||||
final String total_comments;
|
||||
final String total_likes;
|
||||
@@ -883,7 +938,10 @@ class PostCardTile extends StatefulWidget {
|
||||
final String? create_at;
|
||||
final String? postId;
|
||||
final void Function()? onSaveIconTap;
|
||||
final void Function()? PinPopupTap;
|
||||
final bool? isISaved;
|
||||
final bool? isUserPinned;
|
||||
|
||||
// final dynamic commonpostobj;
|
||||
final void Function(Reaction<String>?) onReactionChangedLike;
|
||||
final List<Reaction<String>?> reactionsLike;
|
||||
@@ -891,28 +949,31 @@ class PostCardTile extends StatefulWidget {
|
||||
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);
|
||||
const PostCardTile(
|
||||
{Key? key,
|
||||
required this.profileImg,
|
||||
required this.title,
|
||||
required this.mainImg,
|
||||
required this.description,
|
||||
// required this.containerTitle,
|
||||
required this.tags,
|
||||
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.PinPopupTap,
|
||||
this.isISaved,
|
||||
this.isUserPinned})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_PostCardTileState createState() => _PostCardTileState();
|
||||
@@ -1032,14 +1093,16 @@ class _PostCardTileState extends State<PostCardTile> {
|
||||
),
|
||||
const PopupMenuDivider(),
|
||||
PopupMenuItem(
|
||||
onTap: () {},
|
||||
onTap: widget.PinPopupTap,
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsets.symmetric(horizontal: 12.w),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'Pin',
|
||||
widget.isUserPinned == true
|
||||
? 'Unpin'
|
||||
: 'Pin',
|
||||
style: TextStyle(
|
||||
fontSize: 16.sp,
|
||||
color: Colors.white,
|
||||
@@ -1117,20 +1180,28 @@ class _PostCardTileState extends State<PostCardTile> {
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
itemCount: widget.containerTitle.length,
|
||||
itemCount: widget.tags.length,
|
||||
itemBuilder: (context, index) {
|
||||
var manageTag = widget.tags[index];
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(right: 12.w),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
// Get.toNamed(RouteName.cyclescreen, );
|
||||
// arguments: {
|
||||
// 'tagid': latestpostobj!.data[index].tagsData[index].id,
|
||||
// 'tagname' : latestpostobj!.data[index].tagsData[index].name,
|
||||
// }
|
||||
Get.toNamed(RouteName.tagdetailscreen,
|
||||
arguments: {
|
||||
'tagid': manageTag.id,
|
||||
'tagname': manageTag.name,
|
||||
'ispinnedtag': manageTag.isPinned,
|
||||
});
|
||||
|
||||
// var tags = popularData.attachTags
|
||||
// .where((tag) =>
|
||||
// tag.manageTag?.name?.isNotEmpty ?? false)
|
||||
// .map((tag) => tag.manageTag!)
|
||||
// .toList();
|
||||
},
|
||||
child: containertile2(
|
||||
text: ("#${widget.containerTitle[index]}"))),
|
||||
child:
|
||||
containertile2(text: ('#${manageTag.name}'))),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -1298,22 +1369,6 @@ class _PostCardTileState extends State<PostCardTile> {
|
||||
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: [
|
||||
GestureDetector(
|
||||
|
||||
Reference in New Issue
Block a user