Community detail api integration

This commit is contained in:
Dakshesh42
2024-08-14 16:34:24 +05:30
parent 07e48c9edd
commit c3d9ea58bd
4 changed files with 428 additions and 257 deletions

View File

@@ -86,6 +86,9 @@ class ApiUrls {
static const getmycommunity = "${baseUrl}fetch-my-communities";
static const getcommunitydetail = "${baseUrl}fetch-community-all-details";
static const getrequestedcommunity =
"${baseUrl}fetch-joining-request-for-community";

View File

@@ -0,0 +1,83 @@
class ComDetailModel {
ComDetailModel({
required this.status,
required this.statusCode,
required this.message,
required this.data,
});
final String? status;
final int? statusCode;
final String? message;
final Data? data;
factory ComDetailModel.fromJson(Map<String, dynamic> json){
return ComDetailModel(
status: json["status"],
statusCode: json["status_code"],
message: json["message"],
data: json["data"] == null ? null : Data.fromJson(json["data"]),
);
}
}
class Data {
Data({
required this.id,
required this.totalGroup,
required this.totalAnnouncements,
required this.communityProfilePhoto,
required this.communityBannerImage,
required this.communityName,
required this.communityLocation,
required this.communityDescription,
required this.communityTypeXid,
required this.accessType,
});
final int? id;
final int? totalGroup;
final int? totalAnnouncements;
final String? communityProfilePhoto;
final String? communityBannerImage;
final String? communityName;
final String? communityLocation;
final String? communityDescription;
final int? communityTypeXid;
final AccessType? accessType;
factory Data.fromJson(Map<String, dynamic> json){
return Data(
id: json["id"],
totalGroup: json["total_group"],
totalAnnouncements: json["total_announcements"],
communityProfilePhoto: json["community_profile_photo"],
communityBannerImage: json["community_banner_image"],
communityName: json["community_name"],
communityLocation: json["community_location"],
communityDescription: json["community_description"],
communityTypeXid: json["community_type_xid"],
accessType: json["access_type"] == null ? null : AccessType.fromJson(json["access_type"]),
);
}
}
class AccessType {
AccessType({
required this.id,
required this.name,
});
final int? id;
final String? name;
factory AccessType.fromJson(Map<String, dynamic> json){
return AccessType(
id: json["id"],
name: json["name"],
);
}
}

View File

@@ -10,6 +10,7 @@ import 'package:regroup/Utils/Common/CommonAppbar.dart';
import 'package:regroup/Utils/Common/sized_box.dart';
import 'package:regroup/Utils/texts.dart';
import 'package:regroup/resources/routes/route_name.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/view_model/ComDetails.dart';
class CommunityDetails extends StatefulWidget {
const CommunityDetails({super.key});
@@ -21,10 +22,14 @@ class CommunityDetails extends StatefulWidget {
class _CommunityDetailsState extends State<CommunityDetails> {
bool? additionalContent = false;
var CommunityId;
late Future myfuture;
@override
void initState() {
// TODO: implement initState
CommunityId = Get.arguments["CommunityID"];
myfuture = CommunityDetail().getCommunityDetail(CommunityId);
super.initState();
}
@@ -160,190 +165,279 @@ class _CommunityDetailsState extends State<CommunityDetails> {
width: 20.w,
)),
),
body: Stack(children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill)),
),
Positioned.fill(
child: SingleChildScrollView(
child: Column(children: [
Stack(clipBehavior: Clip.none, children: [
GestureDetector(
onTap: () {
Get.toNamed(RouteName.communityInfo);
},
child: SizedBox(
height: 130.h,
width: double.infinity,
child: Image.asset(
"assets/images/png/img1.png",
fit: BoxFit.cover,
),
),
),
Positioned(
bottom: -35.h,
left: 20.w,
child: Container(
width: 85.r,
height: 85.r,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Color.fromRGBO(255, 255, 255, 0.5),
width: 1,
body: FutureBuilder(
future: myfuture,
builder: (ctx, snapshot) {
if (snapshot.data == null) {
return const Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Center(
child: CircularProgressIndicator(
color: Color(0xFFC18948),
),
boxShadow: [
BoxShadow(
color: Color.fromRGBO(0, 0, 0, 0.25),
blurRadius: 12,
offset: Offset(0, 6),
),
],
)
],
);
}
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
return Center(
child: Text(
'${snapshot.error} occured',
style: TextStyle(fontSize: 18.spMin),
),
child: CircleAvatar(
radius: 42.5.r,
foregroundImage: AssetImage("assets/images/png/img2.png"),
),
))
]),
sizedBoxHeight(40.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Column(
children: [
Row(
children: [
text20w700_FCFCFC("Active alliance network"),
Spacer(),
commonGlassUI(
width: 35.w,
height: 35.h,
borderRadius: BorderRadius.circular(100),
opacity1: 0.24,
opacity2: 0.24,
customWidget: Center(
);
}
}
return Stack(children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image:
AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill)),
),
Positioned.fill(
child: SingleChildScrollView(
child: Column(children: [
Stack(clipBehavior: Clip.none, children: [
GestureDetector(
onTap: () {
Get.toNamed(RouteName.communityInfo);
},
child: comdetailobj!.data!.communityBannerImage != null
? SizedBox(
height: 130.h,
width: double.infinity,
child: Image.network(
comdetailobj!.data!
.communityBannerImage!, // Replace with your API image URL
fit: BoxFit.cover,
),
)
: SizedBox(
height: 130.h,
width: double.infinity,
child: Image.asset(
"assets/images/png/img12.png",
height: 18.w,
width: 18.w,
)),
borderwidth: 0.5),
sizedBoxWidth(8.w),
text16w400_FCFCFCblur("Public"),
],
),
sizedBoxHeight(30.h),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
text13w400_FCFCFC("Show Details"),
sizedBoxWidth(4.w),
InkWell(
onTap: () {
additionalContent = !additionalContent!;
setState(() {});
},
child: Image.asset(
"assets/images/png/Vector 8.png",
height: 8.h,
width: 20.w,
),
)
],
),
if (additionalContent == true)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
sizedBoxHeight(30.h),
text16w400_FCFCFC("About community"),
sizedBoxHeight(16.h),
text14w400_FCFCFCblur(
"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."),
sizedBoxHeight(20.h),
Row(
children: [
commonGlassUI(
width: 35.w,
height: 35.h,
opacity1: 0.24,
opacity2: 0.24,
borderRadius: BorderRadius.circular(100),
customWidget: Center(
child: Image.asset(
"assets/images/png/Group 58645.png",
height: 17.h,
width: 13.w,
),
),
borderwidth: 0.5),
sizedBoxWidth(12.w),
text16400white("Elm street london, United Kingdom")
],
),
sizedBoxHeight(16.h),
Row(
children: [
commonGlassUI(
width: 35.w,
height: 35.h,
opacity1: 0.24,
opacity2: 0.24,
borderRadius: BorderRadius.circular(100),
customWidget: Center(
child: Image.asset(
"assets/images/png/puzzle-pieces 1 (traced).png",
height: 20.h,
width: 16.w,
),
),
borderwidth: 0.5),
sizedBoxWidth(12.w),
text16400white("Sports")
],
),
sizedBoxHeight(20.h),
commonGlassUI(
width: double.infinity,
height: 51.h,
borderRadius: BorderRadius.circular(10.r),
customWidget: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
children: [
sizedBoxWidth(16.w),
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(90.w),
text16w400_white('7 members'),
Spacer(),
Icon(
Icons.arrow_forward,
size: 20.sp,
color: Colors.white,
),
sizedBoxWidth(16.w),
],
),
],
"assets/images/png/img1.png",
fit: BoxFit.cover,
),
),
borderwidth: 1.w),
sizedBoxHeight(20.h),
),
Positioned(
bottom: -35.h,
left: 20.w,
child: Container(
width: 85.r,
height: 85.r,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Color.fromRGBO(255, 255, 255, 0.5),
width: 1,
),
boxShadow: [
BoxShadow(
color: Color.fromRGBO(0, 0, 0, 0.25),
blurRadius: 12,
offset: Offset(0, 6),
),
],
),
child: comdetailobj!.data!.communityProfilePhoto !=
null
? CircleAvatar(
radius: 42.5.r,
foregroundImage: NetworkImage(comdetailobj!
.data!
.communityProfilePhoto!), // Replace with your API image URL
backgroundColor: Colors
.transparent, // Optional: If the image fails to load, a transparent background is shown
)
: CircleAvatar(
radius: 42.5.r,
foregroundImage:
AssetImage("assets/images/png/img2.png"),
),
))
]),
sizedBoxHeight(40.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Column(
children: [
Row(
children: [
text20w700_FCFCFC(
comdetailobj!.data!.communityName ?? ""),
Spacer(),
commonGlassUI(
width: 35.w,
height: 35.h,
borderRadius: BorderRadius.circular(100),
opacity1: 0.24,
opacity2: 0.24,
customWidget: Center(
child: Image.asset(
"assets/images/png/img12.png",
height: 18.w,
width: 18.w,
)),
borderwidth: 0.5),
sizedBoxWidth(8.w),
text16w400_FCFCFCblur(
comdetailobj!.data!.accessType!.name ?? ""),
],
),
sizedBoxHeight(30.h),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
text13w400_FCFCFC("Show Details"),
sizedBoxWidth(4.w),
InkWell(
onTap: () {
additionalContent = !additionalContent!;
setState(() {});
},
child: Image.asset(
"assets/images/png/Vector 8.png",
height: 8.h,
width: 20.w,
),
)
],
),
if (additionalContent == true)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
sizedBoxHeight(30.h),
text16w400_FCFCFC("About community"),
sizedBoxHeight(16.h),
text14w400_FCFCFCblur(
""),
sizedBoxHeight(20.h),
Row(
children: [
commonGlassUI(
width: 35.w,
height: 35.h,
opacity1: 0.24,
opacity2: 0.24,
borderRadius: BorderRadius.circular(100),
customWidget: Center(
child: Image.asset(
"assets/images/png/Group 58645.png",
height: 17.h,
width: 13.w,
),
),
borderwidth: 0.5),
sizedBoxWidth(12.w),
text16400white(
"Elm street london, United Kingdom")
],
),
sizedBoxHeight(16.h),
Row(
children: [
commonGlassUI(
width: 35.w,
height: 35.h,
opacity1: 0.24,
opacity2: 0.24,
borderRadius: BorderRadius.circular(100),
customWidget: Center(
child: Image.asset(
"assets/images/png/puzzle-pieces 1 (traced).png",
height: 20.h,
width: 16.w,
),
),
borderwidth: 0.5),
sizedBoxWidth(12.w),
text16400white("Sports")
],
),
sizedBoxHeight(20.h),
commonGlassUI(
width: double.infinity,
height: 51.h,
borderRadius: BorderRadius.circular(10.r),
customWidget: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
children: [
sizedBoxWidth(16.w),
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(90.w),
text16w400_white('7 members'),
Spacer(),
Icon(
Icons.arrow_forward,
size: 20.sp,
color: Colors.white,
),
sizedBoxWidth(16.w),
],
),
],
),
borderwidth: 1.w),
sizedBoxHeight(20.h),
GestureDetector(
onTap: () {
Get.toNamed(RouteName.addgroup);
},
child: commonGlassUI(
width: double.infinity,
height: 51.h,
borderRadius: BorderRadius.circular(10.r),
customWidget: Padding(
padding: EdgeInsets.symmetric(
horizontal: 16.w),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Row(children: [
Image.asset(
"assets/images/png/Black.png",
height: 23.h,
width: 31.w,
),
sizedBoxWidth(15.w),
text16w400white('10 groups'),
Spacer(),
Icon(
Icons.arrow_forward,
size: 20.sp,
color: Colors.white,
),
]),
],
),
),
borderwidth: 1),
),
],
),
sizedBoxHeight(40.h),
GestureDetector(
onTap: () {
Get.toNamed(RouteName.addgroup);
Get.toNamed(RouteName.announcement);
},
child: commonGlassUI(
width: double.infinity,
@@ -356,105 +450,71 @@ class _CommunityDetailsState extends State<CommunityDetails> {
children: [
Row(children: [
Image.asset(
"assets/images/png/Black.png",
"assets/images/png/marketing 1 (traced).png",
height: 23.h,
width: 31.w,
),
sizedBoxWidth(15.w),
text16w400white('10 groups'),
text16w400white('Announcements'),
Spacer(),
Icon(
Icons.arrow_forward,
size: 20.sp,
color: Colors.white,
),
Container(
height: 21.h,
width: 43.w,
decoration: BoxDecoration(
color: Color(0xFFD90B2E),
borderRadius:
BorderRadius.circular(30.r)),
child: Center(
child: text12w400_FCFCFC("11")),
)
]),
],
),
),
borderwidth: 1),
),
sizedBoxHeight(35.h),
Container(
height: 40.h,
width: 200.w,
decoration: BoxDecoration(
color: Color(0xFFD90B2E),
borderRadius: BorderRadius.circular(30.r)),
child: Center(
child: text14w400white("Leave the community")),
),
sizedBoxHeight(50.h),
],
),
sizedBoxHeight(40.h),
GestureDetector(
onTap: () {
Get.toNamed(RouteName.announcement);
},
child: commonGlassUI(
width: double.infinity,
height: 51.h,
borderRadius: BorderRadius.circular(10.r),
customWidget: Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
),
DefaultTabController(
length: 2,
// initialIndex: selectedIndex.value,
child: Column(
children: [
CommonTabBar(tabs: const [
Tab(
text: 'Posts',
),
Tab(
text: 'Events',
),
]),
SizedBox(
height: 600.h,
child: TabBarView(
children: [
Row(children: [
Image.asset(
"assets/images/png/marketing 1 (traced).png",
height: 23.h,
width: 31.w,
),
sizedBoxWidth(15.w),
text16w400white('Announcements'),
Spacer(),
Container(
height: 21.h,
width: 43.w,
decoration: BoxDecoration(
color: Color(0xFFD90B2E),
borderRadius:
BorderRadius.circular(30.r)),
child: Center(child: text12w400_FCFCFC("11")),
)
]),
poststab(),
eventstab(),
],
),
),
borderwidth: 1),
),
sizedBoxHeight(35.h),
Container(
height: 40.h,
width: 200.w,
decoration: BoxDecoration(
color: Color(0xFFD90B2E),
borderRadius: BorderRadius.circular(30.r)),
child:
Center(child: text14w400white("Leave the community")),
),
sizedBoxHeight(50.h),
],
),
),
DefaultTabController(
length: 2,
// initialIndex: selectedIndex.value,
child: Column(
children: [
CommonTabBar(tabs: const [
Tab(
text: 'Posts',
),
Tab(
text: 'Events',
),
]),
SizedBox(
height: 600.h,
child: TabBarView(
children: [
poststab(),
eventstab(),
],
),
),
],
),
),
])))
]));
])))
]);
}));
}
Widget poststab() {

View File

@@ -0,0 +1,25 @@
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';
ComDetailModel? comdetailobj;
class CommunityDetail {
Future<ResponseData<dynamic>> getCommunityDetail(updata) async {
final response =
await NetworkApiServices().getApi(
"${ApiUrls.getcommunitydetail}?id=$updata",
);
if (response.status == ResponseStatus.SUCCESS) {
comdetailobj = ComDetailModel.fromJson(response.data);
}
return response;
}
}