diff --git a/assets/images/png/Group 1000004149.png b/assets/images/png/Group 1000004149.png new file mode 100644 index 0000000..855035d Binary files /dev/null and b/assets/images/png/Group 1000004149.png differ 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/lib/Common/CommonWidget.dart b/lib/Common/CommonWidget.dart index c17bee3..6d6c8d2 100644 --- a/lib/Common/CommonWidget.dart +++ b/lib/Common/CommonWidget.dart @@ -22,7 +22,7 @@ class TextInputField extends StatefulWidget { class _TextInputFieldState extends State { @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: double.infinity, height: 46.h, child: TextFormField( @@ -274,7 +274,7 @@ Widget stackContainersGroups({ const maxImagesToShow = 3; // Calculate the number of images to show and the remaining count - final remainingCount = containerImages.length - maxImagesToShow; + // final remainingCount = containerImages.length - maxImagesToShow; final imagesToShow = containerImages.take(maxImagesToShow).toList(); return Row( @@ -304,7 +304,7 @@ Widget stackContainersGroups({ ), ), ) - : Container( + : SizedBox( height: 30.h, width: 30.w, ), diff --git a/lib/Common/api_urls.dart b/lib/Common/api_urls.dart index 7c8e78e..6e3e3a8 100644 --- a/lib/Common/api_urls.dart +++ b/lib/Common/api_urls.dart @@ -97,6 +97,8 @@ class ApiUrls { static const getInvitecommunity = "${baseUrl}fetch-all-invite"; + static const postnewinterest = "${baseUrl}store-tags"; + static const postcancelrequest = "${baseUrl}cancel-request-of-community"; static const postacceptinvite = "${baseUrl}accept-invite-to-join-community"; @@ -176,4 +178,13 @@ class ApiUrls { static const geteditcommunity = "${baseUrl}edit-community"; static const posteditcommunity = "${baseUrl}update-community"; + + 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 new file mode 100644 index 0000000..6096b92 --- /dev/null +++ b/lib/Common/controller/NormalPostCard.dart @@ -0,0 +1,662 @@ +import 'dart:developer'; + +import 'package:cached_network_image/cached_network_image.dart'; +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/Common/base_manager.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/postmethod.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/view_model/CountersHelper.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/view_model/communitypostmethod.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/view_model/postmethod.dart'; + +class NormalCardTile extends StatefulWidget { + List tags; + String? createAt; + CommonDatumObjModelData commonObj; + String forWhichTab; + List reactions; + Map selectedReactions; + 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); + + @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; + _handleReactionChange(Reaction? reaction) async { + if (widget.selectedReactions[widget.commonObj.id] != null && + reaction?.value == + widget.selectedReactions[widget.commonObj.id]!.id.toString() || + reaction?.value == null) { + // User tapped on the currently selected reaction, so remove it + + //api call for dislike + + await LikeUploaddata( + widget.selectedReactions[widget.commonObj.id]?.id, + widget.commonObj.id!, + ); + setState(() { + widget.selectedReactions[widget.commonObj.id!] = null; + //decrement gloally + countersHelper.likesCounterPopular[widget.currentIndex]--; + log("global value ${countersHelper.likesCounterPopular[widget.currentIndex]}"); + }); + } else { + // User selected a new reaction + var newSelectedReaction = widget.reactions.firstWhere( + (r) => r.id.toString() == reaction?.value, + orElse: () => widget.reactions.first, // Default reaction if not found + ); + await _handleReactionChangeApiCall( + newSelectedReaction, widget.commonObj.id!); + } + } + + Future _handleReactionChangeApiCall( + ReactionData? reaction, int postId) async { + setState(() { + widget.selectedReactions[postId] = + reaction; // Set the selected reaction for this post + + if (countersHelper.likesCounterPopular[widget.currentIndex] <= + widget.commonObj.totalReactionCount!) { + countersHelper.likesCounterPopular[widget.currentIndex]++; + } + }); + + await LikeUploaddata( + reaction?.id, + postId, + ); + } + + LikeUploaddata(int? likeIconId, int? postid) async { + Map updata = { + "manage_posts_xid": postid, + "like_icons_xid": likeIconId ?? '', + }; + final data = await CommunitypostMethod().postLikepost(updata); + if (data.status == ResponseStatus.SUCCESS) { + // return utils.showToast(data.message); + } else { + return utils.showToast(data.message); + } + } + + void updateImage(String reaction) { + switch (reaction) { + case 'like': + mainImage.value = 'assets/images/png/f7_hand-thumbsup.png'; + break; + case 'heart': + mainImage.value = 'assets/images/png/heart 2.png'; + break; + case 'party': + mainImage.value = 'assets/images/png/party-popper 2.png'; + break; + default: + // Handle any other cases or do nothing + break; + } + } + + saveunsavepost(int popularpostid) async { + // utils.loader(); + Map updata = { + "manage_posts_xid": popularpostid, + }; + final data = await Communitypostmethod().postUserSave(updata); + if (data.status == ResponseStatus.SUCCESS) { + if (countersHelper.saveButtonPopular[widget.currentIndex] == false) { + countersHelper.savePostCounterPopular[widget.currentIndex]++; + } else { + countersHelper.savePostCounterPopular[widget.currentIndex]--; + } + countersHelper.saveButtonPopular[widget.currentIndex] = + !countersHelper.saveButtonPopular[widget.currentIndex]; + return utils.showToast(data.message); + } else { + return utils.showToast(data.message); + } + } + + pinunpinUser(int userid) async { + Map updata = { + "pin_iam_principal_xid": userid, + }; + final data = await SidebarTags().postUserpin(updata); + if (data.status == ResponseStatus.SUCCESS) { + countersHelper.pinButtonPopular[widget.currentIndex] = + !countersHelper.pinButtonPopular[widget.currentIndex]; + countersHelper.updateFeedsPage.value = + !countersHelper.updateFeedsPage.value; + return utils.showToast(data.message); + } else { + return utils.showToast(data.message); + } + } + + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + var imgUrl = widget.commonObj.image! + .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, + 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, + ) + : 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, + ), + ), + sizedBoxHeight(8.h), + text11w400_FCFCFC('Save') + ], + ), + ), + ], + ), + sizedBoxHeight(12.h), + commonDivider(), + sizedBoxHeight(12.h), + ]), + ), + ], + )); + } +} diff --git a/lib/Common/controller/data/network/network_api.dart b/lib/Common/controller/data/network/network_api.dart index 663e624..ba3b12d 100644 --- a/lib/Common/controller/data/network/network_api.dart +++ b/lib/Common/controller/data/network/network_api.dart @@ -47,15 +47,13 @@ class NetworkApiServices { : Options( headers: { 'authorization': basicAuth, - 'access-token': - token + 'access-token': token }, ), ); - } - on Exception catch (e) { + } on Exception catch (e) { // log(e.toString()); - if (e is DioException) { + if (e is DioException) { log(e.response.toString()); if (e.response == null) { return ResponseData( @@ -75,7 +73,6 @@ class NetworkApiServices { ResponseStatus.FAILED, ); } - } if (e.response!.statusCode == 403) { if (e.response!.data['message'] is List) { @@ -212,9 +209,7 @@ class NetworkApiServices { }, ) : Options( - headers: {'authorization': basicAuth, 'access-token': - token - }, + headers: {'authorization': basicAuth, 'access-token': token}, ), ); log(response.toString()); @@ -250,6 +245,10 @@ class NetworkApiServices { return ResponseData( e.response!.data['message'][0]!, ResponseStatus.FAILED, data: e.response!.data); + } else if (e.response!.data['message']['name'] is List) { + return ResponseData( + e.response!.data['message']['name'][0]!, ResponseStatus.FAILED, + data: e.response!.data); } else { return ResponseData( e.response!.data['message'], ResponseStatus.FAILED, diff --git a/lib/Feed Module/Main_Screens/ProfileTab/TimeLine/AddTimeline.dart b/lib/Feed Module/Main_Screens/ProfileTab/TimeLine/AddTimeline.dart index 6377ff6..3246c48 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/TimeLine/AddTimeline.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/TimeLine/AddTimeline.dart @@ -22,7 +22,6 @@ import 'package:regroup/resources/routes/route_name.dart'; import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart'; import 'package:intl/intl.dart'; import 'package:async/src/future_group.dart'; -import 'package:shared_preferences/shared_preferences.dart'; class AddTimeline extends StatefulWidget { const AddTimeline({super.key}); diff --git a/lib/Main_Screens/Community/ViewModel/getmethod.dart b/lib/Main_Screens/Community/ViewModel/getmethod.dart index 2a72663..9804178 100644 --- a/lib/Main_Screens/Community/ViewModel/getmethod.dart +++ b/lib/Main_Screens/Community/ViewModel/getmethod.dart @@ -1,4 +1,4 @@ -import 'dart:developer'; + import 'package:regroup/Common/api_urls.dart'; import 'package:regroup/Common/base_manager.dart'; diff --git a/lib/Main_Screens/Community_HomePage/Community.dart b/lib/Main_Screens/Community_HomePage/Community.dart index f2360a8..1501ed7 100644 --- a/lib/Main_Screens/Community_HomePage/Community.dart +++ b/lib/Main_Screens/Community_HomePage/Community.dart @@ -3,17 +3,14 @@ import 'dart:developer'; import 'package:async/src/future_group.dart'; -import 'package:cached_network_image/cached_network_image.dart'; 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/CommonBottomNavigationBar.dart'; import 'package:regroup/Common/CommonGlassmorphism.dart'; import 'package:regroup/Common/CommonTabBar.dart'; -import 'package:regroup/Common/CommonWidget.dart'; import 'package:regroup/Common/ConvertServerDateToUserDate.dart'; -import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Common/controller/NormalPostCard.dart'; import 'package:regroup/Common/controller/MainScreen.dart'; import 'package:regroup/Main_Screens/Community/Model/CommonDatumObjModel.dart'; import 'package:regroup/Main_Screens/Community/Model/FeedPostModel.dart' @@ -25,17 +22,13 @@ import 'package:regroup/Main_Screens/Community/ViewModel/FeedPost.dart'; import 'package:regroup/Main_Screens/Community/ViewModel/LatestPost.dart'; import 'package:regroup/Main_Screens/Community/ViewModel/PopularPost.dart'; import 'package:regroup/Main_Screens/Community/ViewModel/getmethod.dart'; -import 'package:regroup/Main_Screens/Community/ViewModel/postmethod.dart'; import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/View/ReactionView.dart'; -import 'package:regroup/Main_Screens/Community_HomePage/view_model/communitypostmethod.dart'; import 'package:regroup/Utils/Common/ShimmerCommon.dart'; // import 'package:regroup/Feed%20Module/sidemenu/sidemenu.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/sidemenu.dart'; -import 'package:regroup/sidemenu/view_model/postmethod.dart'; import 'view_model/CountersHelper.dart'; @@ -236,7 +229,7 @@ class _FeedTabState extends State { } } - setValues() { + Future setValues() async { if (mounted) { combinedList.clear(); combinedListGlobal.clear(); @@ -246,7 +239,7 @@ class _FeedTabState extends State { combinedListGlobal.addAll(combinedList); _setModel(); countersHelper.setListsPopular(); - _fetchIcons(); + await _fetchIcons(); } } @@ -387,7 +380,7 @@ class _FeedTabState extends State { children: [ NormalCardTile( tags: _sortTags(index), - create_at: timeAgo ?? '1 hour', + createAt: timeAgo ?? '1 hour', commonObj: commonobjmodel!.data[index], forWhichTab: 'feed', @@ -475,7 +468,7 @@ class _FeedTabState extends State { children: [ NormalCardTile( tags: _sortTags(index), - create_at: timeAgo ?? '1 hour', + createAt: timeAgo ?? '1 hour', commonObj: commonobjmodel!.data[index], forWhichTab: 'feed', @@ -503,624 +496,6 @@ class _FeedTabState extends State { } // ignore: must_be_immutable -class NormalCardTile extends StatefulWidget { - List tags; - String? create_at; - CommonDatumObjModelData commonObj; - String forWhichTab; - List reactions; - Map selectedReactions; - - int currentIndex; - NormalCardTile({ - Key? key, - required this.tags, - this.create_at, - required this.forWhichTab, - required this.commonObj, - required this.reactions, - required this.selectedReactions, - required this.currentIndex, - }) : 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; - _handleReactionChange(Reaction? reaction) async { - if (widget.selectedReactions[widget.commonObj.id] != null && - reaction?.value == - widget.selectedReactions[widget.commonObj.id]!.id.toString() || - reaction?.value == null) { - // User tapped on the currently selected reaction, so remove it - - //api call for dislike - - await LikeUploaddata( - widget.selectedReactions[widget.commonObj.id]?.id, - widget.commonObj.id!, - ); - setState(() { - widget.selectedReactions[widget.commonObj.id!] = null; - //decrement gloally - countersHelper.likesCounterPopular[widget.currentIndex]--; - log("global value ${countersHelper.likesCounterPopular[widget.currentIndex]}"); - }); - } else { - // User selected a new reaction - var newSelectedReaction = widget.reactions.firstWhere( - (r) => r.id.toString() == reaction?.value, - orElse: () => widget.reactions.first, // Default reaction if not found - ); - await _handleReactionChangeApiCall( - newSelectedReaction, widget.commonObj.id!); - } - } - - Future _handleReactionChangeApiCall( - ReactionData? reaction, int postId) async { - setState(() { - widget.selectedReactions[postId] = - reaction; // Set the selected reaction for this post - - if (countersHelper.likesCounterPopular[widget.currentIndex] <= - widget.commonObj.totalReactionCount!) { - countersHelper.likesCounterPopular[widget.currentIndex]++; - } - }); - - await LikeUploaddata( - reaction?.id, - postId, - ); - } - - LikeUploaddata(int? likeIconId, int? postid) async { - Map updata = { - "manage_posts_xid": postid, - "like_icons_xid": likeIconId ?? '', - }; - final data = await CommunitypostMethod().postLikepost(updata); - if (data.status == ResponseStatus.SUCCESS) { - // return utils.showToast(data.message); - } else { - return utils.showToast(data.message); - } - } - - void updateImage(String reaction) { - switch (reaction) { - case 'like': - mainImage.value = 'assets/images/png/f7_hand-thumbsup.png'; - break; - case 'heart': - mainImage.value = 'assets/images/png/heart 2.png'; - break; - case 'party': - mainImage.value = 'assets/images/png/party-popper 2.png'; - break; - default: - // Handle any other cases or do nothing - break; - } - } - - saveunsavepost(int popularpostid) async { - // utils.loader(); - Map updata = { - "manage_posts_xid": popularpostid, - }; - final data = await Communitypostmethod().postUserSave(updata); - if (data.status == ResponseStatus.SUCCESS) { - if (countersHelper.saveButtonPopular[widget.currentIndex] == false) { - countersHelper.savePostCounterPopular[widget.currentIndex]++; - } else { - countersHelper.savePostCounterPopular[widget.currentIndex]--; - } - countersHelper.saveButtonPopular[widget.currentIndex] = - !countersHelper.saveButtonPopular[widget.currentIndex]; - return utils.showToast(data.message); - } else { - return utils.showToast(data.message); - } - } - - pinunpinUser(int userid) async { - Map updata = { - "pin_iam_principal_xid": userid, - }; - final data = await SidebarTags().postUserpin(updata); - if (data.status == ResponseStatus.SUCCESS) { - countersHelper.pinButtonPopular[widget.currentIndex] = - !countersHelper.pinButtonPopular[widget.currentIndex]; - countersHelper.updateFeedsPage.value = - !countersHelper.updateFeedsPage.value; - return utils.showToast(data.message); - } else { - return utils.showToast(data.message); - } - } - - @override - void initState() { - super.initState(); - } - - @override - Widget build(BuildContext context) { - var imgUrl = widget.commonObj.image! - .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: [ - text16w400_FCFCFC( - widget.commonObj.iamPrincipal!.fullName ?? "Regroup"), - 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.create_at!), - ], - ) - ], - ), - 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.create_at, - '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, - 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, - ) - : 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.create_at, - '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), - ]), - ), - ], - )); - } -} Widget containertile({required String text}) { return commonGlassContainer( @@ -1334,7 +709,7 @@ class _PopularTabState extends State { children: [ NormalCardTile( tags: _sortTags(index), - create_at: timeAgo ?? '1 hour', + createAt: timeAgo ?? '1 hour', commonObj: commonobjmodel!.data[index], forWhichTab: 'popular', reactions: _reactions, @@ -1364,12 +739,12 @@ class LatestTab extends StatefulWidget { } class _LatestTabState extends State { - FutureGroup futureGroup = FutureGroup(); + late Future latestfuture; @override void initState() { - futureGroup.add(LatespostApi().getLatestPostApi()); - futureGroup.close(); + latestfuture = LatespostApi().getLatestPostApi(); + super.initState(); } @@ -1482,7 +857,7 @@ class _LatestTabState extends State { @override Widget build(BuildContext context) { return FutureBuilder( - future: futureGroup.future, + future: latestfuture, builder: (ctx, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return const Center(child: ShimmerCommon()); @@ -1548,7 +923,7 @@ class _LatestTabState extends State { children: [ NormalCardTile( tags: _sortTags(index), - create_at: timeAgo ?? '1 hour', + createAt: timeAgo ?? '1 hour', commonObj: commonobjmodel!.data[index], forWhichTab: 'latest', reactions: _reactions, diff --git a/lib/Main_Screens/Community_HomePage/Model/tagpopulardetailsModel.dart b/lib/Main_Screens/Community_HomePage/Model/tagpopulardetailsModel.dart index d681df1..664d9ee 100644 --- a/lib/Main_Screens/Community_HomePage/Model/tagpopulardetailsModel.dart +++ b/lib/Main_Screens/Community_HomePage/Model/tagpopulardetailsModel.dart @@ -34,6 +34,7 @@ class Datum { required this.postIn, required this.caption, required this.image, + required this.manageTagsXids, required this.postAs, required this.ctaTitle, required this.ctaLink, @@ -61,6 +62,8 @@ class Datum { final int? postIn; final String? caption; final String? image; + final String? manageTagsXids; + final String? postAs; final String? ctaTitle; final String? ctaLink; @@ -89,6 +92,7 @@ class Datum { postIn: json["post_in"], caption: json["caption"], image: json["image"], + manageTagsXids: json["manage_tags_xids"], postAs: json["post_as"], ctaTitle: json["cta_title"], ctaLink: json["cta_link"], diff --git a/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart b/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart index c6115b2..98376ff 100644 --- a/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart +++ b/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart @@ -1,20 +1,15 @@ -import 'dart:developer'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/gestures.dart'; + import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:get/get_state_manager/get_state_manager.dart'; import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Common/controller/NormalPostCard.dart'; import 'package:regroup/Global.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_HomePage/Community.dart'; import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/CommentsHelper.dart'; import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/CommentsRepository.dart'; import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/PostDetailApi.dart'; @@ -36,7 +31,7 @@ class PostDetailsScreen extends StatefulWidget { class _PostDetailsScreenState extends State { int? followunfollowid; - FollowUnfollowUploadata() async { + followUnfollowUploadata() async { // utils.loader(); Map newupdata = { "following_iam_principal_xid": followunfollowid, @@ -238,7 +233,7 @@ class _PostDetailsScreenState extends State { NormalCardTile( tags: tags!, - create_at: create_at!, + createAt: create_at!, commonObj: commonObj!, forWhichTab: formWhichTab!, reactions: reactions!, diff --git a/lib/Main_Screens/Community_HomePage/PostScreen.dart b/lib/Main_Screens/Community_HomePage/PostScreen.dart index 6976fbf..f8cc5e4 100644 --- a/lib/Main_Screens/Community_HomePage/PostScreen.dart +++ b/lib/Main_Screens/Community_HomePage/PostScreen.dart @@ -9,7 +9,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart' hide MultipartFile, FormData; -import 'package:regroup/Common/CommonButton.dart'; import 'package:regroup/Common/CommonGlassmorphism.dart'; import 'package:regroup/Common/base_manager.dart'; @@ -95,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 @@ -120,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 } } @@ -132,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 ' + @@ -142,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}, )); @@ -236,15 +229,15 @@ class _PostScreenState extends State { context: context, builder: (BuildContext context) { return AlertDialog( - backgroundColor: Color(0xFF222935).withOpacity(0.9), - title: Text( + backgroundColor: const Color(0xFF222935).withOpacity(0.9), + title: const Text( "Add Tag", style: TextStyle(color: Colors.white), ), content: TextField( - style: TextStyle(color: Colors.white), + style: const TextStyle(color: Colors.white), controller: _tagController, - decoration: InputDecoration( + decoration: const InputDecoration( labelText: "Tag", labelStyle: TextStyle(color: AppColors.white), disabledBorder: UnderlineInputBorder( @@ -261,14 +254,14 @@ class _PostScreenState extends State { onPressed: () { Navigator.of(context).pop(); }, - child: Text("Cancel", style: TextStyle(color: AppColors.white)), + child: const Text("Cancel", style: TextStyle(color: AppColors.white)), ), TextButton( onPressed: () async { tagUploadata(); Navigator.of(context).pop(); }, - child: Text("Submit", style: TextStyle(color: AppColors.white)), + child: const Text("Submit", style: TextStyle(color: AppColors.white)), ), ], ); @@ -289,10 +282,10 @@ class _PostScreenState extends State { label: Text('#${tag.name}', style: const TextStyle(color: Colors.white)), backgroundColor: const Color(0xFFD90B2E).withOpacity(0.9), - side: BorderSide(color: Colors.black), + side: const BorderSide(color: Colors.black), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(30.r), - side: BorderSide(width: 1, color: Colors.white)), + side: const BorderSide(width: 1, color: Colors.white)), onDeleted: () { setState(() { selectedpopularid.remove(tag.id); @@ -341,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) { @@ -380,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) { @@ -427,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", @@ -455,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( @@ -561,11 +608,11 @@ class _PostScreenState extends State { ], ), ), - )), - ), + ), + )), ), sizedBoxHeight(25.h), - text16w400_FCFCFC("Tags"), + text16w400_FCFCFC("Interest"), sizedBoxHeight(18.h), _isSecondDropdownEnabled == true ? CustomDropDownPopularTag( @@ -579,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( @@ -612,10 +667,10 @@ class _PostScreenState extends State { ), ], ) - : SizedBox(), + : const SizedBox(), sizedBoxHeight(25.h), globalAccountType == '1' - ? SizedBox() + ? const SizedBox() : Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -680,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( @@ -701,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( @@ -735,8 +794,8 @@ class _PostScreenState extends State { context: context, builder: (BuildContext context) { return AlertDialog( - insetPadding: EdgeInsets.symmetric(vertical: 10, horizontal: 15), - contentPadding: EdgeInsets.fromLTRB(24, 8, 24, 24), + insetPadding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15), + contentPadding: const EdgeInsets.fromLTRB(24, 8, 24, 24), shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(14.r))), backgroundColor: const Color(0xFF222935), @@ -956,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: @@ -988,6 +1048,7 @@ class _CustomDropDownCheckBoxPostNewState ) : ListView.builder( shrinkWrap: true, + physics: ScrollPhysics(), itemCount: widget.listData.length, itemBuilder: (context, index) { String item = widget.listData[index]; @@ -1198,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), @@ -1208,6 +1270,7 @@ class _CustomDropDownPopularTagState extends State { ), child: ListView.builder( shrinkWrap: true, + physics: ScrollPhysics(), itemCount: filteredTags.length, itemBuilder: (context, index) { return InkWell( @@ -1262,10 +1325,10 @@ class _CustomDropDownPopularTagState extends State { label: Text('#${tag.name!}', style: const TextStyle(color: Colors.white)), backgroundColor: const Color(0xFFD90B2E).withOpacity(0.9), - side: BorderSide(color: Colors.black), + side: const BorderSide(color: Colors.black), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(30.r), - side: BorderSide(width: 1, color: Colors.white)), + side: const BorderSide(width: 1, color: Colors.white)), onDeleted: () { selectedTags.remove(tag); widget.onItemSelected(selectedTags.toList()); @@ -1282,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 b384a73..74b2314 100644 --- a/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart +++ b/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart @@ -9,13 +9,17 @@ import 'package:regroup/Common/CommonTabBar.dart'; import 'package:regroup/Common/CommonWidget.dart'; import 'package:regroup/Common/ConvertServerDateToUserDate.dart'; import 'package:regroup/Common/base_manager.dart'; +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/ViewModel/postmethod.dart'; import 'package:regroup/Main_Screens/Community_HomePage/Community.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/view_model/CountersHelper.dart'; import 'package:regroup/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart'; import 'package:regroup/Main_Screens/Community_HomePage/view_model/communitypostmethod.dart'; import 'package:regroup/Utils/Common/CommonAppbar.dart'; +import 'package:regroup/Utils/Common/ShimmerCommon.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; import 'package:regroup/Utils/dialogs.dart'; import 'package:regroup/Utils/texts.dart'; @@ -551,180 +555,127 @@ class PopularTab extends StatefulWidget { } class _PopularTabState extends State { - FutureGroup futureGroup = FutureGroup(); + late Future futureGroup; + List _reactions = []; + final Map _selectedReactions = {}; + final CountersHelper countersHelper = Get.find(); + int? likeIconIdnew; @override void initState() { - futureGroup - .add(Communitygetmethod().getPopularTagsdata(widget.id).then((value) { - _initializeData(); - })); - futureGroup.close(); + futureGroup = Communitygetmethod().getPopularTagsdata(widget.id); + super.initState(); } - List _reactions = []; - Map _selectedReactions = {}; - - Future _initializeData() async { - await _fetchIcons(); - // _initializeSelectedReaction(); - for (var post in tagpopulardetailobj!.data) { - if (post.likeIcon != null) { - likeIconIdnew = post.likeIcon!.likeIconsXid; // This is safe now - print('like selectedid is ${likeIconIdnew.toString()}'); - } else { - likeIconIdnew = 0; // Or handle it as needed - print('like id is ${likeIconIdnew.toString()}'); - } - _initializeSelectedReaction(post.id!); // Pass the post ID - } - } - Future _fetchIcons() async { - var response = await Communityallgetmethod().getLikeicons(); - if (response.status == ResponseStatus.SUCCESS) { - var responseData = response.data as Map; - FetchlikeIconsModel fetchlikeIconsModel = - FetchlikeIconsModel.fromJson(responseData); + _reactions = fetchlikeIconsModel!.data ?? []; + for (var post in commonobjmodel!.data) { + //Check if post as a like icon + if (post.likeIcon?.likeIcon?.id != null) { + likeIconIdnew = post.likeIcon!.likeIconsXid; - setState(() { - _reactions = fetchlikeIconsModel.data - ?.map((data) => ReactionData( - id: data.id!, - image: data.image!, - )) - .toList() ?? - []; - for (var post in tagpopulardetailobj!.data) { - _initializeSelectedReaction(post.id!); - } - }); - } - } + final selectedReaction = _reactions.firstWhere( + (r) => r.id == likeIconIdnew, + orElse: () => _reactions.first, + ); - int? likeIconIdnew; - - void _initializeSelectedReaction(int postId) { - // Check if there's a stored likeIconId for this post - if (likeIconIdnew != null && likeIconIdnew != 0 && _reactions.isNotEmpty) { - final selectedReaction = _reactions.firstWhere( - (r) => r.id == likeIconIdnew, - orElse: () => _reactions.first, - ); - - setState(() { - _selectedReactions[postId] = + _selectedReactions[post.id!] = selectedReaction; // Set selected reaction for this post - print( - 'Selected reaction for post $postId is ${_selectedReactions[postId].toString()}'); - log(_selectedReactions[postId].toString()); - }); - } else { - setState(() { - _selectedReactions[postId] = null; // No reaction selected - print('No reaction selected for post $postId'); - }); - } - } - - Future _handleReactionChange(ReactionData? reaction, int postId) async { - // Check if the postId is valid - if (postId == null) return; - - setState(() { - if (reaction == null) { - _selectedReactions[postId] = - null; // Mark reaction as removed for this post } else { - _selectedReactions[postId] = - reaction; // Set the selected reaction for this post + _selectedReactions[post.id!] = null; // No reaction selected + // print('No reaction selected for post $postId'); } - }); - - try { - await LikeUploaddata( - reaction?.id, - postId, - ); - } catch (error) { - print('Error updating reaction: $error'); - setState(() { - _selectedReactions[postId] = - reaction; // Restore previous reaction if needed - }); } } - LikeUploaddata(int? likeIconId, int? postid) async { - // utils.loader(); - Map updata = { - "manage_posts_xid": postid, - "like_icons_xid": likeIconId ?? '', - }; - final data = await CommunitypostMethod().postLikepost(updata); - if (data.status == ResponseStatus.SUCCESS) { - // Get.back(); - print("like done"); - return utils.showToast(data.message); - } else { - // Get.back(); - print("like not done"); - return utils.showToast(data.message); + bool _isDataInitialized = true; + + Future setValues() async { + if (_isDataInitialized) { + _setModel(); + countersHelper.setListstagPopular(); + await _fetchIcons(); + + _isDataInitialized = false; } } - saveunsavepost(int postid) async { - // utils.loader(); - Map updata = { - "manage_posts_xid": postid, - }; - final data = await Communitypostmethod().postUserSave(updata); - if (data.status == ResponseStatus.SUCCESS) { - Communitygetmethod().getTagsdata(widget.id).then((value) { - _initializeData(); - setState(() {}); - }); + _sortTags(index) { + var tags = commonobjmodel!.data[index].attachTags + .where((tag) => tag.manageTag?.name?.isNotEmpty ?? false) + .map((tag) => tag.manageTag!) + .toList(); - return utils.showToast(data.message); - } else { - // Get.back(); - return utils.showToast(data.message); - } + return tags; } - pinunpinUser(int userid) async { - // utils.loader(); - Map updata = { - "pin_iam_principal_xid": userid, - }; - final data = await SidebarTags().postUserpin(updata); - if (data.status == ResponseStatus.SUCCESS) { - // Get.back(); - Communitygetmethod().getTagsdata(widget.id).then((value) { - _initializeData(); - setState(() {}); - }); - return utils.showToast(data.message); - } else { - // Get.back(); - return utils.showToast(data.message); - } + _setModel() { + commonobjmodel = null; + commonobjmodel = CommonDatumObjModel( + status: tagpopulardetailobj!.status, + statusCode: tagpopulardetailobj!.statusCode, + message: tagpopulardetailobj!.message, + data: tagpopulardetailobj!.data + .map((e) => CommonDatumObjModelData( + id: e.id, + likecount: e.likecount, + isISaved: e.isISaved, + tagsXid: e.tagsXid, + isILiked: e.isILiked, + totalComment: e.totalComment, + totalSave: e.totalSave, + iamPrincipalXid: e.iamPrincipalXid, + postIn: e.postIn, + caption: e.caption, + image: e.image, + manageTagsXids: e.manageTagsXids, + postAs: e.postAs, + ctaTitle: e.ctaTitle, + ctaLink: e.ctaLink, + createdAt: e.createdAt, + likeIcon: LikeIcon1( + likeIcon: LikeIconClass1( + id: e.likeIcon?.likeIcon?.id, + image: e.likeIcon?.likeIcon?.image), + likeIconsXid: e.likeIcon?.likeIconsXid, + ), + totalViewCount: e.totalViewCount, + totalReactionCount: e.totalReactionCount, + totalCommentCount: e.totalCommentCount, + totalImpressionCount: e.totalImpressionCount, + totalPopularScore: e.totalPopularScore, + totalHoursAgo: e.totalHoursAgo, + iamPrincipal: IamPrincipal( + id: e.iamPrincipal!.id, + isUserPinned: e.iamPrincipal!.isUserPinned, + principalTypeXid: e.iamPrincipal!.principalTypeXid, + userName: e.iamPrincipal!.userName, + fullName: e.iamPrincipal!.fullName, + profilePhoto: e.iamPrincipal!.profilePhoto), + community: Community( + id: e.community!.id, + communityProfilePhoto: e.community!.communityProfilePhoto, + communityName: e.community!.communityName), + attachTags: e.attachTags + .map((e) => AttachTag1( + managePostXid: e.managePostXid, + manageTagXid: e.manageTagXid, + manageTag: ManageTagPopular( + id: e.manageTag?.id, + isPinned: e.manageTag?.isPinned, + name: e.manageTag?.name))) + .toList())) + .toList()); } @override Widget build(BuildContext context) { return FutureBuilder( - future: futureGroup.future, + future: futureGroup, builder: (ctx, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { - return - // ShimmerCommon(); - const Center( - child: CircularProgressIndicator( - color: Colors.blue, - ), - ); + return const Center(child: ShimmerCommon()); } if (snapshot.hasError) { @@ -738,1472 +689,66 @@ class _PopularTabState extends State { if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { - print("Data fetched-->"); - return tagpopulardetailobj!.data.isEmpty - ? _buildNoDataBody(context) - : Column( - children: [ - sizedBoxHeight(16.h), - Expanded( - child: ListView.builder( - shrinkWrap: true, - itemCount: tagpopulardetailobj!.data.length, - itemBuilder: (context, index) { - var timeAgo = ConvertServerDateToUserDate() - .convertServerDateToReadableFormate( - tagpopulardetailobj!.data[index].createdAt - .toString()); - var postId = tagpopulardetailobj!.data[index].id; - var selectedReaction = _selectedReactions[postId]; - if (index == 1) { + setValues(); + return Stack(clipBehavior: Clip.none, children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill), + ), + ), + tagpopulardetailobj!.data.isEmpty + ? Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Center( + child: Column( + children: [ + Text( + "No Posts Available", + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.w600), + ) + ], + ), + ), + ]) + : Column( + children: [ + sizedBoxHeight(20.h), + Expanded( + child: ListView.builder( + shrinkWrap: true, + itemCount: commonobjmodel!.data.length, + itemBuilder: (context, index) { + var timeAgo = ConvertServerDateToUserDate() + .convertServerDateToReadableFormate( + tagpopulardetailobj!.data[index].createdAt + .toString()); + return Column( children: [ - commonGlassUIBlue( - width: double.infinity, - height: 780.h, - borderRadius: BorderRadius.circular(1), - customWidget: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - sizedBoxHeight(25.h), - Padding( - padding: - EdgeInsets.only(left: 16.w), - child: text16w700_FCFCFC( - "#Announcement"), - ), - sizedBoxHeight(25.h), - Padding( - padding: EdgeInsets.symmetric( - horizontal: 16.w), - child: Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - CircleAvatar( - foregroundImage: NetworkImage( - tagpopulardetailobj! - .data[index] - .iamPrincipal! - .profilePhoto ?? - ''), - radius: 25.r, - ), - sizedBoxWidth(12.w), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC( - tagpopulardetailobj! - .data[index] - .iamPrincipal! - .fullName ?? - ''), - 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( - tagpopulardetailobj! - .data[index] - .community! - .communityName ?? - '', - ), - sizedBoxWidth(7.w), - Icon( - Icons.circle, - color: const Color( - 0xFFFCFCFC), - size: 4.sp, - ), - sizedBoxWidth(6.w), - text12w400_FCFCFC( - timeAgo), - ], - ) - ], - ), - 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: () async { - // int pinPospostid = - // tagpopulardetailobj! - // .data[index] - // .id!; - // await pinunpinUser( - // pinPospostid); - // }, - // child: Padding( - // padding: EdgeInsets - // .symmetric( - // horizontal: - // 12.w), - // child: Row( - // children: [ - // Text( - // tagpopulardetailobj! - // .data[ - // index] - // .iamPrincipal! - // .isUserPinned == - // true - // ? 'Unpin' - // : '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: Container( - height: 390.h, - decoration: BoxDecoration( - image: DecorationImage( - image: NetworkImage( - tagpopulardetailobj! - .data[index] - .image ?? - ''), - 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: tagpopulardetailobj! - // .data[index].attachTags.length, - // itemBuilder: (context, tagIndex) { - // print( - // 'tags id are ${tagpopulardetailobj!.data[index].attachTags[tagIndex].manageTag!.id}'); - // print( - // 'tags name are ${tagpopulardetailobj!.data[index].attachTags[tagIndex].manageTag!.name}'); - // return Padding( - // padding: EdgeInsets.only( - // right: 12.w), - // child: GestureDetector( - // onTap: () { - // print('anonymous tag tapped'); - // Get.toNamed( - // RouteName.tagdetailscreen, - // arguments: { - // 'tagid': - // tagpopulardetailobj! - // .data[index] - // .attachTags[ - // tagIndex] - // .manageTag!.id, - // 'tagname': - // tagpopulardetailobj! - // .data[index] - // .attachTags[ - // tagIndex] - // .manageTag!.name, - // }); - // }, - // child: - // // containertile2( - // // text: (tagpopulardetailobj! - // // .data[index] - // // .tagNames[index]) - // // ) - // 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(tagpopulardetailobj! - // .data[ - // index] - // .attachTags[ - // tagIndex].manageTag! - // .name!)), - // )), - // ), - // ); - // }, - // ), - // ), - SizedBox( - height: 30.h, - width: double.infinity, - child: ListView.builder( - scrollDirection: - Axis.horizontal, - shrinkWrap: true, - // Filter the tags to include only those with a non-null and non-empty name - itemCount: tagpopulardetailobj! - .data[index].attachTags - .where((tag) => - tag.manageTag?.name - ?.isNotEmpty ?? - false) - .length, - itemBuilder: - (context, tagIndex) { - // Filtered list of tags - var filteredTags = - tagpopulardetailobj! - .data[index] - .attachTags - .where((tag) => - tag - .manageTag - ?.name - ?.isNotEmpty ?? - false) - .toList(); - - // Safely get the manageTag object - var manageTag = - filteredTags[tagIndex] - .manageTag; - - // Get the tag name, ensuring it's not null or empty - String tagName = - manageTag?.name ?? ''; - - return Padding( - padding: EdgeInsets.only( - right: 12.w, - left: 12.w), - child: GestureDetector( - onTap: () { - print( - 'anonymous tapped'); - Get.back(); - Get.toNamed( - RouteName - .tagdetailscreen, - arguments: { - 'tagid': tagpopulardetailobj! - .data[index] - .attachTags[ - tagIndex] - .manageTag! - .id, - // filteredTags[ - // tagIndex] - // .manageTagXid, - 'tagname': - tagName, - }); - }, - 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( - '#${tagName}'), - ), - ), - ), - ], - ), - ), - ); - }, - ), - ), - sizedBoxHeight(20.h), - SizedBox( - width: double.infinity, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC( - tagpopulardetailobj! - .data[index] - .caption ?? - ''), - ], - ), - ), - Row(children: [ - InkWell( - onTap: () {}, - child: stackReaction( - number: - tagpopulardetailobj! - .data[index] - .likecount - .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( - tagpopulardetailobj! - .data[index] - .totalComment - .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), - text14w400_FCFCFC( - tagpopulardetailobj! - .data[index].totalSave - .toString()), - ]), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - children: [ - Column( - mainAxisAlignment: - MainAxisAlignment - .center, - children: [ - Column( - children: [ - ReactionButton< - String>( - onReactionChanged: - (reaction) async { - if (selectedReaction != - null && - reaction?.value == - selectedReaction - .id - .toString()) { - // User tapped on the currently selected reaction, so remove it - await _handleReactionChange( - selectedReaction, - tagpopulardetailobj! - .data[ - index] - .id!); - } else { - // User selected a new reaction - var newSelectedReaction = - _reactions - .firstWhere( - (r) => - r.id.toString() == - reaction - ?.value, - orElse: () => - _reactions - .first, // Default reaction if not found - ); - await _handleReactionChange( - newSelectedReaction, - tagpopulardetailobj! - .data[ - index] - .id!); - } - debugPrint( - 'Selected value: ${reaction?.value}'); - }, - reactions: - _reactions - .map((reaction) => - Reaction< - String>( - 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: - selectedReaction != - null - ? Reaction< - String>( - value: selectedReaction - .id - .toString(), - icon: Image - .network( - selectedReaction - .image, - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ) - : Reaction< - String>( - value: - '', - icon: Image - .asset( - 'assets/images/png/uiw_like-o.png', - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ), - boxColor: - Colors.white, - boxElevation: 9, - boxRadius: 30, - itemsSpacing: 8, - itemScale: 0.4, - 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: - selectedReaction != - null - ? Image - .network( - selectedReaction - .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(2.h), - text11w400_FCFCFC( - 'Like'), - ], - ) - ], - ), - GestureDetector( - onTap: () {}, - 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: [ - GestureDetector( - onTap: () async { - int postid = - tagpopulardetailobj! - .data[index] - .id!; - await saveunsavepost( - postid); - }, - child: tagpopulardetailobj! - .data[index] - .isISaved == - true - ? 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, - ), - ), - // 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), - ]), - ), - ], - )), - sizedBoxHeight(20.h), - ], - ); - } else { - return Column( - children: [ - commonGlassUI( - width: double.infinity, - height: 760.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( - foregroundImage: NetworkImage( - tagpopulardetailobj! - .data[index] - .iamPrincipal! - .profilePhoto ?? - ''), - radius: 25.r, - ), - sizedBoxWidth(12.w), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC( - tagpopulardetailobj! - .data[index] - .iamPrincipal! - .fullName ?? - ''), - 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( - tagpopulardetailobj! - .data[index] - .community! - .communityName - .toString()), - sizedBoxWidth(7.w), - Icon( - Icons.circle, - color: const Color( - 0xFFFCFCFC), - size: 4.sp, - ), - sizedBoxWidth(6.w), - text12w400_FCFCFC( - timeAgo!), - ], - ) - ], - ), - 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: () async { - int pinPospostid = - tagpopulardetailobj! - .data[index] - .iamPrincipal! - .id!; - await pinunpinUser( - pinPospostid); - }, - child: Padding( - padding: EdgeInsets - .symmetric( - horizontal: - 12.w), - child: Row( - children: [ - Text( - tagpopulardetailobj! - .data[ - index] - .iamPrincipal! - .isUserPinned == - true - ? 'Unpin' - : '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: Container( - height: 360, - width: double.infinity, - decoration: BoxDecoration( - image: DecorationImage( - fit: BoxFit.cover, - image: NetworkImage( - tagpopulardetailobj! - .data[index] - .image ?? - '', - ), - ), - ), - ), - ), - 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: tagpopulardetailobj! - // .data[index].attachTags.length, - // itemBuilder: (context, tagIndex) { - // print( - // 'tags id are ${tagpopulardetailobj!.data[index].attachTags[tagIndex].manageTag!.id}'); - // print( - // 'tags name are ${tagpopulardetailobj!.data[index].attachTags[tagIndex].manageTag!.name}'); - // return Padding( - // padding: EdgeInsets.only( - // right: 12.w), - // child: GestureDetector( - // onTap: () { - // print('tag tapped'); - // Get.toNamed( - // RouteName.tagdetailscreen, - // arguments: { - // 'tagid': - // tagpopulardetailobj! - // .data[index] - // .attachTags[ - // tagIndex].manageTag! - // .id, - // 'tagname': - // tagpopulardetailobj! - // .data[index] - // .attachTags[ - // tagIndex].manageTag! - // .name, - // }); - // }, - // child: - // // containertile2( - // // text: (tagpopulardetailobj! - // // .data[index] - // // .tagNames[index]) - // // ) - // 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(tagpopulardetailobj! - // .data[ - // index] - // .attachTags[ - // tagIndex].manageTag! - // .name!)), - // )), - // ), - // ); - // }, - // ), - // ), - SizedBox( - height: 30.h, - width: double.infinity, - child: ListView.builder( - scrollDirection: - Axis.horizontal, - shrinkWrap: true, - // Filter the tags to include only those with a non-null and non-empty name - itemCount: tagpopulardetailobj! - .data[index].attachTags - .where((tag) => - tag.manageTag?.name - ?.isNotEmpty ?? - false) - .length, - itemBuilder: - (context, tagIndex) { - // Filtered list of tags - var filteredTags = - tagpopulardetailobj! - .data[index] - .attachTags - .where((tag) => - tag - .manageTag - ?.name - ?.isNotEmpty ?? - false) - .toList(); - - // Safely get the manageTag object - var manageTag = - filteredTags[tagIndex] - .manageTag; - - // Get the tag name, ensuring it's not null or empty - String tagName = - manageTag?.name ?? ''; - - return Padding( - padding: EdgeInsets.only( - right: 12.w, - left: 12.w), - child: GestureDetector( - onTap: () { - print( - 'anonymous tapped'); - Get.back(); - Get.toNamed( - RouteName - .tagdetailscreen, - arguments: { - 'tagid': tagpopulardetailobj! - .data[index] - .attachTags[ - tagIndex] - .manageTag! - .id, - - // filteredTags[ - // tagIndex] - // .manageTagXid, - 'tagname': - tagName, - 'ispinnedtag': - filteredTags[ - tagIndex] - .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( - '#${tagName}'), - ), - ), - ), - ], - ), - ), - ); - }, - ), - ), - sizedBoxHeight(20.h), - SizedBox( - width: double.infinity, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC( - tagpopulardetailobj! - .data[index] - .caption ?? - ''), - ], - ), - ), - Row(children: [ - InkWell( - onTap: () { - Get.toNamed( - RouteName.reactionview); - }, - child: stackReaction( - number: - tagpopulardetailobj! - .data[index] - .likecount - .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( - tagpopulardetailobj! - .data[index] - .totalComment - .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), - text14w400_FCFCFC( - tagpopulardetailobj! - .data[index].totalSave - .toString()), - ]), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - children: [ - Column( - mainAxisAlignment: - MainAxisAlignment - .center, - children: [ - Column( - children: [ - ReactionButton< - String>( - onReactionChanged: - (reaction) async { - if (selectedReaction != - null && - reaction?.value == - selectedReaction - .id - .toString()) { - // User tapped on the currently selected reaction, so remove it - await _handleReactionChange( - selectedReaction, - tagpopulardetailobj! - .data[ - index] - .id!); - } else { - // User selected a new reaction - var newSelectedReaction = - _reactions - .firstWhere( - (r) => - r.id.toString() == - reaction - ?.value, - orElse: () => - _reactions - .first, // Default reaction if not found - ); - await _handleReactionChange( - newSelectedReaction, - tagpopulardetailobj! - .data[ - index] - .id!); - } - debugPrint( - 'Selected value: ${reaction?.value}'); - }, - reactions: - _reactions - .map((reaction) => - Reaction< - String>( - 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: - selectedReaction != - null - ? Reaction< - String>( - value: selectedReaction - .id - .toString(), - icon: Image - .network( - selectedReaction - .image, - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ) - : Reaction< - String>( - value: - '', - icon: Image - .asset( - 'assets/images/png/uiw_like-o.png', - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ), - boxColor: - Colors.white, - boxElevation: 9, - boxRadius: 30, - itemsSpacing: 8, - itemScale: 0.4, - 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: - selectedReaction != - null - ? Image - .network( - selectedReaction - .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(2.h), - text11w400_FCFCFC( - 'Like'), - ], - ) - ], - ), - 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') - ], - ), - ), - InkWell( - onTap: () {}, - child: Column( - children: [ - GestureDetector( - onTap: () async { - int postid = - tagpopulardetailobj! - .data[index] - .id!; - await saveunsavepost( - postid); - }, - child: tagpopulardetailobj! - .data[ - index] - .isISaved == - true - ? 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, - ), - ), - // 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), - ]), - ), - ], - )), + NormalCardTile( + tags: _sortTags(index), + createAt: timeAgo ?? '1 hour', + commonObj: commonobjmodel!.data[index], + forWhichTab: 'popular', + reactions: _reactions, + selectedReactions: _selectedReactions, + currentIndex: index, + ), sizedBoxHeight(20.h) ], ); - } - }, + }, + ), ), - ), - ], - ); + ], + ) + ]); } return Container(); }); @@ -2238,179 +783,128 @@ class LatestTab extends StatefulWidget { } class _LatestTabState extends State { - FutureGroup futureGroup = FutureGroup(); + late Future latestfuture; + List _reactions = []; + final Map _selectedReactions = {}; + final CountersHelper countersHelper = Get.find(); + int? likeIconIdnew; @override void initState() { - futureGroup.add(Communitygetmethod().getTagsdata(widget.id).then((value) { - _initializeData(); - })); - futureGroup.close(); + // tagdetailobj + latestfuture = Communitygetmethod().getTagsdata(widget.id); + super.initState(); } - List _reactions = []; - Map _selectedReactions = {}; - - Future _initializeData() async { - await _fetchIcons(); - // _initializeSelectedReaction(); - for (var post in tagpopulardetailobj!.data) { - if (post.likeIcon != null) { - likeIconIdnew = post.likeIcon!.likeIconsXid; // This is safe now - print('like selectedid is ${likeIconIdnew.toString()}'); - } else { - likeIconIdnew = 0; // Or handle it as needed - print('like id is ${likeIconIdnew.toString()}'); - } - _initializeSelectedReaction(post.id!); // Pass the post ID - } - } - Future _fetchIcons() async { - var response = await Communityallgetmethod().getLikeicons(); - if (response.status == ResponseStatus.SUCCESS) { - var responseData = response.data as Map; - FetchlikeIconsModel fetchlikeIconsModel = - FetchlikeIconsModel.fromJson(responseData); + _reactions = fetchlikeIconsModel!.data ?? []; + for (var post in commonobjmodel!.data) { + //Check if post as a like icon + if (post.likeIcon?.likeIcon?.id != null) { + likeIconIdnew = post.likeIcon!.likeIconsXid; - setState(() { - _reactions = fetchlikeIconsModel.data - ?.map((data) => ReactionData( - id: data.id!, - image: data.image!, - )) - .toList() ?? - []; - for (var post in tagdetailobj!.data) { - _initializeSelectedReaction(post.id!); - } - }); - } - } + final selectedReaction = _reactions.firstWhere( + (r) => r.id == likeIconIdnew, + orElse: () => _reactions.first, + ); - int? likeIconIdnew; - - void _initializeSelectedReaction(int postId) { - // Check if there's a stored likeIconId for this post - if (likeIconIdnew != null && likeIconIdnew != 0 && _reactions.isNotEmpty) { - final selectedReaction = _reactions.firstWhere( - (r) => r.id == likeIconIdnew, - orElse: () => _reactions.first, - ); - - setState(() { - _selectedReactions[postId] = + _selectedReactions[post.id!] = selectedReaction; // Set selected reaction for this post - print( - 'Selected reaction for post $postId is ${_selectedReactions[postId].toString()}'); - log(_selectedReactions[postId].toString()); - }); - } else { - setState(() { - _selectedReactions[postId] = null; // No reaction selected - print('No reaction selected for post $postId'); - }); - } - } - - Future _handleReactionChange(ReactionData? reaction, int postId) async { - // Check if the postId is valid - if (postId == null) return; - - setState(() { - if (reaction == null) { - _selectedReactions[postId] = - null; // Mark reaction as removed for this post } else { - _selectedReactions[postId] = - reaction; // Set the selected reaction for this post + _selectedReactions[post.id!] = null; // No reaction selected + // print('No reaction selected for post $postId'); } - }); - - try { - await LikeUploaddata( - reaction?.id, - postId, - ); - } catch (error) { - print('Error updating reaction: $error'); - setState(() { - _selectedReactions[postId] = - reaction; // Restore previous reaction if needed - }); } } - LikeUploaddata(int? likeIconId, int? postid) async { - // utils.loader(); - Map updata = { - "manage_posts_xid": postid, - "like_icons_xid": likeIconId ?? '', - }; - final data = await CommunitypostMethod().postLikepost(updata); - if (data.status == ResponseStatus.SUCCESS) { - // Get.back(); - print("like done"); - return utils.showToast(data.message); - } else { - // Get.back(); - print("like not done"); - return utils.showToast(data.message); + bool _isDataInitialized = true; + + Future setValues() async { + if (_isDataInitialized) { + _setModel(); + countersHelper.setListstagtagLatest(); + await _fetchIcons(); + + _isDataInitialized = false; } } - saveunsavepost(int postid) async { - // utils.loader(); - Map updata = { - "manage_posts_xid": postid, - }; - final data = await Communitypostmethod().postUserSave(updata); - if (data.status == ResponseStatus.SUCCESS) { - Communitygetmethod().getTagsdata(widget.id).then((value) { - _initializeData(); - setState(() {}); - }); + _sortTags(index) { + var tags = commonobjmodel!.data[index].attachTags + .where((tag) => tag.manageTag?.name?.isNotEmpty ?? false) + .map((tag) => tag.manageTag!) + .toList(); - return utils.showToast(data.message); - } else { - // Get.back(); - return utils.showToast(data.message); - } + return tags; } - pinunpinUser(int userid) async { - // utils.loader(); - Map updata = { - "pin_iam_principal_xid": userid, - }; - final data = await SidebarTags().postUserpin(updata); - if (data.status == ResponseStatus.SUCCESS) { - // Get.back(); - Communitygetmethod().getTagsdata(widget.id).then((value) { - _initializeData(); - setState(() {}); - }); - return utils.showToast(data.message); - } else { - // Get.back(); - return utils.showToast(data.message); - } + _setModel() { + commonobjmodel = null; + commonobjmodel = CommonDatumObjModel( + status: tagdetailobj!.status, + statusCode: tagdetailobj!.statusCode, + message: tagdetailobj!.message, + data: tagdetailobj!.data + .map((e) => CommonDatumObjModelData( + id: e.id, + likecount: e.likecount, + isISaved: e.isISaved, + tagsXid: e.tagsXid, + isILiked: e.isILiked, + totalComment: e.totalComment, + totalSave: e.totalSave, + iamPrincipalXid: e.iamPrincipalXid, + postIn: e.postIn, + caption: e.caption, + image: e.image, + manageTagsXids: e.manageTagsXids, + postAs: e.postAs, + ctaTitle: e.ctaTitle, + ctaLink: e.ctaLink, + createdAt: e.createdAt, + likeIcon: LikeIcon1( + likeIcon: LikeIconClass1( + id: e.likeIcon?.likeIcon?.id, + image: e.likeIcon?.likeIcon?.image), + likeIconsXid: e.likeIcon?.likeIconsXid, + ), + totalViewCount: e.totalViewCount, + totalReactionCount: e.totalReactionCount, + totalCommentCount: e.totalCommentCount, + totalImpressionCount: e.totalImpressionCount, + totalPopularScore: e.totalPopularScore, + totalHoursAgo: e.totalHoursAgo, + iamPrincipal: IamPrincipal( + id: e.iamPrincipal!.id, + isUserPinned: e.iamPrincipal!.isUserPinned, + principalTypeXid: e.iamPrincipal!.principalTypeXid, + userName: e.iamPrincipal!.userName, + fullName: e.iamPrincipal!.fullName, + profilePhoto: e.iamPrincipal!.profilePhoto), + community: Community( + id: e.community!.id, + communityProfilePhoto: e.community!.communityProfilePhoto, + communityName: e.community!.communityName), + attachTags: e.attachTags + .map((e) => AttachTag1( + managePostXid: e.managePostXid, + manageTagXid: e.manageTagXid, + manageTag: ManageTagPopular( + id: e.manageTag?.id, + isPinned: e.manageTag?.isPinned, + name: e.manageTag?.name))) + .toList())) + .toList()); } @override Widget build(BuildContext context) { return FutureBuilder( - future: futureGroup.future, + future: latestfuture, builder: (ctx, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { - return - // ShimmerCommon(); - const Center( - child: CircularProgressIndicator( - color: Colors.blue, - ), - ); + return const Center(child: ShimmerCommon()); } if (snapshot.hasError) { @@ -2424,1461 +918,66 @@ class _LatestTabState extends State { if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { - print("Data fetched-->"); - return tagdetailobj!.data.isEmpty - ? _buildNoDataBody(context) - : Column( - children: [ - sizedBoxHeight(16.h), - Expanded( - child: ListView.builder( - shrinkWrap: true, - itemCount: tagdetailobj!.data.length, - itemBuilder: (context, index) { - var timeAgo = ConvertServerDateToUserDate() - .convertServerDateToReadableFormate( - tagdetailobj!.data[index].createdAt - .toString()); - var postId = tagdetailobj!.data[index].id; - var selectedReaction = _selectedReactions[postId]; - if (index == 1) { + setValues(); + return Stack(clipBehavior: Clip.none, children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill), + ), + ), + tagdetailobj!.data.isEmpty + ? Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Center( + child: Column( + children: [ + Text( + "No Posts Available", + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.w600), + ) + ], + ), + ), + ]) + : Column( + children: [ + sizedBoxHeight(20.h), + Expanded( + child: ListView.builder( + shrinkWrap: true, + itemCount: commonobjmodel!.data.length, + itemBuilder: (context, index) { + var timeAgo = ConvertServerDateToUserDate() + .convertServerDateToReadableFormate( + tagdetailobj!.data[index].createdAt + .toString()); + return Column( children: [ - commonGlassUIBlue( - width: double.infinity, - height: 780.h, - borderRadius: BorderRadius.circular(1), - customWidget: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - sizedBoxHeight(25.h), - Padding( - padding: - EdgeInsets.only(left: 16.w), - child: text16w700_FCFCFC( - "#Announcement"), - ), - sizedBoxHeight(25.h), - Padding( - padding: EdgeInsets.symmetric( - horizontal: 16.w), - child: Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - CircleAvatar( - foregroundImage: NetworkImage( - tagdetailobj! - .data[index] - .iamPrincipal! - .profilePhoto ?? - ''), - radius: 25.r, - ), - sizedBoxWidth(12.w), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC( - tagdetailobj! - .data[index] - .iamPrincipal! - .fullName ?? - ''), - 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( - tagdetailobj! - .data[index] - .community! - .communityName ?? - '', - ), - sizedBoxWidth(7.w), - Icon( - Icons.circle, - color: const Color( - 0xFFFCFCFC), - size: 4.sp, - ), - sizedBoxWidth(6.w), - text12w400_FCFCFC( - timeAgo), - ], - ) - ], - ), - 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: () async { - // int pinPospostid = - // tagdetailobj! - // .data[index] - // .id!; - // await pinunpinUser( - // pinPospostid); - // }, - // child: Padding( - // padding: EdgeInsets - // .symmetric( - // horizontal: - // 12.w), - // child: Row( - // children: [ - // Text( - // tagdetailobj! - // .data[ - // index] - // .iamPrincipal! - // .isUserPinned == - // true - // ? 'Unpin' - // : '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: Container( - height: 390.h, - decoration: BoxDecoration( - image: DecorationImage( - image: NetworkImage( - tagdetailobj! - .data[index] - .image ?? - ''), - 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: tagdetailobj! - // .data[index].attachTags.length, - // itemBuilder: (context, tagIndex) { - // print( - // 'tags id are ${tagdetailobj!.data[index].attachTags[tagIndex].manageTag!.id}'); - // print( - // 'tags name are ${tagdetailobj!.data[index].attachTags[tagIndex].manageTag!.name}'); - // return Padding( - // padding: EdgeInsets.only( - // right: 12.w), - // child: GestureDetector( - // onTap: () { - // print('anonymous tag tapped'); - // Get.toNamed( - // RouteName.tagdetailscreen, - // arguments: { - // 'tagid': - // tagdetailobj! - // .data[index] - // .attachTags[ - // tagIndex] - // .manageTag!.id, - // 'tagname': - // tagdetailobj! - // .data[index] - // .attachTags[ - // tagIndex] - // .manageTag!.name, - // }); - // }, - // child: - // // containertile2( - // // text: (tagdetailobj! - // // .data[index] - // // .tagNames[index]) - // // ) - // 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(tagdetailobj! - // .data[ - // index] - // .attachTags[ - // tagIndex].manageTag! - // .name!)), - // )), - // ), - // ); - // }, - // ), - // ), - SizedBox( - height: 30.h, - width: double.infinity, - child: ListView.builder( - scrollDirection: - Axis.horizontal, - shrinkWrap: true, - // Filter the tags to include only those with a non-null and non-empty name - itemCount: tagdetailobj! - .data[index].attachTags - .where((tag) => - tag.manageTag?.name - ?.isNotEmpty ?? - false) - .length, - itemBuilder: - (context, tagIndex) { - // Filtered list of tags - var filteredTags = - tagdetailobj! - .data[index] - .attachTags - .where((tag) => - tag - .manageTag - ?.name - ?.isNotEmpty ?? - false) - .toList(); - - // Safely get the manageTag object - var manageTag = - filteredTags[tagIndex] - .manageTag; - - // Get the tag name, ensuring it's not null or empty - String tagName = - manageTag?.name ?? ''; - - return Padding( - padding: EdgeInsets.only( - right: 12.w, - left: 12.w), - child: GestureDetector( - onTap: () { - print( - 'anonymous tapped'); - Get.back(); - Get.toNamed( - RouteName - .tagdetailscreen, - arguments: { - 'tagid': tagdetailobj! - .data[index] - .attachTags[ - tagIndex] - .manageTag! - .id, - // filteredTags[ - // tagIndex] - // .manageTagXid, - 'tagname': - tagName, - }); - }, - 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( - '#${tagName}'), - ), - ), - ), - ], - ), - ), - ); - }, - ), - ), - sizedBoxHeight(20.h), - SizedBox( - width: double.infinity, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC( - tagdetailobj! - .data[index] - .caption ?? - ''), - ], - ), - ), - Row(children: [ - InkWell( - onTap: () {}, - child: stackReaction( - number: tagdetailobj! - .data[index].likecount - .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(tagdetailobj! - .data[index].totalComment - .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), - text14w400_FCFCFC(tagdetailobj! - .data[index].totalSave - .toString()), - ]), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - children: [ - Column( - mainAxisAlignment: - MainAxisAlignment - .center, - children: [ - Column( - children: [ - ReactionButton< - String>( - onReactionChanged: - (reaction) async { - if (selectedReaction != - null && - reaction?.value == - selectedReaction - .id - .toString()) { - // User tapped on the currently selected reaction, so remove it - await _handleReactionChange( - selectedReaction, - tagdetailobj! - .data[ - index] - .id!); - } else { - // User selected a new reaction - var newSelectedReaction = - _reactions - .firstWhere( - (r) => - r.id.toString() == - reaction - ?.value, - orElse: () => - _reactions - .first, // Default reaction if not found - ); - await _handleReactionChange( - newSelectedReaction, - tagdetailobj! - .data[ - index] - .id!); - } - debugPrint( - 'Selected value: ${reaction?.value}'); - }, - reactions: - _reactions - .map((reaction) => - Reaction< - String>( - 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: - selectedReaction != - null - ? Reaction< - String>( - value: selectedReaction - .id - .toString(), - icon: Image - .network( - selectedReaction - .image, - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ) - : Reaction< - String>( - value: - '', - icon: Image - .asset( - 'assets/images/png/uiw_like-o.png', - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ), - boxColor: - Colors.white, - boxElevation: 9, - boxRadius: 30, - itemsSpacing: 8, - itemScale: 0.4, - 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: - selectedReaction != - null - ? Image - .network( - selectedReaction - .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(2.h), - text11w400_FCFCFC( - 'Like'), - ], - ) - ], - ), - GestureDetector( - onTap: () {}, - 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: [ - GestureDetector( - onTap: () async { - int postid = - tagdetailobj! - .data[index] - .id!; - await saveunsavepost( - postid); - }, - child: tagdetailobj! - .data[index] - .isISaved == - true - ? 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, - ), - ), - // 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), - ]), - ), - ], - )), - sizedBoxHeight(20.h), - ], - ); - } else { - return Column( - children: [ - commonGlassUI( - width: double.infinity, - height: 760.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( - foregroundImage: NetworkImage( - tagdetailobj! - .data[index] - .iamPrincipal! - .profilePhoto ?? - ''), - radius: 25.r, - ), - sizedBoxWidth(12.w), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC( - tagdetailobj! - .data[index] - .iamPrincipal! - .fullName ?? - ''), - 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( - tagdetailobj! - .data[index] - .community! - .communityName - .toString()), - sizedBoxWidth(7.w), - Icon( - Icons.circle, - color: const Color( - 0xFFFCFCFC), - size: 4.sp, - ), - sizedBoxWidth(6.w), - text12w400_FCFCFC( - timeAgo!), - ], - ) - ], - ), - 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: () async { - int pinPospostid = - tagdetailobj! - .data[index] - .iamPrincipal! - .id!; - await pinunpinUser( - pinPospostid); - }, - child: Padding( - padding: EdgeInsets - .symmetric( - horizontal: - 12.w), - child: Row( - children: [ - Text( - tagdetailobj! - .data[ - index] - .iamPrincipal! - .isUserPinned == - true - ? 'Unpin' - : '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: Container( - height: 360, - width: double.infinity, - decoration: BoxDecoration( - image: DecorationImage( - fit: BoxFit.cover, - image: NetworkImage( - tagdetailobj!.data[index] - .image ?? - '', - ), - ), - ), - ), - ), - 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: tagdetailobj! - // .data[index].attachTags.length, - // itemBuilder: (context, tagIndex) { - // print( - // 'tags id are ${tagdetailobj!.data[index].attachTags[tagIndex].manageTag!.id}'); - // print( - // 'tags name are ${tagdetailobj!.data[index].attachTags[tagIndex].manageTag!.name}'); - // return Padding( - // padding: EdgeInsets.only( - // right: 12.w), - // child: GestureDetector( - // onTap: () { - // print('tag tapped'); - // Get.toNamed( - // RouteName.tagdetailscreen, - // arguments: { - // 'tagid': - // tagdetailobj! - // .data[index] - // .attachTags[ - // tagIndex].manageTag! - // .id, - // 'tagname': - // tagdetailobj! - // .data[index] - // .attachTags[ - // tagIndex].manageTag! - // .name, - // }); - // }, - // child: - // // containertile2( - // // text: (tagdetailobj! - // // .data[index] - // // .tagNames[index]) - // // ) - // 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(tagdetailobj! - // .data[ - // index] - // .attachTags[ - // tagIndex].manageTag! - // .name!)), - // )), - // ), - // ); - // }, - // ), - // ), - SizedBox( - height: 30.h, - width: double.infinity, - child: ListView.builder( - scrollDirection: - Axis.horizontal, - shrinkWrap: true, - // Filter the tags to include only those with a non-null and non-empty name - itemCount: tagdetailobj! - .data[index].attachTags - .where((tag) => - tag.manageTag?.name - ?.isNotEmpty ?? - false) - .length, - itemBuilder: - (context, tagIndex) { - // Filtered list of tags - var filteredTags = - tagdetailobj! - .data[index] - .attachTags - .where((tag) => - tag - .manageTag - ?.name - ?.isNotEmpty ?? - false) - .toList(); - - // Safely get the manageTag object - var manageTag = - filteredTags[tagIndex] - .manageTag; - - // Get the tag name, ensuring it's not null or empty - String tagName = - manageTag?.name ?? ''; - - return Padding( - padding: EdgeInsets.only( - right: 12.w, - left: 12.w), - child: GestureDetector( - onTap: () { - print( - 'anonymous tapped'); - Get.back(); - Get.toNamed( - RouteName - .tagdetailscreen, - arguments: { - 'tagid': tagdetailobj! - .data[index] - .attachTags[ - tagIndex] - .manageTag! - .id, - - // filteredTags[ - // tagIndex] - // .manageTagXid, - 'tagname': - tagName, - 'ispinnedtag': - filteredTags[ - tagIndex] - .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( - '#${tagName}'), - ), - ), - ), - ], - ), - ), - ); - }, - ), - ), - sizedBoxHeight(20.h), - SizedBox( - width: double.infinity, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC( - tagdetailobj! - .data[index] - .caption ?? - ''), - ], - ), - ), - Row(children: [ - InkWell( - onTap: () { - Get.toNamed( - RouteName.reactionview); - }, - child: stackReaction( - number: tagdetailobj! - .data[index].likecount - .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(tagdetailobj! - .data[index].totalComment - .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), - text14w400_FCFCFC(tagdetailobj! - .data[index].totalSave - .toString()), - ]), - sizedBoxHeight(12.h), - commonDivider(), - sizedBoxHeight(12.h), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - children: [ - Column( - mainAxisAlignment: - MainAxisAlignment - .center, - children: [ - Column( - children: [ - ReactionButton< - String>( - onReactionChanged: - (reaction) async { - if (selectedReaction != - null && - reaction?.value == - selectedReaction - .id - .toString()) { - // User tapped on the currently selected reaction, so remove it - await _handleReactionChange( - selectedReaction, - tagdetailobj! - .data[ - index] - .id!); - } else { - // User selected a new reaction - var newSelectedReaction = - _reactions - .firstWhere( - (r) => - r.id.toString() == - reaction - ?.value, - orElse: () => - _reactions - .first, // Default reaction if not found - ); - await _handleReactionChange( - newSelectedReaction, - tagdetailobj! - .data[ - index] - .id!); - } - debugPrint( - 'Selected value: ${reaction?.value}'); - }, - reactions: - _reactions - .map((reaction) => - Reaction< - String>( - 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: - selectedReaction != - null - ? Reaction< - String>( - value: selectedReaction - .id - .toString(), - icon: Image - .network( - selectedReaction - .image, - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ) - : Reaction< - String>( - value: - '', - icon: Image - .asset( - 'assets/images/png/uiw_like-o.png', - width: - 24, - height: - 24, - fit: BoxFit - .cover, - ), - ), - boxColor: - Colors.white, - boxElevation: 9, - boxRadius: 30, - itemsSpacing: 8, - itemScale: 0.4, - 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: - selectedReaction != - null - ? Image - .network( - selectedReaction - .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(2.h), - text11w400_FCFCFC( - 'Like'), - ], - ) - ], - ), - 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') - ], - ), - ), - InkWell( - onTap: () {}, - child: Column( - children: [ - GestureDetector( - onTap: () async { - int postid = - tagdetailobj! - .data[index] - .id!; - await saveunsavepost( - postid); - }, - child: tagdetailobj! - .data[ - index] - .isISaved == - true - ? 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, - ), - ), - // 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), - ]), - ), - ], - )), + NormalCardTile( + tags: _sortTags(index), + createAt: timeAgo ?? '1 hour', + commonObj: commonobjmodel!.data[index], + forWhichTab: 'popular', + reactions: _reactions, + selectedReactions: _selectedReactions, + currentIndex: index, + ), sizedBoxHeight(20.h) ], ); - } - }, + }, + ), ), - ), - ], - ); + ], + ) + ]); } return Container(); }); diff --git a/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart b/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart index 2acca0a..0a82861 100644 --- a/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart +++ b/lib/Main_Screens/Community_HomePage/view_model/CountersHelper.dart @@ -59,7 +59,7 @@ List pinButtonPopular = []; RxList commentsCounterComPosts = [].obs; RxList savePostCounterComPosts = [].obs; RxList saveButtonComPosts = [].obs; - RxList pinButtonComPosts = [].obs; + // RxList pinButtonComPosts = [].obs; setListsComPosts() { likesCounterComPosts.clear(); @@ -73,9 +73,35 @@ List pinButtonPopular = []; .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); + // 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/Main_Screens/ProfileTab/Certificate/AddCertificate.dart b/lib/Main_Screens/ProfileTab/Certificate/AddCertificate.dart index 970e945..b6d10fb 100644 --- a/lib/Main_Screens/ProfileTab/Certificate/AddCertificate.dart +++ b/lib/Main_Screens/ProfileTab/Certificate/AddCertificate.dart @@ -3,7 +3,6 @@ import 'dart:io'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart' hide MultipartFile, FormData; import 'package:regroup/Common/base_manager.dart'; @@ -155,7 +154,7 @@ class _AddCertificateState extends State { text16400white("Certification name"), sizedBoxHeight(16.h), CustomTextFormField( - leadingIcon: Container( + leadingIcon: SizedBox( height: 17.h, width: 18.w, child: Center( @@ -186,7 +185,7 @@ class _AddCertificateState extends State { text16400white("Certification reason"), sizedBoxHeight(16.h), CustomTextFormField( - leadingIcon: Container( + leadingIcon: SizedBox( height: 17.h, width: 18.w, child: Center( diff --git a/lib/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart b/lib/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart index 6e497cf..3e19f97 100644 --- a/lib/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart +++ b/lib/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart @@ -17,7 +17,7 @@ class EditProfileApi { EditProfileApi(); Future> postEditProfileIndividual(var data) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); + // SharedPreferences prefs = await SharedPreferences.getInstance(); final response = await NetworkApiServices().postApi(data, ApiUrls.posteditprofile); @@ -62,7 +62,7 @@ class EditProfileApi { } Future> postEditProfileBusiness(var data) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); + // SharedPreferences prefs = await SharedPreferences.getInstance(); final response = await NetworkApiServices() .postApi(data, ApiUrls.posteditprofilebusiness); diff --git a/lib/Main_Screens/ProfileTab/Followers/Followers.dart b/lib/Main_Screens/ProfileTab/Followers/Followers.dart index 69136b0..adc2d9b 100644 --- a/lib/Main_Screens/ProfileTab/Followers/Followers.dart +++ b/lib/Main_Screens/ProfileTab/Followers/Followers.dart @@ -68,7 +68,7 @@ class _FollowersState extends State { int? blockid; int? removeid; - RemoveUploadata() async { + removeUploadata() async { utils.loader(); Map updata = { "iam_principal_xid": removeid, @@ -85,7 +85,7 @@ class _FollowersState extends State { } } - BlockUploadata() async { + blockUploadata() async { utils.loader(); Map updata = { "blocked_iam_principal_xid": blockid, @@ -334,7 +334,7 @@ class _FollowersState extends State { followersobj!.data!.removeWhere((item) => item.follower!.id == removeid); - RemoveUploadata(); + removeUploadata(); }); }, child: @@ -399,7 +399,7 @@ class _FollowersState extends State { followersobj!.data!.removeWhere((item) => item.follower!.id == blockid); - BlockUploadata(); + blockUploadata(); }); }, child: diff --git a/lib/Utils/Helper.dart b/lib/Utils/Helper.dart index 6e5f658..78c737c 100644 --- a/lib/Utils/Helper.dart +++ b/lib/Utils/Helper.dart @@ -7,6 +7,7 @@ import 'package:flutter/services.dart'; import 'package:image_gallery_saver/image_gallery_saver.dart'; import 'package:path_provider/path_provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:path/path.dart' as path; class Helper { static Future networkImageToMultipartFile( @@ -16,14 +17,24 @@ class Helper { Response response = await dio.get(imageUrl, options: Options(responseType: ResponseType.bytes)); + final cleanedFileName = _cleanFileName(imageUrl); + MultipartFile multipartFile = MultipartFile.fromBytes( response.data!, - filename: imageUrl.substring(imageUrl.lastIndexOf("/") + 1), + filename: cleanedFileName, + // imageUrl.substring(imageUrl.lastIndexOf("/") + 1), ); return multipartFile; } +static String _cleanFileName(String url) { + // Parse the URL and extract the path + final uri = Uri.parse(url); + // Extract the base name from the path, removing any query parameters + return path.basename(uri.path); +} + static Future assetImageToMultipartFile( String assetImagePath, String fileName) async { ByteData assetByteData = await rootBundle.load(assetImagePath); diff --git a/lib/Utils/texts.dart b/lib/Utils/texts.dart index de9d751..6836195 100644 --- a/lib/Utils/texts.dart +++ b/lib/Utils/texts.dart @@ -346,6 +346,9 @@ Widget text18w400white(String text, {TextAlign? textAlign}) { ); } + + + Widget text14w400white(String text, {TextAlign? textAlign}) { return Text( text, diff --git a/lib/onboarding/Signup/View/Individual/step2Selectactivity.dart b/lib/onboarding/Signup/View/Individual/step2Selectactivity.dart index 2d54159..70701e3 100644 --- a/lib/onboarding/Signup/View/Individual/step2Selectactivity.dart +++ b/lib/onboarding/Signup/View/Individual/step2Selectactivity.dart @@ -14,8 +14,42 @@ import 'package:regroup/onboarding/Signup/view_model/postmethod.dart'; import 'package:regroup/resources/routes/route_name.dart'; import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart'; -int? _firstSelectedIndex; -bool _isFirstSelectionActive = false; +class ActivityController extends GetxController { + var selectedIndices = [].obs; + var firstSelectedIndex = Rxn(); + var isFirstSelectionActive = false.obs; + + void onContainerTap(int index) { + if (selectedIndices.contains(index)) { + selectedIndices.remove(index); + if (firstSelectedIndex.value == index) { + // If the first selected container is unselected, reset the active state + firstSelectedIndex.value = null; + isFirstSelectionActive.value = false; + selectedIndices.clear(); + } + } else { + if (firstSelectedIndex.value == null) { + // The first item is being selected + firstSelectedIndex.value = index; + isFirstSelectionActive.value = true; + } + selectedIndices.add(index); + } + } + + Color getGradientColor(int index) { + if (selectedIndices.isEmpty) { + return Colors.transparent; + } else if (firstSelectedIndex.value == index && + isFirstSelectionActive.value) { + return Color(0XFFD90B2E); + } else if (selectedIndices.contains(index)) { + return Color(0xFF009DAB); + } + return Colors.transparent; + } +} class SelectIndividualActivity extends StatefulWidget { const SelectIndividualActivity({super.key}); @@ -26,8 +60,8 @@ class SelectIndividualActivity extends StatefulWidget { } class _SelectIndividualActivityState extends State { - final List _selectedIndices = []; TextEditingController otheractivitycontroller = TextEditingController(); + final ActivityController controller = Get.put(ActivityController()); // to select only two containers // void _onContainerTap(int index) { @@ -44,40 +78,6 @@ class _SelectIndividualActivityState extends State { // }); // } - void _onContainerTap(int index) { - setState(() { - if (_selectedIndices.contains(index)) { - _selectedIndices.remove(index); - if (_firstSelectedIndex == index) { - // If the first selected container is unselected, reset the active state - _firstSelectedIndex = null; - _isFirstSelectionActive = false; - _selectedIndices.clear(); - } - } else { - if (_firstSelectedIndex == null) { - // The first item is being selected - _firstSelectedIndex = index; - _isFirstSelectionActive = true; - } - _selectedIndices.add(index); - } - }); - } - - Color _getGradientColor(int index) { - if (_selectedIndices.isEmpty) { - return Colors.transparent; - } else if (_firstSelectedIndex == index && _isFirstSelectionActive) { - // Apply Color(0XFFD90B2E) to the first selected item - return Color(0XFFD90B2E); - } else if (_selectedIndices.contains(index)) { - // Apply Color(0xFF009DAB) to all other selected items - return Color(0xFF009DAB); - } - return Colors.transparent; - } - // void _onContainerTap(int id) { // setState(() { // if (_selectedIndices.contains(id)) { @@ -114,7 +114,7 @@ class _SelectIndividualActivityState extends State { Uploadata() async { utils.loader(); - String selectedIndicesString = '[${_selectedIndices.join(',')}]'; + String selectedIndicesString = '[${controller.selectedIndices.join(',')}]'; Map updata = { "manage_interest_xid": selectedIndicesString, "other_interest": otheractivitycontroller.text, @@ -145,11 +145,11 @@ class _SelectIndividualActivityState extends State { child: CustomButton( text: "Continue", onPressed: () { - if (_selectedIndices.isEmpty && + if (controller.selectedIndices.isEmpty && otheractivitycontroller.text.isEmpty) { utils.showToast('Please select activity'); } else { - print(_selectedIndices.toString()); + print(controller.selectedIndices.toString()); // String selectedIndicesString = // _selectedIndices.join(','); // print( @@ -292,8 +292,7 @@ class _SelectIndividualActivityState extends State { text20400white( 'What are your interests?'), // sizedBoxHeight(5.w), - - _isFirstSelectionActive + controller.isFirstSelectionActive.value ? text13400A7A7A7( 'Select your secondary interests') : text13400A7A7A7( @@ -336,13 +335,7 @@ class _SelectIndividualActivityState extends State { image: indiactivityobj! .data![index].image, // 'assets/images/svg/individualact7.svg', - isSelected: _selectedIndices - .contains(indiactivityobj! - .data![index].id!), - gradientColor: _getGradientColor( - indiactivityobj! - .data![index].id!), - onTap: _onContainerTap, + controller: controller, ); }, ), @@ -556,103 +549,92 @@ class ActivityContainer extends StatelessWidget { final int index; final String titleString; final String? image; - final bool isSelected; - final Color gradientColor; - final Function(int) onTap; + final ActivityController controller; ActivityContainer({ required this.index, required this.titleString, required this.image, - required this.isSelected, - required this.gradientColor, - required this.onTap, + required this.controller, }); @override Widget build(BuildContext context) { - return GestureDetector( - onTap: () => onTap(index), - child: Container( - // width: 110.w, - // height: 120.h, - decoration: ShapeDecoration( - gradient: LinearGradient( - begin: const Alignment(0.98, 0.10), - end: const Alignment(-0.40, -0.70), - colors: isSelected - ? _firstSelectedIndex == index && - _isFirstSelectionActive == true - ? [ - Color(0xFF009DAB).withOpacity(0.80), - Color(0xFF009DAB).withOpacity(0.77), - gradientColor.withOpacity(0.70), - gradientColor.withOpacity(0.50), - ] + return Obx( + () { + bool isSelected = controller.selectedIndices.contains(index); + Color gradientColor = controller.getGradientColor(index); + + return GestureDetector( + onTap: () => controller.onContainerTap(index), + child: Container( + decoration: ShapeDecoration( + gradient: LinearGradient( + begin: const Alignment(0.98, 0.10), + end: const Alignment(-0.40, -0.70), + colors: isSelected + ? controller.firstSelectedIndex.value == index && + controller.isFirstSelectionActive.value + ? [ + Color(0xFF009DAB).withOpacity(0.80), + Color(0xFF009DAB).withOpacity(0.77), + gradientColor.withOpacity(0.70), + gradientColor.withOpacity(0.50), + ] + : [ + Colors.white.withOpacity(0.06), + Colors.white.withOpacity(0.08), + ] : [ Colors.white.withOpacity(0.06), Colors.white.withOpacity(0.08), - ] - : [ - Colors.white.withOpacity(0.06), - Colors.white.withOpacity(0.08), - ], - ), - shape: RoundedRectangleBorder( - side: isSelected - ? _firstSelectedIndex == index && - _isFirstSelectionActive == true - ? BorderSide(width: 0.4.w, color: Colors.transparent) - : BorderSide(width: 3.w, color: gradientColor) - : BorderSide(width: 2.w, color: Color(0xFF434A53)), - borderRadius: BorderRadius.circular(10), - ), - ), - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 0.w, vertical: 10.h), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - // image.isEmpty - // ? SvgPicture.asset( - // "assets/images/svg/individualact7.svg", - // width: 50.w, - // height: 50.h, - // ) - // : Image.network(image), - image == null || image!.isEmpty - ? Image.asset( - 'assets/images/png/redregroup.png', - color: Colors.white, - width: 50.w, - height: 50.h, - ) - // SvgPicture.asset( - // "assets/images/svg/individualact7.svg", - // width: 50.w, - // height: 50.h, - // ) - : Image.network( - image!, - width: 50.w, - height: 50.h, - ), - const Spacer(flex: 3), - SizedBox( - child: Text( - titleString, - style: TextStyle( - fontSize: 14.sp, - color: Colors.white, - fontWeight: FontWeight.w400, - ), - textAlign: TextAlign.center, - ), + ], ), - ], + shape: RoundedRectangleBorder( + side: isSelected + ? controller.firstSelectedIndex.value == index && + controller.isFirstSelectionActive.value + ? BorderSide(width: 0.4.w, color: Colors.transparent) + : BorderSide(width: 3.w, color: gradientColor) + : BorderSide(width: 2.w, color: Color(0xFF434A53)), + borderRadius: BorderRadius.circular(10), + ), + ), + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 0.w, vertical: 10.h), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + image == null || image!.isEmpty + ? Image.asset( + 'assets/images/png/redregroup.png', + color: Colors.white, + width: 50.w, + height: 50.h, + ) + : Image.network( + image!, + width: 50.w, + height: 50.h, + ), + const Spacer(flex: 3), + SizedBox( + child: Text( + titleString, + style: TextStyle( + fontSize: 14.sp, + color: Colors.white, + fontWeight: FontWeight.w400, + ), + textAlign: TextAlign.center, + ), + ), + ], + ), + ), ), - ), - ), + ); + }, ); } } diff --git a/lib/resources/routes/routes.dart b/lib/resources/routes/routes.dart index 9246e61..e8be143 100644 --- a/lib/resources/routes/routes.dart +++ b/lib/resources/routes/routes.dart @@ -68,8 +68,8 @@ import 'package:regroup/onboarding/Signup/View/Business/View/busSignupScreen.dar import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/CommunitySetting.dart'; import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/EditCommunity/EditCommunity.dart'; import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageGroup.dart'; -import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageTags.dart/ManageTags.dart'; -import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageTags.dart/NewTag/NewTag.dart'; +import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageTags.dart/ManageInterest.dart'; +import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageTags.dart/View/NewTag/NewTag.dart'; import 'package:regroup/sidemenu/Community/Announcements/AnnouncementRequest.dart'; import 'package:regroup/sidemenu/Community/Announcements/ManageMembers.dart'; import 'package:regroup/sidemenu/Community/Announcements/NewAnnouncement/NewAnnounceent.dart'; diff --git a/lib/sidemenu/Community/Admin/PopupItem/Community settings/CommunitySetting.dart b/lib/sidemenu/Community/Admin/PopupItem/Community settings/CommunitySetting.dart index 0f0e2a2..6684d16 100644 --- a/lib/sidemenu/Community/Admin/PopupItem/Community settings/CommunitySetting.dart +++ b/lib/sidemenu/Community/Admin/PopupItem/Community settings/CommunitySetting.dart @@ -16,8 +16,7 @@ class CommunitySetting extends StatefulWidget { } class _CommunitySettingState extends State { - - int communityid = Get.arguments['communityid']; + int communityid = Get.arguments['communityid']; @override Widget build(BuildContext context) { return Scaffold( @@ -39,11 +38,9 @@ class _CommunitySettingState extends State { sizedBoxHeight(30.h), GestureDetector( onTap: () { - Get.toNamed(RouteName.editcommunity, - arguments: { - 'communityid' : communityid, - } - ); + Get.toNamed(RouteName.editcommunity, arguments: { + 'communityid': communityid, + }); }, child: rowTile(text: 'Edit community info')), commonDivider(), @@ -55,15 +52,21 @@ class _CommunitySettingState extends State { commonDivider(), GestureDetector( onTap: () { - Get.toNamed(RouteName.managegroups); + Get.toNamed(RouteName.managegroups, + arguments: { + 'communityid' : communityid, + } + ); }, child: rowTile(text: 'Manage groups')), commonDivider(), GestureDetector( onTap: () { - Get.toNamed(RouteName.managetags); + Get.toNamed(RouteName.managetags, arguments: { + 'communityid': communityid, + }); }, - child: rowTile(text: 'Manage tags')), + child: rowTile(text: 'Manage interest')), sizedBoxHeight(20.h), ]) ])); diff --git a/lib/sidemenu/Community/Admin/PopupItem/Community settings/EditCommunity/EditCommunity.dart b/lib/sidemenu/Community/Admin/PopupItem/Community settings/EditCommunity/EditCommunity.dart index 4e23501..ff27986 100644 --- a/lib/sidemenu/Community/Admin/PopupItem/Community settings/EditCommunity/EditCommunity.dart +++ b/lib/sidemenu/Community/Admin/PopupItem/Community settings/EditCommunity/EditCommunity.dart @@ -1,14 +1,13 @@ import 'dart:developer'; import 'dart:io'; +import 'package:dio/dio.dart'; import 'package:dotted_border/dotted_border.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; +import 'package:get/get.dart' hide MultipartFile, FormData; import 'package:regroup/Common/CommonGlassmorphism.dart'; import 'package:regroup/Common/base_manager.dart'; -import 'package:regroup/Main_Screens/ProfileTab/EditProfile/Model/InterestModel.dart' - as primaryactlist; import 'package:regroup/Utils/Common/CommonAppbar.dart'; import 'package:regroup/Utils/Common/CommonDropdown.dart'; import 'package:regroup/Utils/Common/CustomNextButton.dart'; @@ -19,9 +18,13 @@ import 'package:regroup/Utils/Helper.dart'; import 'package:regroup/Utils/dialogs.dart'; import 'package:regroup/Utils/texts.dart'; import 'package:regroup/Utils/Common/CustomTextformfield.dart'; +import 'package:regroup/sidemenu/Community/MyCommunity/Model/activitiesListModel.dart' + as primaryactlist; import 'package:regroup/sidemenu/Community/MyCommunity/view_model/getmethod.dart'; +import 'package:regroup/sidemenu/Community/MyCommunity/view_model/postmethod.dart'; import 'package:regroup/sidemenu/Community/MyCommunity/view_model/primaryactivity.dart'; import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart'; +import 'package:path/path.dart' as path; class EditCommunity extends StatefulWidget { const EditCommunity({super.key}); @@ -42,9 +45,6 @@ class _EditCommunityState extends State { @override void initState() { myfuture = Getcommunity().getCommunityeditpage(communityid); - // communitynameController.text = 'Active alliance network'; - // descriptionController.text = - // "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer ."; super.initState(); } @@ -94,497 +94,631 @@ class _EditCommunityState extends State { }); } - primaryactlist.InterestModel? abilityModel; - List activity = []; + primaryactlist.ActivitiesListsModel? abilityModel; + List activity = []; List _activitydrop = []; - String? selectedActivityName; + String? selectedActivityName = ''; + + bool isDataLoaded = false; + + List> _abilityMap = []; Future fetchActivitylist() async { PrimaryActivityListApi abilityListAPI = PrimaryActivityListApi(); ResponseData response = await abilityListAPI.getActivitylistApi(); if (response.status == ResponseStatus.SUCCESS) { - abilityModel = primaryactlist.InterestModel.fromJson(response.data!); + abilityModel = + primaryactlist.ActivitiesListsModel.fromJson(response.data!); setState(() { activity = abilityModel!.data ?? []; _activitydrop = - activity.map((platform) => platform.name.toString()).toList(); + activity.map((platform) => platform.title.toString()).toList(); + _abilityMap = activity.map((platform) { + return { + "id": platform.id, + "name": platform.title.toString(), + }; + }).toList(); }); - // Ensure dropdown list updates after setting the initial value - setState(() { - // Set the initial selected activity if data is available - int activitiesXids = - communityeditobj!.data!.communityData!.activityData!.id!; - selectedactivityid = activitiesXids; - selectedActivityName = activity - .firstWhere((item) => item.id == activitiesXids, - orElse: () => activity.first) - .name; - isactivityLoaded = true; - }); - log(activity.toString()); + // Debugging log for _abilityMap + print('Ability Map: $_abilityMap'); + + if (communityeditobj != null && communityeditobj!.data != null) { + int abilitiesXids = communityeditobj!.data!.communityData!.activityXid!; + selectedactivityid = abilitiesXids; + + String? name = await getSelectedName(selectedactivityid!); + setState(() { + selectedActivityName = name ?? ''; + isactivityLoaded = true; + isDataLoaded = true; // Mark data as loaded + }); + + // Debugging log for selectedActivityName + print('Selected activity ID is $selectedactivityid'); + print('Selected activity name is $selectedActivityName'); + } } else { - print('Failed to fetch abilities'); + print('Failed to fetch activities'); + setState(() { + isDataLoaded = false; // Ensure loader is not hidden in case of error + }); } } + Future getSelectedName(int selectedId) async { + print('Searching for ID: $selectedId in _abilityMap'); + + for (Map ability in _abilityMap) { + if (ability["id"] == selectedId) { + print('Found ability: ${ability["name"]}'); + return ability["name"] as String; + } + } + return null; + } + int? selectedactivityid; void getCatIdFromName(String selectedAbility) { selectedactivityid = activity - .firstWhere((item) => item.name == selectedAbility, + .firstWhere((item) => item.title == selectedAbility, orElse: () => activity.first) .id; print('Selected activity ID is $selectedactivityid'); } + String _cleanFileName(String filePath) { + return path + .basename(filePath) + .split('?') + .first; + } + + Uploadata() async { + utils.loader(); + List bannermedialist = []; + List profielpicturelist = []; + MultipartFile? imageFile; + + // for (var file in bannerPath.where((file) => file != null)) { + // bannermedialist.add( + // await MultipartFile.fromFile( + // file!.path, + // filename: path.basename(file.path), + // ), + // ); + // } + + for (var file in bannerPath.where((file) => file != null)) { + final filePath = file!.path; + final cleanedFileName = _cleanFileName(filePath); + + print('Original File Path: $filePath'); + print('Cleaned File Name: $cleanedFileName'); + + bannermedialist.add( + await MultipartFile.fromFile( + filePath, + filename: cleanedFileName, + ), + ); + } + + if (filePath.isNotEmpty && filePath[0] != null) { + var profileFile = filePath[0]; + if (profileFile!.path.isNotEmpty) { + // Convert local file to MultipartFile + imageFile = await MultipartFile.fromFile( + profileFile.path, + filename: path.basename(profileFile.path), + ); + } else { + // Handle case where file path is empty + imageFile = await Helper.networkImageToMultipartFile( + communityeditobj!.data!.communityData!.communityProfilePhoto!, + ); + } + } else if (communityeditobj!.data!.communityData!.communityProfilePhoto != + null) { + // Handle case where no file is provided, fallback to network image + imageFile = await Helper.networkImageToMultipartFile( + communityeditobj!.data!.communityData!.communityProfilePhoto!, + ); + } else { + // Handle case where no profile picture is provided + print('No profile picture provided.'); + return; + } + + int communityTypeValue = _typeCommunityMap[_selectedtypecommunity] ?? 0; + print('Image File: ${imageFile.filename}'); + print( + 'Banner Media List: ${bannermedialist.map((file) => file.filename).toList()}'); + + FormData formdata = FormData.fromMap({ + "community_profile_photo": imageFile, + "community_banner_image": bannermedialist[0], + "community_name": communitynameController.text, + "community_location": locationcontroller.text, + "community_description": descriptionController.text, + 'community_type_xid': communityTypeValue, + 'activity_xid': selectedactivityid, + 'community_id': communityid, + }); + print('updata is ${formdata.toString()}'); + log('log is ${formdata.toString()}'); + final data = await PostMethodCommunity().postEditcommunity(formdata); + if (data.status == ResponseStatus.SUCCESS) { + Get.back(); + print("community updated"); + // Get.toNamed(RouteName.mycommunity); + Get.back(); + return utils.showToast(data.message); + } else { + Get.back(); + print("community not updated"); + return utils.showToast(data.message); + } + } + @override Widget build(BuildContext context) { - return Scaffold( - // key: _scaffoldKey1, - backgroundColor: Color(0xFF222935), - extendBody: true, - appBar: CommonAppbar( - titleTxt: "Edit community info", - ), - resizeToAvoidBottomInset: false, - body: FutureBuilder( - future: myfuture, - builder: (ctx, snapshot) { - if (snapshot.data == null) { - return const Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Center( - child: CircularProgressIndicator( - color: Color(0xFFC18948), + return GestureDetector( + onTap: () => FocusManager.instance.primaryFocus?.unfocus(), + child: Scaffold( + // key: _scaffoldKey1, + backgroundColor: Color(0xFF222935), + extendBody: true, + appBar: CommonAppbar( + titleTxt: "Edit community info", + ), + resizeToAvoidBottomInset: true, + body: FutureBuilder( + future: myfuture, + builder: (ctx, snapshot) { + if (snapshot.data == null) { + return const Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Center( + child: CircularProgressIndicator( + color: Color(0xFFC18948), + ), + ) + ], + ); + } + if (snapshot.connectionState == ConnectionState.done) { + if (snapshot.hasError) { + return Center( + child: Text( + '${snapshot.error} occured', + style: TextStyle(fontSize: 18.spMin), ), - ) - ], - ); - } - if (snapshot.connectionState == ConnectionState.done) { - if (snapshot.hasError) { - return Center( - child: Text( - '${snapshot.error} occured', - style: TextStyle(fontSize: 18.spMin), + ); + } + } + if (!isBannerLoaded) { + bannerimage = communityeditobj! + .data!.communityData!.communityBannerImage!; + _loadBannerImage(); // Call only if not already loaded + } + communitynameController.text = + communityeditobj!.data!.communityData!.communityName!; + descriptionController.text = + communityeditobj!.data!.communityData!.communityDescription!; + locationcontroller.text = + communityeditobj!.data!.communityData!.communityLocation!; + websitelinkcontroller.text = + communityeditobj!.data!.communityData!.communityDescription!; + var communityType = communityeditobj! + .data!.communityData!.communityTypeData!.name; + if (_selectedtypecommunity.isEmpty) { + _selectedtypecommunity = communityType ?? 'Public'; + } + if (!isactivityLoaded) { + fetchActivitylist(); + } + if (!isDataLoaded) { + // Show a loader or a placeholder until data is fully loaded + return const Center( + child: CircularProgressIndicator( + color: Color(0xFFC18948), ), ); } - } - if (!isBannerLoaded) { - bannerimage = - communityeditobj!.data!.communityData!.communityBannerImage!; - _loadBannerImage(); // Call only if not already loaded - } - communitynameController.text = - communityeditobj!.data!.communityData!.communityName!; - descriptionController.text = - communityeditobj!.data!.communityData!.communityDescription!; - locationcontroller.text = - communityeditobj!.data!.communityData!.communityLocation!; - websitelinkcontroller.text = - communityeditobj!.data!.communityData!.communityDescription!; - var communityType = - communityeditobj!.data!.communityData!.communityTypeData!.name; - if (_selectedtypecommunity.isEmpty) { - _selectedtypecommunity = communityType ?? 'Public'; - } - if (!isactivityLoaded) { - fetchActivitylist(); - } - return Stack(children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/png/Ellipse 1496.png"), - fit: BoxFit.fill)), - ), - SingleChildScrollView( - child: Column(children: [ - // sizedBoxHeight(30.h), - Stack( - clipBehavior: Clip.none, - children: [ - Container( - height: 100.h, - width: 100.w, - decoration: BoxDecoration( - shape: BoxShape.circle, - border: Border.all( - color: Color(0xFF434A53), width: 0.5.w), + return Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: + AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), + ), + SingleChildScrollView( + child: Column(children: [ + // sizedBoxHeight(30.h), + Stack( + clipBehavior: Clip.none, + children: [ + Container( + height: 100.h, + width: 100.w, + decoration: BoxDecoration( + shape: BoxShape.circle, + border: Border.all( + color: Color(0xFF434A53), width: 0.5.w), + ), + child: Center( + child: filePath.isNotEmpty + ? ClipOval( + child: SizedBox.fromSize( + size: Size.fromRadius(50.r), + child: filePath.isNotEmpty + ? Image.file( + filePath[0]!, + fit: BoxFit.cover, + width: double.infinity, + ) + : Image.asset( + 'assets/images/png/Ellipse 37.png', + fit: BoxFit.cover), + ), + ) + : ClipOval( + child: SizedBox.fromSize( + size: Size.fromRadius(50.r), + child: communityeditobj! + .data! + .communityData! + .communityProfilePhoto! + .isNotEmpty + ? Image.network( + communityeditobj! + .data! + .communityData! + .communityProfilePhoto!, + fit: BoxFit.cover, + errorBuilder: (context, error, + stackTrace) { + // Error handling when image fails to load + return Image.asset( + "assets/images/png/Ellipse 37.png", + fit: BoxFit.cover, + ); + }, + ) + : Image.asset( + 'assets/images/png/Ellipse 37.png', + fit: BoxFit.cover), + ), + )), ), - child: Center( - child: filePath.isNotEmpty - ? ClipOval( - child: SizedBox.fromSize( - size: Size.fromRadius(50.r), - child: filePath.isNotEmpty - ? Image.file( - filePath[0]!, - fit: BoxFit.cover, - width: double.infinity, - ) - : Image.asset( - 'assets/images/png/Ellipse 37.png', - fit: BoxFit.cover), - ), - ) - : ClipOval( - child: SizedBox.fromSize( - size: Size.fromRadius(50.r), - child: communityeditobj! - .data! - .communityData! - .communityProfilePhoto! - .isNotEmpty - ? Image.network( - communityeditobj! - .data! - .communityData! - .communityProfilePhoto!, - fit: BoxFit.cover, - errorBuilder: - (context, error, stackTrace) { - // Error handling when image fails to load - return Image.asset( - "assets/images/png/Ellipse 37.png", - fit: BoxFit.cover, - ); - }, - ) - : Image.asset( - 'assets/images/png/Ellipse 37.png', - fit: BoxFit.cover), - ), - )), - ), - Positioned( - right: -10, - bottom: 0, - child: InkWell( - onTap: () { - ImageUploadBottomSheet().showModal( - context, - false, - (result) { - if (result != null && result.isNotEmpty) { - var file = File(result); - filePath.cast(); - filePath.add(file); - isImageAdded = true; - setState(() {}); - if (Platform.isAndroid) { - Get.back(); + Positioned( + right: -10, + bottom: 0, + child: InkWell( + onTap: () { + ImageUploadBottomSheet().showModal( + context, + false, + (result) { + if (result != null && result.isNotEmpty) { + var file = File(result); + filePath.cast(); + filePath.add(file); + isImageAdded = true; + setState(() {}); + if (Platform.isAndroid) { + Get.back(); + } + } else { + filePath.clear(); + isImageAdded = false; + setState(() {}); } - } else { - filePath.clear(); - isImageAdded = false; - setState(() {}); - } - }, - ); - }, - child: Container( - height: 35.h, - width: 35.w, - decoration: BoxDecoration( - color: Color(0xFFD90B2E), - shape: BoxShape.circle, - border: Border.all( - color: Color(0xFFD90B2E), width: 0.5.w)), - child: Center( - child: Image.asset( - 'assets/images/png/cameraicon.png', - height: 14.h, - width: 15.w, + }, + ); + }, + child: Container( + height: 35.h, + width: 35.w, + decoration: BoxDecoration( + color: Color(0xFFD90B2E), + shape: BoxShape.circle, + border: Border.all( + color: Color(0xFFD90B2E), + width: 0.5.w)), + child: Center( + child: Image.asset( + 'assets/images/png/cameraicon.png', + height: 14.h, + width: 15.w, + ), ), ), - ), - )) - ], - ), - sizedBoxHeight(25.h), - text16w400_white("Edit community profile picture"), - sizedBoxHeight(30.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC("Community banner image"), - sizedBoxHeight(16.h), - DottedBorder( - strokeWidth: 1, - dashPattern: [7, 4], - borderType: BorderType.RRect, - radius: Radius.circular(14.r), - color: Color(0xFF434A53), - child: commonGlassUI( - borderwidth: 0, - width: double.infinity, - height: 150.h, - borderRadius: BorderRadius.circular(10.r), - customWidget: bannerPath.isNotEmpty && isbannerAdded - ? Stack( - children: [ - Image.file( - bannerPath[0]!, - fit: BoxFit.cover, - width: double.infinity, - ), - // Positioned( - // right: 5, - // bottom: 5, - // child: InkWell( - // onTap: () { - // setState(() { - // bannerPath.clear(); - // isbannerAdded = false; - // }); - // }, - // child: Container( - // width: 27, - // height: 27, - // decoration: ShapeDecoration( - // color: Color(0xFF7E7E7E), - // shape: RoundedRectangleBorder( - // borderRadius: - // BorderRadius.circular(5), - // ), - // ), - // child: Icon( - // Icons.delete_outline_outlined, - // color: Colors.white, - // ), - // ), - // ), - // ), - ], - ) - : GestureDetector( - onTap: () { - ImageUploadBottomSheet().showModal( - context, - false, - (result) { - if (result != null && - result.isNotEmpty) { - var file = File(result); + )) + ], + ), + sizedBoxHeight(25.h), + text16w400_white("Edit community profile picture"), + sizedBoxHeight(30.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + text16w400_FCFCFC("Community banner image"), + sizedBoxHeight(16.h), + DottedBorder( + strokeWidth: 1, + dashPattern: [7, 4], + borderType: BorderType.RRect, + radius: Radius.circular(14.r), + color: Color(0xFF434A53), + child: commonGlassUI( + borderwidth: 0, + width: double.infinity, + height: 150.h, + borderRadius: BorderRadius.circular(10.r), + customWidget: + bannerPath.isNotEmpty && isbannerAdded + ? Stack( + children: [ + Image.file( + bannerPath[0]!, + fit: BoxFit.cover, + width: double.infinity, + ), + ], + ) + : 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 - utils.showToast( - "The selected file is too large. Max file size is 10 MB."); - } else { - // Clear the existing image and add the new one - bannerPath.clear(); - bannerPath.add(file); - isbannerAdded = true; - setState(() {}); - } - } else { - // Handle case where no image is selected - bannerPath.clear(); - isbannerAdded = false; - setState(() {}); - } - if (Platform.isAndroid) { - Get.back(); - } - }, - ); - }, - child: Padding( - padding: - EdgeInsets.symmetric(vertical: 16.h), - child: Column( - children: [ - Image.asset( - "assets/images/png/cameraicon2.png", - height: 36.h, - width: 36.w, + if (fileSizeInMB > 10) { + // Show toast message if the file size exceeds 10 MB + utils.showToast( + "The selected file is too large. Max file size is 10 MB."); + } else { + // Clear the existing image and add the new one + bannerPath.clear(); + bannerPath.add(file); + isbannerAdded = true; + setState(() {}); + } + } else { + // Handle case where no image is selected + bannerPath.clear(); + isbannerAdded = false; + setState(() {}); + } + if (Platform.isAndroid) { + Get.back(); + } + }, + ); + }, + child: Padding( + padding: EdgeInsets.symmetric( + vertical: 16.h), + child: Column( + children: [ + Image.asset( + "assets/images/png/cameraicon2.png", + height: 36.h, + width: 36.w, + ), + SizedBox(height: 10.h), + text14w400white( + 'Upload banner image'), + SizedBox(height: 8.h), + SizedBox( + width: 270.w, + child: Center( + child: text8w400_8A8A8A( + "Allowed file extensions: jpg, png, gif Max file size: 10 MB"), + ), + ), + ], + ), ), - SizedBox(height: 10.h), - text14w400white( - 'Upload banner image'), - SizedBox(height: 8.h), - SizedBox( - width: 270.w, - child: text8w400_8A8A8A( - "Allowed file extensions: jpg, png, gif Max file size: 10 MB"), + ), + ), + ), + sizedBoxHeight(16.w), + bannerPath.isNotEmpty && isbannerAdded + ? commonGlassUI( + width: double.infinity, + height: 60.h, + borderRadius: BorderRadius.circular(10.r), + customWidget: Center( + child: Padding( + padding: EdgeInsets.symmetric( + horizontal: 12.w), + child: Row( + children: [ + // Conditionally render image or placeholder + if (bannerPath.isNotEmpty && + isbannerAdded) + Container( + height: 40.h, + width: 40.w, + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(5.r), + ), + child: Image.file( + bannerPath[0]!, + fit: BoxFit.cover, + width: double.infinity, + ), + ) + else + Container( + height: 40.h, + width: 40.w, + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(5.r), + ), + child: Image.asset( + 'assets/images/png/img2.png', + fit: BoxFit.cover, + width: double.infinity, + ), + ), + SizedBox(width: 8.w), + Spacer(), + InkWell( + onTap: () { + setState(() { + // Clear the image and update the state + bannerPath.clear(); + isbannerAdded = false; + }); + // Optionally debug state values + print("bannerPath: $bannerPath"); + print( + "isbannerAdded: $isbannerAdded"); + }, + child: Image.asset( + 'assets/images/png/cancelicon.png', + height: 20.h, + width: 20.w, + ), ), ], ), ), ), + borderwidth: 1, + ) + : SizedBox(), + sizedBoxHeight(25.h), + text16w400_FCFCFC("Community name*"), + sizedBoxHeight(14.h), + CustomTextFormField( + textEditingController: communitynameController, + validator: (val) { + if (val == null || val.isEmpty) { + return 'Enter Community name'; + } + return null; + }, + hintText: 'Enter type of community', ), - ), - sizedBoxHeight(16.w), - bannerPath.isNotEmpty && isbannerAdded - ? commonGlassUI( - width: double.infinity, - height: 60.h, - borderRadius: BorderRadius.circular(10.r), - customWidget: Center( - child: Padding( - padding: - EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - // Conditionally render image or placeholder - if (bannerPath.isNotEmpty && - isbannerAdded) - Container( - height: 40.h, - width: 40.w, - decoration: BoxDecoration( - borderRadius: - BorderRadius.circular(5.r), - ), - child: Image.file( - bannerPath[0]!, - fit: BoxFit.cover, - width: double.infinity, - ), - ) - else - Container( - height: 40.h, - width: 40.w, - decoration: BoxDecoration( - borderRadius: - BorderRadius.circular(5.r), - ), - child: Image.asset( - 'assets/images/png/img2.png', - fit: BoxFit.cover, - width: double.infinity, - ), - ), - SizedBox(width: 8.w), - Spacer(), - InkWell( - onTap: () { - setState(() { - // Clear the image and update the state - bannerPath.clear(); - isbannerAdded = false; - }); - // Optionally debug state values - print("bannerPath: $bannerPath"); - print( - "isbannerAdded: $isbannerAdded"); - }, - child: Image.asset( - 'assets/images/png/cancelicon.png', - height: 20.h, - width: 20.w, - ), - ), - ], - ), - ), - ), - borderwidth: 1, - ) - : SizedBox(), - sizedBoxHeight(25.h), - text16w400_FCFCFC("Community name*"), - sizedBoxHeight(14.h), - CustomTextFormField( - textEditingController: communitynameController, - validator: (val) { - if (val == null || val.isEmpty) { - return 'Enter Community name'; - } - return null; - }, - hintText: 'Enter type of community', - ), - sizedBoxHeight(25.h), - text16w400_FCFCFC("Group description"), - sizedBoxHeight(14.h), - CustomTextFormField( - // maxlines: 3, - hintText: 'Enter description', - textEditingController: descriptionController, - ), - sizedBoxHeight(25.h), - text16w400_FCFCFC("Type of community*"), - sizedBoxHeight(14.h), - CustomDropDownRadio( - header: "", - title: "", - listData: _typeCommunityMap.keys.toList(), - onItemSelected: _onItemSelected, - leadingImage: SizedBox(), - initialSelectedValue: _selectedtypecommunity, - ), - sizedBoxHeight(25.h), - text16w400_FCFCFC("Location*"), - sizedBoxHeight(14.h), - CustomTextFormField( - textEditingController: locationcontroller, - inputFormatters: [ - RemoveEmojiInputFormatter(), - // FilteringTextInputFormatter.allow(RegExp('[a-zA-Z ]')) - ], - hintText: 'Enter location', - validator: (val) { - if (val == null || val.isEmpty) { - return 'Enter location'; - } - return null; - }, - ), - sizedBoxHeight(25.h), - text16w400_FCFCFC("Primary activity*"), - sizedBoxHeight(14.h), - CustomDropDownRadio( - showOtherOption: true, - header: "", - title: "", - listData: _activitydrop, - onItemSelected: getCatIdFromName, - leadingImage: SizedBox(), - initialSelectedValue: selectedActivityName.toString(), - ), - sizedBoxHeight(25.h), - text16w400_FCFCFC("Website link"), - sizedBoxHeight(14.h), - CustomTextFormField( - textEditingController: websitelinkcontroller, - validator: (val) { - if (!isValidWebBannerLink(val)) { - return 'Please enter a valid web banner link.'; - } - return null; - }, - hintText: 'Enter website link', - ), - sizedBoxHeight(25.h), - sizedBoxHeight(50.h), - CustomButton(text: 'Save changes', onPressed: () {}), - sizedBoxHeight(50.h), - ], - ), - ) - ]), - ) - ]); - }, - )); + sizedBoxHeight(25.h), + text16w400_FCFCFC("Group description"), + sizedBoxHeight(14.h), + CustomTextFormField( + // maxlines: 3, + hintText: 'Enter description', + textEditingController: descriptionController, + ), + sizedBoxHeight(25.h), + text16w400_FCFCFC("Type of community*"), + sizedBoxHeight(14.h), + CustomDropDownRadio( + header: "", + title: "", + listData: _typeCommunityMap.keys.toList(), + onItemSelected: _onItemSelected, + leadingImage: SizedBox(), + initialSelectedValue: _selectedtypecommunity, + ), + sizedBoxHeight(25.h), + text16w400_FCFCFC("Location*"), + sizedBoxHeight(14.h), + CustomTextFormField( + textEditingController: locationcontroller, + inputFormatters: [ + RemoveEmojiInputFormatter(), + // FilteringTextInputFormatter.allow(RegExp('[a-zA-Z ]')) + ], + hintText: 'Enter location', + validator: (val) { + if (val == null || val.isEmpty) { + return 'Enter location'; + } + return null; + }, + ), + sizedBoxHeight(25.h), + text16w400_FCFCFC("Primary activity*"), + sizedBoxHeight(14.h), + CustomDropDownRadio( + showOtherOption: false, + header: "", + title: "", + listData: _activitydrop, + onItemSelected: getCatIdFromName, + leadingImage: SizedBox(), + initialSelectedValue: selectedActivityName ?? '', + ), + sizedBoxHeight(25.h), + // text16w400_FCFCFC("Website link"), + // sizedBoxHeight(14.h), + // CustomTextFormField( + // textEditingController: websitelinkcontroller, + // validator: (val) { + // if (!isValidWebBannerLink(val)) { + // return 'Please enter a valid web banner link.'; + // } + // return null; + // }, + // hintText: 'Enter website link', + // ), + // sizedBoxHeight(25.h), + sizedBoxHeight(50.h), + CustomButton( + text: 'Save changes', + onPressed: () { + if (bannerPath.isEmpty || + communitynameController.text.isEmpty || + _selectedtypecommunity.isEmpty || + locationcontroller.text.isEmpty || + selectedactivityid.isBlank!) { + utils.showToast('Please fill all fields'); + } + // else if (filePath.isEmpty) { + // utils.showToast( + // 'Please add community profile picture'); + // } + else { + print('done'); + + Uploadata(); + } + }), + sizedBoxHeight(50.h), + ], + ), + ) + ]), + ) + ]); + }, + )), + ); } } diff --git a/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageGroup.dart b/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageGroup.dart index 30c24e8..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), + 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), + // ), + // ), + ), + body: Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), ), - ), - ), - 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(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( @@ -111,7 +147,7 @@ class _ManageGroupsState extends State { opacity2: 0.24, width: 50.w, height: 50.h, - borderRadius: BorderRadius.circular( 100), + borderRadius: BorderRadius.circular(100), customWidget: Center( child: Image.asset( "assets/images/png/Black.png", @@ -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, @@ -178,11 +449,14 @@ Widget groupWidget({ ], ), Spacer(), - Icon( - Icons.clear, - color: Color(0xFFFFFFFF), - weight: 1.88, + Image.asset( + 'assets/images/png/Group 1000004149.png', ) + // Icon( + // Icons.clear, + // color: Color(0xFFFFFFFF), + // weight: 1.88, + // ) ], ), ); diff --git a/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ManageTags.dart b/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ManageInterest.dart similarity index 93% rename from lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ManageTags.dart rename to lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ManageInterest.dart index 2125226..2a23ba5 100644 --- a/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ManageTags.dart +++ b/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ManageInterest.dart @@ -19,6 +19,8 @@ class ManageTags extends StatefulWidget { } class _ManageTagsState extends State { + int communityid = Get.arguments['communityid']; + @override Widget build(BuildContext context) { return Scaffold( @@ -26,7 +28,7 @@ class _ManageTagsState extends State { backgroundColor: Color(0xFF222935), extendBody: true, appBar: CommonAppbar( - titleTxt: "Manage tags", + titleTxt: "Manage interest", ), resizeToAvoidBottomInset: false, body: Stack(children: [ @@ -45,7 +47,7 @@ class _ManageTagsState extends State { child: Column(children: [ CommonTabBar(tabs: const [ Tab( - text: 'Tags', + text: 'Interest', ), Tab( text: 'Tag requests', @@ -79,7 +81,9 @@ class _ManageTagsState extends State { ), child: FloatingActionButton( onPressed: () { - Get.toNamed(RouteName.newtag); + Get.toNamed(RouteName.newtag, arguments: { + 'communityid': communityid, + }); }, backgroundColor: Color(0xFFD90B2E), autofocus: true, @@ -102,7 +106,7 @@ Widget tagsTab() { sizedBoxHeight(25.h), Padding( padding: EdgeInsets.symmetric(horizontal: 16.w), - child: text16400white("Special Announcement Tags"), + child: text16400white("Special Announcement Interest"), ), sizedBoxHeight(15.h), ListView.builder( @@ -171,7 +175,7 @@ Widget rowTagRequestTile({ child: commonGlassUI( width: double.infinity, height: 60.h, - borderRadius: BorderRadius.circular( 10.r), + borderRadius: BorderRadius.circular(10.r), customWidget: Center( child: Padding( padding: EdgeInsets.symmetric(horizontal: 16.w), @@ -183,7 +187,7 @@ Widget rowTagRequestTile({ height: 35.h, opacity1: 0.24, opacity2: 0.24, - borderRadius: BorderRadius.circular( 100), + borderRadius: BorderRadius.circular(100), customWidget: Center( child: Icon( Icons.clear, diff --git a/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/NewTag/NewTag.dart b/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/NewTag/NewTag.dart deleted file mode 100644 index 32a983b..0000000 --- a/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/NewTag/NewTag.dart +++ /dev/null @@ -1,60 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:regroup/Utils/Common/CommonAppbar.dart'; -import 'package:regroup/Utils/Common/CustomNextButton.dart'; -import 'package:regroup/Utils/Common/CustomTextformfield.dart'; - -import 'package:regroup/Utils/Common/sized_box.dart'; -import 'package:regroup/Utils/texts.dart'; - -class NewTag extends StatefulWidget { - const NewTag({super.key}); - - @override - State createState() => _NewTagState(); -} - -class _NewTagState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - // key: _scaffoldKey1, - backgroundColor: Color(0xFF222935), - extendBody: true, - appBar: CommonAppbar( - titleTxt: "New tag", - ), - resizeToAvoidBottomInset: false, - body: Stack(children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/png/Ellipse 1496.png"), - fit: BoxFit.fill)), - ), - SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.end, - children: [ - sizedBoxHeight(30.h), - text16w400_FCFCFC("Tag name"), - sizedBoxHeight(16.h), - CustomTextFormField( - hintText: "", - validator: (val) { - if (val == null || val.isEmpty) { - return 'Enter a tag name'; - } - return null; - }, - ), - sizedBoxHeight(80.h), - CustomButton(text: "Add", onPressed: () {}) - ]), - )) - ])); - } -} diff --git a/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/View/NewTag/NewTag.dart b/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/View/NewTag/NewTag.dart new file mode 100644 index 0000000..697c3f0 --- /dev/null +++ b/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/View/NewTag/NewTag.dart @@ -0,0 +1,143 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Utils/Common/CommonAppbar.dart'; +import 'package:regroup/Utils/Common/CustomNextButton.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/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageTags.dart/ViewModel/maanageInterestApi.dart'; + +enum Interests { tag1, tag2 } + +class NewTag extends StatefulWidget { + const NewTag({super.key}); + + @override + State createState() => _NewTagState(); +} + +class _NewTagState extends State { + int communityid = Get.arguments['communityid']; + Interests? _tags = Interests.tag1; + final interestController = TextEditingController(); + + addSuccess() async { + String isSpecialValue = _tags == Interests.tag1 ? "0" : "1"; + Map updata = { + "manage_community_xid": communityid.toString(), + "name": interestController.text, + "is_special": isSpecialValue, + }; + final data = await ManageInterestApi().postNewInterest(updata); + if (data.status == ResponseStatus.SUCCESS) { + print("success"); + Get.back(); + + return utils.showToast(data.message); + } else { + // Get.back(); + print("Failed"); + return utils.showToast(data.message); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + // key: _scaffoldKey1, + backgroundColor: const Color(0xFF222935), + extendBody: true, + appBar: const CommonAppbar( + titleTxt: "New interest", + ), + resizeToAvoidBottomInset: false, + body: Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), + ), + SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + sizedBoxHeight(30.h), + text16w400_FCFCFC("Interest name"), + sizedBoxHeight(16.h), + CustomTextFormField( + textEditingController: interestController, + hintText: "", + validator: (val) { + if (val == null || val.isEmpty) { + return 'Enter a interest name'; + } + return null; + }, + ), + sizedBoxHeight(40.h), + text16w400_FCFCFC("Nature of interest"), + sizedBoxHeight(40.h), + Row( + children: [ + Transform.scale( + scale: 1.2, + child: Radio( + fillColor: + const MaterialStatePropertyAll(Color(0xFFD90B2E)), + activeColor: const Color(0xFFD90B2E), + value: Interests.tag1, + groupValue: _tags, + onChanged: (Interests? val) { + setState(() { + _tags = val; + }); + }, + ), + ), + text18w400white("Special Announcement Tag") + ], + ), + sizedBoxHeight(10.h), + Row( + children: [ + Transform.scale( + scale: 1.2, + child: Radio( + fillColor: + const MaterialStatePropertyAll(Color(0xFFD90B2E)), + activeColor: const Color(0xFFD90B2E), + value: Interests.tag2, + groupValue: _tags, + onChanged: (Interests? val) { + setState(() { + _tags = val; + }); + }, + ), + ), + text18w400white("Standard Tag") + ], + ), + sizedBoxHeight(80.h), + CustomButton( + text: "Add", + onPressed: () { + if (interestController.text.isBlank!) { + utils.showToast("Enter your interest"); + } else { + addSuccess(); + } + }) + ]), + )) + ])); + } +} diff --git a/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ViewModel/maanageInterestApi.dart b/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ViewModel/maanageInterestApi.dart new file mode 100644 index 0000000..54ac6d2 --- /dev/null +++ b/lib/sidemenu/Community/Admin/PopupItem/Community settings/ManageTags.dart/ViewModel/maanageInterestApi.dart @@ -0,0 +1,36 @@ +// InviteComModel ? inviteComobj; + +import 'package:regroup/Common/api_urls.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Common/controller/data/network/network_api.dart'; +import 'package:regroup/Utils/dialogs.dart'; + +class ManageInterestApi { + Future> postNewInterest(updata) async { + print("updata is $updata"); + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.postnewinterest, + ); + if (response.status == ResponseStatus.SUCCESS) { + if (response.data["status"] == "success") { + // likepostobj = LikepostModel.fromJson(response.data); + } + + return ResponseData( + response.data['message'], ResponseStatus.SUCCESS, + data: response.data); + } else if (response.status == ResponseStatus.FAILED) { + if (response.data["status"] == "error") { + utils.showToast(response.message); + } + + return ResponseData( + response.data['message'], ResponseStatus.FAILED, + data: response.data); + } else { + return ResponseData( + response.data['message'], ResponseStatus.FAILED); + } + } +} 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 babe215..4d018d0 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(); } @@ -150,153 +152,189 @@ 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 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(); - }, - ), - ), - 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", + 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", + ), + 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(); + }, + ), + ), + 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(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(50.h), + ]), + ) + ])), + ), + ); } Widget _buildNoDataBody(context) { diff --git a/lib/sidemenu/Community/MyCommunity/Model/ComPostModel.dart b/lib/sidemenu/Community/MyCommunity/Model/ComPostModel.dart index 0a1fbe1..4b348b7 100644 --- a/lib/sidemenu/Community/MyCommunity/Model/ComPostModel.dart +++ b/lib/sidemenu/Community/MyCommunity/Model/ComPostModel.dart @@ -80,7 +80,7 @@ class Datum { final bool? isILiked; final bool? isIFollow; final bool? isISaved; - final dynamic likeIcon; + final LikeIcon? likeIcon; final int? totalComment; final int? totalSave; final List tagsXid; @@ -116,7 +116,8 @@ class Datum { isILiked: json["is_i_liked"], isIFollow: json["is_i_follow"], isISaved: json["is_i_saved"], - likeIcon: json["likeIcon"], + // likeIcon: json["likeIcon"], + likeIcon: json["likeIcon"] == null ? null : LikeIcon.fromJson(json["likeIcon"]), totalComment: json["total_comment"], totalSave: json["total_save"], tagsXid: json["tags_xid"] == null @@ -164,6 +165,42 @@ class AttachTag { } } +class LikeIcon { + LikeIcon({ + required this.likeIconsXid, + required this.likeIcon, + }); + + final int? likeIconsXid; + final LikeIconClass? likeIcon; + + factory LikeIcon.fromJson(Map json){ + return LikeIcon( + likeIconsXid: json["like_icons_xid"], + likeIcon: json["like_icon"] == null ? null : LikeIconClass.fromJson(json["like_icon"]), + ); + } + +} + +class LikeIconClass { + LikeIconClass({ + required this.id, + required this.image, + }); + + final int? id; + final String? image; + + factory LikeIconClass.fromJson(Map json){ + return LikeIconClass( + id: json["id"], + image: json["image"], + ); + } + +} + class ManageTag { ManageTag({ required this.id, diff --git a/lib/sidemenu/Community/MyCommunity/Model/activitiesListModel.dart b/lib/sidemenu/Community/MyCommunity/Model/activitiesListModel.dart new file mode 100644 index 0000000..5824135 --- /dev/null +++ b/lib/sidemenu/Community/MyCommunity/Model/activitiesListModel.dart @@ -0,0 +1,44 @@ +class ActivitiesListsModel { + ActivitiesListsModel({ + 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 ActivitiesListsModel.fromJson(Map json){ + return ActivitiesListsModel( + 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.title, + required this.image, + }); + + final int? id; + final String? title; + final String? image; + + factory Datum.fromJson(Map json){ + return Datum( + id: json["id"], + title: json["title"], + image: json["image"], + ); + } + +} 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 7c39a31..80aa8e6 100644 --- a/lib/sidemenu/Community/MyCommunity/NewCommunity.dart +++ b/lib/sidemenu/Community/MyCommunity/NewCommunity.dart @@ -2,17 +2,12 @@ import 'dart:developer'; import 'dart:io'; import 'dart:async'; -import 'package:dio/dio.dart'; import 'package:dotted_border/dotted_border.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart' hide MultipartFile, FormData; -import 'package:get/get_connect/http/src/utils/utils.dart'; -import 'package:regroup/Common/CommonButton.dart'; import 'package:regroup/Common/CommonGlassmorphism.dart'; import 'package:regroup/Common/base_manager.dart'; -import 'package:regroup/Main_Screens/ProfileTab/EditProfile/Model/InterestModel.dart' - as primaryactlist; import 'package:regroup/Utils/Common/CommonAppbar.dart'; import 'package:regroup/Utils/Common/CommonDropdown.dart'; import 'package:regroup/Utils/Common/CustomNextButton.dart'; @@ -23,7 +18,8 @@ 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/view_model/postmethod.dart'; +import 'package:regroup/sidemenu/Community/MyCommunity/Model/activitiesListModel.dart' + as primaryactlist; import 'package:regroup/sidemenu/Community/MyCommunity/view_model/primaryactivity.dart'; import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart'; import 'package:path/path.dart' as path; @@ -60,8 +56,8 @@ class _NewCommunityState extends State { }); } - primaryactlist.InterestModel? abilityModel; - List activity = []; + primaryactlist.ActivitiesListsModel? abilityModel; + List activity = []; List _activitydrop = []; Future fetchActivitylist() async { @@ -69,11 +65,12 @@ class _NewCommunityState extends State { ResponseData response = await abilityLsitAPI.getActivitylistApi(); if (response.status == ResponseStatus.SUCCESS) { - abilityModel = primaryactlist.InterestModel.fromJson(response.data!); + abilityModel = + primaryactlist.ActivitiesListsModel.fromJson(response.data!); setState(() { - activity = abilityModel!.data ?? []; // Store the fetched cities + activity = abilityModel?.data ?? []; // Store the fetched cities _activitydrop = - activity.map((platform) => platform.name.toString()).toList(); + activity.map((platform) => platform.title.toString()).toList(); }); log(activity.toString()); } else { @@ -89,7 +86,7 @@ class _NewCommunityState extends State { // Find and add the ID of the selected ability for (var activityItem in activity) { - if (selectedAbility == activityItem.name) { + if (selectedAbility == activityItem.title) { selectedactivityid = activityItem.id!; break; // Stop once the matching item is found } @@ -160,7 +157,7 @@ class _NewCommunityState extends State { // key: _scaffoldKey1, backgroundColor: Color(0xFF222935), extendBody: true, - resizeToAvoidBottomInset: false, + resizeToAvoidBottomInset: true, appBar: CommonAppbar( titleTxt: "New community", ), @@ -444,18 +441,21 @@ class _NewCommunityState extends State { print('done'); // indiUploadata(); // Uploadata(); - int communityTypeValue = _TypecommunityMap[_selectedtypecommunity] ?? 0; - - Get.toNamed(RouteName.addgroup,arguments: { - 'communityname' : communitycontroller.text, - 'communitylocation' : locationcontroller.text, - 'communitydescription' : communitydescrcontroller.text, - 'communitytype' : communityTypeValue, - 'activityid' : selectedactivityid, - 'communityprofilephoto' : filePath, - 'communitybannerimage' : bannerPath, - }); + int communityTypeValue = + _TypecommunityMap[_selectedtypecommunity] ?? 0; + Get.toNamed(RouteName.addgroup, arguments: { + 'communityname': communitycontroller.text, + 'communitylocation': locationcontroller.text, + 'communitydescription': + communitydescrcontroller.text, + 'communitytype': communityTypeValue, + 'activityid': selectedactivityid, + 'communityprofilephoto': filePath, + 'communitybannerimage': bannerPath, + 'isedited' : false, + 'communityid' : "", + }); } }, ), diff --git a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart index a9013f6..8d2e06c 100644 --- a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart +++ b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart @@ -7,6 +7,9 @@ import 'package:regroup/Common/CommonTabBar.dart'; import 'package:regroup/Common/CommonWidget.dart'; import 'package:regroup/Common/ConvertServerDateToUserDate.dart'; import 'package:regroup/Common/base_manager.dart'; + +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'; @@ -91,7 +94,7 @@ class _CommunityDetailsState extends State { titleTxt: "", customActionWidget: PopupMenuButton( surfaceTintColor: const Color(0xFF222935), - constraints: BoxConstraints.tightFor(width: 180.w), + constraints: BoxConstraints.tightFor(width: 190.w), offset: const Offset(0, 40), color: const Color(0xFF222935), tooltip: "", @@ -601,15 +604,15 @@ class _CommunityDetailsState extends State { borderwidth: 1), ), sizedBoxHeight(40.h), - Container( - height: 40.h, - width: 200.w, - decoration: BoxDecoration( - color: const Color(0xFFD90B2E), - borderRadius: BorderRadius.circular(30.r)), - child: Center( - child: text14w400white("Leave the community")), - ), + // Container( + // height: 40.h, + // width: 200.w, + // decoration: BoxDecoration( + // color: const Color(0xFFD90B2E), + // borderRadius: BorderRadius.circular(30.r)), + // child: Center( + // child: text14w400white("Leave the community")), + // ), sizedBoxHeight(50.h), ])), DefaultTabController( @@ -733,6 +736,7 @@ class _PostsTabState extends State { likeIcon: LikeIcon1( likeIcon: LikeIconClass1( id: e.likeIcon?.likeIcon?.id, + // likeIcon?.id, image: e.likeIcon?.likeIcon?.image), likeIconsXid: e.likeIcon?.likeIconsXid, ), @@ -833,12 +837,13 @@ class _PostsTabState extends State { children: [ NormalCardTile( tags: _sortTags(index), - create_at: timeAgo ?? '1 hour', + createAt: timeAgo ?? '1 hour', commonObj: commonobjmodel!.data[index], forWhichTab: 'popular', reactions: _reactions, selectedReactions: _selectedReactions, currentIndex: index, + coachbool: true, ), sizedBoxHeight(20.h) ], diff --git a/lib/sidemenu/Community/MyCommunity/View/MyCommunity.dart b/lib/sidemenu/Community/MyCommunity/View/MyCommunity.dart index 7cc1514..a83cec3 100644 --- a/lib/sidemenu/Community/MyCommunity/View/MyCommunity.dart +++ b/lib/sidemenu/Community/MyCommunity/View/MyCommunity.dart @@ -186,7 +186,8 @@ class _MyCommunityState extends State { } } - return myCommunityobj!.data.isEmpty + return myCommunityobj!.data!.isEmpty + ? _buildNoDataBody(context) : _buildBody(context); }, diff --git a/lib/sidemenu/Community/MyCommunity/view_model/ComDetails.dart b/lib/sidemenu/Community/MyCommunity/view_model/ComDetails.dart index 03ea356..4c7a265 100644 --- a/lib/sidemenu/Community/MyCommunity/view_model/ComDetails.dart +++ b/lib/sidemenu/Community/MyCommunity/view_model/ComDetails.dart @@ -41,4 +41,15 @@ class CommunityDetail { response.data['message'], ResponseStatus.FAILED); } } + + Future> postLeaveCommunity(updata, comId) async { + final response = await NetworkApiServices().postApi( + updata, + "${ApiUrls.postleavecommunity}?manage_community_xid=$comId", + ); + if (response.status == ResponseStatus.SUCCESS) { + + } + return response; + } } \ No newline at end of file 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 6e43862..ba90f84 100644 --- a/lib/sidemenu/Community/MyCommunity/view_model/postmethod.dart +++ b/lib/sidemenu/Community/MyCommunity/view_model/postmethod.dart @@ -15,4 +15,34 @@ class PostMethodCommunity { print("response message is ${response.message}"); return response; } + + Future> postEditcommunity(updata) async { + print("updata is $updata"); + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.posteditcommunity, + ); + print("response is ${response.data}"); + 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 diff --git a/lib/sidemenu/Community/MyCommunity/view_model/primaryactivity.dart b/lib/sidemenu/Community/MyCommunity/view_model/primaryactivity.dart index 818fd9c..045a1b3 100644 --- a/lib/sidemenu/Community/MyCommunity/view_model/primaryactivity.dart +++ b/lib/sidemenu/Community/MyCommunity/view_model/primaryactivity.dart @@ -1,9 +1,9 @@ import 'package:regroup/Common/api_urls.dart'; import 'package:regroup/Common/base_manager.dart'; import 'package:regroup/Common/controller/data/network/network_api.dart'; -import 'package:regroup/Main_Screens/ProfileTab/EditProfile/Model/InterestModel.dart'; +import 'package:regroup/sidemenu/Community/MyCommunity/Model/activitiesListModel.dart'; -InterestModel? interestlistobj; +ActivitiesListsModel? interestlistobj; class PrimaryActivityListApi { @@ -11,7 +11,7 @@ class PrimaryActivityListApi { var data = ""; Future> getActivitylistApi() async { final response = await NetworkApiServices().getApi( - ApiUrls.getinterestlist, + ApiUrls.getactivitieslist, ); @@ -20,8 +20,8 @@ class PrimaryActivityListApi { Map.from(response.data); if (responseData['status'] == "success") { print("success"); - InterestModel interestlistobj = - InterestModel.fromJson(responseData); + ActivitiesListsModel interestlistobj = + ActivitiesListsModel.fromJson(responseData); } else { // return ResponseData( // responseData['message'], ResponseStatus.FAILED);