Merge pull request #129 from WDI-Ideas/PriyankaH
community posts api integration
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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"],
|
||||
|
||||
@@ -53,4 +53,29 @@ List<bool> pinButtonPopular = <bool>[];
|
||||
savePostCounterFeed.add(latestpostobj!.data[i].totalSave ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
//ComPosts
|
||||
RxList<int> likesCounterComPosts= <int>[].obs;
|
||||
RxList<int> commentsCounterComPosts = <int>[].obs;
|
||||
RxList<int> savePostCounterComPosts = <int>[].obs;
|
||||
RxList<bool> saveButtonComPosts = <bool>[].obs;
|
||||
RxList<bool> pinButtonComPosts = <bool>[].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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
200
lib/sidemenu/Community/MyCommunity/Model/ComPostModel.dart
Normal file
200
lib/sidemenu/Community/MyCommunity/Model/ComPostModel.dart
Normal file
@@ -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<Datum> data;
|
||||
|
||||
factory ComPostModel.fromJson(Map<String, dynamic> json){
|
||||
return ComPostModel(
|
||||
status: json["status"],
|
||||
statusCode: json["status_code"],
|
||||
message: json["message"],
|
||||
data: json["data"] == null ? [] : List<Datum>.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<int> tagsXid;
|
||||
final int? totalViewCount;
|
||||
final int? totalReactionCount;
|
||||
final int? totalCommentCount;
|
||||
final int? totalImpressionCount;
|
||||
final int? totalPopularScore;
|
||||
final int? totalHoursAgo;
|
||||
final UserDetail? userDetail;
|
||||
final List<AttachTag> attachTags;
|
||||
|
||||
factory Datum.fromJson(Map<String, dynamic> 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<int>.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<AttachTag>.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<String, dynamic> 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<String, dynamic> 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<String, dynamic> json){
|
||||
return UserDetail(
|
||||
id: json["id"],
|
||||
principalTypeXid: json["principal_type_xid"],
|
||||
userName: json["user_name"],
|
||||
profilePhoto: json["profile_photo"],
|
||||
isUserPinned: json["is_user_pinned"],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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<ResponseData<dynamic>> 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<dynamic>(
|
||||
response.data['message'], ResponseStatus.SUCCESS,
|
||||
data: response.data);
|
||||
} else {
|
||||
return ResponseData<dynamic>(
|
||||
response.data['message'], ResponseStatus.FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user