diff --git a/assets/images/png/Vector 8.png b/assets/images/png/Vector 8.png new file mode 100644 index 0000000..4abcecd Binary files /dev/null and b/assets/images/png/Vector 8.png differ diff --git a/lib/Common/CommonWidget.dart b/lib/Common/CommonWidget.dart index 3ad8a7e..c17bee3 100644 --- a/lib/Common/CommonWidget.dart +++ b/lib/Common/CommonWidget.dart @@ -185,7 +185,8 @@ Future showCustomTimePicker(BuildContext context, onSurface: Colors.white, ), textTheme: Theme.of(context).textTheme.copyWith( - titleLarge: const TextStyle(color: Colors.blue), // Change the title color + titleLarge: + const TextStyle(color: Colors.blue), // Change the title color ), textButtonTheme: TextButtonThemeData( style: TextButton.styleFrom( @@ -247,7 +248,8 @@ Widget stackContainers({ width: 30, decoration: BoxDecoration( shape: BoxShape.circle, - border: Border.all(color: const Color(0xFF2C3742), width: 1), + border: Border.all( + color: const Color(0xFF2C3742), width: 1), ), child: CircleAvatar( foregroundImage: AssetImage(containerImages[index]), @@ -280,27 +282,34 @@ Widget stackContainersGroups({ Stack( clipBehavior: Clip.none, children: [ - Container( - height: 30, - width: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: const Color(0xFFD90B2E), - border: Border.all(color: const Color(0xFF2C3742), width: 1), - ), - child: Center( - child: Text( - remainingCount > 0 ? '+$remainingCount' : '', - style: const TextStyle( - color: Colors.white, - fontWeight: FontWeight.w400, - fontSize: 8, + containerImages.length > maxImagesToShow + ? Container( + height: 30.h, + width: 30.w, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: const Color(0xFFD90B2E), + border: + Border.all(color: const Color(0xFF2C3742), width: 1), + ), + child: Center( + child: Text( + // remainingCount > 0 ? '+$remainingCount' : '', + number, + style: const TextStyle( + color: Colors.white, + fontWeight: FontWeight.w400, + fontSize: 8, + ), + ), + ), + ) + : Container( + height: 30.h, + width: 30.w, ), - ), - ), - ), Positioned( - left: 22.w, + left: containerImages.length > maxImagesToShow ? 22.w : 0.w, child: SizedBox( height: 30, width: 30 * maxImagesToShow.toDouble(), @@ -314,7 +323,8 @@ Widget stackContainersGroups({ width: 30, decoration: BoxDecoration( shape: BoxShape.circle, - border: Border.all(color: const Color(0xFF2C3742), width: 1), + border: Border.all( + color: const Color(0xFF2C3742), width: 1), ), child: CircleAvatar( backgroundImage: NetworkImage(imagesToShow[index]), @@ -395,7 +405,8 @@ Widget stackReaction({ 1, ], ), - border: Border.all(color: const Color(0xFF1E3A46), width: 1.71)), + border: Border.all( + color: const Color(0xFF1E3A46), width: 1.71)), child: Center( child: Image.asset( containerImages[index], diff --git a/lib/Common/api_urls.dart b/lib/Common/api_urls.dart index 482250f..61cb339 100644 --- a/lib/Common/api_urls.dart +++ b/lib/Common/api_urls.dart @@ -84,6 +84,20 @@ class ApiUrls { static const getmyjoinedgroups = "${baseUrl}my-joined-groups"; + static const getmycommunity = "${baseUrl}fetch-my-communities"; + + static const getrequestedcommunity = + "${baseUrl}fetch-joining-request-for-community"; + + static const getInvitecommunity = "${baseUrl}fetch-all-invite"; + + static const postcancelrequest = "${baseUrl}cancel-request-of-community"; + + static const postacceptinvite = "${baseUrl}accept-invite-to-join-community"; + + static const postrejectinvite = "${baseUrl}reject-invite-to-join-community"; + + static const getusercertificates = "${baseUrl}my-certificates"; static const postnotification = "${baseUrl}update-notification-settings"; @@ -128,7 +142,6 @@ class ApiUrls { static const postusertag = "${baseUrl}pin-unpin"; - //comments static const getComments = "${baseUrl}fetch-comment-with-replied-comment"; static const storeComments = "${baseUrl}store-comment"; @@ -136,7 +149,7 @@ class ApiUrls { static const deleteComments = "${baseUrl}delete-comment"; static const deleteRepliesComments = "${baseUrl}delete-reply-on-comment"; - static const getLikeicons= "${baseUrl}fetch-like-icons"; + static const getLikeicons = "${baseUrl}fetch-like-icons"; static const postLike = "${baseUrl}like-post"; @@ -145,8 +158,6 @@ class ApiUrls { static const postusersave = "${baseUrl}save-post"; static const getpostdetail = "${baseUrl}fetch-single-post"; - - static const getpopularTagsdetails = "${baseUrl}fetch-popular-post"; static const postcreatecommunity = "${baseUrl}create-community"; diff --git a/lib/Main_Screens/Community/View/CommunityDetail.dart b/lib/Main_Screens/Community/View/CommunityDetail.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart b/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart index 293a8a0..a142fcb 100644 --- a/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart +++ b/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart @@ -2,7 +2,6 @@ import 'package:get/get.dart'; import 'package:regroup/Main_Screens/Community/Model/CommonDatumObjModel.dart'; import 'package:regroup/Main_Screens/Community/Model/FeedPostModel.dart'; import 'package:regroup/Main_Screens/Community/ViewModel/LatestPost.dart'; -import 'package:regroup/Main_Screens/Community/ViewModel/PopularPost.dart'; List combinedListGlobal = []; CommonDatumObjModel? commonobjmodel; diff --git a/lib/Utils/texts.dart b/lib/Utils/texts.dart index dc44896..de9d751 100644 --- a/lib/Utils/texts.dart +++ b/lib/Utils/texts.dart @@ -428,6 +428,7 @@ Widget text10400white(String text) { fontWeight: FontWeight.w400), ); } + Widget text9400white(String text) { return Text( text, @@ -473,6 +474,20 @@ Widget text16w700_FCFCFC(String text, {TextAlign? textAlign}) { ); } +Widget text16w700_FCFCFC_line(String text, {TextAlign? textAlign}) { + return Text( + text, + textAlign: textAlign, + style: TextStyle( + decoration: TextDecoration.underline, + decorationColor: Colors.white, + fontSize: 16.sp, + color: const Color(0xFFFCFCFC), + fontFamily: 'Helvetica', + fontWeight: FontWeight.w700), + ); +} + Widget text16w700_D90B2E(String text, {TextDecoration? decoration}) { return Text( text, @@ -485,6 +500,7 @@ Widget text16w700_D90B2E(String text, {TextDecoration? decoration}) { fontWeight: FontWeight.w700), ); } + Widget text14w400_D90B2E(String text, {TextDecoration? decoration}) { return Text( text, @@ -567,6 +583,7 @@ Widget text12w400_FCFCFC(String text) { fontWeight: FontWeight.w400), ); } + Widget text12w400_8E8E8E(String text) { return Text( text, @@ -724,6 +741,18 @@ Widget text14w400_FCFCFC(String text, {TextAlign? textAlign}) { ); } +Widget text13w400_FCFCFC(String text, {TextAlign? textAlign}) { + return Text( + text, + textAlign: textAlign, + style: TextStyle( + fontSize: 13.sp, + color: const Color(0xFFFCFCFC), + fontFamily: 'Helvetica', + fontWeight: FontWeight.w400), + ); +} + Widget text14w400_FCFCFCblur(String text) { return Text( text, diff --git a/lib/resources/routes/route_name.dart b/lib/resources/routes/route_name.dart index de8df67..3b84e82 100644 --- a/lib/resources/routes/route_name.dart +++ b/lib/resources/routes/route_name.dart @@ -38,6 +38,8 @@ class RouteName { static const String communityInfo = '/communityInfo'; static const String announcement = '/announcement'; static const String watchlist = '/watchlist'; + static const String requestscreen = '/requestscreen'; + static const String group = '/group'; static const String communitysetting = '/communitysetting'; diff --git a/lib/resources/routes/routes.dart b/lib/resources/routes/routes.dart index e779448..4f164b4 100644 --- a/lib/resources/routes/routes.dart +++ b/lib/resources/routes/routes.dart @@ -75,6 +75,7 @@ import 'package:regroup/sidemenu/Community/Announcements/ManageMembers.dart'; import 'package:regroup/sidemenu/Community/Announcements/NewAnnouncement/NewAnnounceent.dart'; import 'package:regroup/sidemenu/Community/MyCommunity/AddGroups.dart'; import 'package:regroup/sidemenu/Community/MyCommunity/NewCommunity.dart'; +import 'package:regroup/sidemenu/Community/MyCommunity/View/RequestsScreen.dart'; import 'package:regroup/sidemenu/Community/Watchlist.dart'; import 'package:regroup/Login/View/loginscreen.dart'; @@ -536,5 +537,10 @@ class AppRoutes { name: RouteName.viewalluserspinned, page: () => const Viewtusertags(), ), + GetPage( + name: RouteName.requestscreen, + page: () => const RequestsScreen(), + ), + ]; } diff --git a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart index 505b58e..94f998b 100644 --- a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart +++ b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart @@ -19,6 +19,15 @@ class CommunityDetails extends StatefulWidget { } class _CommunityDetailsState extends State { + bool? additionalContent = false; + var CommunityId; + @override + void initState() { + // TODO: implement initState + CommunityId = Get.arguments["CommunityID"]; + super.initState(); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -213,7 +222,7 @@ class _CommunityDetailsState extends State { commonGlassUI( width: 35.w, height: 35.h, - borderRadius: BorderRadius.circular( 100), + borderRadius: BorderRadius.circular(100), opacity1: 0.24, opacity2: 0.24, customWidget: Center( @@ -227,75 +236,147 @@ class _CommunityDetailsState extends State { text16w400_FCFCFCblur("Public"), ], ), - 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, - ), - ]), - ], - ), + 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, ), - borderwidth: 1), + ) + ], ), - sizedBoxHeight(20.h), + 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), + ], + ), + ], + ), + 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.announcement); @@ -303,7 +384,7 @@ class _CommunityDetailsState extends State { child: commonGlassUI( width: double.infinity, height: 51.h, - borderRadius: BorderRadius.circular( 10.r), + borderRadius: BorderRadius.circular(10.r), customWidget: Padding( padding: EdgeInsets.symmetric(horizontal: 16.w), child: Column( @@ -604,7 +685,7 @@ class _CommunityDetailsState extends State { height: 30.h, opacity1: 0.05, opacity2: 0.06, - borderRadius: BorderRadius.circular( 100), + borderRadius: BorderRadius.circular(100), customWidget: Center( child: Image.asset( 'assets/images/png/Frame 1000004088.png', @@ -620,7 +701,7 @@ class _CommunityDetailsState extends State { borderwidth: 0.43, width: 30.w, height: 30.h, - borderRadius: BorderRadius.circular( 100), + borderRadius: BorderRadius.circular(100), opacity1: 0.05, opacity2: 0.06, customWidget: Center( @@ -757,7 +838,7 @@ class _CommunityDetailsState extends State { borderwidth: 1, width: 100.w, height: 30.h, - borderRadius: BorderRadius.circular( 30.r), + borderRadius: BorderRadius.circular(30.r), borderColor: Color(0xFFD90B2E), customWidget: Padding( padding: EdgeInsets.symmetric(horizontal: 10.w), diff --git a/lib/sidemenu/Community/MyCommunity/View/MyCommunity.dart b/lib/sidemenu/Community/MyCommunity/View/MyCommunity.dart index c51834e..2374dff 100644 --- a/lib/sidemenu/Community/MyCommunity/View/MyCommunity.dart +++ b/lib/sidemenu/Community/MyCommunity/View/MyCommunity.dart @@ -1,4 +1,6 @@ +import 'package:flutter/cupertino.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'; @@ -8,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/view_model/getMyCommunity.dart'; class MyCommunity extends StatefulWidget { const MyCommunity({super.key}); @@ -57,96 +60,452 @@ class _MyCommunityState extends State { } } + late Future myfuture; + + @override + void initState() { + // TODO: implement initState + myfuture = MyCommunityAPI().getMyCommunity(); + super.initState(); + } + @override Widget build(BuildContext context) { return Scaffold( - // key: _scaffoldKey1, - backgroundColor: Color(0xFF222935), - extendBody: true, - resizeToAvoidBottomInset: false, - appBar: CommonAppbar( - titleTxt: "My Communities", - customActionWidget: Row( - children: [ - GestureDetector( - onTap: () { - Get.toNamed(RouteName.newcommunity); - }, - child: Container( - height: 30.h, - width: 30.w, - decoration: BoxDecoration( - color: Color(0xFFD90B2E), - boxShadow: [ - BoxShadow( - color: Color(0x40000000), - offset: Offset(0, 6), - blurRadius: 8, - spreadRadius: 0, - ), - ], - shape: BoxShape.circle), - child: Icon( - Icons.add, - color: Colors.white, - ), + // key: _scaffoldKey1, + backgroundColor: const Color(0xFF222935), + extendBody: true, + resizeToAvoidBottomInset: false, + appBar: CommonAppbar( + titleTxt: "My Communities", + customActionWidget: Row( + children: [ + GestureDetector( + onTap: () { + Get.toNamed(RouteName.newcommunity); + }, + child: Container( + height: 30.h, + width: 30.w, + decoration: const BoxDecoration( + color: Color(0xFFD90B2E), + boxShadow: [ + BoxShadow( + color: Color(0x40000000), + offset: Offset(0, 6), + blurRadius: 8, + spreadRadius: 0, + ), + ], + shape: BoxShape.circle), + child: const Icon( + Icons.add, + color: Colors.white, ), ), - sizedBoxWidth(12.w), - Image.asset( - "assets/images/png/Frame 9.png", - height: 22.h, - width: 22.w, - ) - ], - ), + ), + sizedBoxWidth(12.w), + Image.asset( + "assets/images/png/Frame 9.png", + height: 22.h, + width: 22.w, + ) + ], ), - body: 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.w), - child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - text18w700_FCFCFC("Joined communities"), - sizedBoxHeight(15.h), - Column( - children: - List.generate(JoinedcommunityData.length, (index) { - return communityCard( - ontap: () { - Get.toNamed(RouteName.communityDetails); - }, - imagepath: JoinedcommunityData[index] - ['imagePath'], - title: JoinedcommunityData[index]['text'], - members: JoinedcommunityData[index]['members'], - index: JoinedcommunityData[index]['index']); - }), + ), + 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), + ), + ) + ], + ); + } + if (snapshot.connectionState == ConnectionState.done) { + if (snapshot.hasError) { + return Center( + child: Text( + '${snapshot.error} occured', + style: TextStyle(fontSize: 18.spMin), + ), + ); + } + } + return myCommunityobj!.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: const EdgeInsets.symmetric(horizontal: 16), + child: Column( + children: [ + sizedBoxHeight(20.h), + Row( + children: [ + Spacer(), + GestureDetector( + onTap: () { + Get.toNamed(RouteName.requestscreen); + }, + child: text16w700_FCFCFC_line("Requests")) + ], + ), + sizedBoxHeight(20.h), + Expanded( + child: ListView.builder( + shrinkWrap: true, + physics: const ScrollPhysics(), + itemCount: myCommunityobj!.data.length, + itemBuilder: (context, index) { + var joinnedComData = myCommunityobj!.data[index]; + return Padding( + padding: EdgeInsets.only(bottom: 25.h), + child: GestureDetector( + onTap: () { + Get.toNamed(RouteName.communityDetails, arguments: {"CommunityID" : joinnedComData.manageCommunityXid}); + }, + child: commonGlassUI( + borderwidth: 0.9, + width: double.infinity, + height: 172.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: const BoxDecoration( + shape: BoxShape.circle, + // color: Colors.amber, + ), + child: + // Center( + // child: Image.asset(imagepath, fit: BoxFit.cover)), + joinnedComData.joinedAndRequestedCommunity! + .communityProfilePhoto == + null || + joinnedComData + .joinedAndRequestedCommunity! + .communityProfilePhoto! + .isEmpty + ? const CircleAvatar( + backgroundImage: + AssetImage( + 'assets/images/png/img45.png', + ), + ) + : CircleAvatar( + backgroundImage: NetworkImage( + joinnedComData + .joinedAndRequestedCommunity! + .communityProfilePhoto!), + )), + sizedBoxWidth(13.w), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + // Container( + // // width: 250.w, + // // color: Colors.red, + // width: double.infinity, + // child: + joinnedComData.joinedAndRequestedCommunity! + .communityName == + null || + joinnedComData + .joinedAndRequestedCommunity! + .communityName! + .isEmpty + ? text18w700_FCFCFC('Regroup') + : SizedBox( + width: 200.w, + child: text18w700_FCFCFC( + joinnedComData + .joinedAndRequestedCommunity! + .communityName!), + ), + // ), + sizedBoxHeight(10.h), + joinnedComData.totalCommunityMember == + null || + joinnedComData + .totalCommunityMember! + .toString() + .isEmpty + ? const SizedBox() + : sizedBoxHeight(10.h), + Row( + children: [ + Stack( + clipBehavior: Clip.none, + children: [ + commonGlassUI( + borderwidth: 0.9, + width: 30.w, + height: 30.h, + borderRadius: + BorderRadius + .circular( + 100.r), + opacity1: 0.24, + opacity2: 0.24, + customWidget: Center( + child: Image.asset( + "assets/images/png/Black.png", + height: 12.h, + width: 16.w, + ), + )), + // Positioned( + // top: 0, + // right: -4, + // child: Container( + // height: 12.h, + // width: 12.w, + // decoration: + // const BoxDecoration( + // shape: + // BoxShape.circle, + // color: Color( + // 0xFFD90B2E), + // ), + // child: Center( + // child: + // text6400white( + // "2") + + // ),)) + ]), + sizedBoxWidth(15.w), + text14w400_FCFCFCblur( + "${joinnedComData.joinedAndRequestedCommunity!.totalGroup ?? ''} groups"), + sizedBoxWidth(50.w), + GestureDetector( + onTap: () { + toggleSelectedIndex(index); + }, + child: Container( + height: 21.h, + width: 57.w, + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular( + 50.r), + gradient: + const LinearGradient( + begin: + Alignment.centerLeft, + end: + Alignment.centerRight, + colors: [ + Color.fromRGBO(255, 255, + 255, 0.06), + Color.fromRGBO(255, 255, + 255, 0.08), + ], + stops: [-0.0497, 1.0238], + // converting degrees to radians + ), + border: Border.all( + color: const Color( + 0xFF434A53), + width: 1.0, + ), + ), + child: Center( + child: text10400white( + "Owner")), + ), + ), + ], + ), + ], + ), + const 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) => + [ + 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: + " +${joinnedComData.totalCommunityMember! - 3}", + containerImages: joinnedComData + .fourMemberImages! + .map((photo) => photo + .iamPrincipal!.profilePhoto!) + .toList(), + ), + sizedBoxWidth(75.w), + joinnedComData.totalCommunityMember == + null || + joinnedComData + .totalCommunityMember.isBlank! + ? const SizedBox() + : text16w400_FCFCFC_blur( + '${joinnedComData.totalCommunityMember} members', + ), + ], + ) + ], + ), + )), ), - text18w700_FCFCFC("Requested communities"), - sizedBoxHeight(20.h), - Column( - children: - List.generate(RequestcommunityData.length, (index) { - return communityCard( - ontap: () {}, - imagepath: RequestcommunityData[index] - ['imagePath'], - title: RequestcommunityData[index]['text'], - members: RequestcommunityData[index]['members'], - index: RequestcommunityData[index]['index']); - }), - ) - ]), - )) - ])); + ); + }, + ), + ), + ], + )) + ]); } Widget communityCard({ @@ -175,7 +534,7 @@ class _MyCommunityState extends State { Container( height: 65.h, width: 65.h, - decoration: BoxDecoration( + decoration: const BoxDecoration( shape: BoxShape.circle, // color: Colors.amber, ), @@ -218,7 +577,7 @@ class _MyCommunityState extends State { child: Container( height: 12.h, width: 12.w, - decoration: BoxDecoration( + decoration: const BoxDecoration( shape: BoxShape.circle, color: Color(0xFFD90B2E), ), @@ -231,12 +590,12 @@ class _MyCommunityState extends State { ), ], ), - Spacer(), + const Spacer(), PopupMenuButton( - surfaceTintColor: Color(0xFF222935), + surfaceTintColor: const Color(0xFF222935), constraints: BoxConstraints.tightFor(width: 200.w), - offset: Offset(0, 30), - color: Color(0xFF222935), + offset: const Offset(0, 30), + color: const Color(0xFF222935), tooltip: "", itemBuilder: (BuildContext context) => [ @@ -248,7 +607,7 @@ class _MyCommunityState extends State { child: Row( children: [ text14w400_FCFCFC("Mute community"), - Spacer(), + const Spacer(), Image.asset( "assets/images/png/Black (1).png", height: 18.h, @@ -258,7 +617,7 @@ class _MyCommunityState extends State { ), ), ), - PopupMenuDivider(), + const PopupMenuDivider(), PopupMenuItem( onTap: () {}, child: Padding( @@ -267,7 +626,7 @@ class _MyCommunityState extends State { child: Row( children: [ text14w400_FCFCFC("Hide post"), - Spacer(), + const Spacer(), Image.asset( "assets/images/png/mingcute_eye-close-line.png", height: 20.h, @@ -277,7 +636,7 @@ class _MyCommunityState extends State { ), ), ), - PopupMenuDivider(), + const PopupMenuDivider(), PopupMenuItem( onTap: () {}, child: Padding( @@ -286,7 +645,7 @@ class _MyCommunityState extends State { child: Row( children: [ text14w400_FCFCFC("Pin"), - Spacer(), + const Spacer(), Image.asset( "assets/images/png/f7_pin-fill (2).png", height: 25.h, @@ -296,7 +655,7 @@ class _MyCommunityState extends State { ), ), ), - PopupMenuDivider(), + const PopupMenuDivider(), PopupMenuItem( onTap: () {}, child: Padding( @@ -305,7 +664,7 @@ class _MyCommunityState extends State { child: Row( children: [ text14w400_FCFCFC("Leave community"), - Spacer(), + const Spacer(), Image.asset( "assets/images/png/logout 1 (traced).png", height: 18.h, @@ -340,7 +699,7 @@ class _MyCommunityState extends State { ), sizedBoxWidth(95.w), text12w400_FCFCFC_blur(members), - Spacer(), + const Spacer(), Obx(() { return GestureDetector( onTap: () { @@ -355,12 +714,13 @@ class _MyCommunityState extends State { color: selectedContainerIndices.contains(index) ? null - : Color(0xFFD90B2E), + : const Color(0xFFD90B2E), borderRadius: BorderRadius.all( Radius.circular(30.r), ), border: Border.all( - color: Color(0xFFD90B2E), width: 1.w)), + color: const Color(0xFFD90B2E), + width: 1.w)), child: Center( child: selectedContainerIndices.contains(index) diff --git a/lib/sidemenu/Community/MyCommunity/View/RequestsScreen.dart b/lib/sidemenu/Community/MyCommunity/View/RequestsScreen.dart new file mode 100644 index 0000000..caded4a --- /dev/null +++ b/lib/sidemenu/Community/MyCommunity/View/RequestsScreen.dart @@ -0,0 +1,1060 @@ +import 'package:flutter/cupertino.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/CommonTabBar.dart'; +import 'package:regroup/Common/CommonWidget.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Utils/Common/CommonAppbar.dart'; +import 'package:regroup/Utils/Common/sized_box.dart'; +import 'package:regroup/Utils/dialogs.dart'; +import 'package:regroup/Utils/texts.dart'; +import 'package:regroup/sidemenu/view_model/getMyCommunity.dart'; + +class RequestsScreen extends StatefulWidget { + const RequestsScreen({super.key}); + + @override + State createState() => _RequestsScreenState(); +} + +class _RequestsScreenState extends State { + late Future myfuture; + + @override + void initState() { + // TODO: implement initState + // myfuture = MyCommunityAPI().getMyCommunity(); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + // key: _scaffoldKey1, + backgroundColor: const Color(0xFF222935), + extendBody: true, + resizeToAvoidBottomInset: false, + appBar: CommonAppbar( + titleTxt: "My Communities", + customActionWidget: Row( + children: [ + sizedBoxWidth(12.w), + Image.asset( + "assets/images/png/Frame 9.png", + height: 22.h, + width: 22.w, + ) + ], + ), + ), + body: Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), + ), + Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + sizedBoxHeight(20.h), + const Expanded( + child: DefaultTabController( + length: 2, + child: Column( + children: [ + CommonTabBar(tabs: [ + Tab( + text: 'Requested', + ), + Tab( + text: 'Invited', + ), + ]), + Expanded( + child: TabBarView( + children: [ + RequestedTab(), + InvitedTab(), + ], + ), + ), + ], + )), + ) + ]) + ])); + } +} + +class RequestedTab extends StatefulWidget { + const RequestedTab({super.key}); + + @override + State createState() => _RequestedTabState(); +} + +class _RequestedTabState extends State { + late Future myfuture; + + @override + void initState() { + // TODO: implement initState + myfuture = MyCommunityAPI().getRequestedCommunity(); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return 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), + ), + ) + ], + ); + } + if (snapshot.connectionState == ConnectionState.done) { + if (snapshot.hasError) { + return Center( + child: Text( + '${snapshot.error} occured', + style: TextStyle(fontSize: 18.spMin), + ), + ); + } + } + return requestedComobj!.data.isEmpty + ? _buildNoDataBody(context) + : Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Column( + children: [ + sizedBoxHeight(20.h), + Expanded( + child: ListView.builder( + shrinkWrap: true, + physics: const ScrollPhysics(), + itemCount: requestedComobj!.data.length, + itemBuilder: (context, index) { + var requestedComData = requestedComobj!.data[index]; + return Padding( + padding: EdgeInsets.only(bottom: 25.h), + child: GestureDetector( + onTap: () {}, + child: commonGlassUI( + borderwidth: 0.9, + width: double.infinity, + height: 180.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: + const BoxDecoration( + shape: BoxShape.circle, + // color: Colors.amber, + ), + child: + // Center( + // child: Image.asset(imagepath, fit: BoxFit.cover)), + requestedComData.joinedAndRequestedCommunity! + .communityProfilePhoto == + null || + requestedComData + .joinedAndRequestedCommunity! + .communityProfilePhoto! + .isEmpty + ? const CircleAvatar( + backgroundImage: + AssetImage( + 'assets/images/png/img45.png', + ), + ) + : CircleAvatar( + backgroundImage: NetworkImage( + requestedComData + .joinedAndRequestedCommunity! + .communityProfilePhoto!), + )), + sizedBoxWidth(13.w), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + // Container( + // // width: 250.w, + // // color: Colors.red, + // width: double.infinity, + // child: + requestedComData.joinedAndRequestedCommunity! + .communityName == + null || + requestedComData + .joinedAndRequestedCommunity! + .communityName! + .isEmpty + ? text18w700_FCFCFC( + 'Regroup') + : SizedBox( + width: 200.w, + child: text18w700_FCFCFC( + requestedComData + .joinedAndRequestedCommunity! + .communityName!), + ), + // ), + sizedBoxHeight(10.h), + requestedComData.totalCommunityMember == + null || + requestedComData + .totalCommunityMember! + .toString() + .isEmpty + ? const SizedBox() + : sizedBoxHeight(10.h), + Row( + children: [ + Stack( + clipBehavior: + Clip.none, + children: [ + commonGlassUI( + borderwidth: + 0.9, + width: 30.w, + height: 30.h, + borderRadius: + BorderRadius + .circular(100 + .r), + opacity1: 0.24, + opacity2: 0.24, + customWidget: + Center( + child: Image + .asset( + "assets/images/png/Black.png", + height: + 12.h, + width: 16.w, + ), + )), + // Positioned( + // top: 0, + // right: -4, + // child: Container( + // height: 12.h, + // width: 12.w, + // decoration: + // const BoxDecoration( + // shape: + // BoxShape.circle, + // color: Color( + // 0xFFD90B2E), + // ), + // child: Center( + // child: + // text6400white( + // "2") + + // ),)) + ]), + sizedBoxWidth(15.w), + text14w400_FCFCFCblur( + "${requestedComData.joinedAndRequestedCommunity!.totalGroup ?? ''} groups"), + sizedBoxWidth(50.w), + GestureDetector( + onTap: () { + // toggleSelectedIndex(index); + }, + child: Container( + height: 21.h, + width: 57.w, + decoration: + BoxDecoration( + borderRadius: + BorderRadius + .circular( + 50.r), + gradient: + const LinearGradient( + begin: Alignment + .centerLeft, + end: Alignment + .centerRight, + colors: [ + Color.fromRGBO( + 255, + 255, + 255, + 0.06), + Color.fromRGBO( + 255, + 255, + 255, + 0.08), + ], + stops: [ + -0.0497, + 1.0238 + ], + // converting degrees to radians + ), + border: Border.all( + color: const Color( + 0xFF434A53), + width: 1.0, + ), + ), + child: Center( + child: + text10400white( + "Owner")), + ), + ), + ], + ), + ], + ), + const 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) => + [ + 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), + Expanded( + child: Row( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + stackContainersGroups( + number: + " +${requestedComData.totalCommunityMember! - 3}", + containerImages: + requestedComData + .fourMemberImages! + .map((photo) => photo + .iamPrincipal! + .profilePhoto!) + .toList(), + ), + sizedBoxWidth(75.w), + requestedComData.totalCommunityMember == + null || + requestedComData + .totalCommunityMember! + .isBlank! + ? const SizedBox() + : text16w400_FCFCFC_blur( + '${requestedComData.totalCommunityMember} members', + ), + Spacer(), + GestureDetector( + onTap: () async { + Map + updata = { + "manage_community_xid": + requestedComData + .manageCommunityXid + }; + final data = + await MyCommunityAPI() + .postcancelRequest( + updata); + if (data.status == + ResponseStatus + .SUCCESS) { + print("success"); + setState(() { + requestedComobj!.data + .removeAt(index); + }); + return utils.showToast( + data.message); + } else { + Get.back(); + print("Failed"); + return utils.showToast( + data.message); + } + }, + child: Container( + height: 30.h, + width: 120.w, + decoration: BoxDecoration( + borderRadius: + BorderRadius + .circular(30.r), + color: + Color(0xFFD90B2E)), + child: Center( + child: text12w400_FCFCFC( + "Cancel request")), + ), + ) + ], + ), + ) + ], + ), + )), + ), + ); + }, + ), + ), + ], + ), + ); + }); + } +} + +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), + ) + ], + ), + ); +} + +class InvitedTab extends StatefulWidget { + const InvitedTab({super.key}); + + @override + State createState() => _InvitedTabState(); +} + +class _InvitedTabState extends State { + late Future myfuture; + + @override + void initState() { + // TODO: implement initState + myfuture = MyCommunityAPI().getInviteCommunity(); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return 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), + ), + ) + ], + ); + } + if (snapshot.connectionState == ConnectionState.done) { + if (snapshot.hasError) { + return Center( + child: Text( + '${snapshot.error} occured', + style: TextStyle(fontSize: 18.spMin), + ), + ); + } + } + return inviteComobj!.data.isEmpty + ? _buildNoDataBody(context) + : Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Column( + children: [ + sizedBoxHeight(20.h), + Expanded( + child: ListView.builder( + shrinkWrap: true, + physics: const ScrollPhysics(), + itemCount: inviteComobj!.data.length, + itemBuilder: (context, index) { + var invitedComData = inviteComobj!.data[index]; + return Padding( + padding: EdgeInsets.only(bottom: 25.h), + child: GestureDetector( + onTap: () {}, + child: commonGlassUI( + borderwidth: 0.9, + width: double.infinity, + height: 180.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: + const BoxDecoration( + shape: BoxShape.circle, + // color: Colors.amber, + ), + child: + // Center( + // child: Image.asset(imagepath, fit: BoxFit.cover)), + invitedComData.senderDetail! + .profilePhoto == + null || + invitedComData + .senderDetail! + .profilePhoto! + .isEmpty + ? const CircleAvatar( + backgroundImage: + AssetImage( + 'assets/images/png/img45.png', + ), + ) + : CircleAvatar( + backgroundImage: NetworkImage( + invitedComData + .senderDetail! + .profilePhoto!), + )), + sizedBoxWidth(13.w), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + // width: 250.w, + // color: Colors.red, + // width: double.infinity, + child: invitedComData + .senderDetail! + .fullName == + null || + invitedComData + .senderDetail! + .fullName! + .isEmpty + ? text18w700_FCFCFC( + 'Regroup') + : SizedBox( + width: 200.w, + child: text18w700_FCFCFC( + invitedComData + .senderDetail! + .fullName!), + ), + ), + sizedBoxHeight(10.h), + // invitedComData.totalCommunityMember == + // null || + // joinnedComData + // .totalCommunityMember! + // .toString() + // .isEmpty + // ? const SizedBox() + // : sizedBoxHeight(10.h), + Row( + children: [ + commonGlassUI( + borderwidth: 0.9, + width: 30.w, + height: 30.h, + borderRadius: + BorderRadius + .circular( + 100.r), + opacity1: 0.24, + opacity2: 0.24, + customWidget: Center( + child: Image.asset( + "assets/images/png/Black.png", + height: 12.h, + width: 16.w, + ), + )), + sizedBoxWidth(15.w), + // text14w400_FCFCFCblur( + // "${invitedComData.totalGroup ?? ''} groups"), + sizedBoxWidth(50.w), + GestureDetector( + onTap: () { + // toggleSelectedIndex(index); + }, + child: Container( + height: 21.h, + width: 57.w, + decoration: + BoxDecoration( + borderRadius: + BorderRadius + .circular( + 50.r), + gradient: + const LinearGradient( + begin: Alignment + .centerLeft, + end: Alignment + .centerRight, + colors: [ + Color.fromRGBO( + 255, + 255, + 255, + 0.06), + Color.fromRGBO( + 255, + 255, + 255, + 0.08), + ], + stops: [ + -0.0497, + 1.0238 + ], + // converting degrees to radians + ), + border: Border.all( + color: const Color( + 0xFF434A53), + width: 1.0, + ), + ), + child: Center( + child: + text10400white( + "Owner")), + ), + ), + ], + ), + ], + ), + const 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) => + [ + 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), + Expanded( + child: Row( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + // stackContainersGroups( + // number: + // " +${invitedComData.totalCommunityMember! - 3}", + // containerImages: joinnedComData + // .fourMemberImages! + // .map((photo) => photo + // .iamPrincipal!.profilePhoto!) + // .toList(), + // ), + // sizedBoxWidth(75.w), + // joinnedComData.totalCommunityMember == + // null || + // joinnedComData! + // .totalCommunityMember! + // .isBlank! + // ? const SizedBox() + // : text16w400_FCFCFC_blur( + // '${joinnedComData.totalCommunityMember} members', + // ), + Spacer(), + GestureDetector( + onTap: () async { + Map + updata = { + "community_xid": + invitedComData + .communityXid + }; + final data = + await MyCommunityAPI() + .postRejectInvite( + updata); + if (data.status == + ResponseStatus + .SUCCESS) { + print("success"); + setState(() { + inviteComobj!.data + .removeAt(index); + }); + return utils.showToast( + data.message); + } else { + Get.back(); + print("Failed"); + return utils.showToast( + data.message); + } + }, + child: Container( + height: 30.h, + width: 70.w, + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular( + 50.r), + gradient: + const LinearGradient( + begin: Alignment + .centerLeft, + end: Alignment + .centerRight, + colors: [ + Color.fromRGBO(255, + 255, 255, 0.06), + Color.fromRGBO(255, + 255, 255, 0.08), + ], + stops: [ + -0.0497, + 1.0238 + ], + // converting degrees to radians + ), + border: Border.all( + color: const Color( + 0xFF434A53), + width: 1.0, + ), + ), + child: Center( + child: text10400white( + "Reject")), + ), + ), + sizedBoxWidth(6.w), + GestureDetector( + onTap: () async { + Map + updata = { + "community_xid": + invitedComData + .communityXid + }; + final data = + await MyCommunityAPI() + .postAcceptInvite( + updata); + if (data.status == + ResponseStatus + .SUCCESS) { + print("success"); + setState(() { + inviteComobj!.data + .removeAt(index); + }); + return utils.showToast( + data.message); + } else { + Get.back(); + print("Failed"); + return utils.showToast( + data.message); + } + }, + child: Container( + height: 30.h, + width: 70.w, + decoration: BoxDecoration( + borderRadius: + BorderRadius + .circular(30.r), + color: + Color(0xFFD90B2E)), + child: Center( + child: + text12w400_FCFCFC( + "Accept")), + ), + ) + ], + ), + ) + ], + ), + )), + ), + ); + }, + ), + ), + ], + ), + ); + }); + } +} + +// 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), +// ) +// ], +// ), +// ); +// } + + diff --git a/lib/sidemenu/Model/InviteComModel.dart b/lib/sidemenu/Model/InviteComModel.dart new file mode 100644 index 0000000..f945183 --- /dev/null +++ b/lib/sidemenu/Model/InviteComModel.dart @@ -0,0 +1,92 @@ +class InviteComModel { + InviteComModel({ + required this.status, + required this.statusCode, + required this.message, + required this.data, + }); + + final String? status; + final int? statusCode; + final String? message; + final List data; + + factory InviteComModel.fromJson(Map json){ + return InviteComModel( + status: json["status"], + statusCode: json["status_code"], + message: json["message"], + data: json["data"] == null ? [] : List.from(json["data"]!.map((x) => Datum.fromJson(x))), + ); + } + +} + +class Datum { + Datum({ + required this.id, + required this.senderIamXid, + required this.communityXid, + required this.receiverIamXid, + required this.isAccepted, + required this.createdAt, + required this.updatedAt, + required this.deletedAt, + required this.community, + required this.senderDetail, + }); + + final int? id; + final int? senderIamXid; + final int? communityXid; + final int? receiverIamXid; + final int? isAccepted; + final DateTime? createdAt; + final DateTime? updatedAt; + final dynamic deletedAt; + final dynamic community; + final SenderDetail? senderDetail; + + factory Datum.fromJson(Map json){ + return Datum( + id: json["id"], + senderIamXid: json["sender_iam_xid"], + communityXid: json["community_xid"], + receiverIamXid: json["receiver_iam_xid"], + isAccepted: json["is_accepted"], + createdAt: DateTime.tryParse(json["created_at"] ?? ""), + updatedAt: DateTime.tryParse(json["updated_at"] ?? ""), + deletedAt: json["deleted_at"], + community: json["community"], + senderDetail: json["sender_detail"] == null ? null : SenderDetail.fromJson(json["sender_detail"]), + ); + } + +} + +class SenderDetail { + SenderDetail({ + required this.id, + required this.userName, + required this.fullName, + required this.profilePhoto, + required this.isUserPinned, + }); + + final int? id; + final String? userName; + final String? fullName; + final String? profilePhoto; + final bool? isUserPinned; + + factory SenderDetail.fromJson(Map json){ + return SenderDetail( + id: json["id"], + userName: json["user_name"], + fullName: json["full_name"], + profilePhoto: json["profile_photo"], + isUserPinned: json["is_user_pinned"], + ); + } + +} diff --git a/lib/sidemenu/Model/MyCommunityModel.dart b/lib/sidemenu/Model/MyCommunityModel.dart new file mode 100644 index 0000000..46f7d6b --- /dev/null +++ b/lib/sidemenu/Model/MyCommunityModel.dart @@ -0,0 +1,152 @@ +class MyCommunityModel { + MyCommunityModel({ + required this.status, + required this.statusCode, + required this.message, + required this.data, + }); + + final String? status; + final int? statusCode; + final String? message; + final List data; + + factory MyCommunityModel.fromJson(Map json){ + return MyCommunityModel( + status: json["status"], + statusCode: json["status_code"], + message: json["message"], + data: json["data"] == null ? [] : List.from(json["data"]!.map((x) => Datum.fromJson(x))), + ); + } + +} + +class Datum { + Datum({ + required this.totalCommunityMember, + required this.fourMemberImages, + required this.iamPrincipalXid, + required this.manageCommunityXid, + required this.joinedAt, + required this.userTypeXid, + required this.joinedAndRequestedCommunity, + }); + + final int? totalCommunityMember; + final List fourMemberImages; + final int? iamPrincipalXid; + final int? manageCommunityXid; + final DateTime? joinedAt; + final UserTypeXid? userTypeXid; + final JoinedAndRequestedCommunity? joinedAndRequestedCommunity; + + factory Datum.fromJson(Map json){ + return Datum( + totalCommunityMember: json["total_community_member"], + fourMemberImages: json["four_member_images"] == null ? [] : List.from(json["four_member_images"]!.map((x) => FourMemberImage.fromJson(x))), + iamPrincipalXid: json["iam_principal_xid"], + manageCommunityXid: json["manage_community_xid"], + joinedAt: DateTime.tryParse(json["joined_at"] ?? ""), + userTypeXid: json["user_type_xid"] == null ? null : UserTypeXid.fromJson(json["user_type_xid"]), + joinedAndRequestedCommunity: json["joined_and_requested_community"] == null ? null : JoinedAndRequestedCommunity.fromJson(json["joined_and_requested_community"]), + ); + } + +} + +class FourMemberImage { + FourMemberImage({ + required this.iamPrincipalXid, + required this.manageCommunityXid, + required this.iamPrincipal, + }); + + final int? iamPrincipalXid; + final int? manageCommunityXid; + final IamPrincipal? iamPrincipal; + + factory FourMemberImage.fromJson(Map json){ + return FourMemberImage( + iamPrincipalXid: json["iam_principal_xid"], + manageCommunityXid: json["manage_community_xid"], + iamPrincipal: json["iam_principal"] == null ? null : IamPrincipal.fromJson(json["iam_principal"]), + ); + } + +} + +class IamPrincipal { + IamPrincipal({ + required this.id, + required this.principalTypeXid, + required this.userName, + required this.profilePhoto, + required this.isUserPinned, + }); + + final int? id; + final int? principalTypeXid; + final String? userName; + final String? profilePhoto; + final bool? isUserPinned; + + factory IamPrincipal.fromJson(Map json){ + return IamPrincipal( + id: json["id"], + principalTypeXid: json["principal_type_xid"], + userName: json["user_name"], + profilePhoto: json["profile_photo"], + isUserPinned: json["is_user_pinned"], + ); + } + +} + +class JoinedAndRequestedCommunity { + JoinedAndRequestedCommunity({ + required this.id, + required this.communityProfilePhoto, + required this.communityBannerImage, + required this.communityName, + required this.totalGroup, + required this.totalAnnouncements, + }); + + final int? id; + final String? communityProfilePhoto; + final String? communityBannerImage; + final String? communityName; + final int? totalGroup; + final int? totalAnnouncements; + + factory JoinedAndRequestedCommunity.fromJson(Map json){ + return JoinedAndRequestedCommunity( + id: json["id"], + communityProfilePhoto: json["community_profile_photo"], + communityBannerImage: json["community_banner_image"], + communityName: json["community_name"], + totalGroup: json["total_group"], + totalAnnouncements: json["total_announcements"], + ); + } + +} + +class UserTypeXid { + UserTypeXid({ + required this.id, + required this.name, + }); + + final int? id; + final String? name; + + factory UserTypeXid.fromJson(Map json){ + return UserTypeXid( + id: json["id"], + name: json["name"], + ); + } + +} diff --git a/lib/sidemenu/Model/RequestedComModel.dart b/lib/sidemenu/Model/RequestedComModel.dart new file mode 100644 index 0000000..0d7abf2 --- /dev/null +++ b/lib/sidemenu/Model/RequestedComModel.dart @@ -0,0 +1,137 @@ +class RequestedComModel { + RequestedComModel({ + required this.status, + required this.statusCode, + required this.message, + required this.data, + }); + + final String? status; + final int? statusCode; + final String? message; + final List data; + + factory RequestedComModel.fromJson(Map json){ + return RequestedComModel( + status: json["status"], + statusCode: json["status_code"], + message: json["message"], + data: json["data"] == null ? [] : List.from(json["data"]!.map((x) => Datum.fromJson(x))), + ); + } + +} + +class Datum { + Datum({ + required this.id, + required this.iamPrincipalXid, + required this.fourMemberImages, + required this.totalCommunityMember, + required this.manageCommunityXid, + required this.joinedAt, + required this.isRequested, + required this.joinedAndRequestedCommunity, + }); + + final int? id; + final int? iamPrincipalXid; + final List fourMemberImages; + final int? totalCommunityMember; + final int? manageCommunityXid; + final DateTime? joinedAt; + final int? isRequested; + final JoinedAndRequestedCommunity? joinedAndRequestedCommunity; + + factory Datum.fromJson(Map json){ + return Datum( + id: json["id"], + iamPrincipalXid: json["iam_principal_xid"], + fourMemberImages: json["four_member_images"] == null ? [] : List.from(json["four_member_images"]!.map((x) => FourMemberImage.fromJson(x))), + totalCommunityMember: json["total_community_member"], + manageCommunityXid: json["manage_community_xid"], + joinedAt: DateTime.tryParse(json["joined_at"] ?? ""), + isRequested: json["is_requested"], + joinedAndRequestedCommunity: json["joined_and_requested_community"] == null ? null : JoinedAndRequestedCommunity.fromJson(json["joined_and_requested_community"]), + ); + } + +} + +class FourMemberImage { + FourMemberImage({ + required this.iamPrincipalXid, + required this.manageCommunityXid, + required this.iamPrincipal, + }); + + final int? iamPrincipalXid; + final int? manageCommunityXid; + final IamPrincipal? iamPrincipal; + + factory FourMemberImage.fromJson(Map json){ + return FourMemberImage( + iamPrincipalXid: json["iam_principal_xid"], + manageCommunityXid: json["manage_community_xid"], + iamPrincipal: json["iam_principal"] == null ? null : IamPrincipal.fromJson(json["iam_principal"]), + ); + } + +} + +class IamPrincipal { + IamPrincipal({ + required this.id, + required this.principalTypeXid, + required this.userName, + required this.profilePhoto, + required this.isUserPinned, + }); + + final int? id; + final int? principalTypeXid; + final String? userName; + final String? profilePhoto; + final bool? isUserPinned; + + factory IamPrincipal.fromJson(Map json){ + return IamPrincipal( + id: json["id"], + principalTypeXid: json["principal_type_xid"], + userName: json["user_name"], + profilePhoto: json["profile_photo"], + isUserPinned: json["is_user_pinned"], + ); + } + +} + +class JoinedAndRequestedCommunity { + JoinedAndRequestedCommunity({ + required this.id, + required this.communityProfilePhoto, + required this.communityBannerImage, + required this.communityName, + required this.totalGroup, + required this.totalAnnouncements, + }); + + final int? id; + final String? communityProfilePhoto; + final String? communityBannerImage; + final String? communityName; + final int? totalGroup; + final int? totalAnnouncements; + + factory JoinedAndRequestedCommunity.fromJson(Map json){ + return JoinedAndRequestedCommunity( + id: json["id"], + communityProfilePhoto: json["community_profile_photo"], + communityBannerImage: json["community_banner_image"], + communityName: json["community_name"], + totalGroup: json["total_group"], + totalAnnouncements: json["total_announcements"], + ); + } + +} diff --git a/lib/sidemenu/view_model/getMyCommunity.dart b/lib/sidemenu/view_model/getMyCommunity.dart new file mode 100644 index 0000000..8cabd79 --- /dev/null +++ b/lib/sidemenu/view_model/getMyCommunity.dart @@ -0,0 +1,108 @@ +import 'dart:developer'; + +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/Model/InviteComModel.dart'; +import 'package:regroup/sidemenu/Model/MyCommunityModel.dart'; +import 'package:regroup/sidemenu/Model/RequestedComModel.dart'; + +MyCommunityModel? myCommunityobj; +RequestedComModel ? requestedComobj; +InviteComModel ? inviteComobj; + + +class MyCommunityAPI { + + Future> getMyCommunity() async { + final response = await NetworkApiServices().getApi( + ApiUrls.getmycommunity, + ); + if (response.status == ResponseStatus.SUCCESS) { + myCommunityobj = MyCommunityModel.fromJson(response.data); + log(myCommunityobj!.data.toString()); + } + return response; + } + + Future> getRequestedCommunity() async { + final response = await NetworkApiServices().getApi( + ApiUrls.getrequestedcommunity, + ); + if (response.status == ResponseStatus.SUCCESS) { + requestedComobj = RequestedComModel.fromJson(response.data); + log(requestedComobj!.data.toString()); + } + return response; + } + + Future> getInviteCommunity() async { + final response = await NetworkApiServices().getApi( + ApiUrls.getInvitecommunity, + ); + if (response.status == ResponseStatus.SUCCESS) { + inviteComobj = InviteComModel.fromJson(response.data); + log(inviteComobj!.data.toString()); + } + return response; + } + + + Future> postcancelRequest(updata) async { + print("updata is $updata"); + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.postcancelrequest, + ); + if (response.status == ResponseStatus.SUCCESS) { + if (response.data["status"] == "success") { + // likepostobj = LikepostModel.fromJson(response.data); + } + return ResponseData( + response.data['message'], ResponseStatus.SUCCESS, + data: response.data); + } else { + return ResponseData( + response.data['message'], ResponseStatus.FAILED); + } + } + + Future> postAcceptInvite(updata) async { + print("updata is $updata"); + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.postacceptinvite, + ); + if (response.status == ResponseStatus.SUCCESS) { + if (response.data["status"] == "success") { + // likepostobj = LikepostModel.fromJson(response.data); + } + return ResponseData( + response.data['message'], ResponseStatus.SUCCESS, + data: response.data); + } else { + return ResponseData( + response.data['message'], ResponseStatus.FAILED); + } + } + + Future> postRejectInvite(updata) async { + print("updata is $updata"); + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.postrejectinvite, + ); + if (response.status == ResponseStatus.SUCCESS) { + if (response.data["status"] == "success") { + // likepostobj = LikepostModel.fromJson(response.data); + } + return ResponseData( + response.data['message'], ResponseStatus.SUCCESS, + data: response.data); + } else { + return ResponseData( + response.data['message'], ResponseStatus.FAILED); + } + } + +} \ No newline at end of file