fixes for pages in community details and my communities

This commit is contained in:
Shubhamshirva
2024-08-23 12:53:34 +05:30
parent 0f3b80ce1d
commit dff6fae483
2 changed files with 204 additions and 171 deletions

View File

@@ -110,190 +110,183 @@ class _CommunityDetailsState extends State<CommunityDetails> {
offset: const Offset(0, 40),
color: const Color(0xFF222935),
tooltip: "",
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8.w),
child: Row(
children: [
text14w400white("Invite"),
const Spacer(),
Image.asset(
"assets/images/png/uiw_user-add.png",
height: 15.h,
width: 15.w,
)
],
),
itemBuilder: (BuildContext context) {
bool isMember =
comdetailobj?.data?.userLinkInCommunity?.userTypeXid?.name == "Member";
// => <PopupMenuEntry>
return <PopupMenuEntry<Object>>[
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8.w),
child: Row(
children: [
text14w400white("Invite"),
const Spacer(),
Image.asset(
"assets/images/png/uiw_user-add.png",
height: 15.h,
width: 15.w,
)
],
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8.w),
child: Row(
children: [
text14w400white("Share"),
const Spacer(),
Image.asset(
"assets/images/png/share.png",
height: 20.h,
width: 20.w,
)
],
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8.w),
child: Row(
children: [
text14w400white("Share"),
const Spacer(),
Image.asset(
"assets/images/png/share.png",
height: 20.h,
width: 20.w,
)
],
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8.w),
child: Row(
children: [
text14w400white("Search"),
const Spacer(),
Image.asset(
"assets/images/png/Frame 58575.png",
height: 18.h,
width: 18.w,
)
],
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8.w),
child: Row(
children: [
text14w400white("Search"),
const Spacer(),
Image.asset(
"assets/images/png/Frame 58575.png",
height: 18.h,
width: 18.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () async {
Map<String, dynamic> updata = {
"manage_community_xid": CommunityId,
};
final data = await CommunityDetail()
.postMuteNotification(updata);
if (data.status == ResponseStatus.SUCCESS) {
print("success");
setState(() {});
await CommunityDetail()
.getCommunityDetail(CommunityId);
// Convert int to bool, toggle, and then convert back to int
bool isMuted = ismute == 1;
isMuted = !isMuted;
ismute = isMuted ? 1 : 0;
return utils.showToast(data.message);
} else {
Get.back();
print("Failed");
return utils.showToast(data.message);
}
},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8.w),
child: Row(
children: [
ismute == 1
? text14w400white("Unmute notification")
: text14w400white("Mute notification"),
const Spacer(),
ismute == 1
? Image.asset(
"assets/images/png/Black1233.png",
height: 16.h,
width: 16.w,
)
: Image.asset(
"assets/images/png/Black1233.png",
height: 16.h,
width: 16.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () async {
await pinunpinCommunity(
comdetailobj!.data!.id.toString());
},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
iscommunitypin == true
? Text(
'Unpin',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
)
: Text(
'Pin',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
),
const Spacer(),
iscommunitypin == true
? Image.asset(
"assets/images/png/PinnedIcon.png",
height: 25.h,
width: 25.w,
)
: Image.asset(
"assets/images/png/f7_pin-fill (2).png",
height: 25.h,
width: 25.w,
)
],
),
),
),
// if (comdetailobj!.data!.accessType!.name == "Member")
// const PopupMenuDivider(),
// if (comdetailobj!.data!.accessType!.name == "Member")
if (!isMember) ...[
const PopupMenuDivider(),
PopupMenuItem(
onTap: () async {
Map<String, dynamic> updata = {
"manage_community_xid": CommunityId,
};
final data = await CommunityDetail()
.postMuteNotification(updata);
if (data.status == ResponseStatus.SUCCESS) {
print("success");
setState(() {});
await CommunityDetail()
.getCommunityDetail(CommunityId);
// Convert int to bool, toggle, and then convert back to int
bool isMuted = ismute == 1;
isMuted = !isMuted;
ismute = isMuted ? 1 : 0;
return utils.showToast(data.message);
} else {
Get.back();
print("Failed");
return utils.showToast(data.message);
var result = await Get.toNamed(
RouteName.communitysetting,
arguments: {
'communityid': CommunityId,
});
if (result != null && result) {
refreshData();
print("Updating community details...");
}
},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8.w),
child: Row(
children: [
ismute == 1
? text14w400white("Unmute notification")
: text14w400white("Mute notification"),
const Spacer(),
ismute == 1
? Image.asset(
"assets/images/png/Black1233.png",
height: 16.h,
width: 16.w,
)
: Image.asset(
"assets/images/png/Black1233.png",
height: 16.h,
width: 16.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () async {
await pinunpinCommunity(
comdetailobj!.data!.id.toString());
},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
iscommunitypin == true
? Text(
'Unpin',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
)
: Text(
'Pin',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
),
const Spacer(),
iscommunitypin == true
? Image.asset(
"assets/images/png/PinnedIcon.png",
height: 25.h,
width: 25.w,
)
: Image.asset(
"assets/images/png/f7_pin-fill (2).png",
height: 25.h,
width: 25.w,
)
],
),
),
),
if (comdetailobj!.data!.accessType!.name == "Member")
const PopupMenuDivider(),
if (comdetailobj!.data!.accessType!.name == "Member")
PopupMenuItem(
onTap: () {
Get.toNamed(RouteName.communitysetting, arguments: {
'communityid': CommunityId,
});
},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8.w),
child: Row(
children: [
text14w400white("Edit community"),
const Spacer(),
Image.asset(
"assets/images/png/setting2.png",
height: 18.h,
width: 18.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {
leaveCommunity();
},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8.w),
child: Row(
children: [
text14w400white("Leave community"),
text14w400white("Edit community"),
const Spacer(),
Image.asset(
"assets/images/png/logout 1 (traced).png",
"assets/images/png/setting2.png",
height: 18.h,
width: 18.w,
)
@@ -302,6 +295,28 @@ class _CommunityDetailsState extends State<CommunityDetails> {
),
),
],
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {
leaveCommunity();
},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8.w),
child: Row(
children: [
text14w400white("Leave community"),
const 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: 20.h,

View File

@@ -96,6 +96,11 @@ class _MyCommunityState extends State<MyCommunity> {
}
}
void refreshData() {
setState(() {
myfuture = MyCommunityAPI().getMyCommunity();
});}
@override
Widget build(BuildContext context) {
return WillPopScope(
@@ -113,8 +118,15 @@ class _MyCommunityState extends State<MyCommunity> {
customActionWidget: Row(
children: [
GestureDetector(
onTap: () {
Get.toNamed(RouteName.newcommunity);
onTap: () async {
var result = await Get.toNamed(RouteName.newcommunity);
if (result != null && result) {
refreshData();
// CommunityDetail().getCommunityDetail(CommunityId);
print("Updating community details...");
// setState(() {});
}
},
child: Container(
height: 30.h,
@@ -250,10 +262,16 @@ class _MyCommunityState extends State<MyCommunity> {
return Padding(
padding: EdgeInsets.only(bottom: 25.h),
child: GestureDetector(
onTap: () {
Get.toNamed(RouteName.communityDetails, arguments: {
onTap: () async {
var result = await Get.toNamed(RouteName.communityDetails, arguments: {
"CommunityID": joinnedComData.manageCommunityXid
});
if (result != null && result) {
refreshData();
print("Updating community details...");
}
},
child: commonGlassUI(
borderwidth: 0.9,