diff --git a/assets/images/png/ion_add.png b/assets/images/png/ion_add.png new file mode 100644 index 0000000..9f926cb Binary files /dev/null and b/assets/images/png/ion_add.png differ diff --git a/devtools_options.yaml b/devtools_options.yaml new file mode 100644 index 0000000..7e7e7f6 --- /dev/null +++ b/devtools_options.yaml @@ -0,0 +1 @@ +extensions: diff --git a/lib/Common/CommonGlassmorphism.dart b/lib/Common/CommonGlassmorphism.dart index d049b60..d10d9d3 100644 --- a/lib/Common/CommonGlassmorphism.dart +++ b/lib/Common/CommonGlassmorphism.dart @@ -12,8 +12,7 @@ Widget commonGlassContainer({ double opacity2 = 0.05, Color borderColor = const Color(0xff434A53), }) { - return - GlassmorphicContainer( + return GlassmorphicContainer( width: width, height: height, borderRadius: borderradius, @@ -83,7 +82,7 @@ Widget commonGlassContainerblue({ Widget commonGlassUIBlue({ required double width, - required double height, + required double? height, required Widget customWidget, // required double border, double mainOpacity = 1, @@ -114,7 +113,7 @@ Widget commonGlassUIBlue({ Widget commonGlassUI({ required double width, - required double height, + required double? height, // required double border, double mainOpacity = 1, double opacity1 = 0.04, @@ -148,7 +147,7 @@ Widget commonGlassUI({ Widget commonContainer({ required double width, - required double height, + required double? height, // required double border, // double mainOpacity = 1, double opacity1 = 0.04, diff --git a/lib/Common/CommonPostUI.dart b/lib/Common/CommonPostUI.dart deleted file mode 100644 index 0d0d057..0000000 --- a/lib/Common/CommonPostUI.dart +++ /dev/null @@ -1,401 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_reaction_button/flutter_reaction_button.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; -import 'package:regroup/Common/CommonGlassmorphism.dart'; -import 'package:regroup/Common/CommonWidget.dart'; -import 'package:regroup/Main_Screens/Community_HomePage/Community.dart'; -import 'package:regroup/Utils/Common/sized_box.dart'; -import 'package:regroup/Utils/texts.dart'; -import 'package:regroup/resources/routes/route_name.dart'; - -class CommonPostUI extends StatefulWidget { - CommonPostUI( - {super.key, - required this.containerTitle, - required this.mainImg, - required this.profileImg, - required this.title}); - - String profileImg = ""; - String title = ""; - String mainImg = ""; - List containerTitle = []; - - @override - State createState() => _CommonPostUIState(); -} - -class _CommonPostUIState extends State { - @override - Widget build(BuildContext context) { - return postCards( - containerTitle: widget.containerTitle, - profileImg: widget.profileImg, - title: widget.title, - mainImg: widget.mainImg, - ); - } - - Widget postCards({ - required String profileImg, - required String title, - required String mainImg, - required List containerTitle, - }) { - var mainImage = 'assets/images/png/uiw_like-o.png'.obs; - void updateImage(String reaction) { - if (reaction == 'like') { - mainImage.value = 'assets/images/png/f7_hand-thumbsup.png'; - } else if (reaction == 'heart') { - mainImage.value = 'assets/images/png/heart 2.png'; - } else if (reaction == 'party') { - mainImage.value = 'assets/images/png/party-popper 2.png'; - } - } - - return commonGlassUI( - width: double.infinity, - height: 570.h, - borderwidth: 0, - borderRadius: BorderRadius.circular(0), - customWidget: Column( - children: [ - sizedBoxHeight(25.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CircleAvatar( - foregroundImage: AssetImage(profileImg), - radius: 25.r, - ), - sizedBoxWidth(12.w), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - text16w400_FCFCFC(title), - const Spacer(), - commonGlassUI( - width: 72.w, - height: 26.h, - borderRadius: BorderRadius.circular(5.r), - borderColor: const Color(0xFFD90B2E), - customWidget: - Center(child: text14400white("Follow")), - borderwidth: 1), - sizedBoxWidth(6.w), - PopupMenuButton( - surfaceTintColor: const Color(0xFF222935), - constraints: - BoxConstraints.tightFor(width: 176.w), - offset: const Offset(0, 50), - color: const Color(0xFF222935), - tooltip: "", - itemBuilder: (BuildContext context) => - [ - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: - EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - Text( - 'Report Post', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/Vector (5).png", - height: 15.h, - width: 15.w, - ) - ], - ), - ), - ), - const PopupMenuDivider(), - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: - EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - Text( - 'Share post', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ), - 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: 12.w), - child: Row( - children: [ - Text( - 'Pin', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/f7_pin-fill (2).png", - height: 25.h, - width: 25.w, - ) - ], - ), - ), - ), - ], - child: Image.asset( - 'assets/images/png/Group 1000004071.png', - width: 16.w, - height: 18.h, - ), - ), - ], - ), - sizedBoxHeight(5.h), - Row( - children: [ - Image.asset( - 'assets/images/png/community 1 (traced).png', - height: 14.w, - width: 14.w, - ), - sizedBoxWidth(7.w), - text12w400_FCFCFC('Active alliance network'), - sizedBoxWidth(7.w), - Icon( - Icons.circle, - color: const Color(0xFFFCFCFC), - size: 4.sp, - ), - sizedBoxWidth(6.w), - text12w400_FCFCFC('1 Hour ago'), - ], - ) - ], - ), - ), - ], - ), - ), - sizedBoxHeight(20.h), - GestureDetector( - onTap: () { - // Get.toNamed(RouteName.postdetailsScreen); - }, - child: SizedBox( - height: 163.h, - width: double.infinity, - child: Image.asset( - mainImg, - fit: BoxFit.cover, - ), - )), - sizedBoxHeight(20.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Column(children: [ - SizedBox( - height: 30.h, - child: ListView.builder( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - itemCount: containerTitle.length, - itemBuilder: (context, index) { - return Padding( - padding: EdgeInsets.only(right: 12.w), - child: GestureDetector( - onTap: () { - Get.toNamed(RouteName.tagdetailscreen); - }, - child: containertile(text: containerTitle[index])), - ); - }, - ), - ), - sizedBoxHeight(20.h), - text16w400_FCFCFC( - "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s . . ."), - Row(children: [ - stackReaction(number: '20', containerImages: [ - 'assets/images/png/f7_hand-thumbsup.png', - 'assets/images/png/heart 2.png', - 'assets/images/png/party-popper 2.png' - ]), - const Spacer(), - commonGlassUI( - borderwidth: 0.9, - width: 30.w, - height: 30.h, - borderRadius: BorderRadius.circular(100.r), - customWidget: Center( - child: Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 13.h, - width: 13.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC('20'), - sizedBoxWidth(20.w), - commonGlassUI( - borderwidth: 0.9, - width: 30.w, - height: 30.h, - borderRadius: BorderRadius.circular(100.r), - customWidget: Center( - child: Image.asset( - 'assets/images/png/Vector (1).png', - height: 12.h, - width: 12.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC('10'), - ]), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Obx(() { - return ReactionButton( - onReactionChanged: (reaction) { - updateImage(reaction?.value ?? 'like'); - debugPrint('Selected value: ${reaction?.value}'); - }, - reactions: ?>[ - Reaction( - value: 'like', - previewIcon: _buildReactionsPreviewIcon( - 'assets/images/png/f7_hand-thumbsup.png'), - icon: _buildReactionsIcon( - 'assets/images/png/f7_hand-thumbsup.png'), - ), - Reaction( - value: 'heart', - previewIcon: _buildReactionsPreviewIcon( - 'assets/images/png/heart 2.png'), - icon: _buildReactionsIcon( - 'assets/images/png/heart 2.png'), - ), - Reaction( - value: 'party', - previewIcon: _buildReactionsPreviewIcon( - 'assets/images/png/party-popper 2.png'), - icon: _buildReactionsIcon( - 'assets/images/png/party-popper 2.png'), - ), - ], - selectedReaction: Reaction( - value: 'like', - icon: _buildReactionsIcon( - 'assets/images/png/f7_hand-thumbsup.png'), - ), - boxColor: Colors.white, - boxElevation: 9, - boxRadius: 30, - itemsSpacing: 8, - itemScale: 0.4, - itemSize: const Size(45, 45), - boxPadding: const EdgeInsets.all(8), - boxAnimationDuration: - const Duration(milliseconds: 200), - itemAnimationDuration: - const Duration(milliseconds: 500), - hoverDuration: const Duration(milliseconds: 700), - // toggle: false, - - child: _buildReactionsIcon(mainImage.value), - ); - }) - ], - ), - Column( - children: [ - Image.asset( - 'assets/images/png/Frame 1000004089.png', - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Save') - ], - ) - ], - ), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - ]), - ), - ], - )); - } - - Widget _buildReactionsPreviewIcon(String assetPath) { - return Padding( - padding: const EdgeInsets.all(8.0), - child: Image.asset( - assetPath, - height: 40.h, - width: 40.w, - ), - ); - } - - Widget _buildReactionsIcon(String assetPath) { - return Column( - children: [ - Image.asset( - assetPath, - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Like') - ], - ); - } -} diff --git a/lib/Common/api_urls.dart b/lib/Common/api_urls.dart index eaeb7ec..05db8dd 100644 --- a/lib/Common/api_urls.dart +++ b/lib/Common/api_urls.dart @@ -116,7 +116,6 @@ class ApiUrls { static const postrejectinvite = "${baseUrl}reject-invite-to-join-community"; - static const getusercertificates = "${baseUrl}my-certificates"; static const postnotification = "${baseUrl}update-notification-settings"; @@ -178,9 +177,9 @@ class ApiUrls { static const getpostdetail = "${baseUrl}fetch-single-post"; static const getpopularTagsdetails = "${baseUrl}fetch-popular-post"; - + static const postcreatecommunity = "${baseUrl}create-community"; - + static const getcommunityaddgroups = "${baseUrl}fetch-groups-to-add"; static const getcommunitygroups = "${baseUrl}fetch-community-all-groups"; @@ -193,7 +192,10 @@ class ApiUrls { static const getactivitieslist = "${baseUrl}get_activity"; + static const getcommunitymanagegroups = "${baseUrl}fetch-community-all-groups-list"; + static const postremovegroupscommunity = "${baseUrl}remove-groups-from-community"; + static const postmanageaddgroupscommunity = "${baseUrl}add-groups-in-community"; } diff --git a/lib/Common/controller/NormalPostCard.dart b/lib/Common/controller/NormalPostCard.dart index 6096b92..3f276e6 100644 --- a/lib/Common/controller/NormalPostCard.dart +++ b/lib/Common/controller/NormalPostCard.dart @@ -26,27 +26,26 @@ class NormalCardTile extends StatefulWidget { String forWhichTab; List reactions; Map selectedReactions; - bool? coachbool; + bool? coachbool; int currentIndex; - NormalCardTile({ - Key? key, - required this.tags, - this.createAt, - required this.forWhichTab, - required this.commonObj, - required this.reactions, - required this.selectedReactions, - required this.currentIndex, - this.coachbool - }) : super(key: key); + NormalCardTile( + {Key? key, + required this.tags, + this.createAt, + required this.forWhichTab, + required this.commonObj, + required this.reactions, + required this.selectedReactions, + required this.currentIndex, + this.coachbool}) + : super(key: key); @override _NormalCardTileState createState() => _NormalCardTileState(); } class _NormalCardTileState extends State { - RxString mainImage = 'assets/images/png/uiw_like-o.png'.obs; final CountersHelper countersHelper = Get.find(); int saveCount = 0; @@ -175,488 +174,507 @@ class _NormalCardTileState extends State { .split( "https://regroup.betadelivery.com/storage/app/public/uploads/post_image/") .last; - return commonGlassUI( - width: double.infinity, - height: 765.h, - mainOpacity: 1, - borderRadius: BorderRadius.circular(1), - customWidget: Column( - children: [ - sizedBoxHeight(25.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CircleAvatar( - backgroundImage: widget - .commonObj.iamPrincipal?.profilePhoto != - null - ? NetworkImage( - widget.commonObj.iamPrincipal!.profilePhoto!) - as ImageProvider - : const AssetImage('assets/images/default_profile.png') - as ImageProvider, - radius: 25.r, - ), - sizedBoxWidth(12.w), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - text16w400_FCFCFC( - widget.commonObj.iamPrincipal!.fullName ?? - "Regroup"), - sizedBoxWidth(10.w), - widget.coachbool == true - ? Container( - width: 75.w, - height: 25.h, - decoration: BoxDecoration( - border: Border.all( - color: const Color(0xFFD90B2E), - width: 1.w, - ), - borderRadius: BorderRadius.circular(5.r), - ), - child: - Center(child: text12w400_FCFCFC("Coach")), - ) - : const SizedBox(), - ], - ), - sizedBoxHeight(5.h), - Row( - children: [ - Image.asset( - 'assets/images/png/community 1 (traced).png', - height: 14.w, - width: 14.w, - ), - sizedBoxWidth(7.w), - text12w400_FCFCFC( - widget.commonObj.community!.communityName ?? ""), - sizedBoxWidth(7.w), - Icon( - Icons.circle, - color: const Color(0xFFFCFCFC), - size: 4.sp, - ), - sizedBoxWidth(6.w), - text12w400_FCFCFC(widget.createAt!), - ], - ) - ], - ), - const Spacer(), - PopupMenuButton( - surfaceTintColor: const Color(0xFF222935), - constraints: BoxConstraints.tightFor(width: 176.w), - offset: const Offset(0, 50), - color: const Color(0xFF222935), - tooltip: "", - itemBuilder: (BuildContext context) => [ - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - Text( - 'Report Post', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/Vector (5).png", - height: 15.h, - width: 15.w, - ) - ], - ), - ), - ), - const PopupMenuDivider(), - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - Text( - 'Share post', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/share.png", - height: 20.h, - width: 20.w, - ) - ], - ), - ), - ), - const PopupMenuDivider(), - PopupMenuItem( - onTap: () { - pinunpinUser(widget.commonObj.iamPrincipal!.id!); - }, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - countersHelper.pinButtonPopular[widget.currentIndex] - ? 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(), - countersHelper - .pinButtonPopular[widget.currentIndex] - ? 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, - ) - ], - ), - ), - ), - ], - child: Image.asset( - 'assets/images/png/Group 1000004071.png', - width: 16.w, - height: 18.h, - ), - ), - sizedBoxWidth(5.w) - ], - ), - ), - sizedBoxHeight(20.h), - GestureDetector( - onTap: () async { - bool result = await Get.toNamed(RouteName.postdetailsScreen, - arguments: { - 'postId': widget.commonObj.id, - 'tagsList': widget.tags, - 'created_at': widget.createAt, - 'commonObj': widget.commonObj, - 'fromWhichTab': widget.forWhichTab, - 'reactions': widget.reactions, - 'selectedReactions': widget.selectedReactions, - 'currentIndex': widget.currentIndex - }); - if (result) { - setState(() {}); - } - }, - child: SizedBox( - height: 360, - width: double.infinity, - child: CachedNetworkImage( - cacheKey: imgUrl, - imageUrl: widget.commonObj.image!, - fit: BoxFit.cover, - placeholder: (context, url) => const Center( - child: - CircularProgressIndicator()), // Optional: shows a loading indicator while the image is loading - errorWidget: (context, url, error) => const Center( - child: Icon(Icons - .error)), // Optional: shows an error icon if the image fails to load - ), - )), - sizedBoxHeight(20.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Column(children: [ - SizedBox( - height: 30.h, - child: ListView.builder( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - itemCount: widget.tags.length, - itemBuilder: (context, index) { - var manageTag = widget.tags[index]; - return Padding( - padding: EdgeInsets.only(right: 12.w), - child: GestureDetector( - onTap: () { - Get.toNamed(RouteName.tagdetailscreen, arguments: { - 'tagid': manageTag.id, - 'tagname': manageTag.name, - 'ispinnedtag': manageTag.isPinned, - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - commonContainer( - width: 130.w, - height: 30.h, - borderRadius: BorderRadius.circular(30.r), - borderColor: const Color(0xFFD90B2E), - opacity1: 0.04, - opacity2: 0.05, - customWidget: Padding( - padding: - EdgeInsets.symmetric(horizontal: 10.w), - child: Center( - child: text14w400_FCFCFC( - '#${manageTag.name}', - ), - ), - ), - ), - ], - ), - ), - ); - }, - ), - ), - sizedBoxHeight(20.h), - SizedBox( - height: 80.h, - width: double.infinity, - child: SingleChildScrollView( - child: text16w400_FCFCFC(widget.commonObj.caption ?? "")), - ), - sizedBoxHeight(20.h), - Row(children: [ - Obx( - () => InkWell( - onTap: () { - Get.toNamed(RouteName.reactionview, arguments: { - 'postId': widget.commonObj.id, - }); - }, - child: stackReaction( - number: countersHelper - .likesCounterPopular[widget.currentIndex] - .toString(), - containerImages: [ - 'assets/images/png/f7_hand-thumbsup.png', - 'assets/images/png/heart 2.png', - 'assets/images/png/party-popper 2.png' - ]), - ), - ), - const Spacer(), - commonContainer( - width: 30.w, - height: 30.h, - borderColor: const Color(0xFF434A53), - borderwidth: 0.43, - opacity1: 0.2, - opacity2: 0.2, - boxShape: BoxShape.circle, - customWidget: Center( - child: Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 13.h, - width: 13.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC( - widget.commonObj.totalCommentCount.toString()), - sizedBoxWidth(20.w), - commonContainer( - width: 30.w, - height: 30.h, - borderColor: const Color(0xFF434A53), - borderwidth: 0.43, - opacity1: 0.2, - opacity2: 0.2, - boxShape: BoxShape.circle, - customWidget: Center( - child: Image.asset( - 'assets/images/png/Vector (1).png', - height: 12.h, - width: 12.w, - ), - ), - ), - sizedBoxWidth(12.w), - Obx( - () => text14w400_FCFCFC(countersHelper - .savePostCounterPopular[widget.currentIndex] - .toString()), - ), - ]), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + + return ConstrainedBox( + constraints: BoxConstraints(minHeight: 750.h), + child: commonGlassUI( + width: double.infinity, + height: 600.h, + mainOpacity: 1, + borderRadius: BorderRadius.circular(1), + customWidget: Column( + children: [ + sizedBoxHeight(25.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, children: [ + CircleAvatar( + backgroundImage: + widget.commonObj.iamPrincipal?.profilePhoto != null + ? NetworkImage(widget.commonObj.iamPrincipal! + .profilePhoto!) as ImageProvider + : const AssetImage( + 'assets/images/default_profile.png') + as ImageProvider, + radius: 25.r, + ), + sizedBoxWidth(12.w), Column( - mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - ReactionButton( - onReactionChanged: (reaction) async { - _handleReactionChange(reaction); + Row( + children: [ + text16w400_FCFCFC( + widget.commonObj.iamPrincipal!.fullName ?? + "Regroup"), + sizedBoxWidth(10.w), + widget.coachbool == true + ? Container( + width: 75.w, + height: 25.h, + decoration: BoxDecoration( + border: Border.all( + color: const Color(0xFFD90B2E), + width: 1.w, + ), + borderRadius: BorderRadius.circular(5.r), + + ), + child: Center( + child: text12w400_FCFCFC("Coach")), + ) + : const SizedBox(), + ], + ), + sizedBoxHeight(5.h), + Row( + children: [ + Image.asset( + 'assets/images/png/community 1 (traced).png', + height: 14.w, + width: 14.w, + ), + sizedBoxWidth(7.w), + text12w400_FCFCFC( + widget.commonObj.community!.communityName ?? + ""), + sizedBoxWidth(7.w), + Icon( + Icons.circle, + color: const Color(0xFFFCFCFC), + size: 4.sp, + ), + sizedBoxWidth(6.w), + text12w400_FCFCFC(widget.createAt!), + ], + ) + ], + ), + const Spacer(), + PopupMenuButton( + surfaceTintColor: const Color(0xFF222935), + constraints: BoxConstraints.tightFor(width: 176.w), + offset: const Offset(0, 50), + color: const Color(0xFF222935), + tooltip: "", + itemBuilder: (BuildContext context) => [ + PopupMenuItem( + onTap: () {}, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 12.w), + child: Row( + children: [ + Text( + 'Report Post', + style: TextStyle( + fontSize: 16.sp, + color: Colors.white, + fontWeight: FontWeight.w800, + fontFamily: "Nunito Sans", + ), + ), + const Spacer(), + Image.asset( + "assets/images/png/Vector (5).png", + height: 15.h, + width: 15.w, + ) + ], + ), + ), + ), + const PopupMenuDivider(), + PopupMenuItem( + onTap: () {}, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 12.w), + child: Row( + children: [ + Text( + 'Share post', + style: TextStyle( + fontSize: 16.sp, + color: Colors.white, + fontWeight: FontWeight.w800, + fontFamily: "Nunito Sans", + ), + ), + const Spacer(), + Image.asset( + "assets/images/png/share.png", + height: 20.h, + width: 20.w, + ) + ], + ), + ), + ), + const PopupMenuDivider(), + PopupMenuItem( + onTap: () { + pinunpinUser(widget.commonObj.iamPrincipal!.id!); }, - reactions: widget.reactions - .map((reaction) => Reaction( - value: reaction.id.toString(), - previewIcon: Image.network(reaction.image, - width: 24, - height: 24, - fit: BoxFit.cover), - icon: Image.network(reaction.image, - width: 24, - height: 24, - fit: BoxFit.cover), - )) - .toList(), - selectedReaction: widget - .selectedReactions[widget.commonObj.id] != - null - ? Reaction( - value: widget - .selectedReactions[widget.commonObj.id]! - .id - .toString(), - icon: Image.network( + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 12.w), + child: Row( + children: [ + countersHelper + .pinButtonPopular[widget.currentIndex] + ? 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(), + countersHelper + .pinButtonPopular[widget.currentIndex] + ? 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, + ) + ], + ), + ), + ), + ], + child: Image.asset( + 'assets/images/png/Group 1000004071.png', + width: 16.w, + height: 18.h, + ), + ), + sizedBoxWidth(5.w) + ], + ), + ), + sizedBoxHeight(20.h), + GestureDetector( + onTap: () async { + bool result = await Get.toNamed(RouteName.postdetailsScreen, + arguments: { + 'postId': widget.commonObj.id, + 'tagsList': widget.tags, + 'created_at': widget.createAt, + 'commonObj': widget.commonObj, + 'fromWhichTab': widget.forWhichTab, + 'reactions': widget.reactions, + 'selectedReactions': widget.selectedReactions, + 'currentIndex': widget.currentIndex + }); + if (result) { + setState(() {}); + } + }, + child: SizedBox( + height: 360, + width: double.infinity, + child: CachedNetworkImage( + cacheKey: imgUrl, + imageUrl: widget.commonObj.image!, + fit: BoxFit.cover, + placeholder: (context, url) => const Center( + child: + CircularProgressIndicator()), // Optional: shows a loading indicator while the image is loading + errorWidget: (context, url, error) => const Center( + child: Icon(Icons + .error)), // Optional: shows an error icon if the image fails to load + ), + )), + sizedBoxHeight(20.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Column(children: [ + SizedBox( + height: 30.h, + child: ListView.builder( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + itemCount: widget.tags.length, + itemBuilder: (context, index) { + var manageTag = widget.tags[index]; + return Padding( + padding: EdgeInsets.only(right: 12.w), + child: GestureDetector( + onTap: () { + Get.toNamed(RouteName.tagdetailscreen, + arguments: { + 'tagid': manageTag.id, + 'tagname': manageTag.name, + 'ispinnedtag': manageTag.isPinned, + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + commonContainer( + width: 130.w, + height: 30.h, + borderRadius: BorderRadius.circular(30.r), + borderColor: const Color(0xFFD90B2E), + opacity1: 0.04, + opacity2: 0.05, + customWidget: Padding( + padding: + EdgeInsets.symmetric(horizontal: 10.w), + child: Center( + child: text14w400_FCFCFC( + '#${manageTag.name}', + ), + ), + ), + ), + ], + ), + ), + ); + }, + ), + ), + sizedBoxHeight(20.h), + SizedBox( + width: double.infinity, + child: Text( + widget.commonObj.caption ?? "", + style: TextStyle( + fontSize: 16.sp, + color: Colors.white, + fontFamily: "Nunito Sans", + ), + maxLines: 2, // Set the maximum number of lines + overflow: TextOverflow + .ellipsis, // Truncate the text with an ellipsis + ), + ), + // sizedBoxHeight(20.h), + Row(children: [ + Obx( + () => InkWell( + onTap: () { + Get.toNamed(RouteName.reactionview, arguments: { + 'postId': widget.commonObj.id, + }); + }, + child: stackReaction( + number: countersHelper + .likesCounterPopular[widget.currentIndex] + .toString(), + containerImages: [ + 'assets/images/png/f7_hand-thumbsup.png', + 'assets/images/png/heart 2.png', + 'assets/images/png/party-popper 2.png' + ]), + ), + ), + const Spacer(), + commonContainer( + width: 30.w, + height: 30.h, + borderColor: const Color(0xFF434A53), + borderwidth: 0.43, + opacity1: 0.2, + opacity2: 0.2, + boxShape: BoxShape.circle, + customWidget: Center( + child: Image.asset( + 'assets/images/png/Frame 1000004088.png', + height: 13.h, + width: 13.w, + ), + ), + ), + sizedBoxWidth(12.w), + text14w400_FCFCFC( + widget.commonObj.totalCommentCount.toString()), + sizedBoxWidth(20.w), + commonContainer( + width: 30.w, + height: 30.h, + borderColor: const Color(0xFF434A53), + borderwidth: 0.43, + opacity1: 0.2, + opacity2: 0.2, + boxShape: BoxShape.circle, + customWidget: Center( + child: Image.asset( + 'assets/images/png/Vector (1).png', + height: 12.h, + width: 12.w, + ), + ), + ), + sizedBoxWidth(12.w), + Obx( + () => text14w400_FCFCFC(countersHelper + .savePostCounterPopular[widget.currentIndex] + .toString()), + ), + ]), + sizedBoxHeight(12.h), + commonDivider(), + sizedBoxHeight(12.h), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ReactionButton( + onReactionChanged: (reaction) async { + _handleReactionChange(reaction); + }, + reactions: widget.reactions + .map((reaction) => Reaction( + value: reaction.id.toString(), + previewIcon: Image.network(reaction.image, + width: 24, + height: 24, + fit: BoxFit.cover), + icon: Image.network(reaction.image, + width: 24, + height: 24, + fit: BoxFit.cover), + )) + .toList(), + selectedReaction: widget.selectedReactions[ + widget.commonObj.id] != + null + ? Reaction( + value: widget + .selectedReactions[widget.commonObj.id]! + .id + .toString(), + icon: Image.network( + widget + .selectedReactions[ + widget.commonObj.id]! + .image, + width: 24, + height: 24, + fit: BoxFit.cover, + ), + ) + : null, + boxColor: Colors.white, + boxElevation: 9, + boxRadius: 30, + itemsSpacing: 20, + itemScale: 0.3, + itemSize: const Size(30, 30), + boxPadding: const EdgeInsets.all(8), + boxAnimationDuration: + const Duration(milliseconds: 200), + itemAnimationDuration: + const Duration(milliseconds: 500), + hoverDuration: const Duration(milliseconds: 700), + child: widget.selectedReactions[ + widget.commonObj.id] != + null + ? Image.network( widget .selectedReactions[widget.commonObj.id]! .image, width: 24, height: 24, fit: BoxFit.cover, - ), - ) - : null, - boxColor: Colors.white, - boxElevation: 9, - boxRadius: 30, - itemsSpacing: 20, - itemScale: 0.3, - itemSize: const Size(30, 30), - boxPadding: const EdgeInsets.all(8), - boxAnimationDuration: - const Duration(milliseconds: 200), - itemAnimationDuration: - const Duration(milliseconds: 500), - hoverDuration: const Duration(milliseconds: 700), - child: widget - .selectedReactions[widget.commonObj.id] != - null - ? Image.network( - widget.selectedReactions[widget.commonObj.id]! - .image, - width: 24, - height: 24, - fit: BoxFit.cover, - ) - : Image.asset( - 'assets/images/png/uiw_like-o.png', - width: 24, - height: 24, - fit: BoxFit.cover, - ), - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Like'), - ], - ), - GestureDetector( - onTap: () async { - bool result = await Get.toNamed( - RouteName.postdetailsScreen, - arguments: { - 'postId': widget.commonObj.id, - 'tagsList': widget.tags, - 'created_at': widget.createAt, - 'commonObj': widget.commonObj, - 'fromWhichTab': widget.forWhichTab, - 'reactions': widget.reactions, - 'selectedReactions': widget.selectedReactions, - 'currentIndex': widget.currentIndex - }); - if (result) { - setState(() {}); - } - }, - child: Column( - children: [ - Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Comment') - ], - ), - ), - Obx( - () => Column( - //here - children: [ - GestureDetector( - onTap: () async => - await saveunsavepost(widget.commonObj.id!), - child: countersHelper - .saveButtonPopular[widget.currentIndex] - ? Image.asset( - 'assets/images/png/postSaved.png', - height: 19.h, - width: 19.w, ) : Image.asset( - 'assets/images/png/Frame 1000004089.png', - height: 19.h, - width: 19.w, + 'assets/images/png/uiw_like-o.png', + width: 24, + height: 24, + fit: BoxFit.cover, ), ), sizedBoxHeight(8.h), - text11w400_FCFCFC('Save') + text11w400_FCFCFC('Like'), ], ), - ), - ], - ), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - ]), - ), - ], - )); + GestureDetector( + onTap: () async { + bool result = await Get.toNamed( + RouteName.postdetailsScreen, + arguments: { + 'postId': widget.commonObj.id, + 'tagsList': widget.tags, + 'created_at': widget.createAt, + 'commonObj': widget.commonObj, + 'fromWhichTab': widget.forWhichTab, + 'reactions': widget.reactions, + 'selectedReactions': widget.selectedReactions, + 'currentIndex': widget.currentIndex + }); + if (result) { + setState(() {}); + } + }, + child: Column( + children: [ + Image.asset( + 'assets/images/png/Frame 1000004088.png', + height: 19.h, + width: 19.w, + ), + sizedBoxHeight(8.h), + text11w400_FCFCFC('Comment') + ], + ), + ), + Obx( + () => Column( + //here + children: [ + GestureDetector( + onTap: () async => + await saveunsavepost(widget.commonObj.id!), + child: countersHelper + .saveButtonPopular[widget.currentIndex] + ? Image.asset( + 'assets/images/png/postSaved.png', + height: 19.h, + width: 19.w, + ) + : Image.asset( + 'assets/images/png/Frame 1000004089.png', + height: 19.h, + width: 19.w, + ), + ), + sizedBoxHeight(8.h), + text11w400_FCFCFC('Save') + ], + ), + ), + ], + ), + sizedBoxHeight(12.h), + commonDivider(), + sizedBoxHeight(12.h), + ]), + ), + ], + )), + ); } } diff --git a/lib/Feed Module/Main_Screens/Community/view_model/getApi.dart b/lib/Feed Module/Main_Screens/Community/view_model/getApi.dart index 6948edd..318df56 100644 --- a/lib/Feed Module/Main_Screens/Community/view_model/getApi.dart +++ b/lib/Feed Module/Main_Screens/Community/view_model/getApi.dart @@ -7,6 +7,7 @@ import 'package:regroup/Common/controller/data/network/network_api.dart'; class Communitygetmethod { + getTagsdata(id) {} } \ No newline at end of file diff --git a/lib/Main_Screens/Community_HomePage/Community.dart b/lib/Main_Screens/Community_HomePage/Community.dart index 5da33ef..41cfc94 100644 --- a/lib/Main_Screens/Community_HomePage/Community.dart +++ b/lib/Main_Screens/Community_HomePage/Community.dart @@ -494,34 +494,6 @@ class _FeedTabState extends State { } } -// ignore: must_be_immutable - -Widget containertile({required String text}) { - return commonGlassContainer( - border: 1, - width: 130.w, - height: 30.h, - borderradius: 30.r, - borderColor: const Color(0xFFD90B2E), - customWidget: Padding( - padding: EdgeInsets.symmetric(horizontal: 10.w), - child: Center(child: text14w400_FCFCFC(text)), - )); -} - -Widget containertile2({required String text}) { - return commonContainer( - width: 130.w, - height: 30.h, - borderRadius: BorderRadius.circular(30.r), - borderColor: const Color(0xFFD90B2E), - opacity1: 0.04, - opacity2: 0.05, - customWidget: Padding( - padding: EdgeInsets.symmetric(horizontal: 10.w), - child: Center(child: text14w400_FCFCFC(text)), - )); -} class PopularTab extends StatefulWidget { const PopularTab({super.key}); diff --git a/lib/Main_Screens/Community_HomePage/PostScreen.dart b/lib/Main_Screens/Community_HomePage/PostScreen.dart index 344c561..f8cc5e4 100644 --- a/lib/Main_Screens/Community_HomePage/PostScreen.dart +++ b/lib/Main_Screens/Community_HomePage/PostScreen.dart @@ -94,23 +94,9 @@ class _PostScreenState extends State { List selectedabilityid = []; int? communityid; - // void getCatIdFromName(List selectedAbilities) { - // selectedabilityid.clear(); // Clear existing selections - // for (var name in selectedAbilities) { - // for (var i = 0; i < postcommunity.length; i++) { - // if (name == postcommunity[i].community!.communityName) { - // selectedabilityid.add(postcommunity[i].community!.id!); - // communityid = postcommunity[i].community!.id!; - // // fetchPopularlist(postcommunity[i].id!); - // fetchPopularTags(communityid!); - // _isSecondDropdownEnabled = true; - - // break; // Assuming each name is unique, we break after finding a match - // } - // } - // } - // print('Selected IDs: $selectedabilityid'); - // } + String? _selectedPostType; + int? posttagtype; + bool isCommunitySelected = false; void getCatIdFromName(List selectedAbilities) { selectedabilityid.clear(); // Clear existing selections @@ -119,9 +105,17 @@ class _PostScreenState extends State { if (name == postcommunity[i].community!.communityName) { selectedabilityid.add(postcommunity[i].community!.id!); communityid = postcommunity[i].community!.id!; + setState(() { + _selectedPostType = null; + _isSecondDropdownEnabled = false; + }); // Fetch tags for the selected community - fetchPopularTags(communityid!); - _isSecondDropdownEnabled = true; + // fetchPopularTags(communityid!, tagtype!); + // _isSecondDropdownEnabled = true; + // if (tagtype != null) { + // fetchPopularTags(communityid!, tagtype!); + // _isSecondDropdownEnabled = true; + // } break; // Assuming each name is unique, we break after finding a match } } @@ -131,7 +125,7 @@ class _PostScreenState extends State { List tags = []; // Change the type to List - Future fetchPopularTags(int communityId) async { + Future fetchPopularTags(int communityId, int tagtype) async { SharedPreferences prefs = await SharedPreferences.getInstance(); token = prefs.getString('access-token'); String basicAuth = 'Basic ' + @@ -141,7 +135,7 @@ class _PostScreenState extends State { try { final response = await Dio().get( // 'https://regroup.betadelivery.com/api/v1/fetch-popular-tags?manage_community_xid=$communityId&name=', - 'https://regroup.betadelivery.com/api/v1/fetch-popular-tags?manage_community_xid=$communityId&name=', + 'https://regroup.betadelivery.com/api/v1/fetch-popular-tags?manage_community_xid=$communityId&is_special=$tagtype&name=', options: Options( headers: {'authorization': basicAuth, 'access-token': token}, )); @@ -340,6 +334,7 @@ class _PostScreenState extends State { "post_in": communityid, "manage_tags_xids": selectedtags, "post_as": _selectedPostas, + "is_announcement": posttagtype }); final data = await Communitypostmethod().postUpload(formdata); if (data.status == ResponseStatus.SUCCESS) { @@ -379,6 +374,7 @@ class _PostScreenState extends State { "post_as": _selectedPostas, "cta_title": ctatitilecontroller.text, "cta_link": ctalinkcontroller.text, + "is_announcement": posttagtype }); final data = await Communitypostmethod().postUpload(formdata); if (data.status == ResponseStatus.SUCCESS) { @@ -426,15 +422,67 @@ class _PostScreenState extends State { title: "", listData: _postindrop, - onItemSelected: getCatIdFromName, + onItemSelected: + // getCatIdFromName, + (List selectedAbilities) { + getCatIdFromName(selectedAbilities); + isCommunitySelected = true; + }, // (p0) {}, images: _postindropimages, leadingImage: const SizedBox(), ), sizedBoxHeight(20.h), - text16w400_FCFCFC("Caption"), + // sizedBoxHeight(20.h), + text16w400_FCFCFC("Post type"), sizedBoxHeight(18.h), + CustomRadioListTile( + title: 'Regular', + subtitle: + 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.', + value: 'Regular', + groupValue: _selectedPostType, + onChanged: (String? value) { + if (isCommunitySelected && communityid != null) { + setState(() { + _selectedPostType = value!; + posttagtype = 0; + fetchPopularTags(communityid!, + posttagtype!); // Call the API after both selections + _isSecondDropdownEnabled = true; + }); + } else { + utils.showToast('Please select a community first.'); + } + }, + activeColor: Color(0XFFD90B2E), + ), + CustomRadioListTile( + title: 'Announcement', + subtitle: + 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.', + value: 'Announcement', + groupValue: _selectedPostType, + onChanged: (String? value) { + if (isCommunitySelected && communityid != null) { + setState(() { + _selectedPostType = value!; + posttagtype = 1; + fetchPopularTags(communityid!, + posttagtype!); // Call the API after both selections + _isSecondDropdownEnabled = true; + }); + } else { + utils.showToast('Please select a community first.'); + } + }, + activeColor: Color(0XFFD90B2E), + ), + + sizedBoxHeight(38.h), + // text16w400_FCFCFC("Caption"), + // sizedBoxHeight(18.h), CustomTextFormField2( maxlines: 3, hintText: "Enter caption", @@ -454,90 +502,90 @@ class _PostScreenState extends State { sizedBoxHeight(25.h), text16w400_FCFCFC("Media"), sizedBoxHeight(18.h), - GestureDetector( - onTap: () { - ImageUploadBottomSheet().showModal( - context, - false, - (result) { - if (result != null && result.isNotEmpty) { - var file = File(result); + DottedBorder( + strokeWidth: 1, + dashPattern: const [7, 4], + borderType: BorderType.RRect, + radius: Radius.circular(14.r), + color: const Color(0xFF434A53), + child: commonGlassUI( + width: double.infinity, + height: 339.h, + borderRadius: BorderRadius.circular(10.r), + borderColor: Colors.transparent, + 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: const Color(0xFF7E7E7E), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 5)), + ), + child: const 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); + // 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 + 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: DottedBorder( - strokeWidth: 1, - dashPattern: const [7, 4], - borderType: BorderType.RRect, - radius: Radius.circular(14.r), - color: const Color(0xFF434A53), - child: commonGlassUI( - width: double.infinity, - height: 339.h, - borderRadius: BorderRadius.circular(10.r), - borderColor: Colors.transparent, - customWidget: bannerPath.isNotEmpty && - isbannerAdded - ? Stack(children: [ - Image.file( - bannerPath[0]!, - fit: BoxFit.cover, - width: double.infinity, - ), - Positioned( - right: 5, - bottom: 5, - child: GestureDetector( - onTap: () { + 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(); - isbannerAdded = false; + bannerPath.add(file); + isbannerAdded = true; setState(() {}); - }, - child: Container( - width: 27, - height: 27, - decoration: ShapeDecoration( - color: - const Color(0xFF7E7E7E), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular( - 5)), - ), - child: const Icon( - Icons.delete_outline_outlined, - color: Colors.white, - ))), - ), - ]) - : Padding( + } + } 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: Center( @@ -560,11 +608,11 @@ class _PostScreenState extends State { ], ), ), - )), - ), + ), + )), ), sizedBoxHeight(25.h), - text16w400_FCFCFC("Tags"), + text16w400_FCFCFC("Interest"), sizedBoxHeight(18.h), _isSecondDropdownEnabled == true ? CustomDropDownPopularTag( @@ -578,7 +626,15 @@ class _PostScreenState extends State { }, isFirstDropdownSelected: _isSecondDropdownEnabled, ) - : Center(child: text14400white('Select community')), + : + // SizedBox(), + Center( + child: + // isCommunitySelected == true + // ? text14400white('Select post type') + // : + text14400white('No Interests')), + sizedBoxHeight(25.h), _isSecondDropdownEnabled == true ? Column( @@ -679,14 +735,16 @@ class _PostScreenState extends State { // Condition for account type 1 if (selectedabilityid.isEmpty || selectedpopularid.isEmpty || - bannerPath.isEmpty || captioncontroller.text.isEmpty || - _selectedPostas.isEmpty) { + _selectedPostas.isEmpty || + posttagtype.isBlank!) { print('Tags selected are $selectedpopularid'); print( 'Community selected are $selectedabilityid'); print('Post as selected are $_selectedPostas'); utils.showToast('Please fill all fields'); + } else if (bannerPath.isEmpty) { + utils.showToast('Please add a media image'); } else { print('Tags selected are $selectedpopularid'); print( @@ -700,15 +758,17 @@ class _PostScreenState extends State { // You can define different validation criteria here for account type 2 if (selectedabilityid.isEmpty || selectedpopularid.isEmpty || - bannerPath.isEmpty || captioncontroller.text.isEmpty || _selectedPostas.isEmpty || ctalinkcontroller.text.isEmpty || - ctatitilecontroller.text.isEmpty) { + ctatitilecontroller.text.isEmpty || + posttagtype.isBlank!) { print('Tags selected are $selectedpopularid'); print( 'Community selected are $selectedabilityid'); utils.showToast('Please fill all fields'); + } else if (bannerPath.isEmpty) { + utils.showToast('Please add a media image'); } else { print('Tags selected are $selectedpopularid'); print( @@ -955,6 +1015,7 @@ class _CustomDropDownCheckBoxPostNewState if (onDropTap.value) Container( width: double.infinity, + height: 250.h, decoration: BoxDecoration( color: const Color(0xFFFFFFFF).withOpacity(0.10), borderRadius: @@ -987,6 +1048,7 @@ class _CustomDropDownCheckBoxPostNewState ) : ListView.builder( shrinkWrap: true, + physics: ScrollPhysics(), itemCount: widget.listData.length, itemBuilder: (context, index) { String item = widget.listData[index]; @@ -1197,6 +1259,7 @@ class _CustomDropDownPopularTagState extends State { // Dropdown List if (onDropTap.value && filteredTags.isNotEmpty) Container( + height: 250.h, width: double.infinity, decoration: BoxDecoration( color: const Color(0xFFFFFFFF).withOpacity(0.10), @@ -1207,6 +1270,7 @@ class _CustomDropDownPopularTagState extends State { ), child: ListView.builder( shrinkWrap: true, + physics: ScrollPhysics(), itemCount: filteredTags.length, itemBuilder: (context, index) { return InkWell( @@ -1281,220 +1345,55 @@ class _CustomDropDownPopularTagState extends State { } } -// class CustomDropDownPopularTag extends StatefulWidget { -// final List tags; -// final Function(List) onItemSelected; -// final bool isFirstDropdownSelected; - -// CustomDropDownPopularTag({ -// required this.tags, -// required this.onItemSelected, -// required this.isFirstDropdownSelected, -// }); - -// @override -// _CustomDropDownPopularTagState createState() => -// _CustomDropDownPopularTagState(); -// } - -// class _CustomDropDownPopularTagState extends State { -// RxBool onDropTap = false.obs; -// RxList selectedTags = [].obs; -// RxList filteredTags = [].obs; -// TextEditingController textEditingController = TextEditingController(); - -// @override -// void initState() { -// super.initState(); -// filteredTags.value = widget.tags; -// textEditingController.addListener(() { -// filterTags(); -// }); -// } - -// void _handleDropdownTap() { -// if (widget.isFirstDropdownSelected) { -// onDropTap.value = !onDropTap.value; -// } else { -// utils.showToast('Please select an item from the first dropdown.'); -// } -// } - -// void filterTags() { -// String query = textEditingController.text.toLowerCase(); -// if (query.isNotEmpty) { -// filteredTags.value = widget.tags -// .where((tag) => -// tag.name!.toLowerCase().contains(query) && -// !selectedTags.contains(tag)) -// .toList(); -// } else { -// filteredTags.value = -// widget.tags.where((tag) => !selectedTags.contains(tag)).toList(); -// } -// onDropTap.value = filteredTags.isNotEmpty; -// } - -// @override -// Widget build(BuildContext context) { -// return Obx( -// () => Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// children: [ -// // Dropdown Search Input -// Container( -// width: double.infinity, -// height: 50, -// padding: const EdgeInsets.symmetric(horizontal: 12), -// decoration: BoxDecoration( -// color: const Color(0xFFFFFFFF).withOpacity(0.10), -// borderRadius: onDropTap.value && filteredTags.isNotEmpty -// ? const BorderRadius.vertical( -// top: Radius.circular(30), -// ) -// : BorderRadius.circular(30), -// border: Border.all(color: const Color(0xFF434A53)), -// ), -// child: Center( -// child: TextFormField( -// controller: textEditingController, -// style: const TextStyle( -// fontSize: 16, -// color: Colors.white, -// fontFamily: 'Helvetica', -// ), -// cursorColor: Colors.red, -// obscureText: false, -// decoration: InputDecoration( -// hintText: 'Search Tags', -// hintStyle: const TextStyle( -// fontSize: 16, -// color: Colors.white, -// fontWeight: FontWeight.w400, -// fontFamily: 'Helvetica', -// ), -// suffixIcon: GestureDetector( -// onTap: _handleDropdownTap, -// // () { -// // onDropTap.value = !onDropTap.value; - -// // }, -// child: SizedBox( -// height: 20, -// width: 20, -// child: Center( -// child: Icon( -// onDropTap.value -// ? Icons.arrow_drop_up -// : Icons.arrow_drop_down, -// color: Colors.white, -// ), -// ), -// ), -// ), -// border: InputBorder.none, -// ), -// onTap: _handleDropdownTap -// // () { -// // onDropTap.value = !onDropTap.value; -// // }, -// ), -// ), -// ), - -// // Dropdown List -// if (onDropTap.value && filteredTags.isNotEmpty) -// Container( -// width: double.infinity, -// decoration: BoxDecoration( -// color: const Color(0xFFFFFFFF).withOpacity(0.10), -// borderRadius: const BorderRadius.vertical( -// bottom: Radius.circular(30), -// ), -// border: Border.all(color: const Color(0xFF434A53)), -// ), -// child: ListView.builder( -// shrinkWrap: true, -// itemCount: filteredTags.length, -// itemBuilder: (context, index) { -// return InkWell( -// onTap: () { -// Data selectedItem = filteredTags[index]; -// if (selectedTags.contains(selectedItem)) { -// selectedTags.remove(selectedItem); -// } else { -// selectedTags.add(selectedItem); -// } -// textEditingController.clear(); -// widget.onItemSelected(selectedTags.toList()); -// filterTags(); // Update the filtered list -// }, -// child: Padding( -// padding: const EdgeInsets.all(10.0), -// child: Row( -// children: [ -// Text( -// filteredTags[index].name!, -// style: const TextStyle( -// color: Colors.white, -// fontSize: 16, -// fontWeight: FontWeight.w400, -// fontFamily: 'Helvetica', -// ), -// ), -// const Spacer(), -// Text( -// 'Popularity: ${filteredTags[index].tagPopularity}', -// style: const TextStyle( -// color: Colors.white70, -// fontSize: 12, -// ), -// ), -// ], -// ), -// ), -// ); -// }, -// ), -// ), -// sizedBoxHeight(20.h), - -// // Selected Tags Displayed as Chips -// if (selectedTags.isNotEmpty) -// Wrap( -// spacing: 8.0, -// runSpacing: 4.0, -// children: selectedTags.map((tag) { -// return Chip( -// label: Text('#${tag.name!}', -// style: const TextStyle(color: Colors.white)), -// backgroundColor: const Color(0xFFD90B2E).withOpacity(0.9), -// // Color(0xFFD90B2E).withOpacity(0.90), - -// // Colors.transparent, // Make Chip background transparent -// side: BorderSide(color: Colors.black), -// shape: RoundedRectangleBorder( -// borderRadius: BorderRadius.circular(30.r), -// side: BorderSide(width: 1, color: Colors.white)), -// onDeleted: () { -// selectedTags.remove(tag); -// widget.onItemSelected(selectedTags.toList()); -// filterTags(); // Update the filtered list after removing a tag -// }, -// materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, -// padding: const EdgeInsets.symmetric(horizontal: 16), -// ); -// }).toList(), -// ), -// ], -// ), -// ); -// } -// } - class CreateData { final int id; final String name; CreateData({required this.id, required this.name}); } + +class CustomRadioListTile extends StatelessWidget { + final String title; + final String subtitle; + final String value; + final String? groupValue; + final ValueChanged onChanged; + final Color activeColor; + + const CustomRadioListTile({ + Key? key, + required this.title, + required this.subtitle, + required this.value, + required this.groupValue, + required this.onChanged, + required this.activeColor, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () { + onChanged(value); + }, + child: ListTile( + contentPadding: EdgeInsets.zero, + leading: Transform.translate( + offset: Offset(0, -10), + child: Transform.scale( + scale: 1.5, + child: Radio( + value: value, + groupValue: groupValue, + onChanged: onChanged, + activeColor: activeColor, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + ), + ), + ), + title: text18w400white(title), + subtitle: text14400white(subtitle), + ), + ); + } +} diff --git a/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart b/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart index 74b2314..67065be 100644 --- a/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart +++ b/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart @@ -127,424 +127,6 @@ class _TagdetailScreenState extends State { } } -Widget cyclepopularTab() { - return SingleChildScrollView( - child: Column(children: [ - sizedBoxHeight(20.h), - normalcardtile( - profileImg: 'assets/images/png/Ellipse 52.png', - title: 'Ryan Dorwat', - mainImg: 'assets/images/png/img322.png', - containerTitle: [ - 'Football', - 'Teams player', - 'Events', - 'Marathon', - 'Events' - ]), - sizedBoxHeight(30.h), - normalcardtile( - profileImg: 'assets/images/png/Ellipse 43.png', - title: 'Edward Hackket', - mainImg: 'assets/images/png/Rectangle 24.png', - containerTitle: [ - 'Cycle', - 'Marathon', - 'Events', - 'Marathon', - 'Events' - ]), - ]), - ); -} - -Widget cyclelatestTab() { - return SingleChildScrollView( - child: Column(children: [ - sizedBoxHeight(20.h), - normalcardtile( - profileImg: 'assets/images/png/Ellipse 43.png', - title: 'Edward Hackket', - mainImg: 'assets/images/png/Rectangle 24.png', - containerTitle: [ - 'Cycle', - 'Marathon', - 'Events', - 'Marathon', - 'Events' - ]), - ]), - ); -} - -Widget normalcardtile({ - required String profileImg, - required String title, - required String mainImg, - required List containerTitle, -}) { - var mainImage = 'assets/images/png/uiw_like-o.png'.obs; - void updateImage(String reaction) { - if (reaction == 'like') { - mainImage.value = 'assets/images/png/f7_hand-thumbsup.png'; - } else if (reaction == 'heart') { - mainImage.value = 'assets/images/png/heart 2.png'; - } else if (reaction == 'party') { - mainImage.value = 'assets/images/png/party-popper 2.png'; - } - } - - return commonGlassUI( - width: double.infinity, - height: 570.h, - borderwidth: 0, - borderRadius: BorderRadius.circular(1), - customWidget: Column( - children: [ - sizedBoxHeight(25.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CircleAvatar( - foregroundImage: AssetImage(profileImg), - radius: 25.r, - ), - sizedBoxWidth(12.w), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC(title), - sizedBoxHeight(5.h), - Row( - children: [ - Image.asset( - 'assets/images/png/community 1 (traced).png', - height: 14.w, - width: 14.w, - ), - sizedBoxWidth(7.w), - text12w400_FCFCFC('Active alliance network'), - sizedBoxWidth(7.w), - Icon( - Icons.circle, - color: const Color(0xFFFCFCFC), - size: 4.sp, - ), - sizedBoxWidth(6.w), - text12w400_FCFCFC('1 Hour ago'), - ], - ) - ], - ), - const Spacer(), - PopupMenuButton( - surfaceTintColor: const Color(0xFF222935), - constraints: BoxConstraints.tightFor(width: 176.w), - offset: const Offset(0, 50), - color: const Color(0xFF222935), - tooltip: "", - itemBuilder: (BuildContext context) => [ - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - Text( - 'Report Post', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/Vector (5).png", - height: 15.h, - width: 15.w, - ) - ], - ), - ), - ), - const PopupMenuDivider(), - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - Text( - 'Share post', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ), - 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: 12.w), - child: Row( - children: [ - Text( - 'Pin', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/f7_pin-fill (2).png", - height: 25.h, - width: 25.w, - ) - ], - ), - ), - ), - ], - child: Image.asset( - 'assets/images/png/Group 1000004071.png', - width: 16.w, - height: 18.h, - ), - ), - sizedBoxWidth(5.w) - ], - ), - ), - sizedBoxHeight(20.h), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.postdetailsScreen); - }, - child: SizedBox( - height: 360.h, - width: double.infinity, - child: Image.asset( - mainImg, - fit: BoxFit.cover, - ), - )), - sizedBoxHeight(20.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Column(children: [ - SizedBox( - height: 30.h, - child: ListView.builder( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - itemCount: containerTitle.length, - itemBuilder: (context, index) { - return Padding( - padding: EdgeInsets.only(right: 12.w), - child: GestureDetector( - onTap: () { - // Get.toNamed(RouteName.tagdetailscreen); - }, - child: containertile(text: containerTitle[index])), - ); - }, - ), - ), - sizedBoxHeight(20.h), - text16w400_FCFCFC( - "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s . . ."), - Row(children: [ - InkWell( - onTap: () { - Get.toNamed(RouteName.reactionview); - }, - child: stackReaction(number: '20', containerImages: [ - 'assets/images/png/f7_hand-thumbsup.png', - 'assets/images/png/heart 2.png', - 'assets/images/png/party-popper 2.png' - ]), - ), - const Spacer(), - commonGlassUI( - borderwidth: 0.43, - width: 30.w, - height: 30.h, - opacity1: 0.05, - opacity2: 0.06, - borderRadius: BorderRadius.circular(100), - customWidget: Center( - child: Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 13.h, - width: 13.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC('20'), - sizedBoxWidth(20.w), - commonGlassUI( - borderwidth: 0.43, - width: 30.w, - height: 30.h, - borderRadius: BorderRadius.circular(100), - opacity1: 0.05, - opacity2: 0.06, - customWidget: Center( - child: Image.asset( - 'assets/images/png/Vector (1).png', - height: 12.h, - width: 12.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC('10'), - ]), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Obx(() { - return ReactionButton( - onReactionChanged: (reaction) { - updateImage(reaction?.value ?? 'like'); - debugPrint('Selected value: ${reaction?.value}'); - }, - reactions: ?>[ - Reaction( - value: 'like', - previewIcon: _buildReactionsPreviewIcon( - 'assets/images/png/f7_hand-thumbsup.png'), - icon: _buildReactionsIcon( - 'assets/images/png/f7_hand-thumbsup.png'), - ), - Reaction( - value: 'heart', - previewIcon: _buildReactionsPreviewIcon( - 'assets/images/png/heart 2.png'), - icon: _buildReactionsIcon( - 'assets/images/png/heart 2.png'), - ), - Reaction( - value: 'party', - previewIcon: _buildReactionsPreviewIcon( - 'assets/images/png/party-popper 2.png'), - icon: _buildReactionsIcon( - 'assets/images/png/party-popper 2.png'), - ), - ], - selectedReaction: Reaction( - value: 'like', - icon: _buildReactionsIcon( - 'assets/images/png/f7_hand-thumbsup.png'), - ), - boxColor: Colors.white, - boxElevation: 9, - boxRadius: 30, - itemsSpacing: 8, - itemScale: 0.4, - itemSize: const Size(45, 45), - boxPadding: const EdgeInsets.all(8), - boxAnimationDuration: - const Duration(milliseconds: 200), - itemAnimationDuration: - const Duration(milliseconds: 500), - hoverDuration: const Duration(milliseconds: 700), - // toggle: false, - - child: _buildReactionsIcon(mainImage.value), - ); - }) - ], - ), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.postdetailsScreen); - }, - child: Column( - children: [ - Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Comment') - ], - ), - ), - Column( - children: [ - Image.asset( - 'assets/images/png/Frame 1000004089.png', - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Save') - ], - ) - ], - ), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - ]), - ), - ], - )); -} - -Widget _buildReactionsPreviewIcon(String assetPath) { - return Padding( - padding: const EdgeInsets.all(8.0), - child: Image.asset( - assetPath, - height: 40.h, - width: 40.w, - ), - ); -} - -Widget _buildReactionsIcon(String assetPath) { - return Column( - children: [ - Image.asset( - assetPath, - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Like') - ], - ); -} - class PopularTab extends StatefulWidget { PopularTab({super.key, required this.id}); @@ -592,13 +174,15 @@ class _PopularTabState extends State { bool _isDataInitialized = true; Future setValues() async { - if (_isDataInitialized) { + // WidgetsBinding.instance.addPostFrameCallback((_) {}); + WidgetsBinding.instance.addPostFrameCallback((_) { _setModel(); - countersHelper.setListstagPopular(); - await _fetchIcons(); + countersHelper.setListsPopular(); + _fetchIcons(); + }); + //if (mounted) { - _isDataInitialized = false; - } + // } } _sortTags(index) { @@ -698,7 +282,7 @@ class _PopularTabState extends State { fit: BoxFit.fill), ), ), - tagpopulardetailobj!.data.isEmpty + commonobjmodel!.data.isEmpty ? Column( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -726,7 +310,7 @@ class _PopularTabState extends State { itemBuilder: (context, index) { var timeAgo = ConvertServerDateToUserDate() .convertServerDateToReadableFormate( - tagpopulardetailobj!.data[index].createdAt + commonobjmodel!.data[index].createdAt .toString()); return Column( @@ -821,13 +405,15 @@ class _LatestTabState extends State { bool _isDataInitialized = true; Future setValues() async { - if (_isDataInitialized) { + // WidgetsBinding.instance.addPostFrameCallback((_) {}); + WidgetsBinding.instance.addPostFrameCallback((_) { _setModel(); - countersHelper.setListstagtagLatest(); - await _fetchIcons(); + countersHelper.setListsPopular(); + _fetchIcons(); + }); + //if (mounted) { - _isDataInitialized = false; - } + // } } _sortTags(index) { @@ -927,7 +513,7 @@ class _LatestTabState extends State { fit: BoxFit.fill), ), ), - tagdetailobj!.data.isEmpty + commonobjmodel!.data.isEmpty ? Column( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -955,7 +541,7 @@ class _LatestTabState extends State { itemBuilder: (context, index) { var timeAgo = ConvertServerDateToUserDate() .convertServerDateToReadableFormate( - tagdetailobj!.data[index].createdAt + commonobjmodel!.data[index].createdAt .toString()); return Column( diff --git a/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart b/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart index 0a82861..b68e987 100644 --- a/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart +++ b/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart @@ -11,7 +11,7 @@ class CountersHelper extends GetxController { RxList commentsCounterPopular = [].obs; RxList savePostCounterPopular = [].obs; RxList saveButtonPopular = [].obs; -List pinButtonPopular = []; + List pinButtonPopular = []; RxBool updateFeedsPage = false.obs; setListsPopular() { likesCounterPopular.clear(); @@ -29,79 +29,4 @@ List pinButtonPopular = []; .add(commonobjmodel?.data[i].iamPrincipal?.isUserPinned ?? false); } } - - RxList likesCounterFeed = [].obs; - RxList commentsCounterFeed = [].obs; - RxList savePostCounterFeed = [].obs; - - setListsFeed() { - for (var i = 0; i < combinedListGlobal.length; i++) { - likesCounterLatest.add(combinedListGlobal[i].likecount ?? 0); - commentsCounterLatest.add(combinedListGlobal[i].totalCommentCount ?? 0); - savePostCounterLatest.add(combinedListGlobal[i].totalSave ?? 0); - } - } - - RxList likesCounterLatest = [].obs; - RxList commentsCounterLatest = [].obs; - RxList savePostCounterLatest = [].obs; - - setListsLatest() { - for (var i = 0; i < latestpostobj!.data.length; i++) { - likesCounterFeed.add(latestpostobj!.data[i].likecount ?? 0); - commentsCounterFeed.add(latestpostobj!.data[i].totalCommentCount ?? 0); - savePostCounterFeed.add(latestpostobj!.data[i].totalSave ?? 0); - } - } - -//ComPosts - RxList likesCounterComPosts= [].obs; - RxList commentsCounterComPosts = [].obs; - RxList savePostCounterComPosts = [].obs; - RxList saveButtonComPosts = [].obs; - // RxList pinButtonComPosts = [].obs; - - setListsComPosts() { - likesCounterComPosts.clear(); - commentsCounterComPosts.clear(); - savePostCounterComPosts.clear(); - saveButtonComPosts.clear(); - - for (var i = 0; i < commonobjmodel!.data.length; i++) { - likesCounterComPosts.add(commonobjmodel?.data[i].likecount ?? 0); - commentsCounterComPosts - .add(commonobjmodel?.data[i].totalCommentCount ?? 0); - savePostCounterComPosts.add(commonobjmodel?.data[i].totalSave ?? 0); - saveButtonComPosts.add(commonobjmodel?.data[i].isISaved ?? false); - // pinButtonComPosts - // .add(commonobjmodel?.data[i].iamPrincipal?.isUserPinned ?? false); - } - } - - -//tagPostPopular - RxList likesCountertagPopular = [].obs; - RxList commentsCountertagPopular = [].obs; - RxList savePostCountertagPopular = [].obs; - - setListstagPopular() { - for (var i = 0; i < combinedListGlobal.length; i++) { - likesCounterLatest.add(combinedListGlobal[i].likecount ?? 0); - commentsCounterLatest.add(combinedListGlobal[i].totalCommentCount ?? 0); - savePostCounterLatest.add(combinedListGlobal[i].totalSave ?? 0); - } - } - - //tagPostLatest - RxList likesCountertagLatest = [].obs; - RxList commentsCountertagLatest = [].obs; - RxList savePostCountertagLatest = [].obs; - - setListstagtagLatest() { - for (var i = 0; i < combinedListGlobal.length; i++) { - likesCounterLatest.add(combinedListGlobal[i].likecount ?? 0); - commentsCounterLatest.add(combinedListGlobal[i].totalCommentCount ?? 0); - savePostCounterLatest.add(combinedListGlobal[i].totalSave ?? 0); - } - } } diff --git a/lib/sidemenu/Community/Admin/PopupItem/Community settings/CommunitySetting.dart b/lib/sidemenu/Community/Admin/PopupItem/Community settings/CommunitySetting.dart index 5f32faf..f0cbde2 100644 --- a/lib/sidemenu/Community/Admin/PopupItem/Community settings/CommunitySetting.dart +++ b/lib/sidemenu/Community/Admin/PopupItem/Community settings/CommunitySetting.dart @@ -19,53 +19,64 @@ class _CommunitySettingState extends State { int communityid = Get.arguments['communityid']; @override Widget build(BuildContext context) { - return Scaffold( - // key: _scaffoldKey1, - backgroundColor: Color(0xFF222935), - extendBody: true, - resizeToAvoidBottomInset: false, - appBar: CommonAppbar( - titleTxt: "Community settings", - ), - body: Stack(children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/png/Ellipse 1496.png"), - fit: BoxFit.fill)), + return WillPopScope( + onWillPop: () async{ + Get.back(result: true); + return true; + }, + child: Scaffold( + // key: _scaffoldKey1, + backgroundColor: Color(0xFF222935), + extendBody: true, + resizeToAvoidBottomInset: false, + appBar: CommonAppbar( + titleTxt: "Community settings", + customBack: true, ), - Column(children: [ - sizedBoxHeight(30.h), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.editcommunity, arguments: { - 'communityid': communityid, - }); - }, - child: rowTile(text: 'Edit community info')), - commonDivider(), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.managemembers); - }, - child: rowTile(text: 'Manage members')), - commonDivider(), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.managegroups); - }, - child: rowTile(text: 'Manage groups')), - commonDivider(), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.managetags, arguments: { - 'communityid': communityid, - }); - }, - child: rowTile(text: 'Manage interest')), - sizedBoxHeight(20.h), - ]) - ])); + body: Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), + ), + Column(children: [ + sizedBoxHeight(30.h), + GestureDetector( + onTap: () { + Get.toNamed(RouteName.editcommunity, arguments: { + 'communityid': communityid, + }); + }, + child: rowTile(text: 'Edit community info')), + commonDivider(), + GestureDetector( + onTap: () { + Get.toNamed(RouteName.managemembers); + }, + child: rowTile(text: 'Manage members')), + commonDivider(), + GestureDetector( + onTap: () { + Get.toNamed(RouteName.managegroups, + arguments: { + 'communityid' : communityid, + } + ); + }, + child: rowTile(text: 'Manage groups')), + commonDivider(), + GestureDetector( + onTap: () { + Get.toNamed(RouteName.managetags, arguments: { + 'communityid': communityid, + }); + }, + child: rowTile(text: 'Manage interest')), + sizedBoxHeight(20.h), + ]) + ])), + ); } Widget rowTile({ diff --git a/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageGroup.dart b/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageGroup.dart index 7665380..dd14cb2 100644 --- a/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageGroup.dart +++ b/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageGroup.dart @@ -1,12 +1,26 @@ +import 'dart:async'; +import 'dart:io'; + +import 'package:cached_network_image/cached_network_image.dart'; +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/CommonWidget.dart'; +import 'package:regroup/Common/base_manager.dart'; import 'package:regroup/Utils/Common/CommonAppbar.dart'; import 'package:regroup/Utils/Common/CustomTextformfield.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; +import 'package:regroup/Utils/dialogs.dart'; import 'package:regroup/Utils/texts.dart'; +import 'package:regroup/resources/routes/route_name.dart'; +import 'package:regroup/sidemenu/Community/MyCommunity/Model/communitymanageGroupsModel.dart'; +import 'package:regroup/sidemenu/Community/MyCommunity/view_model/getmethod.dart'; +import 'package:regroup/sidemenu/Community/MyCommunity/view_model/postmethod.dart'; +import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart'; class ManageGroups extends StatefulWidget { const ManageGroups({super.key}); @@ -16,73 +30,87 @@ class ManageGroups extends StatefulWidget { } class _ManageGroupsState extends State { - List groupData = [ - { - "imagePath": "assets/images/png/img45.png", - "title": "Iron titans fitness crew", - "subtitle": "Lorem ipsum dummy text", - }, - { - "imagePath": "assets/images/png/Rectangle 25.png", - "title": "Body blitz brigade", - "subtitle": "Lorem ipsum dummy text", - }, - { - "imagePath": "assets/images/png/img2.png", - "title": "Fit fusion squad", - "subtitle": "Lorem ipsum dummy text", - }, - { - "imagePath": "assets/images/png/img2.png", - "title": "Power pulse posse", - "subtitle": "Lorem ipsum dummy text", - }, - { - "imagePath": "assets/images/png/img2.png", - "title": "Wellness warriors collective", - "subtitle": "Lorem ipsum dummy text", - }, - ]; + int communityid = Get.arguments['communityid']; + StreamController searchcontroller = + StreamController(); + + @override + void initState() { + print(communityid); + var updata = communityid; + var updata2 = ""; + Getcommunity().getCommunityManageGroupssearch(updata, updata2, + streamController: searchcontroller); + + super.initState(); + } + + @override + void dispose() { + searchcontroller.close(); + super.dispose(); + } + + int? removeid; + + RemoveUploadata(int remove) async { + utils.loader(); + Map updata = { + "manage_community_xid": communityid, + "manage_group_xid": removeid, + }; + final data = await PostMethodCommunity().postGroupsRemove(updata); + if (data.status == ResponseStatus.SUCCESS) { + Get.back(); + print("remove done"); + return utils.showToast(data.message); + } else { + Get.back(); + print("remove not done"); + return utils.showToast(data.message); + } + } @override Widget build(BuildContext context) { - return Scaffold( - // key: _scaffoldKey1, - backgroundColor: Color(0xFF222935), - extendBody: true, - resizeToAvoidBottomInset: false, - appBar: CommonAppbar( - titleTxt: "Manage groups", - // customActionWidget: InkWell( - // onTap: () {}, - // child: Container( - // height: 35.h, - // width: 35.w, - // decoration: BoxDecoration( - // color: Color(0xFFD90B2E), - // shape: BoxShape.circle, - // boxShadow: [ - // BoxShadow( - // color: Color(0x40000000), - // offset: Offset(0, 6), - // blurRadius: 8, - // spreadRadius: 0, - // ), - // ], - // ), - // child: Icon(Icons.add, color: Colors.white, weight: 2), - // ), - // ), - ), - body: Stack(children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/png/Ellipse 1496.png"), - fit: BoxFit.fill)), + return GestureDetector( + onTap: () => FocusManager.instance.primaryFocus?.unfocus(), + child: Scaffold( + // key: _scaffoldKey1, + backgroundColor: Color(0xFF222935), + extendBody: true, + resizeToAvoidBottomInset: false, + appBar: CommonAppbar( + titleTxt: "Manage groups", + // customActionWidget: InkWell( + // onTap: () {}, + // child: Container( + // height: 35.h, + // width: 35.w, + // decoration: BoxDecoration( + // color: Color(0xFFD90B2E), + // shape: BoxShape.circle, + // boxShadow: [ + // BoxShadow( + // color: Color(0x40000000), + // offset: Offset(0, 6), + // blurRadius: 8, + // spreadRadius: 0, + // ), + // ], + // ), + // child: Icon(Icons.add, color: Colors.white, weight: 2), + // ), + // ), ), - SingleChildScrollView( - child: Column(children: [ + body: Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), + ), + Column(children: [ Padding( padding: EdgeInsets.symmetric(horizontal: 16.w), child: Column( @@ -102,6 +130,14 @@ class _ManageGroupsState extends State { ), ), hintText: "Search groups", + inputFormatters: [ + RemoveEmojiInputFormatter(), + ], + onInput: (value) { + Getcommunity().getCommunityManageGroupssearch( + communityid, value, + streamController: searchcontroller); + }, ), sizedBoxHeight(25.h), Row( @@ -130,31 +166,266 @@ class _ManageGroupsState extends State { ], ), sizedBoxHeight(30.h), + GestureDetector( + onTap: () async { + List filePath = []; + List bannerPath = []; + var result = + await Get.toNamed(RouteName.addgroup, arguments: { + 'communityname': "", + 'communitylocation': "", + 'communitydescription': "", + 'communitytype': 0, + 'activityid': 0, + 'communityprofilephoto': filePath, + 'communitybannerimage': bannerPath, + 'isedited': true, + 'communityid': communityid.toString(), + }); + if (result != null && result) { + setState(() { + Getcommunity().getCommunityManageGroupssearch( + communityid, '', + streamController: searchcontroller); + }); + } + }, + child: Row( + children: [ + commonGlassUI( + opacity1: 0.24, + opacity2: 0.24, + width: 50.w, + height: 50.h, + borderRadius: BorderRadius.circular(100), + customWidget: Center( + child: Image.asset( + "assets/images/png/ion_add.png", + height: 30.h, + width: 30.w, + )), + borderwidth: 0.5), + sizedBoxWidth(8.w), + text18w400_FCFCFC("Add existing groups"), + Spacer(), + Icon( + Icons.arrow_forward_ios_outlined, + color: Colors.white, + size: 14.sp, + ), + ], + ), + ), + sizedBoxHeight(30.h), text18w700white("Groups"), sizedBoxHeight(20.h), ]), ), - ListView.builder( - shrinkWrap: true, - itemCount: groupData.length, - itemBuilder: (context, index) { - return Column( - children: [ - groupWidget( - imagePath: groupData[index]["imagePath"], - title: groupData[index]["title"], - subtitle: groupData[index]["subtitle"]), - commonDivider(), - ], - ); - }, - ) - ]), - ) - ])); + Expanded( + child: StreamBuilder( + stream: searchcontroller.stream, + builder: (ctx, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + // Display shimmer effect while waiting for data + return const Center(child: CircularProgressIndicator()); + } else if (snapshot.hasError) { + // Handle error state + return Center( + child: Text( + '${snapshot.error} occurred', + style: const TextStyle(fontSize: 18), + ), + ); + } else { + // Data has been loaded, show actual UI + return communitymanagegroupsobj!.data.isEmpty + ? _buildNoDataBody(context) + : ListView.separated( + physics: const ScrollPhysics(), + shrinkWrap: true, + itemCount: communitymanagegroupsobj!.data.length, + separatorBuilder: + (BuildContext context, int index) { + return commonDivider(); + }, + itemBuilder: (context, index) { + var mainGroupsData = + communitymanagegroupsobj!.data[index]; + return Column( + children: [ + Padding( + padding: EdgeInsets.symmetric( + vertical: 16.h, horizontal: 16.w), + child: Row( + children: [ + mainGroupsData.groupsData! + .groupImage == + null || + mainGroupsData.groupsData! + .groupImage!.isEmpty + ? CircleAvatar( + backgroundImage: AssetImage( + 'assets/images/png/img45.png'), + radius: 20.r, + ) + : CircleAvatar( + backgroundImage: + CachedNetworkImageProvider( + mainGroupsData.groupsData! + .groupImage!, + ), + radius: 25.r, + child: CachedNetworkImage( + cacheKey: mainGroupsData + .groupsData!.id + .toString(), + maxHeightDiskCache: 100, + maxWidthDiskCache: 100, + imageUrl: mainGroupsData + .groupsData! + .groupImage!, + placeholder: + (context, url) => + Container(), + errorWidget: + (context, url, error) => + Icon(Icons.error), + imageBuilder: (context, + imageProvider) => + CircleAvatar( + backgroundImage: + imageProvider, + radius: 25.r, + ), + ), + ), + + sizedBoxWidth(10.w), + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + mainGroupsData.groupsData! + .title == + null || + mainGroupsData + .groupsData! + .title! + .isEmpty + ? text16w400_FCFCFC( + 'ReGroup') + : + // text16w400_FCFCFC( mainGroupsData.groupsData!.title!), + Text( + mainGroupsData + .groupsData!.title!, + overflow: TextOverflow + .ellipsis, + style: TextStyle( + fontSize: 16.sp, + color: const Color( + 0xFFFCFCFC), + fontFamily: + 'Helvetica', + fontWeight: + FontWeight + .w400), + ), + sizedBoxHeight(4.h), + mainGroupsData.groupsData! + .description == + null || + mainGroupsData + .groupsData! + .description! + .isEmpty + ? text12w400_FCFCFC_blur( + 'ReGroup') + : Text( + mainGroupsData + .groupsData! + .description!, + overflow: TextOverflow + .ellipsis, + style: TextStyle( + fontSize: 12.sp, + color: const Color( + 0xFFFCFCFC) + .withOpacity( + 0.8), + fontFamily: + 'Helvetica', + fontWeight: + FontWeight + .w400), + ), + ], + ), + ), + Spacer(), + InkWell( + onTap: () async { + setState(() { + removeid = + communitymanagegroupsobj! + .data[index] + .manageGroupXid ?? + 0; + communitymanagegroupsobj!.data + .removeWhere((item) => + item.manageGroupXid == + removeid); + print(removeid.toString()); + + RemoveUploadata(removeid!); + }); + }, + child: Image.asset( + 'assets/images/png/Group 1000004149.png', + ), + ) + // Icon( + // Icons.clear, + // color: Color(0xFFFFFFFF), + // weight: 1.88, + // ) + ], + ), + ), + commonDivider(), + ], + ); + }, + ); + } + }, + ), + ), + ]) + ])), + ); } } +Widget _buildNoDataBody(context) { + return Center( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "No Groups Found", + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.w600), + ) + ], + ), + ); +} + Widget groupWidget({ required String imagePath, required String title, diff --git a/lib/sidemenu/Community/Group/view/Group.dart b/lib/sidemenu/Community/Group/view/Group.dart index 8971cf5..16c2b61 100644 --- a/lib/sidemenu/Community/Group/view/Group.dart +++ b/lib/sidemenu/Community/Group/view/Group.dart @@ -1,15 +1,13 @@ 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/CommonWidget.dart'; -import 'package:regroup/sidemenu/Community/MyCommunity/view_model/getmethod.dart'; -import 'package:regroup/sidemenu/view_model/getmethod.dart'; import 'package:regroup/Utils/Common/CommonAppbar.dart'; - import 'package:regroup/Utils/Common/sized_box.dart'; import 'package:regroup/Utils/texts.dart'; +import 'package:regroup/sidemenu/Community/MyCommunity/view_model/getmethod.dart'; +import 'package:regroup/sidemenu/view_model/getmethod.dart'; class Group extends StatefulWidget { const Group({super.key}); @@ -562,7 +560,7 @@ class _GroupState extends State { "Make primary"), const Spacer(), Image.asset( - "assets/images/png/leave group.png", + "assets/images/png/group.png", height: 20.h, width: 20.w, ) diff --git a/lib/sidemenu/Community/Members/CommunityMembers.dart b/lib/sidemenu/Community/Members/CommunityMembers.dart index 8c952e8..a6222e7 100644 --- a/lib/sidemenu/Community/Members/CommunityMembers.dart +++ b/lib/sidemenu/Community/Members/CommunityMembers.dart @@ -46,204 +46,207 @@ class _CommunityMembersState extends State { @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: const Color(0xFF222935), - extendBody: true, - appBar: const CommonAppbar( - titleTxt: "Members", - ), - resizeToAvoidBottomInset: false, - body: Stack(children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/png/Ellipse 1496.png"), - fit: BoxFit.fill)), + return GestureDetector( + onTap: () => FocusManager.instance.primaryFocus?.unfocus(), + child: Scaffold( + backgroundColor: const Color(0xFF222935), + extendBody: true, + appBar: const CommonAppbar( + titleTxt: "Members", ), - SingleChildScrollView( - child: Column(children: [ - Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: CustomTextFormField( - leadingIcon: SizedBox( - height: 23, - width: 23, - child: Center( - child: Image.asset( - "assets/images/png/ion_search-outline.png", - height: 23, - width: 23, + 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: [ + Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: CustomTextFormField( + leadingIcon: SizedBox( + height: 23, + width: 23, + child: Center( + child: Image.asset( + "assets/images/png/ion_search-outline.png", + height: 23, + width: 23, + ), ), ), + texttype: TextInputType.text, + inputFormatters: [ + RemoveEmojiInputFormatter(), + ], + onInput: (value) { + Getcommunity().getCommunityMemberssearch(communityid, value, + streamController: searchcontroller); + }, + hintText: "Search people", ), - texttype: TextInputType.text, - inputFormatters: [ - RemoveEmojiInputFormatter(), - ], - onInput: (value) { - Getcommunity().getCommunityMemberssearch(communityid, value, - streamController: searchcontroller); - }, - hintText: "Search people", ), - ), - sizedBoxHeight(25.h), - StreamBuilder( - stream: searchcontroller.stream, - builder: (ctx, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - // Display shimmer effect while waiting for data - return const Center(child: CircularProgressIndicator()); - } else if (snapshot.hasError) { - // Handle error state - return Center( - child: Text( - '${snapshot.error} occurred', - style: const TextStyle(fontSize: 18), - ), - ); - } else { - // Data has been loaded, show actual UI - return communitymembersobj!.data.isEmpty - ? _buildNoDataBody(context) - : ListView.separated( - physics: const ScrollPhysics(), - shrinkWrap: true, - itemCount: communitymembersobj!.data.length, - separatorBuilder: - (BuildContext context, int index) { - return commonDivider(); - }, - itemBuilder: (context, index) { - var mainFollowersData = - communitymembersobj!.data[index]; - return GestureDetector( - onTap: () { - mainFollowersData - .iamPrincipal!.principalTypeXid == - 1 - ? Get.toNamed( - RouteName.profiletabindguest, - arguments: { - "FolloweridIndex": - mainFollowersData - .iamPrincipalXid!, - }) - : Get.toNamed( - RouteName.profiletabbusguest, - arguments: { - "FolloweridIndex": - mainFollowersData - .iamPrincipalXid!, - }); - }, - child: Column( - children: [ - Padding( - padding: EdgeInsets.symmetric( - vertical: 16.h, horizontal: 16.w), - child: Row( - children: [ - mainFollowersData.iamPrincipal! - .profilePhoto == - null || - mainFollowersData - .iamPrincipal! - .profilePhoto! - .isEmpty - ? CircleAvatar( - backgroundImage: const AssetImage( - 'assets/images/png/Ellipse 43.png'), - radius: 25.r, - ) - : CircleAvatar( - backgroundImage: - CachedNetworkImageProvider( + sizedBoxHeight(25.h), + StreamBuilder( + stream: searchcontroller.stream, + builder: (ctx, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + // Display shimmer effect while waiting for data + return const Center(child: CircularProgressIndicator()); + } else if (snapshot.hasError) { + // Handle error state + return Center( + child: Text( + '${snapshot.error} occurred', + style: const TextStyle(fontSize: 18), + ), + ); + } else { + // Data has been loaded, show actual UI + return communitymembersobj!.data.isEmpty + ? _buildNoDataBody(context) + : ListView.separated( + physics: const ScrollPhysics(), + shrinkWrap: true, + itemCount: communitymembersobj!.data.length, + separatorBuilder: + (BuildContext context, int index) { + return commonDivider(); + }, + itemBuilder: (context, index) { + var mainFollowersData = + communitymembersobj!.data[index]; + return GestureDetector( + onTap: () { + mainFollowersData + .iamPrincipal!.principalTypeXid == + 1 + ? Get.toNamed( + RouteName.profiletabindguest, + arguments: { + "FolloweridIndex": + mainFollowersData + .iamPrincipalXid!, + }) + : Get.toNamed( + RouteName.profiletabbusguest, + arguments: { + "FolloweridIndex": + mainFollowersData + .iamPrincipalXid!, + }); + }, + child: Column( + children: [ + Padding( + padding: EdgeInsets.symmetric( + vertical: 16.h, horizontal: 16.w), + child: Row( + children: [ + mainFollowersData.iamPrincipal! + .profilePhoto == + null || mainFollowersData .iamPrincipal! - .profilePhoto!, - ), - - // NetworkImage( - // mainFollowersData - // .iamPrincipal! - // .profilePhoto!), - radius: 25.r, - child: CachedNetworkImage( - cacheKey: mainFollowersData - .iamPrincipalXid - .toString(), - maxHeightDiskCache: 100, - maxWidthDiskCache: 100, - imageUrl: mainFollowersData - .iamPrincipal! - .profilePhoto!, - placeholder: - (context, url) => - Container(), - errorWidget: - (context, url, error) => - Icon(Icons.error), - imageBuilder: (context, - imageProvider) => - CircleAvatar( - backgroundImage: - imageProvider, - radius: 25.r, + .profilePhoto! + .isEmpty + ? CircleAvatar( + backgroundImage: const AssetImage( + 'assets/images/png/Ellipse 43.png'), + radius: 25.r, + ) + : CircleAvatar( + backgroundImage: + CachedNetworkImageProvider( + mainFollowersData + .iamPrincipal! + .profilePhoto!, + ), + + // NetworkImage( + // mainFollowersData + // .iamPrincipal! + // .profilePhoto!), + radius: 25.r, + child: CachedNetworkImage( + cacheKey: mainFollowersData + .iamPrincipalXid + .toString(), + maxHeightDiskCache: 100, + maxWidthDiskCache: 100, + imageUrl: mainFollowersData + .iamPrincipal! + .profilePhoto!, + placeholder: + (context, url) => + Container(), + errorWidget: + (context, url, error) => + Icon(Icons.error), + imageBuilder: (context, + imageProvider) => + CircleAvatar( + backgroundImage: + imageProvider, + radius: 25.r, + ), ), ), - ), - sizedBoxWidth(10.w), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - mainFollowersData.iamPrincipal! - .fullName == - null || - mainFollowersData - .iamPrincipal! - .fullName! - .isEmpty == - true - ? text16w400_FCFCFC("Regroup") - : text16w400_FCFCFC( - mainFollowersData - .iamPrincipal! - .fullName!), - sizedBoxHeight(4.h), - mainFollowersData.iamPrincipal! - .userName == - null || - mainFollowersData - .iamPrincipal! - .userName! - .isEmpty == - true - ? text12w400_FCFCFC_blur( - "regroup") - : text12w400_FCFCFC_blur( - mainFollowersData - .iamPrincipal! - .userName!) - ], - ), - ], - ), - ) - ], - ), - ); - }, - ); - } - }, - ), - ]) - ]), - ) - ]), + sizedBoxWidth(10.w), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + mainFollowersData.iamPrincipal! + .fullName == + null || + mainFollowersData + .iamPrincipal! + .fullName! + .isEmpty == + true + ? text16w400_FCFCFC("Regroup") + : text16w400_FCFCFC( + mainFollowersData + .iamPrincipal! + .fullName!), + sizedBoxHeight(4.h), + mainFollowersData.iamPrincipal! + .userName == + null || + mainFollowersData + .iamPrincipal! + .userName! + .isEmpty == + true + ? text12w400_FCFCFC_blur( + "regroup") + : text12w400_FCFCFC_blur( + mainFollowersData + .iamPrincipal! + .userName!) + ], + ), + ], + ), + ) + ], + ), + ); + }, + ); + } + }, + ), + ]) + ]), + ) + ]), + ), ); } diff --git a/lib/sidemenu/Community/MyCommunity/AddGroups.dart b/lib/sidemenu/Community/MyCommunity/AddGroups.dart index 5c07b2c..a4f139f 100644 --- a/lib/sidemenu/Community/MyCommunity/AddGroups.dart +++ b/lib/sidemenu/Community/MyCommunity/AddGroups.dart @@ -65,6 +65,8 @@ class _AddGroupState extends State { String communitydescription = Get.arguments["communitydescription"]; List filepath = Get.arguments['communityprofilephoto']; List bannerPath = Get.arguments['communitybannerimage']; + bool edited = Get.arguments['isedited']; + String communityid = Get.arguments['communityid']; StreamController searchcontroller = StreamController(); @@ -72,8 +74,8 @@ class _AddGroupState extends State { @override void initState() { var updata = ""; - Getcommunity() - .getCommunityAddGroupsearch(updata, streamController: searchcontroller); + Getcommunity().getCommunityAddGroupsearch(updata, communityid, + streamController: searchcontroller); super.initState(); } @@ -141,7 +143,9 @@ class _AddGroupState extends State { print("community created"); // Get.toNamed(RouteName.mycommunity); Get.back(); - Get.back(); + Get.back( + result: true + ); return utils.showToast(data.message); } else { Get.back(); @@ -150,155 +154,188 @@ class _AddGroupState extends State { } } + ManageGroupsUploadata() async { + utils.loader(); + String selectedIndicesString = '[${_selectedIndices.join(',')}]'; + print('Selected Indices: $selectedIndicesString'); + Map updata = { + "manage_community_xid": communityid, + "manage_groups_xid": selectedIndicesString, + }; + print('updata is ${updata.toString()}'); + log('log is ${updata.toString()}'); + final data = await PostMethodCommunity().postmanageaddgroupscommunity(updata); + if (data.status == ResponseStatus.SUCCESS) { + Get.back(); + print("groups added"); + // Get.back(); + return utils.showToast(data.message); + } else { + Get.back(); + print("groups not added"); + return utils.showToast(data.message); + } + } + @override Widget build(BuildContext context) { - return GestureDetector( - onTap: () => FocusManager.instance.primaryFocus?.unfocus(), - child: Scaffold( - // key: _scaffoldKey1, - backgroundColor: Color(0xFF222935), - extendBody: true, - appBar: CommonAppbar( - titleTxt: "Add groups", - ), - resizeToAvoidBottomInset: false, - bottomNavigationBar: Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 10.h), - child: CustomButton( - text: "Add", - onPressed: () { - // Get.toNamed(RouteName.mycommunity); - print('selected groups are ${_selectedIndices.toString()}'); - Uploadata(); - }, + return WillPopScope( + onWillPop: () async { + edited == true ? Get.back(result: true) : Get.back(); + return true; + }, + child: GestureDetector( + onTap: () => FocusManager.instance.primaryFocus?.unfocus(), + child: Scaffold( + // key: _scaffoldKey1, + backgroundColor: Color(0xFF222935), + extendBody: true, + appBar: CommonAppbar( + titleTxt: "Add groups", ), - ), - body: Stack(children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/png/Ellipse 1496.png"), - fit: BoxFit.fill)), + resizeToAvoidBottomInset: false, + bottomNavigationBar: Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 10.h), + child: CustomButton( + text: "Add", + onPressed: () { + // Get.toNamed(RouteName.mycommunity); + print('selected groups are ${_selectedIndices.toString()}'); + + edited == true ? ManageGroupsUploadata() : Uploadata(); + }, + ), ), - SingleChildScrollView( - child: Column(children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - sizedBoxHeight(20.h), - CustomTextFormField( - leadingIcon: SizedBox( - height: 23, - width: 23, - child: Center( - child: Image.asset( - "assets/images/png/ion_search-outline.png", - height: 23, - width: 23, + body: Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), + ), + SingleChildScrollView( + child: Column(children: [ + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + sizedBoxHeight(20.h), + CustomTextFormField( + leadingIcon: SizedBox( + height: 23, + width: 23, + child: Center( + child: Image.asset( + "assets/images/png/ion_search-outline.png", + height: 23, + width: 23, + ), ), ), + hintText: "Search groups", + onInput: (value) { + Getcommunity().getCommunityAddGroupsearch( + value, communityid, + streamController: searchcontroller); + }, ), - hintText: "Search groups", - onInput: (value) { - Getcommunity().getCommunityAddGroupsearch(value, - streamController: searchcontroller); - }, - ), - sizedBoxHeight(25.h), - // Row( - // children: [ - // commonGlassUI( - // opacity1: 0.24, - // opacity2: 0.24, - // width: 50.w, - // height: 50.h, - // borderRadius: BorderRadius.circular( 100), - // customWidget: Center( - // child: Image.asset( - // "assets/images/png/Black.png", - // height: 30.h, - // width: 30.w, - // )), - // borderwidth: 0.5), - // sizedBoxWidth(8.w), - // text18w400_FCFCFC("Create group"), - // Spacer(), - // Icon( - // Icons.arrow_forward_ios_outlined, - // color: Colors.white, - // size: 14.sp, - // ), - // ], - // ), - // sizedBoxHeight(25.h), - sizedBoxHeight(30.h), - text18w700white("Existing Groups"), - sizedBoxHeight(20.h), - ]), - ), - StreamBuilder( - stream: searchcontroller.stream, - builder: (ctx, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return const Center( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - CircularProgressIndicator(), - ], - ), - ); - } else if (snapshot.hasError) { - return Center( - child: Text( - '${snapshot.error} occured', - style: TextStyle(fontSize: 18.sp), - ), - ); - } else { - return communityaddgroupobj!.data.isEmpty - ? _buildNoDataBody(context) - : ListView.builder( - shrinkWrap: true, - physics: ScrollPhysics(), - itemCount: communityaddgroupobj!.data.length, - itemBuilder: (context, index) { - final isChecked = _selectedIndices.contains( - communityaddgroupobj!.data[index].id!); - return Column( - children: [ - groupWidget( - index: - communityaddgroupobj!.data[index].id!, - imagePath: communityaddgroupobj! - .data[index].groupImage ?? - '', - title: communityaddgroupobj! - .data[index].title!, - subtitle: communityaddgroupobj! - .data[index].description!, - isChecked: isChecked, - // isCheckedList[index], - onCheckedChanged: (bool? value) { - // isCheckedList[index] = value ?? false; - _onContainerTap(communityaddgroupobj! - .data[index].id!); - }, - ), - commonDivider(), - ], - ); - }, - ); - } - }), - sizedBoxHeight(50.h), - ]), - ) - ])), + sizedBoxHeight(25.h), + // Row( + // children: [ + // commonGlassUI( + // opacity1: 0.24, + // opacity2: 0.24, + // width: 50.w, + // height: 50.h, + // borderRadius: BorderRadius.circular( 100), + // customWidget: Center( + // child: Image.asset( + // "assets/images/png/Black.png", + // height: 30.h, + // width: 30.w, + // )), + // borderwidth: 0.5), + // sizedBoxWidth(8.w), + // text18w400_FCFCFC("Create group"), + // Spacer(), + // Icon( + // Icons.arrow_forward_ios_outlined, + // color: Colors.white, + // size: 14.sp, + // ), + // ], + // ), + // sizedBoxHeight(25.h), + sizedBoxHeight(30.h), + text18w700white("Existing Groups"), + sizedBoxHeight(20.h), + ]), + ), + StreamBuilder( + stream: searchcontroller.stream, + builder: (ctx, snapshot) { + if (snapshot.connectionState == + ConnectionState.waiting) { + return const Center( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + CircularProgressIndicator(), + ], + ), + ); + } else if (snapshot.hasError) { + return Center( + child: Text( + '${snapshot.error} occured', + style: TextStyle(fontSize: 18.sp), + ), + ); + } else { + return communityaddgroupobj!.data.isEmpty + ? _buildNoDataBody(context) + : ListView.builder( + shrinkWrap: true, + physics: ScrollPhysics(), + itemCount: communityaddgroupobj!.data.length, + itemBuilder: (context, index) { + final isChecked = _selectedIndices.contains( + communityaddgroupobj!.data[index].id!); + return Column( + children: [ + groupWidget( + index: communityaddgroupobj! + .data[index].id!, + imagePath: communityaddgroupobj! + .data[index].groupImage ?? + '', + title: communityaddgroupobj! + .data[index].title!, + subtitle: communityaddgroupobj! + .data[index].description!, + isChecked: isChecked, + // isCheckedList[index], + onCheckedChanged: (bool? value) { + // isCheckedList[index] = value ?? false; + _onContainerTap( + communityaddgroupobj! + .data[index].id!); + }, + ), + commonDivider(), + ], + ); + }, + ); + } + }), + sizedBoxHeight(50.h), + ]), + ) + ])), + ), ); } diff --git a/lib/sidemenu/Community/MyCommunity/Model/communityalldetails.dart b/lib/sidemenu/Community/MyCommunity/Model/communityalldetails.dart new file mode 100644 index 0000000..4cf1d08 --- /dev/null +++ b/lib/sidemenu/Community/MyCommunity/Model/communityalldetails.dart @@ -0,0 +1,91 @@ + + + +class CommunityAllDetailsModel { + CommunityAllDetailsModel({ + 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 CommunityAllDetailsModel.fromJson(Map json) { + return CommunityAllDetailsModel( + status: json["status"], + statusCode: json["status_code"], + message: json["message"], + data: json["data"] == null ? null : Data.fromJson(json["data"]), + ); + } +} + +class Data { + Data({ + required this.id, + required this.isCommunityPinned, + required this.totalGroup, + required this.totalAnnouncements, + required this.communityProfilePhoto, + required this.communityBannerImage, + required this.communityName, + required this.communityLocation, + required this.communityDescription, + required this.communityTypeXid, + required this.userLinkInCommunity, + required this.accessType, + }); + + final int? id; + final bool? isCommunityPinned; + final int? totalGroup; + final int? totalAnnouncements; + final String? communityProfilePhoto; + final String? communityBannerImage; + final String? communityName; + final String? communityLocation; + final String? communityDescription; + final int? communityTypeXid; + final dynamic userLinkInCommunity; + final AccessType? accessType; + + factory Data.fromJson(Map json) { + return Data( + id: json["id"], + isCommunityPinned: json["is_community_pinned"], + totalGroup: json["total_group"], + totalAnnouncements: json["total_announcements"], + communityProfilePhoto: json["community_profile_photo"], + communityBannerImage: json["community_banner_image"], + communityName: json["community_name"], + communityLocation: json["community_location"], + communityDescription: json["community_description"], + communityTypeXid: json["community_type_xid"], + userLinkInCommunity: json["user_link_in_community"], + accessType: json["access_type"] == null + ? null + : AccessType.fromJson(json["access_type"]), + ); + } +} + +class AccessType { + AccessType({ + required this.id, + required this.name, + }); + + final int? id; + final String? name; + + factory AccessType.fromJson(Map json) { + return AccessType( + id: json["id"], + name: json["name"], + ); + } +} diff --git a/lib/sidemenu/Community/MyCommunity/Model/communitymanageGroupsModel.dart b/lib/sidemenu/Community/MyCommunity/Model/communitymanageGroupsModel.dart new file mode 100644 index 0000000..f47a638 --- /dev/null +++ b/lib/sidemenu/Community/MyCommunity/Model/communitymanageGroupsModel.dart @@ -0,0 +1,80 @@ +class CommunityManageGroupsModel { + CommunityManageGroupsModel({ + 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 CommunityManageGroupsModel.fromJson(Map json){ + return CommunityManageGroupsModel( + 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.manageCommunityXid, + required this.manageGroupXid, + required this.groupsData, + }); + + final int? id; + final int? manageCommunityXid; + final int? manageGroupXid; + final GroupsData? groupsData; + + factory Datum.fromJson(Map json){ + return Datum( + id: json["id"], + manageCommunityXid: json["manage_community_xid"], + manageGroupXid: json["manage_group_xid"], + groupsData: json["groups_data"] == null ? null : GroupsData.fromJson(json["groups_data"]), + ); + } + +} + +class GroupsData { + GroupsData({ + required this.id, + required this.manageGroupTypeXid, + required this.title, + required this.backgroundImage, + required this.groupImage, + required this.description, + required this.totalMember, + }); + + final int? id; + final int? manageGroupTypeXid; + final String? title; + final String? backgroundImage; + final String? groupImage; + final String? description; + final int? totalMember; + + factory GroupsData.fromJson(Map json){ + return GroupsData( + id: json["id"], + manageGroupTypeXid: json["manage_group_type_xid"], + title: json["title"], + backgroundImage: json["background_image"], + groupImage: json["group_image"], + description: json["description"], + totalMember: json["total_member"], + ); + } + +} diff --git a/lib/sidemenu/Community/MyCommunity/NewCommunity.dart b/lib/sidemenu/Community/MyCommunity/NewCommunity.dart index f9e6531..2017c3f 100644 --- a/lib/sidemenu/Community/MyCommunity/NewCommunity.dart +++ b/lib/sidemenu/Community/MyCommunity/NewCommunity.dart @@ -151,194 +151,201 @@ class _NewCommunityState extends State { @override Widget build(BuildContext context) { - return GestureDetector( - onTap: () => FocusManager.instance.primaryFocus?.unfocus(), - child: Scaffold( - // key: _scaffoldKey1, - backgroundColor: Color(0xFF222935), - extendBody: true, - resizeToAvoidBottomInset: true, - appBar: CommonAppbar( - titleTxt: "New community", - ), - body: Stack(children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/png/Ellipse 1496.png"), - fit: BoxFit.fill)), + return WillPopScope( + onWillPop: () async{ + Get.back(result: true); + return true; + }, + child: GestureDetector( + onTap: () => FocusManager.instance.primaryFocus?.unfocus(), + child: Scaffold( + // key: _scaffoldKey1, + backgroundColor: Color(0xFF222935), + extendBody: true, + resizeToAvoidBottomInset: true, + appBar: CommonAppbar( + titleTxt: "New community", + customBack: true, ), - SingleChildScrollView( - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - sizedBoxHeight(20.h), - Center( - child: InkWell( + body: Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), + ), + SingleChildScrollView( + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + sizedBoxHeight(20.h), + Center( + 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 { + // Handle case where no image is selected + filePath.clear(); + isImageAdded = false; + setState(() {}); + } + }, + ); + }, + child: commonGlassUI( + width: 95.w, + height: 95.h, + borderRadius: BorderRadius.circular(100), + opacity1: 0.24, + opacity2: 0.24, + customWidget: filePath.isNotEmpty && isImageAdded + ? ClipOval( + child: SizedBox.fromSize( + size: Size.fromRadius(47.5.r), + child: Image.file( + filePath[0]!, + fit: BoxFit.cover, + width: double.infinity, + ), + ), + ) + : Center( + child: Image.asset( + "assets/images/png/cameraicon2.png", + height: 30.h, + width: 30.w, + ), + ), + borderwidth: 0.5), + ), + ), + sizedBoxHeight(20.h), + Center( + child: + text16w400_white("Add community profile picture")), + sizedBoxHeight(30.h), + text16w400_FCFCFC("Banner image"), + sizedBoxHeight(15.h), + InkWell( onTap: () { ImageUploadBottomSheet().showModal( context, false, (result) { + // var file = File(result); + + // bannerPath.add(file); + // isbannerAdded = true; + // setState(() {}); if (result != null && result.isNotEmpty) { var file = File(result); - filePath.cast(); - filePath.add(file); - isImageAdded = true; - setState(() {}); - if (Platform.isAndroid) { - Get.back(); + + // 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 - filePath.clear(); - isImageAdded = false; + bannerPath.clear(); + isbannerAdded = false; setState(() {}); } + if (Platform.isAndroid) { + Get.back(); + } }, ); }, - child: commonGlassUI( - width: 95.w, - height: 95.h, - borderRadius: BorderRadius.circular(100), - opacity1: 0.24, - opacity2: 0.24, - customWidget: filePath.isNotEmpty && isImageAdded - ? ClipOval( - child: SizedBox.fromSize( - size: Size.fromRadius(47.5.r), - child: Image.file( - filePath[0]!, - fit: BoxFit.cover, - width: double.infinity, - ), + 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: 130.h, + borderRadius: BorderRadius.circular(10.r), + customWidget: bannerPath.isNotEmpty && isbannerAdded + ? Stack(children: [ + Image.file( + bannerPath[0]!, + fit: BoxFit.cover, + width: double.infinity, ), - ) - : Center( - child: Image.asset( - "assets/images/png/cameraicon2.png", - height: 30.h, - width: 30.w, + 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/bi_download.png", + height: 36.h, + width: 36.w, + ), + sizedBoxHeight(10.h), + text14w400white('Upload banner image'), + sizedBoxHeight(8.h), + text8w400_8A8A8A( + "Allowed file extensions: jpg, png, gif Max file size: 10 MB"), + ], ), ), - borderwidth: 0.5), - ), - ), - sizedBoxHeight(20.h), - Center( - child: - text16w400_white("Add community profile picture")), - sizedBoxHeight(30.h), - text16w400_FCFCFC("Banner image"), - sizedBoxHeight(15.h), - InkWell( - onTap: () { - ImageUploadBottomSheet().showModal( - context, - false, - (result) { - // var file = File(result); - - // bannerPath.add(file); - // isbannerAdded = true; - // setState(() {}); - 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: 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: 130.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/bi_download.png", - height: 36.h, - width: 36.w, - ), - sizedBoxHeight(10.h), - text14w400white('Upload banner image'), - sizedBoxHeight(8.h), - text8w400_8A8A8A( - "Allowed file extensions: jpg, png, gif Max file size: 10 MB"), - ], - ), - ), + ), ), ), - ), + sizedBoxHeight(25.h), text16w400_FCFCFC("Community name*"), @@ -467,6 +474,6 @@ class _NewCommunityState extends State { ]), )) ])), - ); + )); } } diff --git a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart index fd069f7..cd96f7a 100644 --- a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart +++ b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart @@ -11,7 +11,6 @@ import 'package:regroup/Common/controller/NormalPostCard.dart'; import 'package:regroup/Main_Screens/Community/Model/CommonDatumObjModel.dart'; import 'package:regroup/Main_Screens/Community/Model/fetchicons.dart'; import 'package:regroup/Main_Screens/Community/ViewModel/getmethod.dart'; -import 'package:regroup/Main_Screens/Community_HomePage/Community.dart'; import 'package:regroup/Main_Screens/Community_HomePage/view_model/CountersHelper.dart'; import 'package:regroup/Utils/Common/CommonAppbar.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; @@ -19,9 +18,11 @@ import 'package:regroup/Utils/dialogs.dart'; import 'package:regroup/Utils/texts.dart'; import 'package:regroup/resources/routes/route_name.dart'; import 'package:regroup/sidemenu/Community/MyCommunity/view_model/ComDetails.dart'; +import 'package:regroup/sidemenu/view_model/postmethod.dart'; var CommunityId; int? ismute; +var communitypinid; class CommunityDetails extends StatefulWidget { const CommunityDetails({super.key}); @@ -32,6 +33,8 @@ class CommunityDetails extends StatefulWidget { class _CommunityDetailsState extends State { var additionalContent = false.obs; + + bool? iscommunitypin = false; late Future myfuture; @@ -43,6 +46,32 @@ class _CommunityDetailsState extends State { super.initState(); } + void refreshData() { + setState(() { + myfuture = CommunityDetail().getCommunityDetail(CommunityId); + }); + } + + pinunpinCommunity(String communitypinid) async { + // utils.loader(); + Map updata = { + "manage_communities_xid": communitypinid, + }; + final data = await SidebarTags().postUserpin(updata); + if (data.status == ResponseStatus.SUCCESS) { + print("success"); + // Get.back(); + setState(() { + iscommunitypin = !iscommunitypin!; + CommunityDetail().getCommunityDetail(CommunityId); + }); + return utils.showToast(data.message); + } else { + // Get.back(); + return utils.showToast(data.message); + } + } + leaveCommunity() async { utils.loader(); Map updata = {}; @@ -183,23 +212,50 @@ class _CommunityDetailsState extends State { ), ), const PopupMenuDivider(), - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 8.w), - child: Row( - children: [ - text14w400white("Pin"), - const Spacer(), - Image.asset( - "assets/images/png/f7_pin-fill (2).png", - height: 25.h, - width: 25.w, - ) - ], - ), + 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") @@ -709,16 +765,16 @@ class _PostsTabState extends State { } } - bool _isDataInitialized = true; - Future setValues() async { - if (_isDataInitialized) { + // WidgetsBinding.instance.addPostFrameCallback((_) {}); + WidgetsBinding.instance.addPostFrameCallback((_) { _setModel(); countersHelper.setListsPopular(); - await _fetchIcons(); + _fetchIcons(); + }); + //if (mounted) { - _isDataInitialized = false; - } + // } } _sortTags(index) { @@ -757,7 +813,6 @@ class _PostsTabState extends State { likeIcon: LikeIcon1( likeIcon: LikeIconClass1( id: e.likeIcon?.likeIcon?.id, - // likeIcon?.id, image: e.likeIcon?.likeIcon?.image), likeIconsXid: e.likeIcon?.likeIconsXid, ), @@ -823,7 +878,7 @@ class _PostsTabState extends State { fit: BoxFit.fill), ), ), - compostobj!.data.isEmpty + commonobjmodel!.data.isEmpty ? Column( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -851,7 +906,7 @@ class _PostsTabState extends State { itemBuilder: (context, index) { var timeAgo = ConvertServerDateToUserDate() .convertServerDateToReadableFormate( - compostobj!.data[index].createdAt + commonobjmodel!.data[index].createdAt .toString()); return Column( @@ -864,7 +919,6 @@ class _PostsTabState extends State { reactions: _reactions, selectedReactions: _selectedReactions, currentIndex: index, - coachbool: true, ), sizedBoxHeight(20.h) ], @@ -886,367 +940,3 @@ Widget eventstab() { children: [], ); } - -Widget normalcardtile({ - required String profileImg, - required String title, - required String mainImg, - required List containerTitle, -}) { - var mainImage = 'assets/images/png/uiw_like-o.png'.obs; - void updateImage(String reaction) { - if (reaction == 'like') { - mainImage.value = 'assets/images/png/f7_hand-thumbsup.png'; - } else if (reaction == 'heart') { - mainImage.value = 'assets/images/png/heart 2.png'; - } else if (reaction == 'party') { - mainImage.value = 'assets/images/png/party-popper 2.png'; - } - } - - return Column( - children: [ - sizedBoxHeight(25.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CircleAvatar( - foregroundImage: AssetImage(profileImg), - radius: 25.r, - ), - sizedBoxWidth(12.w), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC(title), - sizedBoxHeight(5.h), - Row( - children: [ - Image.asset( - 'assets/images/png/community 1 (traced).png', - height: 14.w, - width: 14.w, - ), - sizedBoxWidth(7.w), - text12w400_FCFCFC('Active alliance network'), - sizedBoxWidth(7.w), - Icon( - Icons.circle, - color: const Color(0xFFFCFCFC), - size: 4.sp, - ), - sizedBoxWidth(6.w), - text12w400_FCFCFC('1 Hour ago'), - ], - ) - ], - ), - const Spacer(), - PopupMenuButton( - surfaceTintColor: const Color(0xFF222935), - constraints: BoxConstraints.tightFor(width: 176.w), - offset: const Offset(0, 50), - color: const Color(0xFF222935), - tooltip: "", - itemBuilder: (BuildContext context) => [ - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - Text( - 'Report Post', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/Vector (5).png", - height: 15.h, - width: 15.w, - ) - ], - ), - ), - ), - const PopupMenuDivider(), - PopupMenuItem( - onTap: () {}, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - Text( - 'Share post', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ), - 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: 12.w), - child: Row( - children: [ - Text( - 'Pin', - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Nunito Sans", - ), - ), - const Spacer(), - Image.asset( - "assets/images/png/f7_pin-fill (2).png", - height: 25.h, - width: 25.w, - ) - ], - ), - ), - ), - ], - child: Image.asset( - 'assets/images/png/Group 1000004071.png', - width: 16.w, - height: 18.h, - ), - ), - sizedBoxWidth(5.w) - ], - ), - ), - sizedBoxHeight(20.h), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.postdetailsScreen); - }, - child: SizedBox( - height: 163.h, - width: double.infinity, - child: Image.asset( - mainImg, - fit: BoxFit.cover, - ), - )), - sizedBoxHeight(20.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Column(children: [ - SizedBox( - height: 30.h, - child: ListView.builder( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - itemCount: containerTitle.length, - itemBuilder: (context, index) { - return Padding( - padding: EdgeInsets.only(right: 12.w), - child: GestureDetector( - onTap: () { - Get.toNamed(RouteName.tagdetailscreen); - }, - child: containertile(text: containerTitle[index])), - ); - }, - ), - ), - sizedBoxHeight(20.h), - text16w400_FCFCFC( - "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s . . ."), - Row(children: [ - stackReaction(number: '20', containerImages: [ - 'assets/images/png/f7_hand-thumbsup.png', - 'assets/images/png/heart 2.png', - 'assets/images/png/party-popper 2.png' - ]), - const Spacer(), - commonGlassUI( - borderwidth: 0.43, - width: 30.w, - height: 30.h, - opacity1: 0.05, - opacity2: 0.06, - borderRadius: BorderRadius.circular(100), - customWidget: Center( - child: Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 13.h, - width: 13.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC('20'), - sizedBoxWidth(20.w), - commonGlassUI( - borderwidth: 0.43, - width: 30.w, - height: 30.h, - borderRadius: BorderRadius.circular(100), - opacity1: 0.05, - opacity2: 0.06, - customWidget: Center( - child: Image.asset( - 'assets/images/png/Vector (1).png', - height: 12.h, - width: 12.w, - ), - ), - ), - sizedBoxWidth(12.w), - text14w400_FCFCFC('10'), - ]), - sizedBoxHeight(30.h), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Obx(() { - return ReactionButton( - onReactionChanged: (reaction) { - updateImage(reaction?.value ?? 'like'); - debugPrint('Selected value: ${reaction?.value}'); - }, - reactions: ?>[ - Reaction( - value: 'like', - previewIcon: _buildReactionsPreviewIcon( - 'assets/images/png/f7_hand-thumbsup.png'), - icon: _buildReactionsIcon( - 'assets/images/png/f7_hand-thumbsup.png'), - ), - Reaction( - value: 'heart', - previewIcon: _buildReactionsPreviewIcon( - 'assets/images/png/heart 2.png'), - icon: _buildReactionsIcon( - 'assets/images/png/heart 2.png'), - ), - Reaction( - value: 'party', - previewIcon: _buildReactionsPreviewIcon( - 'assets/images/png/party-popper 2.png'), - icon: _buildReactionsIcon( - 'assets/images/png/party-popper 2.png'), - ), - ], - selectedReaction: Reaction( - value: 'like', - icon: _buildReactionsIcon( - 'assets/images/png/f7_hand-thumbsup.png'), - ), - boxColor: Colors.white, - boxElevation: 9, - boxRadius: 30, - itemsSpacing: 8, - itemScale: 0.4, - itemSize: const Size(45, 45), - boxPadding: const EdgeInsets.all(8), - boxAnimationDuration: const Duration(milliseconds: 200), - itemAnimationDuration: const Duration(milliseconds: 500), - hoverDuration: const Duration(milliseconds: 700), - // toggle: false, - - child: _buildReactionsIcon(mainImage.value), - ); - }) - ], - ), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.postdetailsScreen); - }, - child: Column( - children: [ - Image.asset( - 'assets/images/png/Frame 1000004088.png', - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Comment') - ], - ), - ), - Column( - children: [ - Image.asset( - 'assets/images/png/Frame 1000004089.png', - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Save') - ], - ) - ], - ) - ]), - ), - ], - ); -} - -Widget _buildReactionsPreviewIcon(String assetPath) { - return Padding( - padding: const EdgeInsets.all(8.0), - child: Image.asset( - assetPath, - height: 40.h, - width: 40.w, - ), - ); -} - -Widget _buildReactionsIcon(String assetPath) { - return Column( - children: [ - Image.asset( - assetPath, - height: 19.h, - width: 19.w, - ), - sizedBoxHeight(8.h), - text11w400_FCFCFC('Like') - ], - ); -} - -Widget containertile({required String text}) { - return commonGlassUI( - borderwidth: 1, - width: 100.w, - height: 30.h, - borderRadius: BorderRadius.circular(30.r), - borderColor: const Color(0xFFD90B2E), - customWidget: Padding( - padding: EdgeInsets.symmetric(horizontal: 10.w), - child: Center(child: text14w400_FCFCFC(text)), - )); -} diff --git a/lib/sidemenu/Community/MyCommunity/view_model/getmethod.dart b/lib/sidemenu/Community/MyCommunity/view_model/getmethod.dart index d093096..bf24383 100644 --- a/lib/sidemenu/Community/MyCommunity/view_model/getmethod.dart +++ b/lib/sidemenu/Community/MyCommunity/view_model/getmethod.dart @@ -8,22 +8,24 @@ import 'package:regroup/sidemenu/Community/MyCommunity/Model/communityMebersMode 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'; +import 'package:regroup/sidemenu/Community/MyCommunity/Model/communitymanageGroupsModel.dart'; CommunityAddgroupsModel? communityaddgroupobj; CommunitygroupsModel? communitygroupspobj; CommunityMembersModel? communitymembersobj; CommunityinfopageEditModel? communityeditobj; +CommunityManageGroupsModel? communitymanagegroupsobj; class Getcommunity { - Future> getCommunityAddGroupsearch(updata, + Future> getCommunityAddGroupsearch(updata,community, {required StreamController streamController}) async { final response = await NetworkApiServices().getApi( - "${ApiUrls.getcommunityaddgroups}?search=$updata", + "${ApiUrls.getcommunityaddgroups}?manage_community_xid=$community&search=$updata", ); @@ -73,4 +75,19 @@ class Getcommunity { return response; } + Future> getCommunityManageGroupssearch(updata,updata2, + {required StreamController streamController}) async { + final response = + await NetworkApiServices().getApi( + "${ApiUrls.getcommunitymanagegroups}?manage_community_xid=$updata&search=$updata2", + + ); + + if (response.status == ResponseStatus.SUCCESS) { + communitymanagegroupsobj = CommunityManageGroupsModel.fromJson(response.data); + if (!streamController.isClosed) streamController.sink.add(communitymanagegroupsobj!); + } + return response; + } + } \ No newline at end of file diff --git a/lib/sidemenu/Community/MyCommunity/view_model/postmethod.dart b/lib/sidemenu/Community/MyCommunity/view_model/postmethod.dart index 5015f0a..ba90f84 100644 --- a/lib/sidemenu/Community/MyCommunity/view_model/postmethod.dart +++ b/lib/sidemenu/Community/MyCommunity/view_model/postmethod.dart @@ -26,4 +26,23 @@ class PostMethodCommunity { print("response message is ${response.message}"); return response; } + + Future> postGroupsRemove(updata) async { + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.postremovegroupscommunity, + ); + return response; + } + + Future> postmanageaddgroupscommunity(updata) async { + print("updata is $updata"); + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.postmanageaddgroupscommunity, + ); + print("response is ${response.data}"); + print("response message is ${response.message}"); + return response; + } } \ No newline at end of file