Merge pull request #127 from WDI-Ideas/editcommunity

get api called for edit commiunity page,and some fixes
This commit is contained in:
Shubham Shetty
2024-08-14 20:44:12 +05:30
committed by GitHub
10 changed files with 765 additions and 254 deletions

View File

@@ -171,6 +171,9 @@ class ApiUrls {
static const getcommunitymembers = "${baseUrl}fetch-community-all-members";
static const geteditcommunity = "${baseUrl}edit-community";
}

View File

@@ -66,4 +66,19 @@ class Helper {
);
}
}
static Future<File> networkImageToFile(String imageUrl) async {
Dio dio = Dio();
Response<Uint8List> response = await dio.get<Uint8List>(imageUrl,
options: Options(responseType: ResponseType.bytes));
final directory = await getTemporaryDirectory();
final filePath = '${directory.path}/${imageUrl.split('/').last}';
final file = File(filePath);
await file.writeAsBytes(response.data!);
return file;
}
}

View File

@@ -16,6 +16,8 @@ class CommunitySetting extends StatefulWidget {
}
class _CommunitySettingState extends State<CommunitySetting> {
int communityid = Get.arguments['communityid'];
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -37,7 +39,11 @@ class _CommunitySettingState extends State<CommunitySetting> {
sizedBoxHeight(30.h),
GestureDetector(
onTap: () {
Get.toNamed(RouteName.editcommunity);
Get.toNamed(RouteName.editcommunity,
arguments: {
'communityid' : communityid,
}
);
},
child: rowTile(text: 'Edit community info')),
commonDivider(),

View File

@@ -1,18 +1,27 @@
import 'dart:developer';
import 'dart:io';
import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:regroup/Common/CommonDropDown.dart';
import 'package:get/get.dart';
import 'package:regroup/Common/CommonGlassmorphism.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Main_Screens/ProfileTab/EditProfile/Model/InterestModel.dart'
as primaryactlist;
import 'package:regroup/Utils/Common/CommonAppbar.dart';
import 'package:regroup/Utils/Common/CommonDropdown.dart';
import 'package:regroup/Utils/Common/CustomNextButton.dart';
import 'package:regroup/Utils/Common/ImageUpload.dart';
import 'package:regroup/Utils/Common/sized_box.dart';
import 'package:regroup/Utils/Helper.dart';
import 'package:regroup/Utils/dialogs.dart';
import 'package:regroup/Utils/texts.dart';
import 'package:regroup/Utils/Common/CustomTextformfield.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/view_model/getmethod.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/view_model/primaryactivity.dart';
import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart';
class EditCommunity extends StatefulWidget {
const EditCommunity({super.key});
@@ -24,12 +33,19 @@ class EditCommunity extends StatefulWidget {
class _EditCommunityState extends State<EditCommunity> {
TextEditingController communitynameController = TextEditingController();
TextEditingController descriptionController = TextEditingController();
TextEditingController locationcontroller = TextEditingController();
TextEditingController websitelinkcontroller = TextEditingController();
late Future myfuture;
int communityid = Get.arguments['communityid'];
@override
void initState() {
communitynameController.text = 'Active alliance network';
descriptionController.text =
"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer .";
myfuture = Getcommunity().getCommunityeditpage(communityid);
// communitynameController.text = 'Active alliance network';
// descriptionController.text =
// "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer .";
super.initState();
}
@@ -37,6 +53,93 @@ class _EditCommunityState extends State<EditCommunity> {
List<File?> bannerPath = [];
bool isImageAdded = false;
bool isbannerAdded = false;
String? bannerimage;
bool isBannerLoaded = false;
bool isactivityLoaded = false;
Future<void> _loadBannerImage() async {
if (bannerimage!.isNotEmpty) {
File bannerFile = await Helper.networkImageToFile(bannerimage!);
setState(() {
bannerPath.add(bannerFile);
isbannerAdded = true;
isBannerLoaded = true;
});
}
}
bool isValidWebBannerLink(String link) {
RegExp urlRegExp = RegExp(
r"^(http(s)?://)?"
r"((([a-zA-Z0-9-]+)\.)+[a-zA-Z]{2,}|"
r"((\d{1,3}\.){3}\d{1,3}))"
r"(:\d{1,5})?(/([a-zA-Z0-9-._?,'+&%\$#=~])*)?$",
);
return urlRegExp.hasMatch(link);
}
final Map<String, int> _typeCommunityMap = {
'Public': 1,
'Private - Request to join': 2,
'Secret': 3,
};
String _selectedtypecommunity = '';
void _onItemSelected(String value) {
setState(() {
_selectedtypecommunity = value;
print('selected community is $_selectedtypecommunity');
});
}
primaryactlist.InterestModel? abilityModel;
List<primaryactlist.Data> activity = [];
List<String> _activitydrop = [];
String? selectedActivityName;
Future<void> fetchActivitylist() async {
PrimaryActivityListApi abilityListAPI = PrimaryActivityListApi();
ResponseData<dynamic> response = await abilityListAPI.getActivitylistApi();
if (response.status == ResponseStatus.SUCCESS) {
abilityModel = primaryactlist.InterestModel.fromJson(response.data!);
setState(() {
activity = abilityModel!.data ?? [];
_activitydrop =
activity.map((platform) => platform.name.toString()).toList();
});
// Ensure dropdown list updates after setting the initial value
setState(() {
// Set the initial selected activity if data is available
int activitiesXids =
communityeditobj!.data!.communityData!.activityData!.id!;
selectedactivityid = activitiesXids;
selectedActivityName = activity
.firstWhere((item) => item.id == activitiesXids,
orElse: () => activity.first)
.name;
isactivityLoaded = true;
});
log(activity.toString());
} else {
print('Failed to fetch abilities');
}
}
int? selectedactivityid;
void getCatIdFromName(String selectedAbility) {
selectedactivityid = activity
.firstWhere((item) => item.name == selectedAbility,
orElse: () => activity.first)
.id;
print('Selected activity ID is $selectedactivityid');
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -47,261 +150,441 @@ class _EditCommunityState extends State<EditCommunity> {
titleTxt: "Edit community info",
),
resizeToAvoidBottomInset: false,
body: Stack(children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill)),
),
SingleChildScrollView(
child: Column(children: [
sizedBoxHeight(30.h),
Stack(
clipBehavior: Clip.none,
body: FutureBuilder(
future: myfuture,
builder: (ctx, snapshot) {
if (snapshot.data == null) {
return const Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
height: 100.h,
width: 100.w,
decoration: BoxDecoration(
shape: BoxShape.circle,
border:
Border.all(color: Color(0xFF434A53), width: 0.5.w),
Center(
child: CircularProgressIndicator(
color: Color(0xFFC18948),
),
child: Center(
child: filePath.isNotEmpty
? ClipOval(
child: SizedBox.fromSize(
size: Size.fromRadius(50.r),
child: Image.file(
filePath[0]!,
fit: BoxFit.cover,
width: double.infinity,
),
),
)
: Image.asset('assets/images/png/Ellipse 37.png',
fit: BoxFit.cover),
),
),
Positioned(
right: -10,
bottom: 0,
child: InkWell(
onTap: () {
ImageUploadBottomSheet().showModal(
context,
true,
(result) {
var file = File(result);
filePath.add(file);
isImageAdded = true;
setState(() {});
},
);
},
child: Container(
height: 35.h,
width: 35.w,
decoration: BoxDecoration(
color: Color(0xFFD90B2E),
shape: BoxShape.circle,
border: Border.all(
color: Color(0xFFD90B2E), width: 0.5.w)),
child: Center(
child: Image.asset(
'assets/images/png/cameraicon.png',
height: 14.h,
width: 15.w,
),
),
),
))
)
],
),
sizedBoxHeight(25.h),
text16w400_white("Edit community profile picture"),
sizedBoxHeight(30.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text16w400_FCFCFC("Community banner image"),
sizedBoxHeight(16.h),
GestureDetector(
onTap: () {
ImageUploadBottomSheet().showModal(
context,
false,
(result) {
var file = File(result);
);
}
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
return Center(
child: Text(
'${snapshot.error} occured',
style: TextStyle(fontSize: 18.spMin),
),
);
}
}
if (!isBannerLoaded) {
bannerimage =
communityeditobj!.data!.communityData!.communityBannerImage!;
_loadBannerImage(); // Call only if not already loaded
}
communitynameController.text =
communityeditobj!.data!.communityData!.communityName!;
descriptionController.text =
communityeditobj!.data!.communityData!.communityDescription!;
locationcontroller.text =
communityeditobj!.data!.communityData!.communityLocation!;
websitelinkcontroller.text =
communityeditobj!.data!.communityData!.communityDescription!;
var communityType =
communityeditobj!.data!.communityData!.communityTypeData!.name;
if (_selectedtypecommunity.isEmpty) {
_selectedtypecommunity = communityType ?? 'Public';
}
if (!isactivityLoaded) {
fetchActivitylist();
}
bannerPath.add(file);
isbannerAdded = true;
setState(() {});
},
);
},
child: DottedBorder(
strokeWidth: 1,
dashPattern: [7, 4],
borderType: BorderType.RRect,
radius: Radius.circular(14.r),
color: Color(0xFF434A53),
child: commonGlassUI(
borderwidth: 0,
width: double.infinity,
height: 150.h,
borderRadius: BorderRadius.circular( 10.r),
customWidget: bannerPath.isNotEmpty && isbannerAdded
? Stack(children: [
Image.file(
bannerPath[0]!,
fit: BoxFit.cover,
width: double.infinity,
),
Positioned(
right: 5,
bottom: 5,
child: GestureDetector(
onTap: () {
bannerPath.clear();
isbannerAdded = false;
setState(() {});
},
child: Container(
width: 27,
height: 27,
decoration: ShapeDecoration(
color: Color(0xFF7E7E7E),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(5)),
),
child: Icon(
Icons.delete_outline_outlined,
color: Colors.white,
))),
),
])
: Padding(
padding: EdgeInsets.symmetric(vertical: 16.h),
child: Column(
children: [
Image.asset(
"assets/images/png/cameraicon2.png",
height: 36.h,
width: 36.w,
),
sizedBoxHeight(10.h),
text14w400white('Upload banner image'),
sizedBoxHeight(8.h),
SizedBox(
width: 270.w,
child: text10w400_whiteCenter(
"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s"),
),
],
),
),
return Stack(children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill)),
),
SingleChildScrollView(
child: Column(children: [
// sizedBoxHeight(30.h),
Stack(
clipBehavior: Clip.none,
children: [
Container(
height: 100.h,
width: 100.w,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Color(0xFF434A53), width: 0.5.w),
),
child: Center(
child: filePath.isNotEmpty
? ClipOval(
child: SizedBox.fromSize(
size: Size.fromRadius(50.r),
child: filePath.isNotEmpty
? Image.file(
filePath[0]!,
fit: BoxFit.cover,
width: double.infinity,
)
: Image.asset(
'assets/images/png/Ellipse 37.png',
fit: BoxFit.cover),
),
)
: ClipOval(
child: SizedBox.fromSize(
size: Size.fromRadius(50.r),
child: communityeditobj!
.data!
.communityData!
.communityProfilePhoto!
.isNotEmpty
? Image.network(
communityeditobj!
.data!
.communityData!
.communityProfilePhoto!,
fit: BoxFit.cover,
errorBuilder:
(context, error, stackTrace) {
// Error handling when image fails to load
return Image.asset(
"assets/images/png/Ellipse 37.png",
fit: BoxFit.cover,
);
},
)
: Image.asset(
'assets/images/png/Ellipse 37.png',
fit: BoxFit.cover),
),
)),
),
),
sizedBoxHeight(16.w),
commonGlassUI(
width: double.infinity,
height: 60.h,
borderRadius: BorderRadius.circular( 10.r),
customWidget: Center(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(children: [
Container(
height: 40.h,
width: 40.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.r)),
Positioned(
right: -10,
bottom: 0,
child: InkWell(
onTap: () {
ImageUploadBottomSheet().showModal(
context,
false,
(result) {
if (result != null && result.isNotEmpty) {
var file = File(result);
filePath.cast();
filePath.add(file);
isImageAdded = true;
setState(() {});
if (Platform.isAndroid) {
Get.back();
}
} else {
filePath.clear();
isImageAdded = false;
setState(() {});
}
},
);
},
child: Container(
height: 35.h,
width: 35.w,
decoration: BoxDecoration(
color: Color(0xFFD90B2E),
shape: BoxShape.circle,
border: Border.all(
color: Color(0xFFD90B2E), width: 0.5.w)),
child: Center(
child: Image.asset(
"assets/images/png/img2.png",
fit: BoxFit.cover,
'assets/images/png/cameraicon.png',
height: 14.h,
width: 15.w,
),
),
sizedBoxWidth(8.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
text14400white("group1.png"),
sizedBoxHeight(2.h),
text12w400_FCFCFC_blur("10 kb")
],
),
Spacer(),
Image.asset(
'assets/images/png/cancelicon.png',
height: 20.h,
width: 20.w,
)
]),
),
))
],
),
sizedBoxHeight(25.h),
text16w400_white("Edit community profile picture"),
sizedBoxHeight(30.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text16w400_FCFCFC("Community banner image"),
sizedBoxHeight(16.h),
DottedBorder(
strokeWidth: 1,
dashPattern: [7, 4],
borderType: BorderType.RRect,
radius: Radius.circular(14.r),
color: Color(0xFF434A53),
child: commonGlassUI(
borderwidth: 0,
width: double.infinity,
height: 150.h,
borderRadius: BorderRadius.circular(10.r),
customWidget: bannerPath.isNotEmpty && isbannerAdded
? Stack(
children: [
Image.file(
bannerPath[0]!,
fit: BoxFit.cover,
width: double.infinity,
),
// Positioned(
// right: 5,
// bottom: 5,
// child: InkWell(
// onTap: () {
// setState(() {
// bannerPath.clear();
// isbannerAdded = false;
// });
// },
// child: Container(
// width: 27,
// height: 27,
// decoration: ShapeDecoration(
// color: Color(0xFF7E7E7E),
// shape: RoundedRectangleBorder(
// borderRadius:
// BorderRadius.circular(5),
// ),
// ),
// child: Icon(
// Icons.delete_outline_outlined,
// color: Colors.white,
// ),
// ),
// ),
// ),
],
)
: GestureDetector(
onTap: () {
ImageUploadBottomSheet().showModal(
context,
false,
(result) {
if (result != null &&
result.isNotEmpty) {
var file = File(result);
// Check if the file size exceeds 10 MB
int fileSizeInBytes =
file.lengthSync();
double fileSizeInMB =
fileSizeInBytes / (1024 * 1024);
if (fileSizeInMB > 10) {
// Show toast message if the file size exceeds 10 MB
utils.showToast(
"The selected file is too large. Max file size is 10 MB.");
} else {
// Clear the existing image and add the new one
bannerPath.clear();
bannerPath.add(file);
isbannerAdded = true;
setState(() {});
}
} else {
// Handle case where no image is selected
bannerPath.clear();
isbannerAdded = false;
setState(() {});
}
if (Platform.isAndroid) {
Get.back();
}
},
);
},
child: Padding(
padding:
EdgeInsets.symmetric(vertical: 16.h),
child: Column(
children: [
Image.asset(
"assets/images/png/cameraicon2.png",
height: 36.h,
width: 36.w,
),
SizedBox(height: 10.h),
text14w400white(
'Upload banner image'),
SizedBox(height: 8.h),
SizedBox(
width: 270.w,
child: text8w400_8A8A8A(
"Allowed file extensions: jpg, png, gif Max file size: 10 MB"),
),
],
),
),
),
),
),
borderwidth: 1),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Community name"),
sizedBoxHeight(14.h),
CustomTextFormField(
textEditingController: communitynameController,
validator: (val) {
if (val == null || val.isEmpty) {
return 'Enter Community name';
}
return null;
},
sizedBoxHeight(16.w),
bannerPath.isNotEmpty && isbannerAdded
? commonGlassUI(
width: double.infinity,
height: 60.h,
borderRadius: BorderRadius.circular(10.r),
customWidget: Center(
child: Padding(
padding:
EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
// Conditionally render image or placeholder
if (bannerPath.isNotEmpty &&
isbannerAdded)
Container(
height: 40.h,
width: 40.w,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(5.r),
),
child: Image.file(
bannerPath[0]!,
fit: BoxFit.cover,
width: double.infinity,
),
)
else
Container(
height: 40.h,
width: 40.w,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(5.r),
),
child: Image.asset(
'assets/images/png/img2.png',
fit: BoxFit.cover,
width: double.infinity,
),
),
SizedBox(width: 8.w),
Spacer(),
InkWell(
onTap: () {
setState(() {
// Clear the image and update the state
bannerPath.clear();
isbannerAdded = false;
});
// Optionally debug state values
print("bannerPath: $bannerPath");
print(
"isbannerAdded: $isbannerAdded");
},
child: Image.asset(
'assets/images/png/cancelicon.png',
height: 20.h,
width: 20.w,
),
),
],
),
),
),
borderwidth: 1,
)
: SizedBox(),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Community name*"),
sizedBoxHeight(14.h),
CustomTextFormField(
textEditingController: communitynameController,
validator: (val) {
if (val == null || val.isEmpty) {
return 'Enter Community name';
}
return null;
},
hintText: 'Enter type of community',
),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Group description"),
sizedBoxHeight(14.h),
CustomTextFormField(
// maxlines: 3,
hintText: 'Enter description',
textEditingController: descriptionController,
),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Type of community*"),
sizedBoxHeight(14.h),
CustomDropDownRadio(
header: "",
title: "",
listData: _typeCommunityMap.keys.toList(),
onItemSelected: _onItemSelected,
leadingImage: SizedBox(),
initialSelectedValue: _selectedtypecommunity,
),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Location*"),
sizedBoxHeight(14.h),
CustomTextFormField(
textEditingController: locationcontroller,
inputFormatters: [
RemoveEmojiInputFormatter(),
// FilteringTextInputFormatter.allow(RegExp('[a-zA-Z ]'))
],
hintText: 'Enter location',
validator: (val) {
if (val == null || val.isEmpty) {
return 'Enter location';
}
return null;
},
),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Primary activity*"),
sizedBoxHeight(14.h),
CustomDropDownRadio(
showOtherOption: true,
header: "",
title: "",
listData: _activitydrop,
onItemSelected: getCatIdFromName,
leadingImage: SizedBox(),
initialSelectedValue: selectedActivityName.toString(),
),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Website link"),
sizedBoxHeight(14.h),
CustomTextFormField(
textEditingController: websitelinkcontroller,
validator: (val) {
if (!isValidWebBannerLink(val)) {
return 'Please enter a valid web banner link.';
}
return null;
},
hintText: 'Enter website link',
),
sizedBoxHeight(25.h),
sizedBoxHeight(50.h),
CustomButton(text: 'Save changes', onPressed: () {}),
sizedBoxHeight(50.h),
],
),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Group description"),
sizedBoxHeight(14.h),
CustomTextFormField2(
maxlines: 3,
textEditingController: descriptionController,
),
text16w400_FCFCFC("Type of community"),
sizedBoxHeight(14.h),
CustomDropDownRadio(
header: "",
title: "",
listData: ["Public", "Private - Request to join"],
onItemSelected: (p0) {},
leadingImage: SizedBox()),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Location*"),
sizedBoxHeight(14.h),
CustomDropDownRadio(
header: "",
title: "",
listData: ["Public", "Private", "Secret"],
onItemSelected: (p0) {},
leadingImage: SizedBox()),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Primary activity*"),
sizedBoxHeight(14.h),
CustomDropDownRadio(
showOtherOption: true,
header: "",
title: "",
listData: ["Sports", "Hobby"],
onItemSelected: (p0) {},
leadingImage: SizedBox()),
sizedBoxHeight(50.h),
CustomButton(text: 'Save changes', onPressed: () {}),
sizedBoxHeight(50.h),
],
),
)
]),
)
]),
)
]));
]);
},
));
}
}

View File

@@ -200,18 +200,18 @@ class _CommunityMembersState extends State<CommunityMembers> {
CrossAxisAlignment.start,
children: [
mainFollowersData.iamPrincipal!
.userName ==
.fullName ==
null ||
mainFollowersData
.iamPrincipal!
.userName!
.fullName!
.isEmpty ==
true
? text16w400_FCFCFC("Regroup")
: text16w400_FCFCFC(
mainFollowersData
.iamPrincipal!
.userName!),
.fullName!),
sizedBoxHeight(4.h),
mainFollowersData.iamPrincipal!
.userName ==

View File

@@ -51,6 +51,7 @@ class IamPrincipal {
required this.id,
required this.principalTypeXid,
required this.userName,
required this.fullName,
required this.profilePhoto,
required this.isUserPinned,
});
@@ -58,6 +59,7 @@ class IamPrincipal {
final int? id;
final int? principalTypeXid;
final String? userName;
final String? fullName;
final String? profilePhoto;
final bool? isUserPinned;
@@ -66,6 +68,7 @@ class IamPrincipal {
id: json["id"],
principalTypeXid: json["principal_type_xid"],
userName: json["user_name"],
fullName: json["full_name"],
profilePhoto: json["profile_photo"],
isUserPinned: json["is_user_pinned"],
);

View File

@@ -0,0 +1,185 @@
class CommunityinfopageEditModel {
CommunityinfopageEditModel({
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 CommunityinfopageEditModel.fromJson(Map<String, dynamic> json){
return CommunityinfopageEditModel(
status: json["status"],
statusCode: json["status_code"],
message: json["message"],
data: json["data"] == null ? null : Data.fromJson(json["data"]),
);
}
}
class Data {
Data({
required this.typesOfCommunity,
required this.communityData,
});
final List<TypesOfCommunity> typesOfCommunity;
final CommunityData? communityData;
factory Data.fromJson(Map<String, dynamic> json){
return Data(
typesOfCommunity: json["typesOfCommunity"] == null ? [] : List<TypesOfCommunity>.from(json["typesOfCommunity"]!.map((x) => TypesOfCommunity.fromJson(x))),
communityData: json["communityData"] == null ? null : CommunityData.fromJson(json["communityData"]),
);
}
}
class CommunityData {
CommunityData({
required this.id,
required this.communityProfilePhoto,
required this.communityBannerImage,
required this.communityName,
required this.communityLocation,
required this.communityDescription,
required this.communityTypeXid,
required this.activityXid,
required this.isActive,
required this.totalGroup,
required this.totalAnnouncements,
required this.activityData,
required this.communityTypeData,
});
final int? id;
final String? communityProfilePhoto;
final String? communityBannerImage;
final String? communityName;
final String? communityLocation;
final String? communityDescription;
final int? communityTypeXid;
final int? activityXid;
final int? isActive;
final int? totalGroup;
final int? totalAnnouncements;
final ActivityData? activityData;
final CommunityTypeData? communityTypeData;
factory CommunityData.fromJson(Map<String, dynamic> json){
return CommunityData(
id: json["id"],
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"],
activityXid: json["activity_xid"],
isActive: json["is_active"],
totalGroup: json["total_group"],
totalAnnouncements: json["total_announcements"],
activityData: json["activity_data"] == null ? null : ActivityData.fromJson(json["activity_data"]),
communityTypeData: json["community_type_data"] == null ? null : CommunityTypeData.fromJson(json["community_type_data"]),
);
}
}
class ActivityData {
ActivityData({
required this.id,
required this.title,
required this.description,
required this.image,
required this.deletedAt,
required this.createdAt,
required this.updatedAt,
});
final int? id;
final String? title;
final String? description;
final String? image;
final dynamic deletedAt;
final DateTime? createdAt;
final DateTime? updatedAt;
factory ActivityData.fromJson(Map<String, dynamic> json){
return ActivityData(
id: json["id"],
title: json["title"],
description: json["description"],
image: json["image"],
deletedAt: json["deleted_at"],
createdAt: DateTime.tryParse(json["created_at"] ?? ""),
updatedAt: DateTime.tryParse(json["updated_at"] ?? ""),
);
}
}
class CommunityTypeData {
CommunityTypeData({
required this.id,
required this.name,
required this.image,
required this.description,
required this.isActive,
required this.createdBy,
required this.modifiedBy,
required this.deletedAt,
required this.createdAt,
required this.updatedAt,
});
final int? id;
final String? name;
final dynamic image;
final dynamic description;
final int? isActive;
final dynamic createdBy;
final dynamic modifiedBy;
final dynamic deletedAt;
final dynamic createdAt;
final dynamic updatedAt;
factory CommunityTypeData.fromJson(Map<String, dynamic> json){
return CommunityTypeData(
id: json["id"],
name: json["name"],
image: json["image"],
description: json["description"],
isActive: json["is_active"],
createdBy: json["created_by"],
modifiedBy: json["modified_by"],
deletedAt: json["deleted_at"],
createdAt: json["created_at"],
updatedAt: json["updated_at"],
);
}
}
class TypesOfCommunity {
TypesOfCommunity({
required this.id,
required this.name,
});
final int? id;
final String? name;
factory TypesOfCommunity.fromJson(Map<String, dynamic> json){
return TypesOfCommunity(
id: json["id"],
name: json["name"],
);
}
}

View File

@@ -196,8 +196,8 @@ class _NewCommunityState extends State<NewCommunity> {
}
} else {
// Handle case where no image is selected
bannerPath.clear();
isbannerAdded = false;
filePath.clear();
isImageAdded = false;
setState(() {});
}
},

View File

@@ -143,7 +143,9 @@ class _CommunityDetailsState extends State<CommunityDetails> {
PopupMenuDivider(),
PopupMenuItem(
onTap: () {
Get.toNamed(RouteName.communitysetting);
Get.toNamed(RouteName.communitysetting,arguments: {
'communityid' : CommunityId,
});
},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8.w),

View File

@@ -6,11 +6,13 @@ import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Common/controller/data/network/network_api.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/Model/communityMebersModel.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/Model/communityaddgroupsModel.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/Model/communityeditpageModel.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/Model/communitygroupsModel.dart';
CommunityAddgroupsModel? communityaddgroupobj;
CommunitygroupsModel? communitygroupspobj;
CommunityMembersModel? communitymembersobj;
CommunityinfopageEditModel? communityeditobj;
@@ -59,4 +61,16 @@ class Getcommunity {
return response;
}
Future<ResponseData<dynamic>> getCommunityeditpage(updata) async {
final response = await NetworkApiServices().getApi(
"${ApiUrls.geteditcommunity}?community_id=$updata",
// optionalpar: false
);
if (response.status == ResponseStatus.SUCCESS) {
communityeditobj = CommunityinfopageEditModel.fromJson(response.data);
log(communityeditobj!.data.toString());
}
return response;
}
}