Files
Regroup/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/ReactionView.dart
2024-08-08 12:11:45 +05:30

484 lines
16 KiB
Dart

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';
String? postId;
class ReactionView extends StatefulWidget {
const ReactionView({super.key});
@override
State<ReactionView> createState() => _ReactionViewState();
}
class _ReactionViewState extends State<ReactionView> {
@override
Widget build(BuildContext context) {
return Scaffold(
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"),
]),
),
]),
const Expanded(
child: TabBarView(
children: [
AllTabs(),
LikeTabs(),
FavouriteTabs(),
PartyTabs(),
],
),
),
sizedBoxHeight(20.h)
],
),
),
),
],
),
],
),
);
}
}
class AllTabs extends StatefulWidget {
const AllTabs({super.key});
@override
State<AllTabs> createState() => _AllTabsState();
}
class _AllTabsState extends State<AllTabs> {
late Future alltabfuture;
@override
void initState() {
postId = Get.arguments['postId'];
alltabfuture = LikePostApi().postLike({'manage_posts_xid': postId});
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() {
postId = Get.arguments['postId'];
liketabfuture = LikePostApi() .postLike({'manage_posts_xid': postId, '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() {
postId = Get.arguments['postId'];
favouritetabfuture = LikePostApi() .postLike({'manage_posts_xid': postId, '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() {
postId = Get.arguments['postId'];
partytabfuture = LikePostApi().postLike({'manage_posts_xid': postId, '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),
],
),
);
}