diff --git a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart index 0149a04..94cb427 100644 --- a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart +++ b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart @@ -110,190 +110,183 @@ class _CommunityDetailsState extends State { offset: const Offset(0, 40), color: const Color(0xFF222935), tooltip: "", - itemBuilder: (BuildContext context) => [ - 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"; + // => + return >[ + 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 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 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 { ), ), ], + 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, diff --git a/lib/sidemenu/Community/MyCommunity/View/MyCommunity.dart b/lib/sidemenu/Community/MyCommunity/View/MyCommunity.dart index 7ce9005..5055007 100644 --- a/lib/sidemenu/Community/MyCommunity/View/MyCommunity.dart +++ b/lib/sidemenu/Community/MyCommunity/View/MyCommunity.dart @@ -96,6 +96,11 @@ class _MyCommunityState extends State { } } + void refreshData() { + setState(() { + myfuture = MyCommunityAPI().getMyCommunity(); + });} + @override Widget build(BuildContext context) { return WillPopScope( @@ -113,8 +118,15 @@ class _MyCommunityState extends State { 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 { 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,