Files
Regroup/lib/sidemenu/Community/Group/view/Group.dart

828 lines
42 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:regroup/Common/CommonGlassmorphism.dart';
import 'package:regroup/Common/CommonWidget.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/view_model/getmethod.dart';
import 'package:regroup/sidemenu/view_model/getmethod.dart';
import 'package:regroup/Utils/Common/CommonAppbar.dart';
import 'package:regroup/Utils/Common/sized_box.dart';
import 'package:regroup/Utils/texts.dart';
class Group extends StatefulWidget {
const Group({super.key});
@override
State<Group> createState() => _GroupState();
}
class _GroupState extends State<Group> {
int id = Get.arguments["id"];
bool iscommunity = Get.arguments["iscommunity"];
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
// key: _scaffoldKey1,
backgroundColor: Color(0xFF222935),
extendBody: true,
appBar: CommonAppbar(
titleTxt: "Groups",
),
resizeToAvoidBottomInset: false,
body: iscommunity == true
? FutureBuilder(
future: Getcommunity().getCommunitygroups(id),
builder: (ctx, snapshot) {
if (snapshot.data == null) {
return const Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Center(
child: CircularProgressIndicator(
color: Color(0xFFC18948),
),
)
],
);
}
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
return Center(
child: Text(
'${snapshot.error} occured',
style: TextStyle(fontSize: 18.spMin),
),
);
}
}
return communitygroupspobj!.data.isEmpty
? _buildNoDataBody(context)
: _communitybuildBody(context);
},
)
: FutureBuilder(
future: Sidegetmethod().getJoinedusergroups(id),
builder: (ctx, snapshot) {
if (snapshot.data == null) {
return const Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Center(
child: CircularProgressIndicator(
color: Color(0xFFC18948),
),
)
],
);
}
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
return Center(
child: Text(
'${snapshot.error} occured',
style: TextStyle(fontSize: 18.spMin),
),
);
}
}
return joinedgroupsobj!.data!.isEmpty
? _buildNoDataBody(context)
: _buildBody(context);
},
),
);
}
Widget _buildNoDataBody(context) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"No Data Found",
style: TextStyle(
color: Colors.white,
fontSize: 16.sp,
fontWeight: FontWeight.w600),
)
],
),
);
}
Widget _buildBody(context) {
return Stack(children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill)),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: SingleChildScrollView(
child: Column(
children: [
ListView.builder(
shrinkWrap: true,
physics: ScrollPhysics(),
itemCount: joinedgroupsobj!.data!.length,
itemBuilder: (context, index) {
return Padding(
padding: EdgeInsets.only(bottom: 25.h),
child: GestureDetector(
onTap: () {},
child: commonGlassUI(
borderwidth: 0.9,
width: double.infinity,
height: 162.h,
borderRadius: BorderRadius.circular(10.r),
customWidget: Padding(
padding: EdgeInsets.symmetric(
horizontal: 16.w, vertical: 16.h),
child: Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 65.h,
width: 65.h,
decoration: BoxDecoration(
shape: BoxShape.circle,
// color: Colors.amber,
),
child:
// Center(
// child: Image.asset(imagepath, fit: BoxFit.cover)),
joinedgroupsobj!
.data![index]
.groupData!
.groupImage ==
null ||
joinedgroupsobj!
.data![index]
.groupData!
.groupImage!
.isEmpty
? CircleAvatar(
backgroundImage: AssetImage(
'assets/images/png/img45.png',
),
)
: CircleAvatar(
backgroundImage:
NetworkImage(
joinedgroupsobj!
.data![index]
.groupData!
.groupImage!),
)),
sizedBoxWidth(13.w),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
// Container(
// // width: 250.w,
// // color: Colors.red,
// width: double.infinity,
// child:
joinedgroupsobj!.data![index].groupData!
.title ==
null ||
joinedgroupsobj!.data![index]
.groupData!.title!.isEmpty
? text18w700_FCFCFC('Regroup')
: SizedBox(
width: 200.w,
child: text18w700_FCFCFC(
joinedgroupsobj!
.data![index]
.groupData!
.title!),
),
// ),
sizedBoxHeight(10.h),
joinedgroupsobj!.data![index]
.myJoinedCommunityDetails ==
null ||
joinedgroupsobj!
.data![index]
.myJoinedCommunityDetails!
.communityData!
.communityName!
.isEmpty
? SizedBox()
: Row(
children: [
Image.asset(
'assets/images/png/community 1 (traced).png',
width: 18.w,
height: 18.h,
),
sizedBoxWidth(4.w),
text14w400_FCFCFCblur(
joinedgroupsobj!
.data![index]
.myJoinedCommunityDetails!
.communityData!
.communityName!)
],
),
],
),
Spacer(),
PopupMenuButton(
surfaceTintColor:
const Color(0xFF222935),
constraints: BoxConstraints.tightFor(
width: 200.w),
offset: const Offset(0, 30),
color: const Color(0xFF222935),
tooltip: "",
itemBuilder: (BuildContext context) =>
<PopupMenuEntry>[
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: 8.w),
child: Row(
children: [
text14w400_FCFCFC(
"Mute group"),
const Spacer(),
Image.asset(
"assets/images/png/Black (1).png",
height: 18.h,
width: 18.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: 8.w),
child: Row(
children: [
text14w400_FCFCFC(
"Pin group"),
const Spacer(),
Image.asset(
"assets/images/png/f7_pin-fill (2).png",
height: 27.h,
width: 27.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: 8.w),
child: Row(
children: [
text14w400_FCFCFC(
"Make primary"),
const Spacer(),
Image.asset(
"assets/images/png/leave group.png",
height: 20.h,
width: 20.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: 8.w),
child: Row(
children: [
// text14w400_FCFCFC("Leave group"),
text14w400_D90B2E(
"Leave group"),
const Spacer(),
Image.asset(
"assets/images/png/LightGray22.png",
height: 18.h,
width: 18.w,
)
],
),
),
),
],
child: Image.asset(
"assets/images/png/Group 1000004071.png",
height: 18.h,
width: 20.w,
)),
],
),
sizedBoxHeight(16.h),
commonDivider(),
sizedBoxHeight(10.h),
Row(
children: [
stackContainersGroups(
number: joinedgroupsobj!
.data![index].membersCount
.toString(),
containerImages: joinedgroupsobj!
.data![index].membersProfilePhotos!
.map((photo) => photo.profilePhoto!)
.toList(),
),
sizedBoxWidth(75.w),
joinedgroupsobj!.data![index]
.membersCount ==
null ||
joinedgroupsobj!.data![index]
.membersCount.isBlank!
? SizedBox()
: text16w400_FCFCFC_blur(
'${joinedgroupsobj!.data![index].membersCount} members',
),
],
)
],
),
)),
),
);
},
)
],
)))
]);
}
Widget _communitybuildBody(context) {
return Stack(children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill)),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: SingleChildScrollView(
child: Column(
children: [
ListView.builder(
shrinkWrap: true,
physics: ScrollPhysics(),
itemCount: communitygroupspobj!.data.length,
itemBuilder: (context, index) {
return Padding(
padding: EdgeInsets.only(bottom: 25.h),
child: GestureDetector(
onTap: () {},
child: commonGlassUI(
borderwidth: 0.9,
width: double.infinity,
height: 162.h,
borderRadius: BorderRadius.circular(10.r),
customWidget: Padding(
padding: EdgeInsets.symmetric(
horizontal: 16.w, vertical: 16.h),
child: Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 65.h,
width: 65.h,
decoration: BoxDecoration(
shape: BoxShape.circle,
// color: Colors.amber,
),
child:
// Center(
// child: Image.asset(imagepath, fit: BoxFit.cover)),
communitygroupspobj!
.data[index]
.groups!
.groupImage ==
null ||
communitygroupspobj!
.data[index]
.groups!
.groupImage!
.isEmpty
? CircleAvatar(
backgroundImage: AssetImage(
'assets/images/png/img45.png',
),
)
: CircleAvatar(
backgroundImage:
NetworkImage(
communitygroupspobj!
.data[index]
.groups!
.groupImage!),
)),
sizedBoxWidth(13.w),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
// Container(
// // width: 250.w,
// // color: Colors.red,
// width: double.infinity,
// child:
communitygroupspobj!.data[index].groups!
.title ==
null ||
communitygroupspobj!.data[index]
.groups!.title!.isEmpty
? text18w700_FCFCFC('Regroup')
: SizedBox(
width: 200.w,
child: text18w700_FCFCFC(
communitygroupspobj!
.data[index]
.groups!
.title!),
),
// ),
sizedBoxHeight(10.h),
communitygroupspobj!.data[index]
.communityData ==
null ||
communitygroupspobj!
.data[index]
.communityData!
.communityName!
.isEmpty
? SizedBox()
: Row(
children: [
Image.asset(
'assets/images/png/community 1 (traced).png',
width: 18.w,
height: 18.h,
),
sizedBoxWidth(4.w),
text14w400_FCFCFCblur(
communitygroupspobj!
.data[index]
.communityData!
.communityName!)
],
),
],
),
Spacer(),
PopupMenuButton(
surfaceTintColor:
const Color(0xFF222935),
constraints: BoxConstraints.tightFor(
width: 200.w),
offset: const Offset(0, 30),
color: const Color(0xFF222935),
tooltip: "",
itemBuilder: (BuildContext context) =>
<PopupMenuEntry>[
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: 8.w),
child: Row(
children: [
text14w400_FCFCFC(
"Mute group"),
const Spacer(),
Image.asset(
"assets/images/png/Black (1).png",
height: 18.h,
width: 18.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: 8.w),
child: Row(
children: [
text14w400_FCFCFC(
"Pin group"),
const Spacer(),
Image.asset(
"assets/images/png/f7_pin-fill (2).png",
height: 27.h,
width: 27.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: 8.w),
child: Row(
children: [
text14w400_FCFCFC(
"Make primary"),
const Spacer(),
Image.asset(
"assets/images/png/leave group.png",
height: 20.h,
width: 20.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: 8.w),
child: Row(
children: [
// text14w400_FCFCFC("Leave group"),
text14w400_D90B2E(
"Leave group"),
const Spacer(),
Image.asset(
"assets/images/png/LightGray22.png",
height: 18.h,
width: 18.w,
)
],
),
),
),
],
child: Image.asset(
"assets/images/png/Group 1000004071.png",
height: 18.h,
width: 20.w,
)),
],
),
sizedBoxHeight(16.h),
commonDivider(),
sizedBoxHeight(10.h),
Row(
children: [
stackContainersGroups(
number: communitygroupspobj!
.data[index].groups!.totalMember
.toString(),
containerImages: communitygroupspobj!
.data[index].groups!.sevenMemberImage
.map((photo) => photo
.iamPrincipalData!.profilePhoto!)
.toList(),
),
sizedBoxWidth(75.w),
communitygroupspobj!.data[index].groups ==
null ||
communitygroupspobj!.data[index]
.groups!.totalMember.isBlank!
? SizedBox()
: text16w400_FCFCFC_blur(
'${communitygroupspobj!.data[index].groups!.totalMember} members',
),
],
)
],
),
)),
),
);
},
)
],
)))
]);
}
// Widget groupCard({
// required String? imagepath,
// required String? title,
// required void Function()? ontap,
// required String? members,
// required String? subtitle,
// }) {
// return Padding(
// padding: EdgeInsets.only(bottom: 25.h),
// child: GestureDetector(
// onTap: ontap,
// child: commonGlassContainer(
// border: 0.9,
// width: double.infinity,
// height: 162.h,
// borderradius: 10.r,
// customWidget: Padding(
// padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h),
// child: Column(
// children: [
// Row(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Container(
// height: 65.h,
// width: 65.h,
// decoration: BoxDecoration(
// shape: BoxShape.circle,
// // color: Colors.amber,
// ),
// child:
// // Center(
// // child: Image.asset(imagepath, fit: BoxFit.cover)),
// imagepath == null || imagepath.isEmpty
// ?
// CircleAvatar(
// backgroundImage: AssetImage(
// 'assets/images/png/img45.png',
// ),
// )
// :
// CircleAvatar(
// backgroundImage: NetworkImage(
// imagepath
// ),
// )
// ),
// sizedBoxWidth(13.w),
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// title == null || title.isEmpty
// ?
// text18w700_FCFCFC('Regroup')
// :
// text18w700_FCFCFC(title),
// sizedBoxHeight(10.h),
// Row(
// children: [
// Image.asset(
// 'assets/images/png/community 1 (traced).png',
// width: 18.w,
// height: 18.h,
// ),
// sizedBoxWidth(4.w),
// text14w400_FCFCFCblur(subtitle)
// ],
// ),
// ],
// ),
// Spacer(),
// PopupMenuButton(
// surfaceTintColor: Color(0xFF222935),
// constraints: BoxConstraints.tightFor(width: 200.w),
// offset: Offset(0, 30),
// color: Color(0xFF222935),
// tooltip: "",
// itemBuilder: (BuildContext context) =>
// <PopupMenuEntry>[
// PopupMenuItem(
// onTap: () {},
// child: Padding(
// padding:
// EdgeInsets.symmetric(horizontal: 8.w),
// child: Row(
// children: [
// text14w400_FCFCFC("Mute community"),
// Spacer(),
// Image.asset(
// "assets/images/png/Black (1).png",
// height: 18.h,
// width: 18.w,
// )
// ],
// ),
// ),
// ),
// PopupMenuDivider(),
// PopupMenuItem(
// onTap: () {},
// child: Padding(
// padding:
// EdgeInsets.symmetric(horizontal: 8.w),
// child: Row(
// children: [
// text14w400_FCFCFC("Hide post"),
// Spacer(),
// Image.asset(
// "assets/images/png/mingcute_eye-close-line.png",
// height: 20.h,
// width: 20.w,
// )
// ],
// ),
// ),
// ),
// PopupMenuDivider(),
// PopupMenuItem(
// onTap: () {},
// child: Padding(
// padding:
// EdgeInsets.symmetric(horizontal: 8.w),
// child: Row(
// children: [
// text14w400_FCFCFC("Pin"),
// Spacer(),
// Image.asset(
// "assets/images/png/f7_pin-fill (2).png",
// height: 25.h,
// width: 25.w,
// )
// ],
// ),
// ),
// ),
// PopupMenuDivider(),
// PopupMenuItem(
// onTap: () {},
// child: Padding(
// padding:
// EdgeInsets.symmetric(horizontal: 8.w),
// child: Row(
// children: [
// text14w400_FCFCFC("Leave community"),
// Spacer(),
// Image.asset(
// "assets/images/png/logout 1 (traced).png",
// height: 18.h,
// width: 18.w,
// )
// ],
// ),
// ),
// ),
// ],
// child: Image.asset(
// "assets/images/png/Group 1000004071.png",
// height: 13.h,
// width: 3.w,
// )),
// ],
// ),
// sizedBoxHeight(16.h),
// commonDivider(),
// sizedBoxHeight(10.h),
// Row(
// children: [
// stackContainers(
// number: "+2",
// containerImages: [
// "assets/images/png/cimg3.png",
// "assets/images/png/cimg2.png",
// "assets/images/png/cimg3.png",
// "assets/images/png/cimg2.png",
// ],
// ),
// sizedBoxWidth(95.w),
// text12w400_FCFCFC_blur(members),
// ],
// )
// ],
// ),
// )),
// ),
// );
// }
}