intigrated fetch-like-post api

This commit is contained in:
jayesh
2024-08-06 10:31:43 +05:30
parent 63bcd725e8
commit 9d436c2a74
5 changed files with 597 additions and 308 deletions

View File

@@ -120,12 +120,9 @@ class ApiUrls {
static const postnewtags = "${baseUrl}store-tags";
static const postupload = "${baseUrl}store-post";
static const postlike = "${baseUrl}fetch-like-list";
static const getuserpinlist = "${baseUrl}fetch-pinned-detail";
static const postusertag = "${baseUrl}pin-unpin";
}

View File

@@ -3,7 +3,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_reaction_button/flutter_reaction_button.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:regroup/Common/CommonBottomNavigationBar.dart';
import 'package:regroup/Common/CommonGlassmorphism.dart';
@@ -86,8 +85,7 @@ class _CommunityScreenState extends State<CommunityScreen> {
sizedBoxWidth(16.w),
],
),
body:
Stack(clipBehavior: Clip.none, children: [
body: Stack(clipBehavior: Clip.none, children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
@@ -134,10 +132,10 @@ class _CommunityScreenState extends State<CommunityScreen> {
floatingActionButton: Container(
height: 40.h,
width: 164.w,
decoration: BoxDecoration(
decoration: BoxDecoration(
// shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(30.r),
boxShadow: [
boxShadow: const [
BoxShadow(
color: Color(0x40000000),
offset: Offset(0, 6),
@@ -152,9 +150,9 @@ class _CommunityScreenState extends State<CommunityScreen> {
backgroundColor: const Color(0xFFD90B2E),
autofocus: true,
// shape: const OvalBorder(),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.r),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.r),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
@@ -301,6 +299,7 @@ class _FeedTabState extends State<FeedTab> {
.community!
.communityName
.toString(),
RecationId: combinedList[index].id.toString(),
),
sizedBoxHeight(20.h)
],
@@ -331,6 +330,7 @@ Widget normalcardtile2({
required String total_likes,
required String total_save,
required String? create_at,
required String? RecationId,
}) {
var mainImage = 'assets/images/png/uiw_like-o.png'.obs;
void updateImage(String reaction) {
@@ -537,7 +537,9 @@ Widget normalcardtile2({
Row(children: [
InkWell(
onTap: () {
Get.toNamed(RouteName.reactionview);
Get.toNamed(RouteName.reactionview, arguments: {
'reactionId': RecationId,
});
},
child: stackReaction(number: total_likes, containerImages: [
'assets/images/png/f7_hand-thumbsup.png',
@@ -1187,17 +1189,17 @@ Widget popularTab() {
return Column(
children: [
normalcardtile2(
profileImg: popularTabData[index]["profileImg"],
title: popularTabData[index]["title"],
mainImg: popularTabData[index]["mainImg"],
containerTitle: popularTabData[index]["containerTitle"],
description: 'test',
create_at: '1 hour',
total_comments: '20',
total_likes: '20',
total_save: '10',
community_name: 'text',
),
profileImg: popularTabData[index]["profileImg"],
title: popularTabData[index]["title"],
mainImg: popularTabData[index]["mainImg"],
containerTitle: popularTabData[index]["containerTitle"],
description: 'test',
create_at: '1 hour',
total_comments: '20',
total_likes: '20',
total_save: '10',
community_name: 'text',
RecationId: ''),
sizedBoxHeight(20.h)
],
);
@@ -1324,6 +1326,8 @@ class _LatestTabState extends State<LatestTab> {
community_name: latestpostobj!
.data[index].community!.communityName
.toString(),
RecationId:
latestpostobj!.data[index].id.toString(),
),
sizedBoxHeight(20.h)
],

View File

@@ -0,0 +1,97 @@
class LikepostModel {
LikepostModel({
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 LikepostModel.fromJson(Map<String, dynamic> json) {
return LikepostModel(
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.managePostsXid,
required this.iamPrincipalXid,
required this.likeIconsXid,
required this.iamPrincipal,
required this.likeIcon,
});
final int? id;
final int? managePostsXid;
final int? iamPrincipalXid;
final int? likeIconsXid;
final IamPrincipal? iamPrincipal;
final LikeIcon? likeIcon;
factory Datum.fromJson(Map<String, dynamic> json) {
return Datum(
id: json["id"],
managePostsXid: json["manage_posts_xid"],
iamPrincipalXid: json["iam_principal_xid"],
likeIconsXid: json["like_icons_xid"],
iamPrincipal: json["iam_principal"] == null
? null
: IamPrincipal.fromJson(json["iam_principal"]),
likeIcon: json["like_icon"] == null
? null
: LikeIcon.fromJson(json["like_icon"]),
);
}
}
class IamPrincipal {
IamPrincipal({
required this.id,
required this.userName,
required this.fullName,
required this.profilePhoto,
});
final int? id;
final String? userName;
final String? fullName;
final String? profilePhoto;
factory IamPrincipal.fromJson(Map<String, dynamic> json) {
return IamPrincipal(
id: json["id"],
userName: json["user_name"],
fullName: json["full_name"],
profilePhoto: json["profile_photo"],
);
}
}
class LikeIcon {
LikeIcon({
required this.id,
required this.image,
});
final int? id;
final String? image;
factory LikeIcon.fromJson(Map<String, dynamic> json) {
return LikeIcon(
id: json["id"],
image: json["image"],
);
}
}

View File

@@ -1,12 +1,16 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
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/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/LikePost.dart';
import 'package:regroup/Utils/Common/CommonAppbar.dart';
import 'package:regroup/Utils/Common/sized_box.dart';
import 'package:regroup/Utils/texts.dart';
var recationid = Get.arguments['reactionId'];
class ReactionView extends StatefulWidget {
const ReactionView({super.key});
@@ -15,301 +19,461 @@ class ReactionView extends StatefulWidget {
}
class _ReactionViewState extends State<ReactionView> {
List allTabData = [
{
"imagePath": "assets/images/png/cimg1.png",
"reactionimg": "assets/images/png/f7_hand-thumbsup.png",
"title": "Edward Hackket"
},
{
"imagePath": "assets/images/png/cimg2.png",
"reactionimg": "assets/images/png/heart 2.png",
"title": "Dulce Vaccaro"
},
{
"imagePath": "assets/images/png/cimg3.png",
"reactionimg": "assets/images/png/party-popper 2.png",
"title": "Edward Hackket"
},
{
"imagePath": "assets/images/png/cimg4.png",
"reactionimg": "assets/images/png/f7_hand-thumbsup.png",
"title": "Dulce Vaccaro"
},
{
"imagePath": "assets/images/png/Rectangle 65.png",
"reactionimg": "assets/images/png/heart 2.png",
"title": "Edward Hackket"
},
{
"imagePath": "assets/images/png/Ellipse 43.png",
"reactionimg": "assets/images/png/party-popper 2.png",
"title": "Dulce Vaccaro"
},
{
"imagePath": "assets/images/png/cimg4.png",
"reactionimg": "assets/images/png/f7_hand-thumbsup.png",
"title": "Dulce Vaccaro"
},
{
"imagePath": "assets/images/png/cimg3.png",
"reactionimg": "assets/images/png/party-popper 2.png",
"title": "Edward Hackket"
},
{
"imagePath": "assets/images/png/cimg4.png",
"reactionimg": "assets/images/png/f7_hand-thumbsup.png",
"title": "Dulce Vaccaro"
},
];
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFF222935),
extendBody: true,
appBar: const CommonAppbar(
titleTxt: "Post",
),
resizeToAvoidBottomInset: false,
body: Stack(children: [
Container(
backgroundColor: const Color(0xFF222935),
extendBody: true,
appBar: const CommonAppbar(
titleTxt: "Post",
),
resizeToAvoidBottomInset: false,
body: Stack(
children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill)),
), Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
sizedBoxHeight(10.h),
Expanded(
child: DefaultTabController(
length: 4,
// initialIndex: selectedIndex.value,
child: Column(children: [
CommonTabBar(tabs: [
const Tab(
text: 'All',
),
Tab(
child: Row(children: [
commonGlassUI(
borderColor: const Color(0xFF1E3A46),
opacity1: 0.05,
opacity2: 0.06,
width: 30.w,
height: 30.h,
borderRadius: BorderRadius.circular( 100),
customWidget: Center(
child: Image.asset(
"assets/images/png/f7_hand-thumbsup.png",
height: 17.h,
width: 17.w,
),
),
borderwidth: 1.71),
const Spacer(),
text14400white("110K"),
]),
),
Tab(
child: Row(children: [
commonGlassUI(
borderColor: const Color(0xFF1E3A46),
opacity1: 0.05,
opacity2: 0.06,
width: 30.w,
height: 30.h,
borderRadius: BorderRadius.circular( 100),
customWidget: Center(
child: Image.asset(
"assets/images/png/heart 2.png",
height: 17.h,
width: 17.w,
),
),
borderwidth: 1.71),
const Spacer(),
text14400white("9.7K"),
]),
),
Tab(
child: Row(children: [
commonGlassUI(
borderColor: const Color(0xFF1E3A46),
opacity1: 0.05,
opacity2: 0.06,
width: 30.w,
height: 30.h,
borderRadius: BorderRadius.circular( 100),
customWidget: Center(
child: Image.asset(
"assets/images/png/party-popper 2.png",
height: 17.h,
width: 17.w,
),
),
borderwidth: 1.71),
const Spacer(),
text14400white("7.4K"),
]),
),
]),
Expanded(
child: TabBarView(
children: [
allTab(),
likeTab(),
favouriteTab(),
partyTab(),
],
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
sizedBoxHeight(10.h),
Expanded(
child: DefaultTabController(
length: 4,
// initialIndex: selectedIndex.value,
child: Column(
children: [
CommonTabBar(tabs: [
const Tab(
text: 'All',
),
sizedBoxHeight(20.h)
])),
)
])
]));
}
Widget allTab() {
return Column(
children: [
sizedBoxHeight(20.h),
Expanded(
child: ListView.builder(
itemCount: allTabData.length,
shrinkWrap: true,
itemBuilder: (context, index) {
return Column(
children: [
commonReaction(
imagePath: allTabData[index]["imagePath"],
reactionimg: allTabData[index]["reactionimg"],
title: allTabData[index]["title"]),
if (allTabData.length - 1 != index) commonDivider(),
],
);
},
),
)
],
);
}
Widget likeTab() {
return Column(
children: [
sizedBoxHeight(20.h),
Expanded(
child: ListView.builder(
itemCount: allTabData.length,
shrinkWrap: true,
itemBuilder: (context, index) {
return Column(
children: [
commonReaction(
imagePath: allTabData[index]["imagePath"],
reactionimg: allTabData[index]["reactionimg"],
title: allTabData[index]["title"]),
if (allTabData.length - 1 != index) commonDivider(),
],
);
},
),
)
],
);
}
Widget favouriteTab() {
return Column(
children: [
sizedBoxHeight(20.h),
Expanded(
child: ListView.builder(
itemCount: allTabData.length,
shrinkWrap: true,
itemBuilder: (context, index) {
return Column(
children: [
commonReaction(
imagePath: allTabData[index]["imagePath"],
reactionimg: allTabData[index]["reactionimg"],
title: allTabData[index]["title"]),
if (allTabData.length - 1 != index) commonDivider(),
],
);
},
),
)
],
);
}
Widget partyTab() {
return Column(
children: [
sizedBoxHeight(20.h),
Expanded(
child: ListView.builder(
itemCount: allTabData.length,
shrinkWrap: true,
itemBuilder: (context, index) {
return Column(
children: [
commonReaction(
imagePath: allTabData[index]["imagePath"],
reactionimg: allTabData[index]["reactionimg"],
title: allTabData[index]["title"]),
if (allTabData.length - 1 != index) commonDivider(),
],
);
},
),
)
],
);
}
Widget commonReaction(
{required String imagePath,
required String reactionimg,
required String title}) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 25.w, vertical: 18.h),
child: Row(
children: [
Stack(children: [
CircleAvatar(
radius: 25.r,
backgroundImage: AssetImage(imagePath),
),
Positioned(
bottom: 0,
right: 0,
child: Container(
height: 22.h,
width: 22.w,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: const Color(0xFF1E3A46),
border: Border.all(
color: const Color(0xFFFCFCFC).withOpacity(0.18),
width: 0.6)),
child: Center(
child: Image.asset(
reactionimg,
height: 12.h,
width: 12.w,
),
Tab(
child: Row(children: [
commonGlassUI(
borderColor: const Color(0xFF1E3A46),
opacity1: 0.05,
opacity2: 0.06,
width: 30.w,
height: 30.h,
borderRadius: BorderRadius.circular(100),
customWidget: Center(
child: Image.asset(
"assets/images/png/f7_hand-thumbsup.png",
height: 17.h,
width: 17.w,
),
),
borderwidth: 1.71),
const Spacer(),
text14400white("110K"),
]),
),
Tab(
child: Row(children: [
commonGlassUI(
borderColor: const Color(0xFF1E3A46),
opacity1: 0.05,
opacity2: 0.06,
width: 30.w,
height: 30.h,
borderRadius: BorderRadius.circular(100),
customWidget: Center(
child: Image.asset(
"assets/images/png/heart 2.png",
height: 17.h,
width: 17.w,
),
),
borderwidth: 1.71),
const Spacer(),
text14400white("9.7K"),
]),
),
Tab(
child: Row(children: [
commonGlassUI(
borderColor: const Color(0xFF1E3A46),
opacity1: 0.05,
opacity2: 0.06,
width: 30.w,
height: 30.h,
borderRadius: BorderRadius.circular(100),
customWidget: Center(
child: Image.asset(
"assets/images/png/party-popper 2.png",
height: 17.h,
width: 17.w,
),
),
borderwidth: 1.71),
const Spacer(),
text14400white("7.4K"),
]),
),
]),
const Expanded(
child: TabBarView(
children: [
AllTabs(),
LikeTabs(),
FavouriteTabs(),
PartyTabs(),
],
),
),
sizedBoxHeight(20.h)
],
),
)),
]),
sizedBoxWidth(10.w),
text17400white(title),
),
),
],
),
],
),
);
}
}
class AllTabs extends StatefulWidget {
const AllTabs({super.key});
@override
State<AllTabs> createState() => _AllTabsState();
}
class _AllTabsState extends State<AllTabs> {
late Future alltabfuture;
@override
void initState() {
alltabfuture = LikePostApi().postLike({'manage_posts_xid': recationid});
super.initState();
}
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: alltabfuture,
builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(
color: Colors.blue,
),
);
}
if (snapshot.hasError) {
return Center(
child: Text(
'${snapshot.error} occurred',
style: TextStyle(fontSize: 18.spMin),
),
);
}
if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData) {
return Column(
children: [
sizedBoxHeight(20.h),
Expanded(
child: ListView.builder(
itemCount: likepostobj!.data.length,
shrinkWrap: true,
itemBuilder: (context, index) {
return Column(
children: [
commonReaction(
imagePath: likepostobj!
.data[index].iamPrincipal!.profilePhoto ??
'',
reactionimg:
likepostobj!.data[index].likeIcon!.image ??
'',
title: likepostobj!
.data[index].iamPrincipal!.fullName ??
''),
if (likepostobj!.data.length - 1 != index)
commonDivider(),
],
);
},
),
)
],
);
}
return Container();
});
}
}
class LikeTabs extends StatefulWidget {
const LikeTabs({super.key});
@override
State<LikeTabs> createState() => _LikeTabsState();
}
class _LikeTabsState extends State<LikeTabs> {
late Future liketabfuture;
@override
void initState() {
liketabfuture = LikePostApi()
.postLike({'manage_posts_xid': recationid, 'like_icons_xid': 1});
super.initState();
}
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: liketabfuture,
builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(
color: Colors.blue,
),
);
}
if (snapshot.hasError) {
return Center(
child: Text(
'${snapshot.error} occurred',
style: TextStyle(fontSize: 18.spMin),
),
);
}
if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData) {
return Column(
children: [
sizedBoxHeight(20.h),
Expanded(
child: ListView.builder(
itemCount: likepostobj!.data.length,
shrinkWrap: true,
itemBuilder: (context, index) {
return Column(
children: [
commonReaction(
imagePath: likepostobj!
.data[index].iamPrincipal!.profilePhoto ??
'',
reactionimg:
likepostobj!.data[index].likeIcon!.image ??
'',
title: likepostobj!
.data[index].iamPrincipal!.fullName ??
''),
if (likepostobj!.data.length - 1 != index)
commonDivider(),
],
);
},
),
)
],
);
}
return Container();
});
}
}
class FavouriteTabs extends StatefulWidget {
const FavouriteTabs({super.key});
@override
State<FavouriteTabs> createState() => _FavouriteTabsState();
}
class _FavouriteTabsState extends State<FavouriteTabs> {
late Future favouritetabfuture;
@override
void initState() {
favouritetabfuture = LikePostApi()
.postLike({'manage_posts_xid': recationid, 'like_icons_xid': 2});
super.initState();
}
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: favouritetabfuture,
builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(
color: Colors.blue,
),
);
}
if (snapshot.hasError) {
return Center(
child: Text(
'${snapshot.error} occurred',
style: TextStyle(fontSize: 18.spMin),
),
);
}
if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData) {
return Column(
children: [
sizedBoxHeight(20.h),
Expanded(
child: ListView.builder(
itemCount: likepostobj!.data.length,
shrinkWrap: true,
itemBuilder: (context, index) {
return Column(
children: [
commonReaction(
imagePath: likepostobj!
.data[index].iamPrincipal!.profilePhoto ??
'',
reactionimg:
likepostobj!.data[index].likeIcon!.image ??
'',
title: likepostobj!
.data[index].iamPrincipal!.fullName ??
''),
if (likepostobj!.data.length - 1 != index)
commonDivider(),
],
);
},
),
)
],
);
}
return Container();
});
}
}
class PartyTabs extends StatefulWidget {
const PartyTabs({super.key});
@override
State<PartyTabs> createState() => _PartyTabsState();
}
class _PartyTabsState extends State<PartyTabs> {
late Future partytabfuture;
@override
void initState() {
partytabfuture = LikePostApi()
.postLike({'manage_posts_xid': recationid, 'like_icons_xid': 3});
super.initState();
}
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: partytabfuture,
builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(
color: Colors.blue,
),
);
}
if (snapshot.hasError) {
return Center(
child: Text(
'${snapshot.error} occurred',
style: TextStyle(fontSize: 18.spMin),
),
);
}
if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData) {
return Column(
children: [
sizedBoxHeight(20.h),
Expanded(
child: ListView.builder(
itemCount: likepostobj!.data.length,
shrinkWrap: true,
itemBuilder: (context, index) {
return Column(
children: [
commonReaction(
imagePath: likepostobj!
.data[index].iamPrincipal!.profilePhoto ??
'',
reactionimg:
likepostobj!.data[index].likeIcon!.image ??
'',
title: likepostobj!
.data[index].iamPrincipal!.fullName ??
''),
if (likepostobj!.data.length - 1 != index)
commonDivider(),
],
);
},
),
)
],
);
}
return Container();
});
}
}
Widget commonReaction(
{required String imagePath,
required String reactionimg,
required String title}) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 25.w, vertical: 18.h),
child: Row(
children: [
Stack(children: [
CircleAvatar(
radius: 25.r,
backgroundImage: NetworkImage(imagePath),
),
Positioned(
bottom: 0,
right: 0,
child: Container(
height: 22.h,
width: 22.w,
decoration: BoxDecoration(
shape: BoxShape.circle,
// color: const Color(0xFF1E3A46),
border: Border.all(
color: const Color(0xFFFCFCFC).withOpacity(0.18),
width: 0.6),
image: DecorationImage(
image: NetworkImage(reactionimg),
),
),
)),
]),
sizedBoxWidth(10.w),
text17400white(title),
],
),
);
}

View File

@@ -0,0 +1,27 @@
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/LikePostModel.dart';
LikepostModel? likepostobj;
class LikePostApi {
Future<ResponseData<dynamic>> postLike(updata) async {
print("updata is $updata");
final response = await NetworkApiServices().postApi(
updata,
ApiUrls.postlike,
);
if (response.status == ResponseStatus.SUCCESS) {
if (response.data["status"] == "success") {
likepostobj = LikepostModel.fromJson(response.data);
}
return ResponseData<dynamic>(
response.data['message'], ResponseStatus.SUCCESS,
data: response.data);
} else {
return ResponseData<dynamic>(
response.data['message'], ResponseStatus.FAILED);
}
}
}