diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 6e5bb08..2bd5b2c 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -82,6 +82,8 @@ PODS: - flutter_facebook_auth (6.0.4): - FBSDKLoginKit (~> 16.3.1) - Flutter + - flutter_keyboard_visibility (0.0.1): + - Flutter - fluttertoast (0.0.2): - Flutter - Toast @@ -169,6 +171,7 @@ DEPENDENCIES: - firebase_core (from `.symlinks/plugins/firebase_core/ios`) - Flutter (from `Flutter`) - flutter_facebook_auth (from `.symlinks/plugins/flutter_facebook_auth/ios`) + - flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`) - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) - geolocator_apple (from `.symlinks/plugins/geolocator_apple/ios`) - google_maps_flutter_ios (from `.symlinks/plugins/google_maps_flutter_ios/ios`) @@ -222,6 +225,8 @@ EXTERNAL SOURCES: :path: Flutter flutter_facebook_auth: :path: ".symlinks/plugins/flutter_facebook_auth/ios" + flutter_keyboard_visibility: + :path: ".symlinks/plugins/flutter_keyboard_visibility/ios" fluttertoast: :path: ".symlinks/plugins/fluttertoast/ios" geolocator_apple: @@ -265,6 +270,7 @@ SPEC CHECKSUMS: FirebaseCoreInternal: df84dd300b561c27d5571684f389bf60b0a5c934 Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 flutter_facebook_auth: c8700ab1770f3d8e5e7456220e4f3bbcdb831454 + flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069 fluttertoast: 9f2f8e81bb5ce18facb9748d7855bf5a756fe3db geolocator_apple: 6cbaf322953988e009e5ecb481f07efece75c450 google_maps_flutter_ios: d1318b4ff711612cab16862d7a87e31a7403d458 diff --git a/lib/Common/ApiRepositoy.dart b/lib/Common/ApiRepositoy.dart new file mode 100644 index 0000000..a34f525 --- /dev/null +++ b/lib/Common/ApiRepositoy.dart @@ -0,0 +1,18 @@ +// import 'package:get/get.dart'; +// import 'package:flutter/material.dart'; +// import 'package:async/async.dart'; +// import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/CommentsRepository.dart'; +// class ApiRepository extends GetxController { +// Future> fetchMultipleAPIs() async { +// FutureGroup futureGroup = FutureGroup(); +// // PostDetail +// futureGroup.add(CommentsRepository().getAllComments()); + + +// // Close the group (no more futures can be added) +// futureGroup.close(); + +// // Wait for all futures to complete +// return await futureGroup.future; +// } +// } diff --git a/lib/Common/api_urls.dart b/lib/Common/api_urls.dart index 2e1bae2..722bac2 100644 --- a/lib/Common/api_urls.dart +++ b/lib/Common/api_urls.dart @@ -128,6 +128,14 @@ class ApiUrls { static const postusertag = "${baseUrl}pin-unpin"; + + //comments + static const getComments = "${baseUrl}fetch-comment-with-replied-comment"; + static const storeComments = "${baseUrl}store-comment"; + static const storeRepliesOnComments = "${baseUrl}reply-on-comment"; + static const deleteComments = "${baseUrl}delete-comment"; + static const deleteRepliesComments = "${baseUrl}delete-reply-on-comment"; + static const getLikeicons= "${baseUrl}fetch-like-icons"; static const postLike = "${baseUrl}like-post"; @@ -137,5 +145,7 @@ class ApiUrls { static const postusersave = "${baseUrl}save-post"; + static const getpopularTagsdetails = "${baseUrl}fetch-popular-post"; + } diff --git a/lib/Common/controller/MainScreen.dart b/lib/Common/controller/MainScreen.dart index 87a871f..c14ddc3 100644 --- a/lib/Common/controller/MainScreen.dart +++ b/lib/Common/controller/MainScreen.dart @@ -4,9 +4,7 @@ import 'package:get/get.dart'; import 'package:regroup/Common/controller/MainController.dart'; import 'package:regroup/Main_Screens/ProfileTab/EditProfile/ViewModel/InterestApiList.dart'; - final MainController mainController = Get.put(MainController()); - class MainScreen extends StatefulWidget { const MainScreen({super.key}); @@ -15,10 +13,10 @@ class MainScreen extends StatefulWidget { } class _MainScreenState extends State { - @override void initState() { InterestListApi().getinterestlistApi(); + super.initState(); } diff --git a/lib/Global.dart b/lib/Global.dart index 665a8cf..dc71b9e 100644 --- a/lib/Global.dart +++ b/lib/Global.dart @@ -15,5 +15,7 @@ late Timer timerhomeglobal; bool isTimerInitialize = false; String? globalAccountType; String? mainWelcomeName; +String userIdGlobal = "0"; + diff --git a/lib/Main_Screens/Community/Model/FeedPostModel.dart b/lib/Main_Screens/Community/Model/FeedPostModel.dart index 7315185..dbe4abd 100644 --- a/lib/Main_Screens/Community/Model/FeedPostModel.dart +++ b/lib/Main_Screens/Community/Model/FeedPostModel.dart @@ -45,168 +45,232 @@ class Data { // pinnedTagsPost: json["pinned_tags_post"] == null ? [] : List.from(json["pinned_tags_post"]!.map((x) => PinnedPost.fromJson(x))), pinnedTagsPost: json["pinned_tags_post"] == null ? [] - : List.from(json["pinned_tags_post"]! - .expand((x) => x as List) - .map((x) => PinnedPost.fromJson(x))), + : + List.from( + json["pinned_tags_post"]!.map((x) => PinnedPost.fromJson(x))), + // List.from(json["pinned_tags_post"]! + // .expand((x) => x as List) + // .map((x) => PinnedPost.fromJson(x))), ); } } class PinnedPost { - PinnedPost({ - required this.id, - required this.likecount, - required this.tagsXid, - required this.isILiked, - required this.totalComment, - required this.totalSave, - required this.iamPrincipalXid, - required this.postIn, - required this.caption, - required this.image, - required this.manageTagsXids, - required this.postAs, - required this.ctaTitle, - required this.ctaLink, - required this.createdAt, - required this.tagNames, - required this.likeIcon, - required this.iamPrincipal, - required this.community, - }); + PinnedPost({ + required this.id, + required this.likecount, + required this.isISaved, + required this.tagsXid, + required this.isILiked, + required this.totalComment, + required this.totalSave, + required this.iamPrincipalXid, + required this.postIn, + required this.caption, + required this.image, + required this.manageTagsXids, + required this.postAs, + required this.ctaTitle, + required this.ctaLink, + required this.createdAt, + required this.likeIcon, + required this.totalViewCount, + required this.totalReactionCount, + required this.totalCommentCount, + required this.totalImpressionCount, + required this.totalPopularScore, + required this.totalHoursAgo, + required this.iamPrincipal, + required this.community, + required this.attachTags, + }); - final int? id; - final int? likecount; - final List tagsXid; - final bool? isILiked; - final int? totalComment; - final int? totalSave; - final int? iamPrincipalXid; - final int? postIn; - final String? caption; - final String? image; - final String? manageTagsXids; - final String? postAs; - final String? ctaTitle; - final String? ctaLink; - final DateTime? createdAt; - final List tagNames; - final LikeIcon? likeIcon; - final IamPrincipal? iamPrincipal; - final Community? community; + final int? id; + final int? likecount; + final bool? isISaved; + final List tagsXid; + final bool? isILiked; + final int? totalComment; + final int? totalSave; + final int? iamPrincipalXid; + final int? postIn; + final String? caption; + final String? image; + final String? manageTagsXids; + final String? postAs; + final String? ctaTitle; + final String? ctaLink; + final DateTime? createdAt; + final LikeIcon? likeIcon; + final int? totalViewCount; + final int? totalReactionCount; + final int? totalCommentCount; + final int? totalImpressionCount; + final int? totalPopularScore; + final int? totalHoursAgo; + final IamPrincipal? iamPrincipal; + final Community? community; + final List attachTags; + + factory PinnedPost.fromJson(Map json){ + return PinnedPost( + id: json["id"], + likecount: json["likecount"], + isISaved: json["is_i_saved"], + tagsXid: json["tags_xid"] == null ? [] : List.from(json["tags_xid"]!.map((x) => x)), + isILiked: json["is_i_liked"], + totalComment: json["total_comment"], + totalSave: json["total_save"], + iamPrincipalXid: json["iam_principal_xid"], + 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"], + createdAt: DateTime.tryParse(json["created_at"] ?? ""), + likeIcon: json["likeIcon"] == null ? null : LikeIcon.fromJson(json["likeIcon"]), + totalViewCount: json["totalViewCount"], + totalReactionCount: json["totalReactionCount"], + totalCommentCount: json["totalCommentCount"], + totalImpressionCount: json["totalImpressionCount"], + totalPopularScore: json["totalPopularScore"], + totalHoursAgo: json["totalHoursAgo"], + iamPrincipal: json["iam_principal"] == null ? null : IamPrincipal.fromJson(json["iam_principal"]), + community: json["community"] == null ? null : Community.fromJson(json["community"]), + attachTags: json["attach_tags"] == null ? [] : List.from(json["attach_tags"]!.map((x) => AttachTag.fromJson(x))), + ); + } + +} + +class AttachTag { + AttachTag({ + required this.managePostXid, + required this.manageTagXid, + required this.manageTag, + }); + + final int? managePostXid; + final int? manageTagXid; + final ManageTag? manageTag; + + factory AttachTag.fromJson(Map json){ + return AttachTag( + managePostXid: json["manage_post_xid"], + manageTagXid: json["manage_tag_xid"], + manageTag: json["manage_tag"] == null ? null : ManageTag.fromJson(json["manage_tag"]), + ); + } + +} + +class ManageTag { + ManageTag({ + required this.id, + required this.isPinned, + required this.name, + }); + + final int? id; + final bool? isPinned; + final String? name; + + factory ManageTag.fromJson(Map json){ + return ManageTag( + id: json["id"], + isPinned: json["is_pinned"], + name: json["name"], + ); + } - factory PinnedPost.fromJson(Map json) { - return PinnedPost( - id: json["id"], - likecount: json["likecount"], - tagsXid: json["tags_xid"] == null - ? [] - : List.from(json["tags_xid"]!.map((x) => x)), - isILiked: json["is_i_liked"], - totalComment: json["total_comment"], - totalSave: json["total_save"], - iamPrincipalXid: json["iam_principal_xid"], - 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"], - createdAt: DateTime.tryParse(json["created_at"] ?? ""), - tagNames: json["tag_names"] == null - ? [] - : List.from(json["tag_names"]!.map((x) => x)), - likeIcon: - json["likeIcon"] == null ? null : LikeIcon.fromJson(json["likeIcon"]), - iamPrincipal: json["iam_principal"] == null - ? null - : IamPrincipal.fromJson(json["iam_principal"]), - community: json["community"] == null - ? null - : Community.fromJson(json["community"]), - ); - } } class Community { - Community({ - required this.id, - required this.communityProfilePhoto, - required this.communityName, - }); + Community({ + required this.id, + required this.communityProfilePhoto, + required this.communityName, + }); - final int? id; - final String? communityProfilePhoto; - final String? communityName; + final int? id; + final String? communityProfilePhoto; + final String? communityName; + + factory Community.fromJson(Map json){ + return Community( + id: json["id"], + communityProfilePhoto: json["community_profile_photo"], + communityName: json["community_name"], + ); + } - factory Community.fromJson(Map json) { - return Community( - id: json["id"], - communityProfilePhoto: json["community_profile_photo"], - communityName: json["community_name"], - ); - } } class IamPrincipal { - IamPrincipal({ - required this.id, - required this.principalTypeXid, - required this.userName, - required this.fullName, - required this.profilePhoto, - }); + IamPrincipal({ + required this.id, + required this.isUserPinned, + required this.principalTypeXid, + required this.userName, + required this.fullName, + required this.profilePhoto, + }); - final int? id; - final int? principalTypeXid; - final String? userName; - final String? fullName; - final String? profilePhoto; + final int? id; + final bool? isUserPinned; + final int? principalTypeXid; + final String? userName; + final String? fullName; + final String? profilePhoto; + + factory IamPrincipal.fromJson(Map json){ + return IamPrincipal( + id: json["id"], + isUserPinned: json["is_user_pinned"], + principalTypeXid: json["principal_type_xid"], + userName: json["user_name"], + fullName: json["full_name"], + profilePhoto: json["profile_photo"], + ); + } - factory IamPrincipal.fromJson(Map json) { - return IamPrincipal( - id: json["id"], - principalTypeXid: json["principal_type_xid"], - userName: json["user_name"], - fullName: json["full_name"], - profilePhoto: json["profile_photo"], - ); - } } class LikeIcon { - LikeIcon({ - required this.likeIconsXid, - required this.likeIcon, - }); + LikeIcon({ + required this.likeIconsXid, + required this.likeIcon, + }); - final int? likeIconsXid; - final LikeIconClass? 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"]), + ); + } - 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, - }); + LikeIconClass({ + required this.id, + required this.image, + }); - final int? id; - final String? image; + final int? id; + final String? image; + + factory LikeIconClass.fromJson(Map json){ + return LikeIconClass( + id: json["id"], + image: json["image"], + ); + } - factory LikeIconClass.fromJson(Map json) { - return LikeIconClass( - id: json["id"], - image: json["image"], - ); - } } + diff --git a/lib/Main_Screens/Community_HomePage/Community.dart b/lib/Main_Screens/Community_HomePage/Community.dart index 8553bf9..0afaf23 100644 --- a/lib/Main_Screens/Community_HomePage/Community.dart +++ b/lib/Main_Screens/Community_HomePage/Community.dart @@ -313,7 +313,7 @@ class _FeedTabState extends State { '', mainImg: combinedList[index].image ?? '', containerTitle: - combinedList[index].tagNames ?? [''], + [''], create_at: timeAgo, community_name: combinedList[index] .community! diff --git a/lib/Main_Screens/Community_HomePage/Model/tagpopulardetailsModel.dart b/lib/Main_Screens/Community_HomePage/Model/tagpopulardetailsModel.dart new file mode 100644 index 0000000..d681df1 --- /dev/null +++ b/lib/Main_Screens/Community_HomePage/Model/tagpopulardetailsModel.dart @@ -0,0 +1,239 @@ +class TagPopulardetailsModel { + TagPopulardetailsModel({ + 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 TagPopulardetailsModel.fromJson(Map json){ + return TagPopulardetailsModel( + 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.likecount, + required this.isISaved, + required this.isILiked, + required this.totalComment, + required this.totalSave, + required this.iamPrincipalXid, + required this.postIn, + required this.caption, + required this.image, + required this.postAs, + required this.ctaTitle, + required this.ctaLink, + required this.createdAt, + required this.totalViewCount, + required this.totalReactionCount, + required this.totalCommentCount, + required this.totalImpressionCount, + required this.likeIcon, + required this.tagsXid, + required this.totalPopularScore, + required this.totalHoursAgo, + required this.iamPrincipal, + required this.community, + required this.attachTags, + }); + + final int? id; + final int? likecount; + final bool? isISaved; + final bool? isILiked; + final int? totalComment; + final int? totalSave; + final int? iamPrincipalXid; + final int? postIn; + final String? caption; + final String? image; + final String? postAs; + final String? ctaTitle; + final String? ctaLink; + final DateTime? createdAt; + final int? totalViewCount; + final int? totalReactionCount; + final int? totalCommentCount; + final int? totalImpressionCount; + final LikeIcon? likeIcon; + final List tagsXid; + final int? totalPopularScore; + final int? totalHoursAgo; + final IamPrincipal? iamPrincipal; + final Community? community; + final List attachTags; + + factory Datum.fromJson(Map json){ + return Datum( + id: json["id"], + likecount: json["likecount"], + isISaved: json["is_i_saved"], + isILiked: json["is_i_liked"], + totalComment: json["total_comment"], + totalSave: json["total_save"], + iamPrincipalXid: json["iam_principal_xid"], + postIn: json["post_in"], + caption: json["caption"], + image: json["image"], + postAs: json["post_as"], + ctaTitle: json["cta_title"], + ctaLink: json["cta_link"], + createdAt: DateTime.tryParse(json["created_at"] ?? ""), + totalViewCount: json["totalViewCount"], + totalReactionCount: json["totalReactionCount"], + totalCommentCount: json["totalCommentCount"], + totalImpressionCount: json["totalImpressionCount"], + likeIcon: json["likeIcon"] == null ? null : LikeIcon.fromJson(json["likeIcon"]), + tagsXid: json["tags_xid"] == null ? [] : List.from(json["tags_xid"]!.map((x) => x)), + totalPopularScore: json["totalPopularScore"], + totalHoursAgo: json["totalHoursAgo"], + iamPrincipal: json["iam_principal"] == null ? null : IamPrincipal.fromJson(json["iam_principal"]), + community: json["community"] == null ? null : Community.fromJson(json["community"]), + attachTags: json["attach_tags"] == null ? [] : List.from(json["attach_tags"]!.map((x) => AttachTag.fromJson(x))), + ); + } + +} + +class AttachTag { + AttachTag({ + required this.managePostXid, + required this.manageTagXid, + required this.manageTag, + }); + + final int? managePostXid; + final int? manageTagXid; + final ManageTag? manageTag; + + factory AttachTag.fromJson(Map json){ + return AttachTag( + managePostXid: json["manage_post_xid"], + manageTagXid: json["manage_tag_xid"], + manageTag: json["manage_tag"] == null ? null : ManageTag.fromJson(json["manage_tag"]), + ); + } + +} + +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, + required this.isPinned, + required this.name, + }); + + final int? id; + final bool? isPinned; + final String? name; + + factory ManageTag.fromJson(Map json){ + return ManageTag( + id: json["id"], + isPinned: json["is_pinned"], + name: json["name"], + ); + } + +} + +class Community { + Community({ + required this.id, + required this.communityProfilePhoto, + required this.communityName, + }); + + final int? id; + final String? communityProfilePhoto; + final String? communityName; + + factory Community.fromJson(Map json){ + return Community( + id: json["id"], + communityProfilePhoto: json["community_profile_photo"], + communityName: json["community_name"], + ); + } + +} + +class IamPrincipal { + IamPrincipal({ + required this.id, + required this.isUserPinned, + required this.principalTypeXid, + required this.userName, + required this.fullName, + required this.profilePhoto, + }); + + final int? id; + final bool? isUserPinned; + final int? principalTypeXid; + final String? userName; + final String? fullName; + final String? profilePhoto; + + factory IamPrincipal.fromJson(Map json){ + return IamPrincipal( + id: json["id"], + isUserPinned: json["is_user_pinned"], + principalTypeXid: json["principal_type_xid"], + userName: json["user_name"], + fullName: json["full_name"], + profilePhoto: json["profile_photo"], + ); + } + +} diff --git a/lib/Main_Screens/Community_HomePage/PostDetailScreen/Model/NestedCommentsModel.dart b/lib/Main_Screens/Community_HomePage/PostDetailScreen/Model/NestedCommentsModel.dart new file mode 100644 index 0000000..596cf7d --- /dev/null +++ b/lib/Main_Screens/Community_HomePage/PostDetailScreen/Model/NestedCommentsModel.dart @@ -0,0 +1,101 @@ +class NestedCommentsModel { + NestedCommentsModel({ + 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 NestedCommentsModel.fromJson(Map json){ + return NestedCommentsModel( + 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.managePostsXid, + required this.iamPrincipalXid, + required this.comment, + required this.userDetail, + required this.repliedComment, + }); + + final int? id; + final int? managePostsXid; + final int? iamPrincipalXid; + final String? comment; + final UserDetail? userDetail; + final List repliedComment; + + factory Datum.fromJson(Map json){ + return Datum( + id: json["id"], + managePostsXid: json["manage_posts_xid"], + iamPrincipalXid: json["iam_principal_xid"], + comment: json["comment"], + userDetail: json["user_detail"] == null ? null : UserDetail.fromJson(json["user_detail"]), + repliedComment: json["replied_comment"] == null ? [] : List.from(json["replied_comment"]!.map((x) => RepliedComment.fromJson(x))), + ); + } + +} + +class RepliedComment { + RepliedComment({ + required this.id, + required this.postsMasterCommentXid, + required this.iamPrincipalXid, + required this.comment, + required this.userDetail, + }); + + final int? id; + final int? postsMasterCommentXid; + final int? iamPrincipalXid; + final String? comment; + final UserDetail? userDetail; + + factory RepliedComment.fromJson(Map json){ + return RepliedComment( + id: json["id"], + postsMasterCommentXid: json["posts_master_comment_xid"], + iamPrincipalXid: json["iam_principal_xid"], + comment: json["comment"], + userDetail: json["user_detail"] == null ? null : UserDetail.fromJson(json["user_detail"]), + ); + } + +} + +class UserDetail { + UserDetail({ + required this.id, + required this.userName, + required this.profilePhoto, + }); + + final int? id; + final String? userName; + final String? profilePhoto; + + factory UserDetail.fromJson(Map json){ + return UserDetail( + id: json["id"], + userName: json["user_name"], + profilePhoto: json["profile_photo"], + ); + } + +} diff --git a/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart b/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart index a0c71dd..4eb2e43 100644 --- a/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart +++ b/lib/Main_Screens/Community_HomePage/PostDetailScreen/View/PostDetailScreen.dart @@ -1,16 +1,25 @@ import 'package:comment_tree/comment_tree.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; +import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart'; import 'package:flutter_reaction_button/flutter_reaction_button.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/CommonGlassmorphism.dart'; import 'package:regroup/Common/CommonWidget.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Global.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/Utils/Common/CommonAppbar.dart'; import 'package:regroup/Utils/Common/CustomTextformfield.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; import 'package:regroup/Utils/texts.dart'; import 'package:regroup/resources/routes/route_name.dart'; +import 'package:async/async.dart'; class PostDetailsScreen extends StatefulWidget { const PostDetailsScreen({super.key}); @@ -20,301 +29,632 @@ class PostDetailsScreen extends StatefulWidget { } class _PostDetailsScreenState extends State { - List _hideReplies = List.filled(5, true); + List hideReplies = []; + FutureGroup futureGroup = FutureGroup(); + final FocusNode _focusNode = FocusNode(); + final TextEditingController _controllerComments = TextEditingController(); + final CommentsHelper _commentsHelper = Get.put(CommentsHelper()); + + @override + void initState() { + futureGroup.add(CommentsRepository().getAllComments()); + futureGroup.close(); + super.initState(); + } + + bool isOnce = true; + _setViewMoreList() { + if (isOnce) { + hideReplies = List.filled(nestedComments!.data.length, false); + isOnce = false; + } + } + + _toggleReplies(index) { + setState(() { + hideReplies[index] = !hideReplies[index]; + }); + } + + void _focusTextField() { + FocusScope.of(context).requestFocus(_focusNode); + } + + _postComments() async { + var updata = { + "manage_posts_xid": "1", + "comment": _controllerComments.text, + }; + final result = await CommentsRepository().postComments(updata); + if (result.status == ResponseStatus.SUCCESS) { + CommentsRepository().getAllComments().then((value) => setState(() { + isOnce = true; + _commentsHelper.isLoading.value = false; + _controllerComments.clear(); + })); + } + } + + String repliedCommentId = ""; + _postRepliesOnComment(repliedCommentId) async { + var updata = { + "manage_posts_xid": "1", + "posts_master_comment_xid": repliedCommentId, + "comment": _controllerComments.text, + }; + final result = await CommentsRepository().postRepliesOnComments(updata); + if (result.status == ResponseStatus.SUCCESS) { + CommentsRepository().getAllComments().then((value) => setState(() { + isOnce = true; + _commentsHelper.isLoading.value = false; + _controllerComments.clear(); + })); + } + } + // _setComments(index) { + // List repliedCommentsList = []; + // for (var i = 0; + // i < nestedComments!.data[index].repliedComment.length; + // i++) { + // repliedCommentsList.add(Comment( + // avatar: nestedComments! + // .data[index].repliedComment[i].userDetail?.profilePhoto, + // userName: nestedComments! + // .data[index].repliedComment[i].userDetail?.userName, + // content: nestedComments!.data[index].repliedComment[i].comment)); + // } + // return repliedCommentsList; + // } + // bool _hideReplies = true; + _deleteComment(String commentId) async { + var updata = {"id": commentId}; + final result = await CommentsRepository().deleteComments(updata); + if (result.status == ResponseStatus.SUCCESS) { + CommentsRepository().getAllComments().then((value) => setState(() { + isOnce = true; + })); + } + } + + _deleteRepliedComment(String commentId) async { + var updata = {"id": commentId}; + final result = await CommentsRepository().deleteRepliedComments(updata); + if (result.status == ResponseStatus.SUCCESS) { + CommentsRepository().getAllComments().then((value) => setState(() { + isOnce = true; + })); + } + } + @override Widget build(BuildContext context) { - return Scaffold( - resizeToAvoidBottomInset: false, - backgroundColor: const Color(0xFF222935), - extendBody: true, - appBar: const CommonAppbar( - titleTxt: "Post", - ), - body: Stack(children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/png/Ellipse 1496.png"), - fit: BoxFit.fill)), + return KeyboardVisibilityBuilder(builder: (context, isKeyboardVisible) { + return Scaffold( + resizeToAvoidBottomInset: false, + backgroundColor: const Color(0xFF222935), + extendBody: true, + appBar: const CommonAppbar( + titleTxt: "Post", ), - SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - postCards( - profileImg: 'assets/images/png/Ellipse 52.png', - title: 'Ryan Dorwat', - mainImg: 'assets/images/png/Rectangle 25.png', - containerTitle: [ - 'Football', - 'Marathon', - 'Events', - 'Marathon', - 'Events' - ]), - sizedBoxHeight(35.h), - ListView.builder( - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemCount: 2, - itemBuilder: (context, index) { - return Container( - padding: const EdgeInsets.symmetric( - vertical: 12, horizontal: 16), - child: CommentTreeWidget( - Comment( - avatar: 'assets/images/png/Ellipse 52.png', - userName: 'Krishna', - content: - 'felangel made felangel/cubit_and_beyond public'), - [ - Comment( - avatar: 'assets/images/png/Ellipse 52.png', - userName: 'Kishan', - content: 'Sample comment from kishan'), - Comment( - avatar: 'assets/images/png/Ellipse 52.png', - userName: 'Ram', - content: - 'A Dart template generator which helps teams generator which helps teams generator which helps teams'), - // Comment( - // avatar: 'null', - // userName: 'null', - // content: - // 'A Dart template generator which helps teams'), - // Comment( - // avatar: 'null', - // userName: 'null', - // content: - // 'A Dart template generator which helps teams generator which helps teams '), - ], - treeThemeData: const TreeThemeData( - lineColor: Color(0xFFD90B2E), lineWidth: 2.5), - avatarRoot: (context, data) => const PreferredSize( - preferredSize: Size.fromRadius(18), - child: CircleAvatar( - radius: 18, - backgroundColor: Colors.grey, - backgroundImage: AssetImage( - 'assets/images/png/Ellipse 52.png', - ), - ), - ), - avatarChild: (context, data) => const PreferredSize( - preferredSize: Size.fromRadius(12), - child: CircleAvatar( - radius: 12, - backgroundColor: Colors.grey, - backgroundImage: AssetImage( - 'assets/images/png/Ellipse 52.png', - ), - ), - ), - contentChild: (context, data) { - print("printing"); - return data.userName! == "Ram" && _hideReplies[index] - ? GestureDetector( - onTap: () { - setState(() { - _hideReplies[index] = false; - }); - }, - child: Container( - child: const Text( - "View more", - style: TextStyle(color: Colors.white), - ), + body: FutureBuilder( + future: futureGroup.future, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center( + child: CircularProgressIndicator( + color: Colors.blue, + ), + ); + } else if (snapshot.hasError) { + return Center( + child: Text( + '${snapshot.error} occurred', + style: TextStyle(fontSize: 18.spMin), + ), + ); + } else if (snapshot.connectionState == ConnectionState.done) { + _setViewMoreList(); + return _buildBody(isKeyboardVisible); + } else { + return const Center(child: Text('Something went wrong')); + } + }, + )); + }); + } + + _buildBody(isKeyboardVisible) { + return Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), + ), + SingleChildScrollView( + child: + Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + postCards( + profileImg: 'assets/images/png/Ellipse 52.png', + title: 'Ryan Dorwat', + mainImg: 'assets/images/png/Rectangle 25.png', + containerTitle: [ + 'Football', + 'Marathon', + 'Events', + 'Marathon', + 'Events' + ]), + sizedBoxHeight(35.h), + + // ListView.builder( + // physics: const NeverScrollableScrollPhysics(), + // shrinkWrap: true, + // itemCount: nestedComments!.data.length, + // itemBuilder: (context, index) { + // List _repliedCommentsSorted = _setComments(index); + + // return Container( + // padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16), + // child: CommentTreeWidget( + // Comment( + // avatar: + // nestedComments!.data[index].userDetail!.profilePhoto, + // userName: nestedComments!.data[index].userDetail!.userName, + // content: nestedComments!.data[index].comment), + // [], + // // _repliedCommentsSorted.isNotEmpty ? _repliedCommentsSorted : [], + // treeThemeData: const TreeThemeData( + // lineColor: Color(0xFFD90B2E), lineWidth: 2.5), + // avatarRoot: (context, data) => PreferredSize( + // preferredSize: const Size.fromRadius(18), + // child: CircleAvatar( + // radius: 18, + // backgroundColor: Colors.grey, + // backgroundImage: NetworkImage( + // data.avatar ?? + // "https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png?20150327203541", + // ), + // ), + // ), + // avatarChild: (context, data) => PreferredSize( + // preferredSize: const Size.fromRadius(12), + // child: CircleAvatar( + // radius: 12, + // backgroundColor: Colors.grey, + // backgroundImage: NetworkImage( + // data.avatar ?? + // "https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png?20150327203541", + // ), + // ), + // ), + // contentChild: (context, data) { + // return data.userName! == "Ram" && _hideReplies[index] + // ? GestureDetector( + // onTap: () { + // setState(() { + // _hideReplies[index] = false; + // }); + // }, + // child: Container( + // child: const Text( + // "View more", + // style: TextStyle(color: Colors.white), + // ), + // ), + // ) + // : Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Container( + // padding: const EdgeInsets.symmetric( + // vertical: 8, horizontal: 8), + // decoration: BoxDecoration( + // color: Colors.grey[100], + // borderRadius: BorderRadius.circular(12)), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text( + // '${data.userName}', + // style: Theme.of(context) + // .textTheme + // .bodySmall + // ?.copyWith( + // fontWeight: FontWeight.w600, + // color: Colors.black), + // ), + // const SizedBox( + // height: 4, + // ), + // Text( + // '${data.content}', + // style: Theme.of(context) + // .textTheme + // .bodySmall + // ?.copyWith( + // fontWeight: FontWeight.w300, + // color: Colors.black), + // ), + // ], + // ), + // ), + // DefaultTextStyle( + // style: Theme.of(context) + // .textTheme + // .bodySmall! + // .copyWith( + // color: Colors.grey[700], + // fontWeight: FontWeight.bold), + // child: const Padding( + // padding: EdgeInsets.only(top: 4), + // child: Row( + // children: [ + // SizedBox( + // width: 8, + // ), + // Text('Like'), + // SizedBox( + // width: 24, + // ), + // Text('Reply'), + // ], + // ), + // ), + // ) + // ], + // ); + // }, + // contentRoot: (context, data) { + // return Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Container( + // padding: const EdgeInsets.symmetric( + // vertical: 8, horizontal: 8), + // decoration: BoxDecoration( + // color: Colors.grey[100], + // borderRadius: BorderRadius.circular(12)), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text( + // 'dangngocduc', + // style: Theme.of(context) + // .textTheme + // .bodySmall! + // .copyWith( + // fontWeight: FontWeight.w600, + // color: Colors.black), + // ), + // const SizedBox( + // height: 4, + // ), + // Text( + // '${data.content}', + // style: Theme.of(context) + // .textTheme + // .bodySmall! + // .copyWith( + // fontWeight: FontWeight.w300, + // color: Colors.black), + // ), + // ], + // ), + // ), + // DefaultTextStyle( + // style: Theme.of(context).textTheme.bodySmall!.copyWith( + // color: Colors.grey[700], + // fontWeight: FontWeight.bold), + // child: const Padding( + // padding: EdgeInsets.only(top: 4), + // child: Row( + // children: [ + // SizedBox( + // width: 8, + // ), + // Text('Like'), + // SizedBox( + // width: 24, + // ), + // Text('Reply'), + // ], + // ), + // ), + // ) + // ], + // ); + // }, + // ), + // ); + // }, + // ), + + ListView.builder( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: nestedComments?.data.length, + itemBuilder: (context, index) { + return Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Column( + children: [ + GestureDetector( + onLongPressStart: (details) { + nestedComments?.data[index].userDetail!.id + .toString() != + userIdGlobal + ? null + : showMenu( + context: context, + position: RelativeRect.fromLTRB( + details.globalPosition.dx, + details.globalPosition.dy, + details.globalPosition.dx + 1, + details.globalPosition.dy + 1, ), - ) - : Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - padding: const EdgeInsets.symmetric( - vertical: 8, horizontal: 8), - decoration: BoxDecoration( - color: Colors.grey[100], - borderRadius: - BorderRadius.circular(12)), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - '${data.userName}', - style: Theme.of(context) - .textTheme - .bodySmall - ?.copyWith( - fontWeight: FontWeight.w600, - color: Colors.black), - ), - const SizedBox( - height: 4, - ), - Text( - '${data.content}', - style: Theme.of(context) - .textTheme - .bodySmall - ?.copyWith( - fontWeight: FontWeight.w300, - color: Colors.black), - ), - ], - ), + items: [ + const PopupMenuItem( + value: 0, + child: Text("Delete"), ), - DefaultTextStyle( - style: Theme.of(context) - .textTheme - .bodySmall! - .copyWith( - color: Colors.grey[700], - fontWeight: FontWeight.bold), - child: const Padding( - padding: EdgeInsets.only(top: 4), - child: Row( - children: [ - SizedBox( - width: 8, - ), - Text('Like'), - SizedBox( - width: 24, - ), - Text('Reply'), - ], - ), - ), - ) ], - ); + elevation: 8.0, + ).then((value) { + if (value == 0) { + _deleteComment(nestedComments! + .data[index].id + .toString()); + } + }); }, - contentRoot: (context, data) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - padding: const EdgeInsets.symmetric( - vertical: 8, horizontal: 8), - decoration: BoxDecoration( - color: Colors.grey[100], - borderRadius: BorderRadius.circular(12)), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'dangngocduc', - style: Theme.of(context) - .textTheme - .bodySmall! - .copyWith( - fontWeight: FontWeight.w600, - color: Colors.black), - ), - const SizedBox( - height: 4, - ), - Text( - '${data.content}', - style: Theme.of(context) - .textTheme - .bodySmall! - .copyWith( - fontWeight: FontWeight.w300, - color: Colors.black), - ), - ], - ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CircleAvatar( + radius: 20.r, + foregroundImage: NetworkImage( + nestedComments! + .data[index].userDetail!.profilePhoto ?? + "https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png?20150327203541", ), - DefaultTextStyle( - style: Theme.of(context) - .textTheme - .bodySmall! - .copyWith( - color: Colors.grey[700], - fontWeight: FontWeight.bold), - child: const Padding( - padding: EdgeInsets.only(top: 4), - child: Row( - children: [ - SizedBox( - width: 8, - ), - Text('Like'), - SizedBox( - width: 24, - ), - Text('Reply'), - ], + ), + sizedBoxWidth(15.w), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + text12w400_FCFCFC_blur(nestedComments! + .data[index].userDetail!.userName ?? + ""), + text14w400_FCFCFC( + nestedComments!.data[index].comment ?? + ""), + SizedBox(height: 10.h), + GestureDetector( + onTap: () { + _focusTextField(); + _controllerComments.text = + "@${nestedComments!.data[index].userDetail!.userName!}"; + setState(() { + repliedCommentId = nestedComments! + .data[index].id + .toString(); + }); + }, + child: text10w400_FCFCFC_blur("Reply")), + SizedBox(height: 20.h), + nestedComments! + .data[index].repliedComment.isEmpty + ? const SizedBox() + : hideReplies[index] + ? GestureDetector( + onTap: () { + _toggleReplies(index); + }, + child: text10w400_FCFCFC_blur( + "Hide replies"), + ) + : GestureDetector( + onTap: () { + _toggleReplies(index); + }, + child: text10w400_FCFCFC_blur( + "View ${nestedComments!.data[index].repliedComment.length} more replies"), + ), + SizedBox(height: 10.h), + !hideReplies[index] + ? const SizedBox() + : ListView.builder( + physics: + const NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: nestedComments!.data[index] + .repliedComment.length, + itemBuilder: (context, index2) { + return GestureDetector( + onLongPressStart: + (LongPressStartDetails + details) { + nestedComments + ?.data[index] + .repliedComment[ + index2] + .userDetail + ?.id + .toString() != + userIdGlobal + ? null + : showMenu( + context: context, + position: RelativeRect + .fromLTRB( + details.globalPosition + .dx, + details.globalPosition + .dy, + details.globalPosition + .dx + + 1, + details.globalPosition + .dy + + 1, + ), + items: [ + const PopupMenuItem< + int>( + value: 0, + child: + Text("Delete"), + ), + ], + elevation: 8.0, + ).then((value) { + if (value == 0) { + _deleteRepliedComment( + nestedComments! + .data[index] + .repliedComment[ + index2] + .id + .toString()); + } + }); + }, + child: ListTile( + leading: Column( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + CircleAvatar( + radius: 13.r, + foregroundImage: + NetworkImage( + nestedComments! + .data[index] + .repliedComment[ + index2] + .userDetail + ?.profilePhoto ?? + "https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png?20150327203541", + ), + ), + ], + ), + title: text12w400_FCFCFC_blur( + nestedComments! + .data[index] + .repliedComment[ + index2] + .userDetail + ?.userName ?? + ""), + subtitle: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + text14w400_FCFCFC( + nestedComments! + .data[index] + .repliedComment[ + index2] + .comment ?? + ""), + SizedBox(height: 10.h), + GestureDetector( + onTap: () { + _focusTextField(); + _controllerComments + .text = + "@${nestedComments!.data[index].repliedComment[index2].userDetail!.userName!}"; + setState(() { + repliedCommentId = + nestedComments! + .data[index] + .repliedComment[ + index2] + .postsMasterCommentXid + .toString(); + }); + }, + child: + text10w400_FCFCFC_blur( + "Reply")), + ], + ), + ), + ); + }) + ], + ), + ), + ], + ), + ), + sizedBoxHeight(20.h), + //sizedBoxHeight(85.h) + ], + )); + }), + sizedBoxHeight(25.h), + ])), + Positioned.fill( + top: 625.h - MediaQuery.of(context).viewInsets.bottom, + // isKeyboardVisible ? 270.h : 625.h, + right: 16.0, + left: 16.0, + child: Align( + alignment: Alignment.bottomCenter, + child: Padding( + padding: const EdgeInsets.only(top: 15, bottom: 15), + child: Row( + children: [ + Obx(() { + return Expanded( + child: CustomTextFormField( + textEditingController: _controllerComments, + focusNode: _focusNode, + hintText: "Add comment", + suffixIcon: GestureDetector( + onTap: () { + if (_controllerComments.text.isEmpty) { + print("Enter some text"); + } else { + _commentsHelper.isLoading.value = true; + if (repliedCommentId != "") { + _postRepliesOnComment(repliedCommentId); + } else { + _postComments(); + } + } + }, + child: _commentsHelper.isLoading.value + ? Container( + padding: const EdgeInsets.all(10), + height: 10.h, + width: 10.w, + child: const CircularProgressIndicator()) + : SizedBox( + height: 20.h, + width: 25.w, + child: Center( + child: Image.asset( + "assets/images/png/iconoir_send.png", + height: 20.h, + width: 25.w, + ), ), ), - ) - ], - ); - }, + ), ), ); - }, - ), - - // Padding( - // padding: EdgeInsets.symmetric(horizontal: 16.w), - // child: Column(children: [ - // Row( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // CircleAvatar( - // radius: 20.r, - // foregroundImage: const AssetImage( - // "assets/images/png/Ellipse 48.png", - // ), - // ), - // sizedBoxWidth(15.w), - // Expanded( - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // text12w400_FCFCFC_blur("Roger Saris"), - // text14w400_FCFCFC( - // "Lorem Ipsum has been the industry's standard dummy text 😍"), - // text10w400_FCFCFC_blur("Reply. . . ") - // ], - // ), - // ), - // ], - // ), - // sizedBoxHeight(50.h), - // Align( - // alignment: Alignment.bottomCenter, - // child: Padding( - // padding: const EdgeInsets.only(top: 15, bottom: 15), - // child: Row( - // children: [ - // Expanded( - // child: CustomTextFormField( - // hintText: "Add comment", - // suffixIcon: SizedBox( - // height: 20.h, - // width: 25.w, - // child: Center( - // child: Image.asset( - // "assets/images/png/iconoir_send.png", - // height: 20.h, - // width: 25.w, - // ), - // ), - // ), - // ), - // ) - // ], - // ), - // )), - // sizedBoxHeight(85.h) - // ])) - ])) - ])); + }) + ], + ), + )), + ), + ]); } Widget postCards({ @@ -336,7 +676,7 @@ class _PostDetailsScreenState extends State { return commonGlassUI( width: double.infinity, - height: 570.h, + height: 800.h, borderwidth: 0, borderRadius: BorderRadius.circular(0), customWidget: Column( @@ -467,7 +807,7 @@ class _PostDetailsScreenState extends State { ), ], ), - sizedBoxHeight(5.h), + sizedBoxHeight(15.h), Row( children: [ Image.asset( @@ -499,7 +839,7 @@ class _PostDetailsScreenState extends State { // Get.toNamed(RouteName.postdetailsScreen); }, child: SizedBox( - height: 163.h, + height: 390.h, width: double.infinity, child: Image.asset( mainImg, @@ -691,7 +1031,4 @@ class _PostDetailsScreenState extends State { ], ); } - } - - diff --git a/lib/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/CommentsHelper.dart b/lib/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/CommentsHelper.dart new file mode 100644 index 0000000..3456efe --- /dev/null +++ b/lib/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/CommentsHelper.dart @@ -0,0 +1,5 @@ +import 'package:get/get.dart'; + +class CommentsHelper extends GetxController { + RxBool isLoading = false.obs; +} diff --git a/lib/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/CommentsRepository.dart b/lib/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/CommentsRepository.dart new file mode 100644 index 0000000..f4f741b --- /dev/null +++ b/lib/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/CommentsRepository.dart @@ -0,0 +1,51 @@ +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/Community_HomePage/PostDetailScreen/Model/LikePostModel.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/Model/NestedCommentsModel.dart'; + +NestedCommentsModel? nestedComments; + +class CommentsRepository { + Future> getAllComments() async { + final response = await NetworkApiServices().getApi( + "${ApiUrls.getComments}?manage_posts_xid=1", + ); + if (response.status == ResponseStatus.SUCCESS) { + nestedComments = NestedCommentsModel.fromJson(response.data); + } + return response; + } + + Future> postComments(updata) async { + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.storeComments, + ); + return response; + } + + Future> postRepliesOnComments(updata) async { + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.storeRepliesOnComments, + ); + return response; + } + + Future> deleteComments(updata) async { + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.deleteComments, + ); + return response; + } + + Future> deleteRepliedComments(updata) async { + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.deleteRepliesComments, + ); + return response; + } +} diff --git a/lib/Main_Screens/Community_HomePage/PostScreen.dart b/lib/Main_Screens/Community_HomePage/PostScreen.dart index 5be5c47..9de93ad 100644 --- a/lib/Main_Screens/Community_HomePage/PostScreen.dart +++ b/lib/Main_Screens/Community_HomePage/PostScreen.dart @@ -95,23 +95,40 @@ 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; + // 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 - } + // break; // Assuming each name is unique, we break after finding a match + // } + // } + // } + // print('Selected IDs: $selectedabilityid'); + // } + + 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!; + // Fetch tags for the selected community + fetchPopularTags(communityid!); + _isSecondDropdownEnabled = true; + break; // Assuming each name is unique, we break after finding a match } } - print('Selected IDs: $selectedabilityid'); } + print('Selected IDs: $selectedabilityid'); +} List tags = []; // Change the type to List @@ -1063,9 +1080,17 @@ class _CustomDropDownPopularTagState extends State { void initState() { super.initState(); filteredTags.value = widget.tags; - textEditingController.addListener(() { - filterTags(); - }); + textEditingController.addListener(filterTags); + } + + @override + void didUpdateWidget(CustomDropDownPopularTag oldWidget) { + super.didUpdateWidget(oldWidget); + if (widget.tags != oldWidget.tags) { + // Clear the selected tags and update the filtered tags when tags change + selectedTags.clear(); + filteredTags.value = widget.tags; + } } void _handleDropdownTap() { @@ -1131,10 +1156,6 @@ class _CustomDropDownPopularTagState extends State { ), suffixIcon: GestureDetector( onTap: _handleDropdownTap, - // () { - // onDropTap.value = !onDropTap.value; - - // }, child: SizedBox( height: 20, width: 20, @@ -1150,11 +1171,7 @@ class _CustomDropDownPopularTagState extends State { ), border: InputBorder.none, ), - onTap: _handleDropdownTap - // () { - // onDropTap.value = !onDropTap.value; - // }, - ), + onTap: _handleDropdownTap), ), ), @@ -1225,9 +1242,6 @@ class _CustomDropDownPopularTagState extends State { 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), @@ -1248,6 +1262,218 @@ 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; diff --git a/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart b/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart index f22d8ce..b384a73 100644 --- a/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart +++ b/lib/Main_Screens/Community_HomePage/TagsdDetailScreen.dart @@ -110,7 +110,7 @@ class _TagdetailScreenState extends State { height: 670.h, child: TabBarView( children: [ - cyclepopularTab(), + PopularTab(id: tagsid), // cyclelatestTab(), LatestTab(id: tagsid) ], @@ -541,6 +541,1693 @@ Widget _buildReactionsIcon(String assetPath) { ); } +class PopularTab extends StatefulWidget { + PopularTab({super.key, required this.id}); + + int id; + + @override + State createState() => _PopularTabState(); +} + +class _PopularTabState extends State { + FutureGroup futureGroup = FutureGroup(); + + @override + void initState() { + futureGroup + .add(Communitygetmethod().getPopularTagsdata(widget.id).then((value) { + _initializeData(); + })); + futureGroup.close(); + 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); + + setState(() { + _reactions = fetchlikeIconsModel.data + ?.map((data) => ReactionData( + id: data.id!, + image: data.image!, + )) + .toList() ?? + []; + for (var post in tagpopulardetailobj!.data) { + _initializeSelectedReaction(post.id!); + } + }); + } + } + + 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] = + 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 + } + }); + + 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); + } + } + + 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(() {}); + }); + + return utils.showToast(data.message); + } else { + // Get.back(); + return utils.showToast(data.message); + } + } + + 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); + } + } + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: futureGroup.future, + builder: (ctx, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return + // ShimmerCommon(); + const Center( + child: CircularProgressIndicator( + color: Colors.blue, + ), + ); + } + + if (snapshot.hasError) { + return Center( + child: Text( + '${snapshot.error} occurred', + style: TextStyle(fontSize: 18.spMin), + ), + ); + } + + 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) { + 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), + ]), + ), + ], + )), + sizedBoxHeight(20.h) + ], + ); + } + }, + ), + ), + ], + ); + } + return Container(); + }); + } + + Widget _buildNoDataBody(context) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "No Data Found", + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.w600), + ) + ], + ), + ); + } +} + class LatestTab extends StatefulWidget { LatestTab({super.key, required this.id}); @@ -568,7 +2255,7 @@ class _LatestTabState extends State { Future _initializeData() async { await _fetchIcons(); // _initializeSelectedReaction(); - for (var post in tagdetailobj!.data) { + for (var post in tagpopulardetailobj!.data) { if (post.likeIcon != null) { likeIconIdnew = post.likeIcon!.likeIconsXid; // This is safe now print('like selectedid is ${likeIconIdnew.toString()}'); @@ -981,7 +2668,8 @@ class _LatestTabState extends State { tagdetailobj! .data[index] .image ?? - ''))), + ''), + fit: BoxFit.cover)), ), ), sizedBoxHeight(20.h), diff --git a/lib/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart b/lib/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart index 030b9c7..b802ed0 100644 --- a/lib/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart +++ b/lib/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart @@ -4,8 +4,11 @@ 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/Community_HomePage/Model/tagdetailModel.dart'; +import 'package:regroup/Main_Screens/Community_HomePage/Model/tagpopulardetailsModel.dart'; TagdetailsModel? tagdetailobj; +TagPopulardetailsModel? tagpopulardetailobj; + class Communitygetmethod { Future> getTagsdata(updata) async { @@ -19,4 +22,16 @@ class Communitygetmethod { } return response; } + + Future> getPopularTagsdata(updata) async { + final response = await NetworkApiServices().getApi( + "${ApiUrls.getpopularTagsdetails}?search_post_by_tag_id=$updata", + ); + + if (response.status == ResponseStatus.SUCCESS) { + tagpopulardetailobj = TagPopulardetailsModel.fromJson(response.data); + log(tagpopulardetailobj!.data.toString()); + } + return response; + } } diff --git a/lib/Utils/Common/CustomTextformfield.dart b/lib/Utils/Common/CustomTextformfield.dart index ea846a7..ad76c16 100644 --- a/lib/Utils/Common/CustomTextformfield.dart +++ b/lib/Utils/Common/CustomTextformfield.dart @@ -31,7 +31,7 @@ class CustomTextFormField extends StatefulWidget { this.onTap, this.suffixIcon, this.opacity1 = 0.04, - this.opacity2 = 0.05, + this.opacity2 = 0.05, this.focusNode, }) : super(key: key); dynamic validator; @@ -52,7 +52,7 @@ class CustomTextFormField extends StatefulWidget { final Widget? suffixIcon; final double opacity1; final double opacity2; - + final FocusNode? focusNode; String? validationMessage; @override @@ -99,6 +99,7 @@ class _CustomTextFormFieldState extends State { borderRadius: BorderRadius.circular(30.r), border: Border.all(color: const Color(0xff434A53), width: 0.8), child: TextFormField( + focusNode: widget.focusNode, style: TextStyle( fontSize: 16.sp, color: Colors.white, fontFamily: 'Helvetica'), cursorColor: Colors.red, @@ -153,9 +154,7 @@ class _CustomTextFormFieldState extends State { ], ), ) - : widget.suffixIcon == null - ? null - : widget.suffixIcon!, + : widget.suffixIcon, border: InputBorder.none, contentPadding: EdgeInsets.symmetric(horizontal: 20.h, vertical: 13.w), @@ -237,8 +236,8 @@ class _CustomTextFormField2State extends State { void validateField(String value) { setState(() { - widget.validationMessage = widget.validator?.call(value) ?? - (value.isEmpty ? "" : null); + widget.validationMessage = + widget.validator?.call(value) ?? (value.isEmpty ? "" : null); }); } diff --git a/lib/main.dart b/lib/main.dart index 0498ee0..171c6cc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -115,6 +115,7 @@ class _MyAppState extends State with WidgetsBindingObserver { @override Widget build(BuildContext context) { return ScreenUtilInit( + //useInheritedMediaQuery: true, builder: (BuildContext context, Widget? child) => GetMaterialApp( title: 'Regroup', theme: ThemeData( @@ -124,14 +125,11 @@ class _MyAppState extends State with WidgetsBindingObserver { debugShowCheckedModeBanner: false, // initialRoute: RouteName.individualactivitystep2, - - initialRoute: RouteName.splashScreen, - getPages: AppRoutes.appRoutes(), ), designSize: const Size(390, 844), ); - } + } } diff --git a/lib/onboarding/Signup/view_model/getUserprofile.dart b/lib/onboarding/Signup/view_model/getUserprofile.dart index e663759..344240b 100644 --- a/lib/onboarding/Signup/view_model/getUserprofile.dart +++ b/lib/onboarding/Signup/view_model/getUserprofile.dart @@ -36,11 +36,16 @@ class Getuserdetails { 'phone', getuserobj?.data?.userData?.phoneNumber ?? ""); await prefs.setString('accountTypefromLogin', getuserobj?.data?.userData?.principalTypeXid.toString() ?? ""); + await prefs.setString( + 'userId', getuserobj?.data?.userData?.id.toString() ?? ""); + emailid = prefs.getString('email'); myusername = prefs.getString('username'); fullname = prefs.getString('fullname'); phonenumber = prefs.getString('phone'); globalAccountType = prefs.getString('accountTypefromLogin'); + userIdGlobal = prefs.getString('userId') ?? "0"; + globalAccountType = getuserobj?.data?.userData?.principalTypeXid.toString(); } else if (responseData is String) { diff --git a/lib/sidemenu/sidemenu.dart b/lib/sidemenu/sidemenu.dart index 9a83ac2..268aa7d 100644 --- a/lib/sidemenu/sidemenu.dart +++ b/lib/sidemenu/sidemenu.dart @@ -208,415 +208,330 @@ class _SideMenuState extends State { } Widget _buildBody(context) { - return Column( + return ListView( + padding: EdgeInsets.zero, children: [ sizedBoxHeight(50.h), - Expanded( - child: ListView(physics: ScrollPhysics(), children: [ - GestureDetector( - onTap: () { - Get.toNamed(RouteName.mycommunity); - }, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Row( - children: [ - text16w400_FCFCFC("My communities"), - sizedBoxWidth(4.w), - Image.asset('assets/images/png/sidemenu/rightarrow.png') - ], + GestureDetector( + onTap: () { + Get.toNamed(RouteName.mycommunity); + }, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Row( + children: [ + text16w400_FCFCFC("My communities"), + sizedBoxWidth(4.w), + Image.asset('assets/images/png/sidemenu/rightarrow.png') + ], + ), + ), + ), + sizedBoxHeight(18.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Container( + height: 1, + margin: EdgeInsets.symmetric(vertical: 10.h), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: const Color.fromRGBO(255, 255, 255, 0.3), + width: 1.w, ), ), ), - const Spacer(), - sizedBoxHeight(18.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Container( - height: 1, - margin: EdgeInsets.symmetric(vertical: 10.h), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: const Color.fromRGBO(255, 255, 255, 0.3), - width: 1.w, - ), - ), + ), + ), + sizedBoxHeight(18.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: text16w400_FCFCFC("My pinned content"), + ), + sizedBoxHeight(18.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Container( + height: 1, + margin: EdgeInsets.symmetric(vertical: 10.h), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: const Color.fromRGBO(255, 255, 255, 0.3), + width: 1.w, ), ), ), - sizedBoxHeight(18.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: text16w400_FCFCFC("My pinned content"), - ), - const Spacer(), - sizedBoxHeight(18.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Container( - height: 1, - margin: EdgeInsets.symmetric(vertical: 10.h), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: const Color.fromRGBO(255, 255, 255, 0.3), - width: 1.w, - ), - ), - ), - ), - ), - sizedBoxHeight(18.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Row( - children: [ - text16w400_FCFCFC("interest"), - const Spacer(), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.viewalltags); - }, - child: text14w400_FCFCFC("View all")), - ], - ), - ), - sizedBoxHeight(20.h), - userpinnedobj!.data!.pinnedTag!.isEmpty - ? Center(child: text16400white("Pin tags")) - : SizedBox( - height: 200.h, - child: - // Obx( () { - // return - ListView.builder( - shrinkWrap: true, - itemCount: userpinnedobj!.data!.pinnedTag!.take(5).length, - itemBuilder: (context, index) { - final tagid = userpinnedobj! - .data!.pinnedTag![index].manageTagsXid!; + ), + ), + sizedBoxHeight(18.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Row( + children: [ + text16w400_FCFCFC("interest"), + const Spacer(), + GestureDetector( + onTap: () { + Get.toNamed(RouteName.viewalltags); + }, + child: text14w400_FCFCFC("View all")), + ], + ), + ), + sizedBoxHeight(0.h), + userpinnedobj!.data!.pinnedTag!.isEmpty + ? Center(child: text16400white("Pin tags")) + : SizedBox( + height: 200.h, + child: ListView.builder( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: userpinnedobj!.data!.pinnedTag!.take(5).length, + itemBuilder: (context, index) { + final tagid = + userpinnedobj!.data!.pinnedTag![index].manageTagsXid!; - return ListTile( - leading: commonContainer( - width: 29.w, - height: 29.h, - borderwidth: 0.9, - boxShape: BoxShape.circle, - customWidget: Center( - child: Image.asset( - 'assets/images/png/sidemenu/rowing 1 (traced).png', - width: 13.w, - height: 13.h, - ), - )), - title: userpinnedobj!.data!.pinnedTag![index].tag == - null || + return ListTile( + leading: commonContainer( + width: 29.w, + height: 29.h, + borderwidth: 0.9, + boxShape: BoxShape.circle, + customWidget: Center( + child: Image.asset( + 'assets/images/png/sidemenu/rowing 1 (traced).png', + width: 13.w, + height: 13.h, + ), + )), + title: + userpinnedobj!.data!.pinnedTag![index].tag == null || userpinnedobj!.data!.pinnedTag![index].tag! .name!.isEmpty ? text14w400_FCFCFC('') : text14w400_FCFCFC(userpinnedobj! .data!.pinnedTag![index].tag!.name!), - trailing: InkWell( - onTap: () async { - setState(() { - pinunpinTag(tagid); - userpinnedobj!.data!.pinnedTag!.removeWhere( - (item) => item.manageTagsXid == tagid); - }); - - // toggleSelectedIndex(tagid); - }, - child: - // Obx( - // () { - // return selectedIndices.contains(tagid) - // ? - // Image.asset( - // "assets/images/png/sidemenu/f7_pin-fill (1).png", - // width: 19, - // height: 19, - // ) - // : - Image.asset( - "assets/images/png/sidemenu/f7_pin-fill.png", - width: 19, - height: 19, - ), - // }, - // ), - ), - // onTap: () {}, - ); - }, - ), - // } - - // ) - ), - sizedBoxHeight(18.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Container( - height: 1, - margin: EdgeInsets.symmetric(vertical: 10.h), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: const Color.fromRGBO(255, 255, 255, 0.3), - width: 1.w, - ), - ), + trailing: InkWell( + onTap: () async { + setState(() { + pinunpinTag(tagid); + userpinnedobj!.data!.pinnedTag!.removeWhere( + (item) => item.manageTagsXid == tagid); + }); + }, + child: Image.asset( + "assets/images/png/sidemenu/f7_pin-fill.png", + width: 19, + height: 19, + ), + ), + ); + }, + ), + ), + sizedBoxHeight(18.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Container( + height: 1, + margin: EdgeInsets.symmetric(vertical: 10.h), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: const Color.fromRGBO(255, 255, 255, 0.3), + width: 1.w, ), ), ), - sizedBoxHeight(18.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Row( - children: [ - text16w400_FCFCFC("Communities"), - const Spacer(), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.viewallcommunitiespinned); - }, - child: text14w400_FCFCFC("View all")), - ], - ), - ), - sizedBoxHeight(20.h), - userpinnedobj!.data!.pinnedCommunity!.isEmpty - ? Center(child: text16400white("Pin communities")) - : SizedBox( - height: 200.h, - child: ListView.builder( - shrinkWrap: true, - itemCount: - userpinnedobj!.data!.pinnedCommunity!.take(5).length, - itemBuilder: (context, index) { - final commnityid = userpinnedobj!.data! - .pinnedCommunity![index].manageCommunitiesXid!; + ), + ), + sizedBoxHeight(18.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Row( + children: [ + text16w400_FCFCFC("Communities"), + const Spacer(), + GestureDetector( + onTap: () { + Get.toNamed(RouteName.viewallcommunitiespinned); + }, + child: text14w400_FCFCFC("View all")), + ], + ), + ), + sizedBoxHeight(0.h), + userpinnedobj!.data!.pinnedCommunity!.isEmpty + ? Center(child: text16400white("Pin communities")) + : SizedBox( + height: 200.h, + child: ListView.builder( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: + userpinnedobj!.data!.pinnedCommunity!.take(5).length, + itemBuilder: (context, index) { + final commnityid = userpinnedobj! + .data!.pinnedCommunity![index].manageCommunitiesXid!; - return ListTile( - leading: Container( - width: 29.w, - height: 29.h, - decoration: BoxDecoration( - shape: BoxShape.circle, - // color: Colors.amber, - ), - child: - userpinnedobj! - .data! - .pinnedCommunity![index] - .community! - .communityProfilePhoto == - null || - userpinnedobj! - .data! - .pinnedCommunity![index] - .community! - .communityProfilePhoto! - .isEmpty - ? CircleAvatar( - backgroundImage: AssetImage( - 'assets/images/png/sidemenu/rowing 1 (traced).png', - ), - ) - : CircleAvatar( - backgroundImage: NetworkImage( - userpinnedobj! - .data! - .pinnedCommunity![index] - .community! - .communityProfilePhoto!), - ) - - ), - title: userpinnedobj!.data!.pinnedCommunity![index] - .community == + return ListTile( + leading: Container( + width: 29.w, + height: 29.h, + decoration: BoxDecoration( + shape: BoxShape.circle, + ), + child: userpinnedobj!.data!.pinnedCommunity![index] + .community!.communityProfilePhoto == null || userpinnedobj!.data!.pinnedCommunity![index] - .community!.communityName!.isEmpty - ? text14w400_FCFCFC('') - : text14w400_FCFCFC(userpinnedobj! - .data! - .pinnedCommunity![index] - .community! - .communityName!), - trailing: InkWell( - onTap: () async { - setState(() { - pinunpinCommunities(commnityid); - userpinnedobj!.data!.pinnedCommunity! - .removeWhere((item) => - item.manageCommunitiesXid == - commnityid); - }); - - // toggleSelectedIndex(tagid); - }, - // () { - // pinunpinTag(tagid); - // // toggleSelectedIndex(tagid); - // }, - child: Image.asset( - "assets/images/png/sidemenu/f7_pin-fill.png", - width: 19, - height: 19, - ), - // Obx( - // () { - // return selectedIndicescommunity.contains(tagid) - // ? Image.asset( - // "assets/images/png/sidemenu/f7_pin-fill (1).png", - // width: 19, - // height: 19, - // ) - // : Image.asset( - // "assets/images/png/sidemenu/f7_pin-fill.png", - // width: 19, - // height: 19, - // ); - // }, - // ), - ), - ); - }, - ), - ), - sizedBoxHeight(18.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Container( - height: 1, - margin: EdgeInsets.symmetric(vertical: 10.h), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: const Color.fromRGBO(255, 255, 255, 0.3), - width: 1.w, - ), - ), + .community!.communityProfilePhoto!.isEmpty + ? CircleAvatar( + backgroundImage: AssetImage( + 'assets/images/png/sidemenu/rowing 1 (traced).png', + ), + ) + : CircleAvatar( + backgroundImage: NetworkImage(userpinnedobj! + .data! + .pinnedCommunity![index] + .community! + .communityProfilePhoto!), + )), + title: userpinnedobj!.data!.pinnedCommunity![index] + .community == + null || + userpinnedobj!.data!.pinnedCommunity![index] + .community!.communityName!.isEmpty + ? text14w400_FCFCFC('') + : text14w400_FCFCFC(userpinnedobj! + .data! + .pinnedCommunity![index] + .community! + .communityName!), + trailing: InkWell( + onTap: () async { + setState(() { + pinunpinCommunities(commnityid); + userpinnedobj!.data!.pinnedCommunity!.removeWhere( + (item) => + item.manageCommunitiesXid == commnityid); + }); + }, + child: Image.asset( + "assets/images/png/sidemenu/f7_pin-fill.png", + width: 19, + height: 19, + ), + ), + ); + }, + ), + ), + sizedBoxHeight(18.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Container( + height: 1, + margin: EdgeInsets.symmetric(vertical: 10.h), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: const Color.fromRGBO(255, 255, 255, 0.3), + width: 1.w, ), ), ), - sizedBoxHeight(18.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Row( - children: [ - text16w400_FCFCFC("Users"), - const Spacer(), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.viewalluserspinned); - }, - child: text14w400_FCFCFC("View all")), - ], - ), - ), - sizedBoxHeight(20.h), - userpinnedobj!.data!.pinnedUser!.isEmpty - ? Center(child: text16400white("Pin users")) - : SizedBox( - height: 200.h, - child: ListView.builder( - shrinkWrap: true, - itemCount: - userpinnedobj!.data!.pinnedUser!.take(5).length, - itemBuilder: (context, index) { - final userid = userpinnedobj! - .data!.pinnedUser![index].pinIamPrincipalXid!; + ), + ), + sizedBoxHeight(18.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Row( + children: [ + text16w400_FCFCFC("Users"), + const Spacer(), + GestureDetector( + onTap: () { + Get.toNamed(RouteName.viewalluserspinned); + }, + child: text14w400_FCFCFC("View all")), + ], + ), + ), + sizedBoxHeight(0.h), + userpinnedobj!.data!.pinnedUser!.isEmpty + ? Center(child: text16400white("Pin users")) + : SizedBox( + height: 200.h, + child: ListView.builder( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: userpinnedobj!.data!.pinnedUser!.take(5).length, + itemBuilder: (context, index) { + final userid = userpinnedobj! + .data!.pinnedUser![index].pinIamPrincipalXid!; - return ListTile( - leading: commonContainer( - width: 29.w, - height: 29.h, - borderwidth: 0.9, - boxShape: BoxShape.circle, - customWidget: Center( - child: userpinnedobj!.data!.pinnedUser![index] - .pinUser!.profilePhoto == - null || - userpinnedobj! - .data! - .pinnedUser![index] - .pinUser! - .profilePhoto! - .isEmpty - ? Image.asset( + return ListTile( + leading: commonContainer( + width: 29.w, + height: 29.h, + borderwidth: 0.9, + boxShape: BoxShape.circle, + customWidget: Center( + child: userpinnedobj!.data!.pinnedUser![index] + .pinUser!.profilePhoto == + null || + userpinnedobj!.data!.pinnedUser![index] + .pinUser!.profilePhoto!.isEmpty + ? Image.asset( + 'assets/images/png/sidemenu/rowing 1 (traced).png', + width: 13.w, + height: 13.h, + ) + : Image.network( + userpinnedobj!.data!.pinnedUser![index] + .pinUser!.profilePhoto!, + width: 13.w, + height: 13.h, + errorBuilder: + (context, error, stackTrace) { + return Image.asset( 'assets/images/png/sidemenu/rowing 1 (traced).png', width: 13.w, height: 13.h, - ) - : Image.network( - userpinnedobj! - .data! - .pinnedUser![index] - .pinUser! - .profilePhoto!, - width: 13.w, - height: 13.h, - errorBuilder: - (context, error, stackTrace) { - // Error handling when image fails to load - return Image.asset( - 'assets/images/png/sidemenu/rowing 1 (traced).png', - width: 13.w, - height: 13.h, - ); - }, - ))), - title: userpinnedobj!.data!.pinnedUser![index] - .pinUser!.fullName == - null || - userpinnedobj!.data!.pinnedUser![index] - .pinUser!.fullName!.isEmpty - ? text14w400_FCFCFC('') - : text14w400_FCFCFC(userpinnedobj! - .data!.pinnedUser![index].pinUser!.fullName!), - trailing: InkWell( - onTap: () async { - setState(() { - pinunpinUser(userid); - userpinnedobj!.data!.pinnedUser!.removeWhere( - (item) => - item.pinIamPrincipalXid == userid); - }); - - // toggleSelectedIndex(tagid); - }, - child: Image.asset( - "assets/images/png/sidemenu/f7_pin-fill.png", - width: 19, - height: 19, - ), - // Obx( - // () { - // return selectedIndicesuser.contains(userid) - // ? Image.asset( - // "assets/images/png/sidemenu/f7_pin-fill (1).png", - // width: 19, - // height: 19, - // ) - // : Image.asset( - // "assets/images/png/sidemenu/f7_pin-fill.png", - // width: 19, - // height: 19, - // ); - // }, - // ), - ), - ); - }, - ), - ), - sizedBoxHeight(18.h), - sizedBoxHeight(80.h), - ]), - ), + ); + }, + ))), + title: userpinnedobj!.data!.pinnedUser![index].pinUser! + .fullName == + null || + userpinnedobj!.data!.pinnedUser![index].pinUser! + .fullName!.isEmpty + ? text14w400_FCFCFC('') + : text14w400_FCFCFC(userpinnedobj! + .data!.pinnedUser![index].pinUser!.fullName!), + trailing: InkWell( + onTap: () async { + setState(() { + pinunpinUser(userid); + userpinnedobj!.data!.pinnedUser!.removeWhere( + (item) => item.pinIamPrincipalXid == userid); + }); + }, + child: Image.asset( + "assets/images/png/sidemenu/f7_pin-fill.png", + width: 19, + height: 19, + ), + ), + ); + }, + ), + ), + sizedBoxHeight(18.h), + sizedBoxHeight(80.h), ], ); } diff --git a/pubspec.lock b/pubspec.lock index 35f959c..de4afa4 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -350,6 +350,54 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.0-beta.2" + flutter_keyboard_visibility: + dependency: "direct main" + description: + name: flutter_keyboard_visibility + sha256: "98664be7be0e3ffca00de50f7f6a287ab62c763fc8c762e0a21584584a3ff4f8" + url: "https://pub.dev" + source: hosted + version: "6.0.0" + flutter_keyboard_visibility_linux: + dependency: transitive + description: + name: flutter_keyboard_visibility_linux + sha256: "6fba7cd9bb033b6ddd8c2beb4c99ad02d728f1e6e6d9b9446667398b2ac39f08" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + flutter_keyboard_visibility_macos: + dependency: transitive + description: + name: flutter_keyboard_visibility_macos + sha256: c5c49b16fff453dfdafdc16f26bdd8fb8d55812a1d50b0ce25fc8d9f2e53d086 + url: "https://pub.dev" + source: hosted + version: "1.0.0" + flutter_keyboard_visibility_platform_interface: + dependency: transitive + description: + name: flutter_keyboard_visibility_platform_interface + sha256: e43a89845873f7be10cb3884345ceb9aebf00a659f479d1c8f4293fcb37022a4 + url: "https://pub.dev" + source: hosted + version: "2.0.0" + flutter_keyboard_visibility_web: + dependency: transitive + description: + name: flutter_keyboard_visibility_web + sha256: d3771a2e752880c79203f8d80658401d0c998e4183edca05a149f5098ce6e3d1 + url: "https://pub.dev" + source: hosted + version: "2.0.0" + flutter_keyboard_visibility_windows: + dependency: transitive + description: + name: flutter_keyboard_visibility_windows + sha256: fc4b0f0b6be9b93ae527f3d527fb56ee2d918cd88bbca438c478af7bcfd0ef73 + url: "https://pub.dev" + source: hosted + version: "1.0.0" flutter_launcher_icons: dependency: "direct dev" description: diff --git a/pubspec.yaml b/pubspec.yaml index e6b5a0c..4571906 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -76,6 +76,7 @@ dependencies: timer_button: ^2.1.1 flutter_html: ^3.0.0-beta.2 comment_tree: ^0.3.0 + flutter_keyboard_visibility: ^6.0.0 dev_dependencies: flutter_test: