Merge branch 'main' into dipti

This commit is contained in:
diptimhabadi351
2024-08-22 12:49:34 +05:30
committed by GitHub
40 changed files with 3195 additions and 5332 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

View File

@@ -22,7 +22,7 @@ class TextInputField extends StatefulWidget {
class _TextInputFieldState extends State<TextInputField> {
@override
Widget build(BuildContext context) {
return Container(
return SizedBox(
width: double.infinity,
height: 46.h,
child: TextFormField(
@@ -274,7 +274,7 @@ Widget stackContainersGroups({
const maxImagesToShow = 3;
// Calculate the number of images to show and the remaining count
final remainingCount = containerImages.length - maxImagesToShow;
// final remainingCount = containerImages.length - maxImagesToShow;
final imagesToShow = containerImages.take(maxImagesToShow).toList();
return Row(
@@ -304,7 +304,7 @@ Widget stackContainersGroups({
),
),
)
: Container(
: SizedBox(
height: 30.h,
width: 30.w,
),

View File

@@ -97,6 +97,8 @@ class ApiUrls {
static const getInvitecommunity = "${baseUrl}fetch-all-invite";
static const postnewinterest = "${baseUrl}store-tags";
static const postcancelrequest = "${baseUrl}cancel-request-of-community";
static const postacceptinvite = "${baseUrl}accept-invite-to-join-community";
@@ -176,4 +178,13 @@ class ApiUrls {
static const geteditcommunity = "${baseUrl}edit-community";
static const posteditcommunity = "${baseUrl}update-community";
static const getactivitieslist = "${baseUrl}get_activity";
static const getcommunitymanagegroups = "${baseUrl}fetch-community-all-groups-list";
static const postremovegroupscommunity = "${baseUrl}remove-groups-from-community";
static const postmanageaddgroupscommunity = "${baseUrl}add-groups-in-community";
}

View File

@@ -0,0 +1,662 @@
import 'dart:developer';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_reaction_button/flutter_reaction_button.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:regroup/Common/CommonGlassmorphism.dart';
import 'package:regroup/Common/CommonWidget.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Main_Screens/Community/Model/CommonDatumObjModel.dart';
import 'package:regroup/Main_Screens/Community/Model/fetchicons.dart';
import 'package:regroup/Main_Screens/Community/ViewModel/postmethod.dart';
import 'package:regroup/Main_Screens/Community_HomePage/view_model/CountersHelper.dart';
import 'package:regroup/Main_Screens/Community_HomePage/view_model/communitypostmethod.dart';
import 'package:regroup/Utils/Common/sized_box.dart';
import 'package:regroup/Utils/dialogs.dart';
import 'package:regroup/Utils/texts.dart';
import 'package:regroup/resources/routes/route_name.dart';
import 'package:regroup/sidemenu/view_model/postmethod.dart';
class NormalCardTile extends StatefulWidget {
List<ManageTagPopular> tags;
String? createAt;
CommonDatumObjModelData commonObj;
String forWhichTab;
List<ReactionData> reactions;
Map<int, ReactionData?> selectedReactions;
bool? coachbool;
int currentIndex;
NormalCardTile({
Key? key,
required this.tags,
this.createAt,
required this.forWhichTab,
required this.commonObj,
required this.reactions,
required this.selectedReactions,
required this.currentIndex,
this.coachbool
}) : super(key: key);
@override
_NormalCardTileState createState() => _NormalCardTileState();
}
class _NormalCardTileState extends State<NormalCardTile> {
RxString mainImage = 'assets/images/png/uiw_like-o.png'.obs;
final CountersHelper countersHelper = Get.find<CountersHelper>();
int saveCount = 0;
_handleReactionChange(Reaction<String>? reaction) async {
if (widget.selectedReactions[widget.commonObj.id] != null &&
reaction?.value ==
widget.selectedReactions[widget.commonObj.id]!.id.toString() ||
reaction?.value == null) {
// User tapped on the currently selected reaction, so remove it
//api call for dislike
await LikeUploaddata(
widget.selectedReactions[widget.commonObj.id]?.id,
widget.commonObj.id!,
);
setState(() {
widget.selectedReactions[widget.commonObj.id!] = null;
//decrement gloally
countersHelper.likesCounterPopular[widget.currentIndex]--;
log("global value ${countersHelper.likesCounterPopular[widget.currentIndex]}");
});
} else {
// User selected a new reaction
var newSelectedReaction = widget.reactions.firstWhere(
(r) => r.id.toString() == reaction?.value,
orElse: () => widget.reactions.first, // Default reaction if not found
);
await _handleReactionChangeApiCall(
newSelectedReaction, widget.commonObj.id!);
}
}
Future<void> _handleReactionChangeApiCall(
ReactionData? reaction, int postId) async {
setState(() {
widget.selectedReactions[postId] =
reaction; // Set the selected reaction for this post
if (countersHelper.likesCounterPopular[widget.currentIndex] <=
widget.commonObj.totalReactionCount!) {
countersHelper.likesCounterPopular[widget.currentIndex]++;
}
});
await LikeUploaddata(
reaction?.id,
postId,
);
}
LikeUploaddata(int? likeIconId, int? postid) async {
Map<String, dynamic> updata = {
"manage_posts_xid": postid,
"like_icons_xid": likeIconId ?? '',
};
final data = await CommunitypostMethod().postLikepost(updata);
if (data.status == ResponseStatus.SUCCESS) {
// return utils.showToast(data.message);
} else {
return utils.showToast(data.message);
}
}
void updateImage(String reaction) {
switch (reaction) {
case 'like':
mainImage.value = 'assets/images/png/f7_hand-thumbsup.png';
break;
case 'heart':
mainImage.value = 'assets/images/png/heart 2.png';
break;
case 'party':
mainImage.value = 'assets/images/png/party-popper 2.png';
break;
default:
// Handle any other cases or do nothing
break;
}
}
saveunsavepost(int popularpostid) async {
// utils.loader();
Map<String, dynamic> updata = {
"manage_posts_xid": popularpostid,
};
final data = await Communitypostmethod().postUserSave(updata);
if (data.status == ResponseStatus.SUCCESS) {
if (countersHelper.saveButtonPopular[widget.currentIndex] == false) {
countersHelper.savePostCounterPopular[widget.currentIndex]++;
} else {
countersHelper.savePostCounterPopular[widget.currentIndex]--;
}
countersHelper.saveButtonPopular[widget.currentIndex] =
!countersHelper.saveButtonPopular[widget.currentIndex];
return utils.showToast(data.message);
} else {
return utils.showToast(data.message);
}
}
pinunpinUser(int userid) async {
Map<String, dynamic> updata = {
"pin_iam_principal_xid": userid,
};
final data = await SidebarTags().postUserpin(updata);
if (data.status == ResponseStatus.SUCCESS) {
countersHelper.pinButtonPopular[widget.currentIndex] =
!countersHelper.pinButtonPopular[widget.currentIndex];
countersHelper.updateFeedsPage.value =
!countersHelper.updateFeedsPage.value;
return utils.showToast(data.message);
} else {
return utils.showToast(data.message);
}
}
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
var imgUrl = widget.commonObj.image!
.split(
"https://regroup.betadelivery.com/storage/app/public/uploads/post_image/")
.last;
return commonGlassUI(
width: double.infinity,
height: 765.h,
mainOpacity: 1,
borderRadius: BorderRadius.circular(1),
customWidget: Column(
children: [
sizedBoxHeight(25.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(
backgroundImage: widget
.commonObj.iamPrincipal?.profilePhoto !=
null
? NetworkImage(
widget.commonObj.iamPrincipal!.profilePhoto!)
as ImageProvider<Object>
: const AssetImage('assets/images/default_profile.png')
as ImageProvider<Object>,
radius: 25.r,
),
sizedBoxWidth(12.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
text16w400_FCFCFC(
widget.commonObj.iamPrincipal!.fullName ??
"Regroup"),
sizedBoxWidth(10.w),
widget.coachbool == true
? Container(
width: 75.w,
height: 25.h,
decoration: BoxDecoration(
border: Border.all(
color: const Color(0xFFD90B2E),
width: 1.w,
),
borderRadius: BorderRadius.circular(5.r),
),
child:
Center(child: text12w400_FCFCFC("Coach")),
)
: const SizedBox(),
],
),
sizedBoxHeight(5.h),
Row(
children: [
Image.asset(
'assets/images/png/community 1 (traced).png',
height: 14.w,
width: 14.w,
),
sizedBoxWidth(7.w),
text12w400_FCFCFC(
widget.commonObj.community!.communityName ?? ""),
sizedBoxWidth(7.w),
Icon(
Icons.circle,
color: const Color(0xFFFCFCFC),
size: 4.sp,
),
sizedBoxWidth(6.w),
text12w400_FCFCFC(widget.createAt!),
],
)
],
),
const Spacer(),
PopupMenuButton(
surfaceTintColor: const Color(0xFF222935),
constraints: BoxConstraints.tightFor(width: 176.w),
offset: const Offset(0, 50),
color: const Color(0xFF222935),
tooltip: "",
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
Text(
'Report Post',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
),
const Spacer(),
Image.asset(
"assets/images/png/Vector (5).png",
height: 15.h,
width: 15.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
Text(
'Share post',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
),
const Spacer(),
Image.asset(
"assets/images/png/share.png",
height: 20.h,
width: 20.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {
pinunpinUser(widget.commonObj.iamPrincipal!.id!);
},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
countersHelper.pinButtonPopular[widget.currentIndex]
? Text(
'Unpin',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
)
: Text(
'Pin',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
),
const Spacer(),
countersHelper
.pinButtonPopular[widget.currentIndex]
? Image.asset(
"assets/images/png/PinnedIcon.png",
height: 25.h,
width: 25.w,
)
: Image.asset(
"assets/images/png/f7_pin-fill (2).png",
height: 25.h,
width: 25.w,
)
],
),
),
),
],
child: Image.asset(
'assets/images/png/Group 1000004071.png',
width: 16.w,
height: 18.h,
),
),
sizedBoxWidth(5.w)
],
),
),
sizedBoxHeight(20.h),
GestureDetector(
onTap: () async {
bool result = await Get.toNamed(RouteName.postdetailsScreen,
arguments: {
'postId': widget.commonObj.id,
'tagsList': widget.tags,
'created_at': widget.createAt,
'commonObj': widget.commonObj,
'fromWhichTab': widget.forWhichTab,
'reactions': widget.reactions,
'selectedReactions': widget.selectedReactions,
'currentIndex': widget.currentIndex
});
if (result) {
setState(() {});
}
},
child: SizedBox(
height: 360,
width: double.infinity,
child: CachedNetworkImage(
cacheKey: imgUrl,
imageUrl: widget.commonObj.image!,
fit: BoxFit.cover,
placeholder: (context, url) => const Center(
child:
CircularProgressIndicator()), // Optional: shows a loading indicator while the image is loading
errorWidget: (context, url, error) => const Center(
child: Icon(Icons
.error)), // Optional: shows an error icon if the image fails to load
),
)),
sizedBoxHeight(20.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Column(children: [
SizedBox(
height: 30.h,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: widget.tags.length,
itemBuilder: (context, index) {
var manageTag = widget.tags[index];
return Padding(
padding: EdgeInsets.only(right: 12.w),
child: GestureDetector(
onTap: () {
Get.toNamed(RouteName.tagdetailscreen, arguments: {
'tagid': manageTag.id,
'tagname': manageTag.name,
'ispinnedtag': manageTag.isPinned,
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
commonContainer(
width: 130.w,
height: 30.h,
borderRadius: BorderRadius.circular(30.r),
borderColor: const Color(0xFFD90B2E),
opacity1: 0.04,
opacity2: 0.05,
customWidget: Padding(
padding:
EdgeInsets.symmetric(horizontal: 10.w),
child: Center(
child: text14w400_FCFCFC(
'#${manageTag.name}',
),
),
),
),
],
),
),
);
},
),
),
sizedBoxHeight(20.h),
SizedBox(
height: 80.h,
width: double.infinity,
child: SingleChildScrollView(
child: text16w400_FCFCFC(widget.commonObj.caption ?? "")),
),
sizedBoxHeight(20.h),
Row(children: [
Obx(
() => InkWell(
onTap: () {
Get.toNamed(RouteName.reactionview, arguments: {
'postId': widget.commonObj.id,
});
},
child: stackReaction(
number: countersHelper
.likesCounterPopular[widget.currentIndex]
.toString(),
containerImages: [
'assets/images/png/f7_hand-thumbsup.png',
'assets/images/png/heart 2.png',
'assets/images/png/party-popper 2.png'
]),
),
),
const Spacer(),
commonContainer(
width: 30.w,
height: 30.h,
borderColor: const Color(0xFF434A53),
borderwidth: 0.43,
opacity1: 0.2,
opacity2: 0.2,
boxShape: BoxShape.circle,
customWidget: Center(
child: Image.asset(
'assets/images/png/Frame 1000004088.png',
height: 13.h,
width: 13.w,
),
),
),
sizedBoxWidth(12.w),
text14w400_FCFCFC(
widget.commonObj.totalCommentCount.toString()),
sizedBoxWidth(20.w),
commonContainer(
width: 30.w,
height: 30.h,
borderColor: const Color(0xFF434A53),
borderwidth: 0.43,
opacity1: 0.2,
opacity2: 0.2,
boxShape: BoxShape.circle,
customWidget: Center(
child: Image.asset(
'assets/images/png/Vector (1).png',
height: 12.h,
width: 12.w,
),
),
),
sizedBoxWidth(12.w),
Obx(
() => text14w400_FCFCFC(countersHelper
.savePostCounterPopular[widget.currentIndex]
.toString()),
),
]),
sizedBoxHeight(12.h),
commonDivider(),
sizedBoxHeight(12.h),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ReactionButton<String>(
onReactionChanged: (reaction) async {
_handleReactionChange(reaction);
},
reactions: widget.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: widget
.selectedReactions[widget.commonObj.id] !=
null
? Reaction<String>(
value: widget
.selectedReactions[widget.commonObj.id]!
.id
.toString(),
icon: Image.network(
widget
.selectedReactions[widget.commonObj.id]!
.image,
width: 24,
height: 24,
fit: BoxFit.cover,
),
)
: null,
boxColor: Colors.white,
boxElevation: 9,
boxRadius: 30,
itemsSpacing: 20,
itemScale: 0.3,
itemSize: const Size(30, 30),
boxPadding: const EdgeInsets.all(8),
boxAnimationDuration:
const Duration(milliseconds: 200),
itemAnimationDuration:
const Duration(milliseconds: 500),
hoverDuration: const Duration(milliseconds: 700),
child: widget
.selectedReactions[widget.commonObj.id] !=
null
? Image.network(
widget.selectedReactions[widget.commonObj.id]!
.image,
width: 24,
height: 24,
fit: BoxFit.cover,
)
: Image.asset(
'assets/images/png/uiw_like-o.png',
width: 24,
height: 24,
fit: BoxFit.cover,
),
),
sizedBoxHeight(8.h),
text11w400_FCFCFC('Like'),
],
),
GestureDetector(
onTap: () async {
bool result = await Get.toNamed(
RouteName.postdetailsScreen,
arguments: {
'postId': widget.commonObj.id,
'tagsList': widget.tags,
'created_at': widget.createAt,
'commonObj': widget.commonObj,
'fromWhichTab': widget.forWhichTab,
'reactions': widget.reactions,
'selectedReactions': widget.selectedReactions,
'currentIndex': widget.currentIndex
});
if (result) {
setState(() {});
}
},
child: Column(
children: [
Image.asset(
'assets/images/png/Frame 1000004088.png',
height: 19.h,
width: 19.w,
),
sizedBoxHeight(8.h),
text11w400_FCFCFC('Comment')
],
),
),
Obx(
() => Column(
//here
children: [
GestureDetector(
onTap: () async =>
await saveunsavepost(widget.commonObj.id!),
child: countersHelper
.saveButtonPopular[widget.currentIndex]
? Image.asset(
'assets/images/png/postSaved.png',
height: 19.h,
width: 19.w,
)
: Image.asset(
'assets/images/png/Frame 1000004089.png',
height: 19.h,
width: 19.w,
),
),
sizedBoxHeight(8.h),
text11w400_FCFCFC('Save')
],
),
),
],
),
sizedBoxHeight(12.h),
commonDivider(),
sizedBoxHeight(12.h),
]),
),
],
));
}
}

View File

@@ -47,13 +47,11 @@ class NetworkApiServices {
: Options(
headers: {
'authorization': basicAuth,
'access-token':
token
'access-token': token
},
),
);
}
on Exception catch (e) {
} on Exception catch (e) {
// log(e.toString());
if (e is DioException) {
log(e.response.toString());
@@ -75,7 +73,6 @@ class NetworkApiServices {
ResponseStatus.FAILED,
);
}
}
if (e.response!.statusCode == 403) {
if (e.response!.data['message'] is List) {
@@ -212,9 +209,7 @@ class NetworkApiServices {
},
)
: Options(
headers: {'authorization': basicAuth, 'access-token':
token
},
headers: {'authorization': basicAuth, 'access-token': token},
),
);
log(response.toString());
@@ -250,6 +245,10 @@ class NetworkApiServices {
return ResponseData<dynamic>(
e.response!.data['message'][0]!, ResponseStatus.FAILED,
data: e.response!.data);
} else if (e.response!.data['message']['name'] is List) {
return ResponseData<dynamic>(
e.response!.data['message']['name'][0]!, ResponseStatus.FAILED,
data: e.response!.data);
} else {
return ResponseData<dynamic>(
e.response!.data['message'], ResponseStatus.FAILED,

View File

@@ -22,7 +22,6 @@ import 'package:regroup/resources/routes/route_name.dart';
import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart';
import 'package:intl/intl.dart';
import 'package:async/src/future_group.dart';
import 'package:shared_preferences/shared_preferences.dart';
class AddTimeline extends StatefulWidget {
const AddTimeline({super.key});

View File

@@ -1,4 +1,4 @@
import 'dart:developer';
import 'package:regroup/Common/api_urls.dart';
import 'package:regroup/Common/base_manager.dart';

View File

@@ -3,17 +3,14 @@
import 'dart:developer';
import 'package:async/src/future_group.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_reaction_button/flutter_reaction_button.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:regroup/Common/CommonBottomNavigationBar.dart';
import 'package:regroup/Common/CommonGlassmorphism.dart';
import 'package:regroup/Common/CommonTabBar.dart';
import 'package:regroup/Common/CommonWidget.dart';
import 'package:regroup/Common/ConvertServerDateToUserDate.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Common/controller/NormalPostCard.dart';
import 'package:regroup/Common/controller/MainScreen.dart';
import 'package:regroup/Main_Screens/Community/Model/CommonDatumObjModel.dart';
import 'package:regroup/Main_Screens/Community/Model/FeedPostModel.dart'
@@ -25,17 +22,13 @@ import 'package:regroup/Main_Screens/Community/ViewModel/FeedPost.dart';
import 'package:regroup/Main_Screens/Community/ViewModel/LatestPost.dart';
import 'package:regroup/Main_Screens/Community/ViewModel/PopularPost.dart';
import 'package:regroup/Main_Screens/Community/ViewModel/getmethod.dart';
import 'package:regroup/Main_Screens/Community/ViewModel/postmethod.dart';
import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/View/ReactionView.dart';
import 'package:regroup/Main_Screens/Community_HomePage/view_model/communitypostmethod.dart';
import 'package:regroup/Utils/Common/ShimmerCommon.dart';
// import 'package:regroup/Feed%20Module/sidemenu/sidemenu.dart';
import 'package:regroup/Utils/Common/sized_box.dart';
import 'package:regroup/Utils/dialogs.dart';
import 'package:regroup/Utils/texts.dart';
import 'package:regroup/resources/routes/route_name.dart';
import 'package:regroup/sidemenu/sidemenu.dart';
import 'package:regroup/sidemenu/view_model/postmethod.dart';
import 'view_model/CountersHelper.dart';
@@ -236,7 +229,7 @@ class _FeedTabState extends State<FeedTab> {
}
}
setValues() {
Future<void> setValues() async {
if (mounted) {
combinedList.clear();
combinedListGlobal.clear();
@@ -246,7 +239,7 @@ class _FeedTabState extends State<FeedTab> {
combinedListGlobal.addAll(combinedList);
_setModel();
countersHelper.setListsPopular();
_fetchIcons();
await _fetchIcons();
}
}
@@ -387,7 +380,7 @@ class _FeedTabState extends State<FeedTab> {
children: [
NormalCardTile(
tags: _sortTags(index),
create_at: timeAgo ?? '1 hour',
createAt: timeAgo ?? '1 hour',
commonObj:
commonobjmodel!.data[index],
forWhichTab: 'feed',
@@ -475,7 +468,7 @@ class _FeedTabState extends State<FeedTab> {
children: [
NormalCardTile(
tags: _sortTags(index),
create_at: timeAgo ?? '1 hour',
createAt: timeAgo ?? '1 hour',
commonObj:
commonobjmodel!.data[index],
forWhichTab: 'feed',
@@ -503,624 +496,6 @@ class _FeedTabState extends State<FeedTab> {
}
// ignore: must_be_immutable
class NormalCardTile extends StatefulWidget {
List<ManageTagPopular> tags;
String? create_at;
CommonDatumObjModelData commonObj;
String forWhichTab;
List<ReactionData> reactions;
Map<int, ReactionData?> selectedReactions;
int currentIndex;
NormalCardTile({
Key? key,
required this.tags,
this.create_at,
required this.forWhichTab,
required this.commonObj,
required this.reactions,
required this.selectedReactions,
required this.currentIndex,
}) : super(key: key);
@override
_NormalCardTileState createState() => _NormalCardTileState();
}
class _NormalCardTileState extends State<NormalCardTile> {
RxString mainImage = 'assets/images/png/uiw_like-o.png'.obs;
final CountersHelper countersHelper = Get.find<CountersHelper>();
int saveCount = 0;
_handleReactionChange(Reaction<String>? reaction) async {
if (widget.selectedReactions[widget.commonObj.id] != null &&
reaction?.value ==
widget.selectedReactions[widget.commonObj.id]!.id.toString() ||
reaction?.value == null) {
// User tapped on the currently selected reaction, so remove it
//api call for dislike
await LikeUploaddata(
widget.selectedReactions[widget.commonObj.id]?.id,
widget.commonObj.id!,
);
setState(() {
widget.selectedReactions[widget.commonObj.id!] = null;
//decrement gloally
countersHelper.likesCounterPopular[widget.currentIndex]--;
log("global value ${countersHelper.likesCounterPopular[widget.currentIndex]}");
});
} else {
// User selected a new reaction
var newSelectedReaction = widget.reactions.firstWhere(
(r) => r.id.toString() == reaction?.value,
orElse: () => widget.reactions.first, // Default reaction if not found
);
await _handleReactionChangeApiCall(
newSelectedReaction, widget.commonObj.id!);
}
}
Future<void> _handleReactionChangeApiCall(
ReactionData? reaction, int postId) async {
setState(() {
widget.selectedReactions[postId] =
reaction; // Set the selected reaction for this post
if (countersHelper.likesCounterPopular[widget.currentIndex] <=
widget.commonObj.totalReactionCount!) {
countersHelper.likesCounterPopular[widget.currentIndex]++;
}
});
await LikeUploaddata(
reaction?.id,
postId,
);
}
LikeUploaddata(int? likeIconId, int? postid) async {
Map<String, dynamic> updata = {
"manage_posts_xid": postid,
"like_icons_xid": likeIconId ?? '',
};
final data = await CommunitypostMethod().postLikepost(updata);
if (data.status == ResponseStatus.SUCCESS) {
// return utils.showToast(data.message);
} else {
return utils.showToast(data.message);
}
}
void updateImage(String reaction) {
switch (reaction) {
case 'like':
mainImage.value = 'assets/images/png/f7_hand-thumbsup.png';
break;
case 'heart':
mainImage.value = 'assets/images/png/heart 2.png';
break;
case 'party':
mainImage.value = 'assets/images/png/party-popper 2.png';
break;
default:
// Handle any other cases or do nothing
break;
}
}
saveunsavepost(int popularpostid) async {
// utils.loader();
Map<String, dynamic> updata = {
"manage_posts_xid": popularpostid,
};
final data = await Communitypostmethod().postUserSave(updata);
if (data.status == ResponseStatus.SUCCESS) {
if (countersHelper.saveButtonPopular[widget.currentIndex] == false) {
countersHelper.savePostCounterPopular[widget.currentIndex]++;
} else {
countersHelper.savePostCounterPopular[widget.currentIndex]--;
}
countersHelper.saveButtonPopular[widget.currentIndex] =
!countersHelper.saveButtonPopular[widget.currentIndex];
return utils.showToast(data.message);
} else {
return utils.showToast(data.message);
}
}
pinunpinUser(int userid) async {
Map<String, dynamic> updata = {
"pin_iam_principal_xid": userid,
};
final data = await SidebarTags().postUserpin(updata);
if (data.status == ResponseStatus.SUCCESS) {
countersHelper.pinButtonPopular[widget.currentIndex] =
!countersHelper.pinButtonPopular[widget.currentIndex];
countersHelper.updateFeedsPage.value =
!countersHelper.updateFeedsPage.value;
return utils.showToast(data.message);
} else {
return utils.showToast(data.message);
}
}
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
var imgUrl = widget.commonObj.image!
.split(
"https://regroup.betadelivery.com/storage/app/public/uploads/post_image/")
.last;
return commonGlassUI(
width: double.infinity,
height: 765.h,
mainOpacity: 1,
borderRadius: BorderRadius.circular(1),
customWidget: Column(
children: [
sizedBoxHeight(25.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(
backgroundImage: widget
.commonObj.iamPrincipal?.profilePhoto !=
null
? NetworkImage(
widget.commonObj.iamPrincipal!.profilePhoto!)
as ImageProvider<Object>
: const AssetImage('assets/images/default_profile.png')
as ImageProvider<Object>,
radius: 25.r,
),
sizedBoxWidth(12.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text16w400_FCFCFC(
widget.commonObj.iamPrincipal!.fullName ?? "Regroup"),
sizedBoxHeight(5.h),
Row(
children: [
Image.asset(
'assets/images/png/community 1 (traced).png',
height: 14.w,
width: 14.w,
),
sizedBoxWidth(7.w),
text12w400_FCFCFC(
widget.commonObj.community!.communityName ?? ""),
sizedBoxWidth(7.w),
Icon(
Icons.circle,
color: const Color(0xFFFCFCFC),
size: 4.sp,
),
sizedBoxWidth(6.w),
text12w400_FCFCFC(widget.create_at!),
],
)
],
),
const Spacer(),
PopupMenuButton(
surfaceTintColor: const Color(0xFF222935),
constraints: BoxConstraints.tightFor(width: 176.w),
offset: const Offset(0, 50),
color: const Color(0xFF222935),
tooltip: "",
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
Text(
'Report Post',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
),
const Spacer(),
Image.asset(
"assets/images/png/Vector (5).png",
height: 15.h,
width: 15.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
Text(
'Share post',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
),
const Spacer(),
Image.asset(
"assets/images/png/share.png",
height: 20.h,
width: 20.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {
pinunpinUser(widget.commonObj.iamPrincipal!.id!);
},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
countersHelper
.pinButtonPopular[widget.currentIndex]
? Text(
'Unpin',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
)
: Text(
'Pin',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
),
const Spacer(),
countersHelper
.pinButtonPopular[widget.currentIndex]
? Image.asset(
"assets/images/png/PinnedIcon.png",
height: 25.h,
width: 25.w,
)
: Image.asset(
"assets/images/png/f7_pin-fill (2).png",
height: 25.h,
width: 25.w,
)
],
),
),
),
],
child: Image.asset(
'assets/images/png/Group 1000004071.png',
width: 16.w,
height: 18.h,
),
),
sizedBoxWidth(5.w)
],
),
),
sizedBoxHeight(20.h),
GestureDetector(
onTap: () async {
bool result = await Get.toNamed(RouteName.postdetailsScreen,
arguments: {
'postId': widget.commonObj.id,
'tagsList': widget.tags,
'created_at': widget.create_at,
'commonObj': widget.commonObj,
'fromWhichTab': widget.forWhichTab,
'reactions': widget.reactions,
'selectedReactions': widget.selectedReactions,
'currentIndex': widget.currentIndex
});
if (result) {
setState(() {});
}
},
child: SizedBox(
height: 360,
width: double.infinity,
child: CachedNetworkImage(
cacheKey: imgUrl,
imageUrl: widget.commonObj.image!,
fit: BoxFit.cover,
placeholder: (context, url) => const Center(
child:
CircularProgressIndicator()), // Optional: shows a loading indicator while the image is loading
errorWidget: (context, url, error) => const Center(
child: Icon(Icons
.error)), // Optional: shows an error icon if the image fails to load
),
)),
sizedBoxHeight(20.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Column(children: [
SizedBox(
height: 30.h,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: widget.tags.length,
itemBuilder: (context, index) {
var manageTag = widget.tags[index];
return Padding(
padding: EdgeInsets.only(right: 12.w),
child: GestureDetector(
onTap: () {
Get.toNamed(RouteName.tagdetailscreen, arguments: {
'tagid': manageTag.id,
'tagname': manageTag.name,
'ispinnedtag': manageTag.isPinned,
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
commonContainer(
width: 130.w,
height: 30.h,
borderRadius: BorderRadius.circular(30.r),
borderColor: const Color(0xFFD90B2E),
opacity1: 0.04,
opacity2: 0.05,
customWidget: Padding(
padding:
EdgeInsets.symmetric(horizontal: 10.w),
child: Center(
child: text14w400_FCFCFC(
'#${manageTag.name}',
),
),
),
),
],
),
),
);
},
),
),
sizedBoxHeight(20.h),
SizedBox(
height: 80.h,
width: double.infinity,
child: SingleChildScrollView(
child: text16w400_FCFCFC(widget.commonObj.caption ?? "")),
),
sizedBoxHeight(20.h),
Row(children: [
Obx(
() => InkWell(
onTap: () {
Get.toNamed(RouteName.reactionview, arguments: {
'postId': widget.commonObj.id,
});
},
child: stackReaction(
number: countersHelper
.likesCounterPopular[widget.currentIndex]
.toString(),
containerImages: [
'assets/images/png/f7_hand-thumbsup.png',
'assets/images/png/heart 2.png',
'assets/images/png/party-popper 2.png'
]),
),
),
const Spacer(),
commonContainer(
width: 30.w,
height: 30.h,
borderColor: const Color(0xFF434A53),
borderwidth: 0.43,
opacity1: 0.2,
opacity2: 0.2,
boxShape: BoxShape.circle,
customWidget: Center(
child: Image.asset(
'assets/images/png/Frame 1000004088.png',
height: 13.h,
width: 13.w,
),
),
),
sizedBoxWidth(12.w),
text14w400_FCFCFC(
widget.commonObj.totalCommentCount.toString()),
sizedBoxWidth(20.w),
commonContainer(
width: 30.w,
height: 30.h,
borderColor: const Color(0xFF434A53),
borderwidth: 0.43,
opacity1: 0.2,
opacity2: 0.2,
boxShape: BoxShape.circle,
customWidget: Center(
child: Image.asset(
'assets/images/png/Vector (1).png',
height: 12.h,
width: 12.w,
),
),
),
sizedBoxWidth(12.w),
Obx(
() => text14w400_FCFCFC(countersHelper
.savePostCounterPopular[widget.currentIndex]
.toString()),
),
]),
sizedBoxHeight(12.h),
commonDivider(),
sizedBoxHeight(12.h),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ReactionButton<String>(
onReactionChanged: (reaction) async {
_handleReactionChange(reaction);
},
reactions: widget.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: widget
.selectedReactions[widget.commonObj.id] !=
null
? Reaction<String>(
value: widget
.selectedReactions[widget.commonObj.id]!
.id
.toString(),
icon: Image.network(
widget
.selectedReactions[widget.commonObj.id]!
.image,
width: 24,
height: 24,
fit: BoxFit.cover,
),
)
: null,
boxColor: Colors.white,
boxElevation: 9,
boxRadius: 30,
itemsSpacing: 20,
itemScale: 0.3,
itemSize: const Size(30, 30),
boxPadding: const EdgeInsets.all(8),
boxAnimationDuration:
const Duration(milliseconds: 200),
itemAnimationDuration:
const Duration(milliseconds: 500),
hoverDuration: const Duration(milliseconds: 700),
child: widget
.selectedReactions[widget.commonObj.id] !=
null
? Image.network(
widget.selectedReactions[widget.commonObj.id]!
.image,
width: 24,
height: 24,
fit: BoxFit.cover,
)
: Image.asset(
'assets/images/png/uiw_like-o.png',
width: 24,
height: 24,
fit: BoxFit.cover,
),
),
sizedBoxHeight(8.h),
text11w400_FCFCFC('Like'),
],
),
GestureDetector(
onTap: () async {
bool result = await Get.toNamed(
RouteName.postdetailsScreen,
arguments: {
'postId': widget.commonObj.id,
'tagsList': widget.tags,
'created_at': widget.create_at,
'commonObj': widget.commonObj,
'fromWhichTab': widget.forWhichTab,
'reactions': widget.reactions,
'selectedReactions': widget.selectedReactions,
'currentIndex': widget.currentIndex
});
if (result) {
setState(() {});
}
},
child: Column(
children: [
Image.asset(
'assets/images/png/Frame 1000004088.png',
height: 19.h,
width: 19.w,
),
sizedBoxHeight(8.h),
text11w400_FCFCFC('Comment')
],
),
),
Obx(
() => Column(
//here
children: [
GestureDetector(
onTap: () async =>
await saveunsavepost(widget.commonObj.id!),
child: countersHelper
.saveButtonPopular[widget.currentIndex]
? Image.asset(
'assets/images/png/postSaved.png',
height: 19.h,
width: 19.w,
)
: Image.asset(
'assets/images/png/Frame 1000004089.png',
height: 19.h,
width: 19.w,
),
),
sizedBoxHeight(8.h),
text11w400_FCFCFC('Save')
],
),
),
],
),
sizedBoxHeight(12.h),
commonDivider(),
sizedBoxHeight(12.h),
]),
),
],
));
}
}
Widget containertile({required String text}) {
return commonGlassContainer(
@@ -1334,7 +709,7 @@ class _PopularTabState extends State<PopularTab> {
children: [
NormalCardTile(
tags: _sortTags(index),
create_at: timeAgo ?? '1 hour',
createAt: timeAgo ?? '1 hour',
commonObj: commonobjmodel!.data[index],
forWhichTab: 'popular',
reactions: _reactions,
@@ -1364,12 +739,12 @@ class LatestTab extends StatefulWidget {
}
class _LatestTabState extends State<LatestTab> {
FutureGroup futureGroup = FutureGroup();
late Future latestfuture;
@override
void initState() {
futureGroup.add(LatespostApi().getLatestPostApi());
futureGroup.close();
latestfuture = LatespostApi().getLatestPostApi();
super.initState();
}
@@ -1482,7 +857,7 @@ class _LatestTabState extends State<LatestTab> {
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: futureGroup.future,
future: latestfuture,
builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: ShimmerCommon());
@@ -1548,7 +923,7 @@ class _LatestTabState extends State<LatestTab> {
children: [
NormalCardTile(
tags: _sortTags(index),
create_at: timeAgo ?? '1 hour',
createAt: timeAgo ?? '1 hour',
commonObj: commonobjmodel!.data[index],
forWhichTab: 'latest',
reactions: _reactions,

View File

@@ -34,6 +34,7 @@ class Datum {
required this.postIn,
required this.caption,
required this.image,
required this.manageTagsXids,
required this.postAs,
required this.ctaTitle,
required this.ctaLink,
@@ -61,6 +62,8 @@ class Datum {
final int? postIn;
final String? caption;
final String? image;
final String? manageTagsXids;
final String? postAs;
final String? ctaTitle;
final String? ctaLink;
@@ -89,6 +92,7 @@ class Datum {
postIn: json["post_in"],
caption: json["caption"],
image: json["image"],
manageTagsXids: json["manage_tags_xids"],
postAs: json["post_as"],
ctaTitle: json["cta_title"],
ctaLink: json["cta_link"],

View File

@@ -1,20 +1,15 @@
import 'dart:developer';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Common/controller/NormalPostCard.dart';
import 'package:regroup/Global.dart';
import 'package:regroup/Main_Screens/Community/Model/CommonDatumObjModel.dart';
import 'package:regroup/Main_Screens/Community/Model/fetchicons.dart';
import 'package:regroup/Main_Screens/Community_HomePage/Community.dart';
import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/CommentsHelper.dart';
import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/CommentsRepository.dart';
import 'package:regroup/Main_Screens/Community_HomePage/PostDetailScreen/ViewModel/PostDetailApi.dart';
@@ -36,7 +31,7 @@ class PostDetailsScreen extends StatefulWidget {
class _PostDetailsScreenState extends State<PostDetailsScreen> {
int? followunfollowid;
FollowUnfollowUploadata() async {
followUnfollowUploadata() async {
// utils.loader();
Map<String, dynamic> newupdata = {
"following_iam_principal_xid": followunfollowid,
@@ -238,7 +233,7 @@ class _PostDetailsScreenState extends State<PostDetailsScreen> {
NormalCardTile(
tags: tags!,
create_at: create_at!,
createAt: create_at!,
commonObj: commonObj!,
forWhichTab: formWhichTab!,
reactions: reactions!,

View File

@@ -9,7 +9,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart' hide MultipartFile, FormData;
import 'package:regroup/Common/CommonButton.dart';
import 'package:regroup/Common/CommonGlassmorphism.dart';
import 'package:regroup/Common/base_manager.dart';
@@ -95,23 +94,9 @@ class _PostScreenState extends State<PostScreen> {
List<int> selectedabilityid = [];
int? communityid;
// void getCatIdFromName(List<String> selectedAbilities) {
// selectedabilityid.clear(); // Clear existing selections
// for (var name in selectedAbilities) {
// for (var i = 0; i < postcommunity.length; i++) {
// if (name == postcommunity[i].community!.communityName) {
// selectedabilityid.add(postcommunity[i].community!.id!);
// communityid = postcommunity[i].community!.id!;
// // fetchPopularlist(postcommunity[i].id!);
// fetchPopularTags(communityid!);
// _isSecondDropdownEnabled = true;
// break; // Assuming each name is unique, we break after finding a match
// }
// }
// }
// print('Selected IDs: $selectedabilityid');
// }
String? _selectedPostType;
int? posttagtype;
bool isCommunitySelected = false;
void getCatIdFromName(List<String> selectedAbilities) {
selectedabilityid.clear(); // Clear existing selections
@@ -120,9 +105,17 @@ class _PostScreenState extends State<PostScreen> {
if (name == postcommunity[i].community!.communityName) {
selectedabilityid.add(postcommunity[i].community!.id!);
communityid = postcommunity[i].community!.id!;
setState(() {
_selectedPostType = null;
_isSecondDropdownEnabled = false;
});
// Fetch tags for the selected community
fetchPopularTags(communityid!);
_isSecondDropdownEnabled = true;
// fetchPopularTags(communityid!, tagtype!);
// _isSecondDropdownEnabled = true;
// if (tagtype != null) {
// fetchPopularTags(communityid!, tagtype!);
// _isSecondDropdownEnabled = true;
// }
break; // Assuming each name is unique, we break after finding a match
}
}
@@ -132,7 +125,7 @@ class _PostScreenState extends State<PostScreen> {
List<Data> tags = []; // Change the type to List<Data>
Future<void> fetchPopularTags(int communityId) async {
Future<void> fetchPopularTags(int communityId, int tagtype) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
token = prefs.getString('access-token');
String basicAuth = 'Basic ' +
@@ -142,7 +135,7 @@ class _PostScreenState extends State<PostScreen> {
try {
final response = await Dio().get(
// 'https://regroup.betadelivery.com/api/v1/fetch-popular-tags?manage_community_xid=$communityId&name=',
'https://regroup.betadelivery.com/api/v1/fetch-popular-tags?manage_community_xid=$communityId&name=',
'https://regroup.betadelivery.com/api/v1/fetch-popular-tags?manage_community_xid=$communityId&is_special=$tagtype&name=',
options: Options(
headers: {'authorization': basicAuth, 'access-token': token},
));
@@ -236,15 +229,15 @@ class _PostScreenState extends State<PostScreen> {
context: context,
builder: (BuildContext context) {
return AlertDialog(
backgroundColor: Color(0xFF222935).withOpacity(0.9),
title: Text(
backgroundColor: const Color(0xFF222935).withOpacity(0.9),
title: const Text(
"Add Tag",
style: TextStyle(color: Colors.white),
),
content: TextField(
style: TextStyle(color: Colors.white),
style: const TextStyle(color: Colors.white),
controller: _tagController,
decoration: InputDecoration(
decoration: const InputDecoration(
labelText: "Tag",
labelStyle: TextStyle(color: AppColors.white),
disabledBorder: UnderlineInputBorder(
@@ -261,14 +254,14 @@ class _PostScreenState extends State<PostScreen> {
onPressed: () {
Navigator.of(context).pop();
},
child: Text("Cancel", style: TextStyle(color: AppColors.white)),
child: const Text("Cancel", style: TextStyle(color: AppColors.white)),
),
TextButton(
onPressed: () async {
tagUploadata();
Navigator.of(context).pop();
},
child: Text("Submit", style: TextStyle(color: AppColors.white)),
child: const Text("Submit", style: TextStyle(color: AppColors.white)),
),
],
);
@@ -289,10 +282,10 @@ class _PostScreenState extends State<PostScreen> {
label:
Text('#${tag.name}', style: const TextStyle(color: Colors.white)),
backgroundColor: const Color(0xFFD90B2E).withOpacity(0.9),
side: BorderSide(color: Colors.black),
side: const BorderSide(color: Colors.black),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.r),
side: BorderSide(width: 1, color: Colors.white)),
side: const BorderSide(width: 1, color: Colors.white)),
onDeleted: () {
setState(() {
selectedpopularid.remove(tag.id);
@@ -341,6 +334,7 @@ class _PostScreenState extends State<PostScreen> {
"post_in": communityid,
"manage_tags_xids": selectedtags,
"post_as": _selectedPostas,
"is_announcement": posttagtype
});
final data = await Communitypostmethod().postUpload(formdata);
if (data.status == ResponseStatus.SUCCESS) {
@@ -380,6 +374,7 @@ class _PostScreenState extends State<PostScreen> {
"post_as": _selectedPostas,
"cta_title": ctatitilecontroller.text,
"cta_link": ctalinkcontroller.text,
"is_announcement": posttagtype
});
final data = await Communitypostmethod().postUpload(formdata);
if (data.status == ResponseStatus.SUCCESS) {
@@ -427,15 +422,67 @@ class _PostScreenState extends State<PostScreen> {
title: "",
listData: _postindrop,
onItemSelected: getCatIdFromName,
onItemSelected:
// getCatIdFromName,
(List<String> selectedAbilities) {
getCatIdFromName(selectedAbilities);
isCommunitySelected = true;
},
// (p0) {},
images: _postindropimages,
leadingImage: const SizedBox(),
),
sizedBoxHeight(20.h),
text16w400_FCFCFC("Caption"),
// sizedBoxHeight(20.h),
text16w400_FCFCFC("Post type"),
sizedBoxHeight(18.h),
CustomRadioListTile(
title: 'Regular',
subtitle:
'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
value: 'Regular',
groupValue: _selectedPostType,
onChanged: (String? value) {
if (isCommunitySelected && communityid != null) {
setState(() {
_selectedPostType = value!;
posttagtype = 0;
fetchPopularTags(communityid!,
posttagtype!); // Call the API after both selections
_isSecondDropdownEnabled = true;
});
} else {
utils.showToast('Please select a community first.');
}
},
activeColor: Color(0XFFD90B2E),
),
CustomRadioListTile(
title: 'Announcement',
subtitle:
'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
value: 'Announcement',
groupValue: _selectedPostType,
onChanged: (String? value) {
if (isCommunitySelected && communityid != null) {
setState(() {
_selectedPostType = value!;
posttagtype = 1;
fetchPopularTags(communityid!,
posttagtype!); // Call the API after both selections
_isSecondDropdownEnabled = true;
});
} else {
utils.showToast('Please select a community first.');
}
},
activeColor: Color(0XFFD90B2E),
),
sizedBoxHeight(38.h),
// text16w400_FCFCFC("Caption"),
// sizedBoxHeight(18.h),
CustomTextFormField2(
maxlines: 3,
hintText: "Enter caption",
@@ -455,17 +502,62 @@ class _PostScreenState extends State<PostScreen> {
sizedBoxHeight(25.h),
text16w400_FCFCFC("Media"),
sizedBoxHeight(18.h),
GestureDetector(
DottedBorder(
strokeWidth: 1,
dashPattern: const [7, 4],
borderType: BorderType.RRect,
radius: Radius.circular(14.r),
color: const Color(0xFF434A53),
child: commonGlassUI(
width: double.infinity,
height: 339.h,
borderRadius: BorderRadius.circular(10.r),
borderColor: Colors.transparent,
customWidget: bannerPath.isNotEmpty && isbannerAdded
? Stack(children: [
Image.file(
bannerPath[0]!,
fit: BoxFit.cover,
width: double.infinity,
),
Positioned(
right: 5,
bottom: 5,
child: GestureDetector(
onTap: () {
bannerPath.clear();
isbannerAdded = false;
setState(() {});
},
child: Container(
width: 27,
height: 27,
decoration: ShapeDecoration(
color: const Color(0xFF7E7E7E),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(
5)),
),
child: const Icon(
Icons.delete_outline_outlined,
color: Colors.white,
))),
),
])
: GestureDetector(
onTap: () {
ImageUploadBottomSheet().showModal(
context,
false,
(result) {
if (result != null && result.isNotEmpty) {
if (result != null &&
result.isNotEmpty) {
var file = File(result);
// Check if the file size exceeds 10 MB
int fileSizeInBytes = file.lengthSync();
int fileSizeInBytes =
file.lengthSync();
double fileSizeInMB =
fileSizeInBytes / (1024 * 1024);
@@ -493,52 +585,7 @@ class _PostScreenState extends State<PostScreen> {
},
);
},
child: DottedBorder(
strokeWidth: 1,
dashPattern: const [7, 4],
borderType: BorderType.RRect,
radius: Radius.circular(14.r),
color: const Color(0xFF434A53),
child: commonGlassUI(
width: double.infinity,
height: 339.h,
borderRadius: BorderRadius.circular(10.r),
borderColor: Colors.transparent,
customWidget: bannerPath.isNotEmpty &&
isbannerAdded
? Stack(children: [
Image.file(
bannerPath[0]!,
fit: BoxFit.cover,
width: double.infinity,
),
Positioned(
right: 5,
bottom: 5,
child: GestureDetector(
onTap: () {
bannerPath.clear();
isbannerAdded = false;
setState(() {});
},
child: Container(
width: 27,
height: 27,
decoration: ShapeDecoration(
color:
const Color(0xFF7E7E7E),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(
5)),
),
child: const Icon(
Icons.delete_outline_outlined,
color: Colors.white,
))),
),
])
: Padding(
child: Padding(
padding:
EdgeInsets.symmetric(vertical: 16.h),
child: Center(
@@ -561,11 +608,11 @@ class _PostScreenState extends State<PostScreen> {
],
),
),
),
)),
),
),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Tags"),
text16w400_FCFCFC("Interest"),
sizedBoxHeight(18.h),
_isSecondDropdownEnabled == true
? CustomDropDownPopularTag(
@@ -579,7 +626,15 @@ class _PostScreenState extends State<PostScreen> {
},
isFirstDropdownSelected: _isSecondDropdownEnabled,
)
: Center(child: text14400white('Select community')),
:
// SizedBox(),
Center(
child:
// isCommunitySelected == true
// ? text14400white('Select post type')
// :
text14400white('No Interests')),
sizedBoxHeight(25.h),
_isSecondDropdownEnabled == true
? Column(
@@ -612,10 +667,10 @@ class _PostScreenState extends State<PostScreen> {
),
],
)
: SizedBox(),
: const SizedBox(),
sizedBoxHeight(25.h),
globalAccountType == '1'
? SizedBox()
? const SizedBox()
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -680,14 +735,16 @@ class _PostScreenState extends State<PostScreen> {
// Condition for account type 1
if (selectedabilityid.isEmpty ||
selectedpopularid.isEmpty ||
bannerPath.isEmpty ||
captioncontroller.text.isEmpty ||
_selectedPostas.isEmpty) {
_selectedPostas.isEmpty ||
posttagtype.isBlank!) {
print('Tags selected are $selectedpopularid');
print(
'Community selected are $selectedabilityid');
print('Post as selected are $_selectedPostas');
utils.showToast('Please fill all fields');
} else if (bannerPath.isEmpty) {
utils.showToast('Please add a media image');
} else {
print('Tags selected are $selectedpopularid');
print(
@@ -701,15 +758,17 @@ class _PostScreenState extends State<PostScreen> {
// You can define different validation criteria here for account type 2
if (selectedabilityid.isEmpty ||
selectedpopularid.isEmpty ||
bannerPath.isEmpty ||
captioncontroller.text.isEmpty ||
_selectedPostas.isEmpty ||
ctalinkcontroller.text.isEmpty ||
ctatitilecontroller.text.isEmpty) {
ctatitilecontroller.text.isEmpty ||
posttagtype.isBlank!) {
print('Tags selected are $selectedpopularid');
print(
'Community selected are $selectedabilityid');
utils.showToast('Please fill all fields');
} else if (bannerPath.isEmpty) {
utils.showToast('Please add a media image');
} else {
print('Tags selected are $selectedpopularid');
print(
@@ -735,8 +794,8 @@ class _PostScreenState extends State<PostScreen> {
context: context,
builder: (BuildContext context) {
return AlertDialog(
insetPadding: EdgeInsets.symmetric(vertical: 10, horizontal: 15),
contentPadding: EdgeInsets.fromLTRB(24, 8, 24, 24),
insetPadding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15),
contentPadding: const EdgeInsets.fromLTRB(24, 8, 24, 24),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(14.r))),
backgroundColor: const Color(0xFF222935),
@@ -956,6 +1015,7 @@ class _CustomDropDownCheckBoxPostNewState
if (onDropTap.value)
Container(
width: double.infinity,
height: 250.h,
decoration: BoxDecoration(
color: const Color(0xFFFFFFFF).withOpacity(0.10),
borderRadius:
@@ -988,6 +1048,7 @@ class _CustomDropDownCheckBoxPostNewState
)
: ListView.builder(
shrinkWrap: true,
physics: ScrollPhysics(),
itemCount: widget.listData.length,
itemBuilder: (context, index) {
String item = widget.listData[index];
@@ -1198,6 +1259,7 @@ class _CustomDropDownPopularTagState extends State<CustomDropDownPopularTag> {
// Dropdown List
if (onDropTap.value && filteredTags.isNotEmpty)
Container(
height: 250.h,
width: double.infinity,
decoration: BoxDecoration(
color: const Color(0xFFFFFFFF).withOpacity(0.10),
@@ -1208,6 +1270,7 @@ class _CustomDropDownPopularTagState extends State<CustomDropDownPopularTag> {
),
child: ListView.builder(
shrinkWrap: true,
physics: ScrollPhysics(),
itemCount: filteredTags.length,
itemBuilder: (context, index) {
return InkWell(
@@ -1262,10 +1325,10 @@ class _CustomDropDownPopularTagState extends State<CustomDropDownPopularTag> {
label: Text('#${tag.name!}',
style: const TextStyle(color: Colors.white)),
backgroundColor: const Color(0xFFD90B2E).withOpacity(0.9),
side: BorderSide(color: Colors.black),
side: const BorderSide(color: Colors.black),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.r),
side: BorderSide(width: 1, color: Colors.white)),
side: const BorderSide(width: 1, color: Colors.white)),
onDeleted: () {
selectedTags.remove(tag);
widget.onItemSelected(selectedTags.toList());
@@ -1282,220 +1345,55 @@ class _CustomDropDownPopularTagState extends State<CustomDropDownPopularTag> {
}
}
// class CustomDropDownPopularTag extends StatefulWidget {
// final List<Data> tags;
// final Function(List<Data>) onItemSelected;
// final bool isFirstDropdownSelected;
// CustomDropDownPopularTag({
// required this.tags,
// required this.onItemSelected,
// required this.isFirstDropdownSelected,
// });
// @override
// _CustomDropDownPopularTagState createState() =>
// _CustomDropDownPopularTagState();
// }
// class _CustomDropDownPopularTagState extends State<CustomDropDownPopularTag> {
// RxBool onDropTap = false.obs;
// RxList<Data> selectedTags = <Data>[].obs;
// RxList<Data> filteredTags = <Data>[].obs;
// TextEditingController textEditingController = TextEditingController();
// @override
// void initState() {
// super.initState();
// filteredTags.value = widget.tags;
// textEditingController.addListener(() {
// filterTags();
// });
// }
// void _handleDropdownTap() {
// if (widget.isFirstDropdownSelected) {
// onDropTap.value = !onDropTap.value;
// } else {
// utils.showToast('Please select an item from the first dropdown.');
// }
// }
// void filterTags() {
// String query = textEditingController.text.toLowerCase();
// if (query.isNotEmpty) {
// filteredTags.value = widget.tags
// .where((tag) =>
// tag.name!.toLowerCase().contains(query) &&
// !selectedTags.contains(tag))
// .toList();
// } else {
// filteredTags.value =
// widget.tags.where((tag) => !selectedTags.contains(tag)).toList();
// }
// onDropTap.value = filteredTags.isNotEmpty;
// }
// @override
// Widget build(BuildContext context) {
// return Obx(
// () => Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// // Dropdown Search Input
// Container(
// width: double.infinity,
// height: 50,
// padding: const EdgeInsets.symmetric(horizontal: 12),
// decoration: BoxDecoration(
// color: const Color(0xFFFFFFFF).withOpacity(0.10),
// borderRadius: onDropTap.value && filteredTags.isNotEmpty
// ? const BorderRadius.vertical(
// top: Radius.circular(30),
// )
// : BorderRadius.circular(30),
// border: Border.all(color: const Color(0xFF434A53)),
// ),
// child: Center(
// child: TextFormField(
// controller: textEditingController,
// style: const TextStyle(
// fontSize: 16,
// color: Colors.white,
// fontFamily: 'Helvetica',
// ),
// cursorColor: Colors.red,
// obscureText: false,
// decoration: InputDecoration(
// hintText: 'Search Tags',
// hintStyle: const TextStyle(
// fontSize: 16,
// color: Colors.white,
// fontWeight: FontWeight.w400,
// fontFamily: 'Helvetica',
// ),
// suffixIcon: GestureDetector(
// onTap: _handleDropdownTap,
// // () {
// // onDropTap.value = !onDropTap.value;
// // },
// child: SizedBox(
// height: 20,
// width: 20,
// child: Center(
// child: Icon(
// onDropTap.value
// ? Icons.arrow_drop_up
// : Icons.arrow_drop_down,
// color: Colors.white,
// ),
// ),
// ),
// ),
// border: InputBorder.none,
// ),
// onTap: _handleDropdownTap
// // () {
// // onDropTap.value = !onDropTap.value;
// // },
// ),
// ),
// ),
// // Dropdown List
// if (onDropTap.value && filteredTags.isNotEmpty)
// Container(
// width: double.infinity,
// decoration: BoxDecoration(
// color: const Color(0xFFFFFFFF).withOpacity(0.10),
// borderRadius: const BorderRadius.vertical(
// bottom: Radius.circular(30),
// ),
// border: Border.all(color: const Color(0xFF434A53)),
// ),
// child: ListView.builder(
// shrinkWrap: true,
// itemCount: filteredTags.length,
// itemBuilder: (context, index) {
// return InkWell(
// onTap: () {
// Data selectedItem = filteredTags[index];
// if (selectedTags.contains(selectedItem)) {
// selectedTags.remove(selectedItem);
// } else {
// selectedTags.add(selectedItem);
// }
// textEditingController.clear();
// widget.onItemSelected(selectedTags.toList());
// filterTags(); // Update the filtered list
// },
// child: Padding(
// padding: const EdgeInsets.all(10.0),
// child: Row(
// children: [
// Text(
// filteredTags[index].name!,
// style: const TextStyle(
// color: Colors.white,
// fontSize: 16,
// fontWeight: FontWeight.w400,
// fontFamily: 'Helvetica',
// ),
// ),
// const Spacer(),
// Text(
// 'Popularity: ${filteredTags[index].tagPopularity}',
// style: const TextStyle(
// color: Colors.white70,
// fontSize: 12,
// ),
// ),
// ],
// ),
// ),
// );
// },
// ),
// ),
// sizedBoxHeight(20.h),
// // Selected Tags Displayed as Chips
// if (selectedTags.isNotEmpty)
// Wrap(
// spacing: 8.0,
// runSpacing: 4.0,
// children: selectedTags.map((tag) {
// return Chip(
// label: Text('#${tag.name!}',
// style: const TextStyle(color: Colors.white)),
// backgroundColor: const Color(0xFFD90B2E).withOpacity(0.9),
// // Color(0xFFD90B2E).withOpacity(0.90),
// // Colors.transparent, // Make Chip background transparent
// side: BorderSide(color: Colors.black),
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(30.r),
// side: BorderSide(width: 1, color: Colors.white)),
// onDeleted: () {
// selectedTags.remove(tag);
// widget.onItemSelected(selectedTags.toList());
// filterTags(); // Update the filtered list after removing a tag
// },
// materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
// padding: const EdgeInsets.symmetric(horizontal: 16),
// );
// }).toList(),
// ),
// ],
// ),
// );
// }
// }
class CreateData {
final int id;
final String name;
CreateData({required this.id, required this.name});
}
class CustomRadioListTile extends StatelessWidget {
final String title;
final String subtitle;
final String value;
final String? groupValue;
final ValueChanged<String?> onChanged;
final Color activeColor;
const CustomRadioListTile({
Key? key,
required this.title,
required this.subtitle,
required this.value,
required this.groupValue,
required this.onChanged,
required this.activeColor,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
onChanged(value);
},
child: ListTile(
contentPadding: EdgeInsets.zero,
leading: Transform.translate(
offset: Offset(0, -10),
child: Transform.scale(
scale: 1.5,
child: Radio<String>(
value: value,
groupValue: groupValue,
onChanged: onChanged,
activeColor: activeColor,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
),
),
title: text18w400white(title),
subtitle: text14400white(subtitle),
),
);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -59,7 +59,7 @@ List<bool> pinButtonPopular = <bool>[];
RxList<int> commentsCounterComPosts = <int>[].obs;
RxList<int> savePostCounterComPosts = <int>[].obs;
RxList<bool> saveButtonComPosts = <bool>[].obs;
RxList<bool> pinButtonComPosts = <bool>[].obs;
// RxList<bool> pinButtonComPosts = <bool>[].obs;
setListsComPosts() {
likesCounterComPosts.clear();
@@ -73,9 +73,35 @@ List<bool> pinButtonPopular = <bool>[];
.add(commonobjmodel?.data[i].totalCommentCount ?? 0);
savePostCounterComPosts.add(commonobjmodel?.data[i].totalSave ?? 0);
saveButtonComPosts.add(commonobjmodel?.data[i].isISaved ?? false);
pinButtonComPosts
.add(commonobjmodel?.data[i].iamPrincipal?.isUserPinned ?? false);
// pinButtonComPosts
// .add(commonobjmodel?.data[i].iamPrincipal?.isUserPinned ?? false);
}
}
//tagPostPopular
RxList<int> likesCountertagPopular = <int>[].obs;
RxList<int> commentsCountertagPopular = <int>[].obs;
RxList<int> savePostCountertagPopular = <int>[].obs;
setListstagPopular() {
for (var i = 0; i < combinedListGlobal.length; i++) {
likesCounterLatest.add(combinedListGlobal[i].likecount ?? 0);
commentsCounterLatest.add(combinedListGlobal[i].totalCommentCount ?? 0);
savePostCounterLatest.add(combinedListGlobal[i].totalSave ?? 0);
}
}
//tagPostLatest
RxList<int> likesCountertagLatest = <int>[].obs;
RxList<int> commentsCountertagLatest = <int>[].obs;
RxList<int> savePostCountertagLatest = <int>[].obs;
setListstagtagLatest() {
for (var i = 0; i < combinedListGlobal.length; i++) {
likesCounterLatest.add(combinedListGlobal[i].likecount ?? 0);
commentsCounterLatest.add(combinedListGlobal[i].totalCommentCount ?? 0);
savePostCounterLatest.add(combinedListGlobal[i].totalSave ?? 0);
}
}
}

View File

@@ -3,7 +3,6 @@ import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart' hide MultipartFile, FormData;
import 'package:regroup/Common/base_manager.dart';
@@ -155,7 +154,7 @@ class _AddCertificateState extends State<AddCertificate> {
text16400white("Certification name"),
sizedBoxHeight(16.h),
CustomTextFormField(
leadingIcon: Container(
leadingIcon: SizedBox(
height: 17.h,
width: 18.w,
child: Center(
@@ -186,7 +185,7 @@ class _AddCertificateState extends State<AddCertificate> {
text16400white("Certification reason"),
sizedBoxHeight(16.h),
CustomTextFormField(
leadingIcon: Container(
leadingIcon: SizedBox(
height: 17.h,
width: 18.w,
child: Center(

View File

@@ -17,7 +17,7 @@ class EditProfileApi {
EditProfileApi();
Future<ResponseData<dynamic>> postEditProfileIndividual(var data) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
// SharedPreferences prefs = await SharedPreferences.getInstance();
final response =
await NetworkApiServices().postApi(data, ApiUrls.posteditprofile);
@@ -62,7 +62,7 @@ class EditProfileApi {
}
Future<ResponseData<dynamic>> postEditProfileBusiness(var data) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
// SharedPreferences prefs = await SharedPreferences.getInstance();
final response = await NetworkApiServices()
.postApi(data, ApiUrls.posteditprofilebusiness);

View File

@@ -68,7 +68,7 @@ class _FollowersState extends State<Followers> {
int? blockid;
int? removeid;
RemoveUploadata() async {
removeUploadata() async {
utils.loader();
Map<String, dynamic> updata = {
"iam_principal_xid": removeid,
@@ -85,7 +85,7 @@ class _FollowersState extends State<Followers> {
}
}
BlockUploadata() async {
blockUploadata() async {
utils.loader();
Map<String, dynamic> updata = {
"blocked_iam_principal_xid": blockid,
@@ -334,7 +334,7 @@ class _FollowersState extends State<Followers> {
followersobj!.data!.removeWhere((item) =>
item.follower!.id ==
removeid);
RemoveUploadata();
removeUploadata();
});
},
child:
@@ -399,7 +399,7 @@ class _FollowersState extends State<Followers> {
followersobj!.data!.removeWhere((item) =>
item.follower!.id ==
blockid);
BlockUploadata();
blockUploadata();
});
},
child:

View File

@@ -7,6 +7,7 @@ import 'package:flutter/services.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:path/path.dart' as path;
class Helper {
static Future<MultipartFile> networkImageToMultipartFile(
@@ -16,14 +17,24 @@ class Helper {
Response<Uint8List> response = await dio.get<Uint8List>(imageUrl,
options: Options(responseType: ResponseType.bytes));
final cleanedFileName = _cleanFileName(imageUrl);
MultipartFile multipartFile = MultipartFile.fromBytes(
response.data!,
filename: imageUrl.substring(imageUrl.lastIndexOf("/") + 1),
filename: cleanedFileName,
// imageUrl.substring(imageUrl.lastIndexOf("/") + 1),
);
return multipartFile;
}
static String _cleanFileName(String url) {
// Parse the URL and extract the path
final uri = Uri.parse(url);
// Extract the base name from the path, removing any query parameters
return path.basename(uri.path);
}
static Future<MultipartFile> assetImageToMultipartFile(
String assetImagePath, String fileName) async {
ByteData assetByteData = await rootBundle.load(assetImagePath);

View File

@@ -346,6 +346,9 @@ Widget text18w400white(String text, {TextAlign? textAlign}) {
);
}
Widget text14w400white(String text, {TextAlign? textAlign}) {
return Text(
text,

View File

@@ -14,8 +14,42 @@ import 'package:regroup/onboarding/Signup/view_model/postmethod.dart';
import 'package:regroup/resources/routes/route_name.dart';
import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart';
int? _firstSelectedIndex;
bool _isFirstSelectionActive = false;
class ActivityController extends GetxController {
var selectedIndices = <int>[].obs;
var firstSelectedIndex = Rxn<int>();
var isFirstSelectionActive = false.obs;
void onContainerTap(int index) {
if (selectedIndices.contains(index)) {
selectedIndices.remove(index);
if (firstSelectedIndex.value == index) {
// If the first selected container is unselected, reset the active state
firstSelectedIndex.value = null;
isFirstSelectionActive.value = false;
selectedIndices.clear();
}
} else {
if (firstSelectedIndex.value == null) {
// The first item is being selected
firstSelectedIndex.value = index;
isFirstSelectionActive.value = true;
}
selectedIndices.add(index);
}
}
Color getGradientColor(int index) {
if (selectedIndices.isEmpty) {
return Colors.transparent;
} else if (firstSelectedIndex.value == index &&
isFirstSelectionActive.value) {
return Color(0XFFD90B2E);
} else if (selectedIndices.contains(index)) {
return Color(0xFF009DAB);
}
return Colors.transparent;
}
}
class SelectIndividualActivity extends StatefulWidget {
const SelectIndividualActivity({super.key});
@@ -26,8 +60,8 @@ class SelectIndividualActivity extends StatefulWidget {
}
class _SelectIndividualActivityState extends State<SelectIndividualActivity> {
final List<int> _selectedIndices = [];
TextEditingController otheractivitycontroller = TextEditingController();
final ActivityController controller = Get.put(ActivityController());
// to select only two containers
// void _onContainerTap(int index) {
@@ -44,40 +78,6 @@ class _SelectIndividualActivityState extends State<SelectIndividualActivity> {
// });
// }
void _onContainerTap(int index) {
setState(() {
if (_selectedIndices.contains(index)) {
_selectedIndices.remove(index);
if (_firstSelectedIndex == index) {
// If the first selected container is unselected, reset the active state
_firstSelectedIndex = null;
_isFirstSelectionActive = false;
_selectedIndices.clear();
}
} else {
if (_firstSelectedIndex == null) {
// The first item is being selected
_firstSelectedIndex = index;
_isFirstSelectionActive = true;
}
_selectedIndices.add(index);
}
});
}
Color _getGradientColor(int index) {
if (_selectedIndices.isEmpty) {
return Colors.transparent;
} else if (_firstSelectedIndex == index && _isFirstSelectionActive) {
// Apply Color(0XFFD90B2E) to the first selected item
return Color(0XFFD90B2E);
} else if (_selectedIndices.contains(index)) {
// Apply Color(0xFF009DAB) to all other selected items
return Color(0xFF009DAB);
}
return Colors.transparent;
}
// void _onContainerTap(int id) {
// setState(() {
// if (_selectedIndices.contains(id)) {
@@ -114,7 +114,7 @@ class _SelectIndividualActivityState extends State<SelectIndividualActivity> {
Uploadata() async {
utils.loader();
String selectedIndicesString = '[${_selectedIndices.join(',')}]';
String selectedIndicesString = '[${controller.selectedIndices.join(',')}]';
Map<String, dynamic> updata = {
"manage_interest_xid": selectedIndicesString,
"other_interest": otheractivitycontroller.text,
@@ -145,11 +145,11 @@ class _SelectIndividualActivityState extends State<SelectIndividualActivity> {
child: CustomButton(
text: "Continue",
onPressed: () {
if (_selectedIndices.isEmpty &&
if (controller.selectedIndices.isEmpty &&
otheractivitycontroller.text.isEmpty) {
utils.showToast('Please select activity');
} else {
print(_selectedIndices.toString());
print(controller.selectedIndices.toString());
// String selectedIndicesString =
// _selectedIndices.join(',');
// print(
@@ -292,8 +292,7 @@ class _SelectIndividualActivityState extends State<SelectIndividualActivity> {
text20400white(
'What are your interests?'),
// sizedBoxHeight(5.w),
_isFirstSelectionActive
controller.isFirstSelectionActive.value
? text13400A7A7A7(
'Select your secondary interests')
: text13400A7A7A7(
@@ -336,13 +335,7 @@ class _SelectIndividualActivityState extends State<SelectIndividualActivity> {
image: indiactivityobj!
.data![index].image,
// 'assets/images/svg/individualact7.svg',
isSelected: _selectedIndices
.contains(indiactivityobj!
.data![index].id!),
gradientColor: _getGradientColor(
indiactivityobj!
.data![index].id!),
onTap: _onContainerTap,
controller: controller,
);
},
),
@@ -556,33 +549,32 @@ class ActivityContainer extends StatelessWidget {
final int index;
final String titleString;
final String? image;
final bool isSelected;
final Color gradientColor;
final Function(int) onTap;
final ActivityController controller;
ActivityContainer({
required this.index,
required this.titleString,
required this.image,
required this.isSelected,
required this.gradientColor,
required this.onTap,
required this.controller,
});
@override
Widget build(BuildContext context) {
return Obx(
() {
bool isSelected = controller.selectedIndices.contains(index);
Color gradientColor = controller.getGradientColor(index);
return GestureDetector(
onTap: () => onTap(index),
onTap: () => controller.onContainerTap(index),
child: Container(
// width: 110.w,
// height: 120.h,
decoration: ShapeDecoration(
gradient: LinearGradient(
begin: const Alignment(0.98, 0.10),
end: const Alignment(-0.40, -0.70),
colors: isSelected
? _firstSelectedIndex == index &&
_isFirstSelectionActive == true
? controller.firstSelectedIndex.value == index &&
controller.isFirstSelectionActive.value
? [
Color(0xFF009DAB).withOpacity(0.80),
Color(0xFF009DAB).withOpacity(0.77),
@@ -600,8 +592,8 @@ class ActivityContainer extends StatelessWidget {
),
shape: RoundedRectangleBorder(
side: isSelected
? _firstSelectedIndex == index &&
_isFirstSelectionActive == true
? controller.firstSelectedIndex.value == index &&
controller.isFirstSelectionActive.value
? BorderSide(width: 0.4.w, color: Colors.transparent)
: BorderSide(width: 3.w, color: gradientColor)
: BorderSide(width: 2.w, color: Color(0xFF434A53)),
@@ -613,13 +605,6 @@ class ActivityContainer extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// image.isEmpty
// ? SvgPicture.asset(
// "assets/images/svg/individualact7.svg",
// width: 50.w,
// height: 50.h,
// )
// : Image.network(image),
image == null || image!.isEmpty
? Image.asset(
'assets/images/png/redregroup.png',
@@ -627,11 +612,6 @@ class ActivityContainer extends StatelessWidget {
width: 50.w,
height: 50.h,
)
// SvgPicture.asset(
// "assets/images/svg/individualact7.svg",
// width: 50.w,
// height: 50.h,
// )
: Image.network(
image!,
width: 50.w,
@@ -654,5 +634,7 @@ class ActivityContainer extends StatelessWidget {
),
),
);
},
);
}
}

View File

@@ -68,8 +68,8 @@ import 'package:regroup/onboarding/Signup/View/Business/View/busSignupScreen.dar
import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/CommunitySetting.dart';
import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/EditCommunity/EditCommunity.dart';
import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageGroup.dart';
import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageTags.dart/ManageTags.dart';
import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageTags.dart/NewTag/NewTag.dart';
import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageTags.dart/ManageInterest.dart';
import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageTags.dart/View/NewTag/NewTag.dart';
import 'package:regroup/sidemenu/Community/Announcements/AnnouncementRequest.dart';
import 'package:regroup/sidemenu/Community/Announcements/ManageMembers.dart';
import 'package:regroup/sidemenu/Community/Announcements/NewAnnouncement/NewAnnounceent.dart';

View File

@@ -16,7 +16,6 @@ class CommunitySetting extends StatefulWidget {
}
class _CommunitySettingState extends State<CommunitySetting> {
int communityid = Get.arguments['communityid'];
@override
Widget build(BuildContext context) {
@@ -39,11 +38,9 @@ class _CommunitySettingState extends State<CommunitySetting> {
sizedBoxHeight(30.h),
GestureDetector(
onTap: () {
Get.toNamed(RouteName.editcommunity,
arguments: {
Get.toNamed(RouteName.editcommunity, arguments: {
'communityid': communityid,
}
);
});
},
child: rowTile(text: 'Edit community info')),
commonDivider(),
@@ -55,15 +52,21 @@ class _CommunitySettingState extends State<CommunitySetting> {
commonDivider(),
GestureDetector(
onTap: () {
Get.toNamed(RouteName.managegroups);
Get.toNamed(RouteName.managegroups,
arguments: {
'communityid' : communityid,
}
);
},
child: rowTile(text: 'Manage groups')),
commonDivider(),
GestureDetector(
onTap: () {
Get.toNamed(RouteName.managetags);
Get.toNamed(RouteName.managetags, arguments: {
'communityid': communityid,
});
},
child: rowTile(text: 'Manage tags')),
child: rowTile(text: 'Manage interest')),
sizedBoxHeight(20.h),
])
]));

View File

@@ -1,14 +1,13 @@
import 'dart:developer';
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get.dart' hide MultipartFile, FormData;
import 'package:regroup/Common/CommonGlassmorphism.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Main_Screens/ProfileTab/EditProfile/Model/InterestModel.dart'
as primaryactlist;
import 'package:regroup/Utils/Common/CommonAppbar.dart';
import 'package:regroup/Utils/Common/CommonDropdown.dart';
import 'package:regroup/Utils/Common/CustomNextButton.dart';
@@ -19,9 +18,13 @@ import 'package:regroup/Utils/Helper.dart';
import 'package:regroup/Utils/dialogs.dart';
import 'package:regroup/Utils/texts.dart';
import 'package:regroup/Utils/Common/CustomTextformfield.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/Model/activitiesListModel.dart'
as primaryactlist;
import 'package:regroup/sidemenu/Community/MyCommunity/view_model/getmethod.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/view_model/postmethod.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/view_model/primaryactivity.dart';
import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart';
import 'package:path/path.dart' as path;
class EditCommunity extends StatefulWidget {
const EditCommunity({super.key});
@@ -42,9 +45,6 @@ class _EditCommunityState extends State<EditCommunity> {
@override
void initState() {
myfuture = Getcommunity().getCommunityeditpage(communityid);
// communitynameController.text = 'Active alliance network';
// descriptionController.text =
// "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer .";
super.initState();
}
@@ -94,62 +94,189 @@ class _EditCommunityState extends State<EditCommunity> {
});
}
primaryactlist.InterestModel? abilityModel;
List<primaryactlist.Data> activity = [];
primaryactlist.ActivitiesListsModel? abilityModel;
List<primaryactlist.Datum> activity = [];
List<String> _activitydrop = [];
String? selectedActivityName;
String? selectedActivityName = '';
bool isDataLoaded = false;
List<Map<String, dynamic>> _abilityMap = [];
Future<void> fetchActivitylist() async {
PrimaryActivityListApi abilityListAPI = PrimaryActivityListApi();
ResponseData<dynamic> response = await abilityListAPI.getActivitylistApi();
if (response.status == ResponseStatus.SUCCESS) {
abilityModel = primaryactlist.InterestModel.fromJson(response.data!);
abilityModel =
primaryactlist.ActivitiesListsModel.fromJson(response.data!);
setState(() {
activity = abilityModel!.data ?? [];
_activitydrop =
activity.map((platform) => platform.name.toString()).toList();
activity.map((platform) => platform.title.toString()).toList();
_abilityMap = activity.map((platform) {
return {
"id": platform.id,
"name": platform.title.toString(),
};
}).toList();
});
// Ensure dropdown list updates after setting the initial value
// Debugging log for _abilityMap
print('Ability Map: $_abilityMap');
if (communityeditobj != null && communityeditobj!.data != null) {
int abilitiesXids = communityeditobj!.data!.communityData!.activityXid!;
selectedactivityid = abilitiesXids;
String? name = await getSelectedName(selectedactivityid!);
setState(() {
// Set the initial selected activity if data is available
int activitiesXids =
communityeditobj!.data!.communityData!.activityData!.id!;
selectedactivityid = activitiesXids;
selectedActivityName = activity
.firstWhere((item) => item.id == activitiesXids,
orElse: () => activity.first)
.name;
selectedActivityName = name ?? '';
isactivityLoaded = true;
isDataLoaded = true; // Mark data as loaded
});
log(activity.toString());
} else {
print('Failed to fetch abilities');
// Debugging log for selectedActivityName
print('Selected activity ID is $selectedactivityid');
print('Selected activity name is $selectedActivityName');
}
} else {
print('Failed to fetch activities');
setState(() {
isDataLoaded = false; // Ensure loader is not hidden in case of error
});
}
}
Future<String?> getSelectedName(int selectedId) async {
print('Searching for ID: $selectedId in _abilityMap');
for (Map<String, dynamic> ability in _abilityMap) {
if (ability["id"] == selectedId) {
print('Found ability: ${ability["name"]}');
return ability["name"] as String;
}
}
return null;
}
int? selectedactivityid;
void getCatIdFromName(String selectedAbility) {
selectedactivityid = activity
.firstWhere((item) => item.name == selectedAbility,
.firstWhere((item) => item.title == selectedAbility,
orElse: () => activity.first)
.id;
print('Selected activity ID is $selectedactivityid');
}
String _cleanFileName(String filePath) {
return path
.basename(filePath)
.split('?')
.first;
}
Uploadata() async {
utils.loader();
List<MultipartFile> bannermedialist = [];
List<MultipartFile> profielpicturelist = [];
MultipartFile? imageFile;
// for (var file in bannerPath.where((file) => file != null)) {
// bannermedialist.add(
// await MultipartFile.fromFile(
// file!.path,
// filename: path.basename(file.path),
// ),
// );
// }
for (var file in bannerPath.where((file) => file != null)) {
final filePath = file!.path;
final cleanedFileName = _cleanFileName(filePath);
print('Original File Path: $filePath');
print('Cleaned File Name: $cleanedFileName');
bannermedialist.add(
await MultipartFile.fromFile(
filePath,
filename: cleanedFileName,
),
);
}
if (filePath.isNotEmpty && filePath[0] != null) {
var profileFile = filePath[0];
if (profileFile!.path.isNotEmpty) {
// Convert local file to MultipartFile
imageFile = await MultipartFile.fromFile(
profileFile.path,
filename: path.basename(profileFile.path),
);
} else {
// Handle case where file path is empty
imageFile = await Helper.networkImageToMultipartFile(
communityeditobj!.data!.communityData!.communityProfilePhoto!,
);
}
} else if (communityeditobj!.data!.communityData!.communityProfilePhoto !=
null) {
// Handle case where no file is provided, fallback to network image
imageFile = await Helper.networkImageToMultipartFile(
communityeditobj!.data!.communityData!.communityProfilePhoto!,
);
} else {
// Handle case where no profile picture is provided
print('No profile picture provided.');
return;
}
int communityTypeValue = _typeCommunityMap[_selectedtypecommunity] ?? 0;
print('Image File: ${imageFile.filename}');
print(
'Banner Media List: ${bannermedialist.map((file) => file.filename).toList()}');
FormData formdata = FormData.fromMap({
"community_profile_photo": imageFile,
"community_banner_image": bannermedialist[0],
"community_name": communitynameController.text,
"community_location": locationcontroller.text,
"community_description": descriptionController.text,
'community_type_xid': communityTypeValue,
'activity_xid': selectedactivityid,
'community_id': communityid,
});
print('updata is ${formdata.toString()}');
log('log is ${formdata.toString()}');
final data = await PostMethodCommunity().postEditcommunity(formdata);
if (data.status == ResponseStatus.SUCCESS) {
Get.back();
print("community updated");
// Get.toNamed(RouteName.mycommunity);
Get.back();
return utils.showToast(data.message);
} else {
Get.back();
print("community not updated");
return utils.showToast(data.message);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
return GestureDetector(
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
child: Scaffold(
// key: _scaffoldKey1,
backgroundColor: Color(0xFF222935),
extendBody: true,
appBar: CommonAppbar(
titleTxt: "Edit community info",
),
resizeToAvoidBottomInset: false,
resizeToAvoidBottomInset: true,
body: FutureBuilder(
future: myfuture,
builder: (ctx, snapshot) {
@@ -177,8 +304,8 @@ class _EditCommunityState extends State<EditCommunity> {
}
}
if (!isBannerLoaded) {
bannerimage =
communityeditobj!.data!.communityData!.communityBannerImage!;
bannerimage = communityeditobj!
.data!.communityData!.communityBannerImage!;
_loadBannerImage(); // Call only if not already loaded
}
communitynameController.text =
@@ -189,20 +316,29 @@ class _EditCommunityState extends State<EditCommunity> {
communityeditobj!.data!.communityData!.communityLocation!;
websitelinkcontroller.text =
communityeditobj!.data!.communityData!.communityDescription!;
var communityType =
communityeditobj!.data!.communityData!.communityTypeData!.name;
var communityType = communityeditobj!
.data!.communityData!.communityTypeData!.name;
if (_selectedtypecommunity.isEmpty) {
_selectedtypecommunity = communityType ?? 'Public';
}
if (!isactivityLoaded) {
fetchActivitylist();
}
if (!isDataLoaded) {
// Show a loader or a placeholder until data is fully loaded
return const Center(
child: CircularProgressIndicator(
color: Color(0xFFC18948),
),
);
}
return Stack(children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/png/Ellipse 1496.png"),
image:
AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill)),
),
SingleChildScrollView(
@@ -249,8 +385,8 @@ class _EditCommunityState extends State<EditCommunity> {
.communityData!
.communityProfilePhoto!,
fit: BoxFit.cover,
errorBuilder:
(context, error, stackTrace) {
errorBuilder: (context, error,
stackTrace) {
// Error handling when image fails to load
return Image.asset(
"assets/images/png/Ellipse 37.png",
@@ -297,7 +433,8 @@ class _EditCommunityState extends State<EditCommunity> {
color: Color(0xFFD90B2E),
shape: BoxShape.circle,
border: Border.all(
color: Color(0xFFD90B2E), width: 0.5.w)),
color: Color(0xFFD90B2E),
width: 0.5.w)),
child: Center(
child: Image.asset(
'assets/images/png/cameraicon.png',
@@ -330,7 +467,8 @@ class _EditCommunityState extends State<EditCommunity> {
width: double.infinity,
height: 150.h,
borderRadius: BorderRadius.circular(10.r),
customWidget: bannerPath.isNotEmpty && isbannerAdded
customWidget:
bannerPath.isNotEmpty && isbannerAdded
? Stack(
children: [
Image.file(
@@ -338,33 +476,6 @@ class _EditCommunityState extends State<EditCommunity> {
fit: BoxFit.cover,
width: double.infinity,
),
// Positioned(
// right: 5,
// bottom: 5,
// child: InkWell(
// onTap: () {
// setState(() {
// bannerPath.clear();
// isbannerAdded = false;
// });
// },
// child: Container(
// width: 27,
// height: 27,
// decoration: ShapeDecoration(
// color: Color(0xFF7E7E7E),
// shape: RoundedRectangleBorder(
// borderRadius:
// BorderRadius.circular(5),
// ),
// ),
// child: Icon(
// Icons.delete_outline_outlined,
// color: Colors.white,
// ),
// ),
// ),
// ),
],
)
: GestureDetector(
@@ -381,7 +492,8 @@ class _EditCommunityState extends State<EditCommunity> {
int fileSizeInBytes =
file.lengthSync();
double fileSizeInMB =
fileSizeInBytes / (1024 * 1024);
fileSizeInBytes /
(1024 * 1024);
if (fileSizeInMB > 10) {
// Show toast message if the file size exceeds 10 MB
@@ -407,8 +519,8 @@ class _EditCommunityState extends State<EditCommunity> {
);
},
child: Padding(
padding:
EdgeInsets.symmetric(vertical: 16.h),
padding: EdgeInsets.symmetric(
vertical: 16.h),
child: Column(
children: [
Image.asset(
@@ -422,9 +534,11 @@ class _EditCommunityState extends State<EditCommunity> {
SizedBox(height: 8.h),
SizedBox(
width: 270.w,
child: Center(
child: text8w400_8A8A8A(
"Allowed file extensions: jpg, png, gif Max file size: 10 MB"),
),
),
],
),
),
@@ -439,8 +553,8 @@ class _EditCommunityState extends State<EditCommunity> {
borderRadius: BorderRadius.circular(10.r),
customWidget: Center(
child: Padding(
padding:
EdgeInsets.symmetric(horizontal: 12.w),
padding: EdgeInsets.symmetric(
horizontal: 12.w),
child: Row(
children: [
// Conditionally render image or placeholder
@@ -553,30 +667,49 @@ class _EditCommunityState extends State<EditCommunity> {
text16w400_FCFCFC("Primary activity*"),
sizedBoxHeight(14.h),
CustomDropDownRadio(
showOtherOption: true,
showOtherOption: false,
header: "",
title: "",
listData: _activitydrop,
onItemSelected: getCatIdFromName,
leadingImage: SizedBox(),
initialSelectedValue: selectedActivityName.toString(),
),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Website link"),
sizedBoxHeight(14.h),
CustomTextFormField(
textEditingController: websitelinkcontroller,
validator: (val) {
if (!isValidWebBannerLink(val)) {
return 'Please enter a valid web banner link.';
}
return null;
},
hintText: 'Enter website link',
initialSelectedValue: selectedActivityName ?? '',
),
sizedBoxHeight(25.h),
// text16w400_FCFCFC("Website link"),
// sizedBoxHeight(14.h),
// CustomTextFormField(
// textEditingController: websitelinkcontroller,
// validator: (val) {
// if (!isValidWebBannerLink(val)) {
// return 'Please enter a valid web banner link.';
// }
// return null;
// },
// hintText: 'Enter website link',
// ),
// sizedBoxHeight(25.h),
sizedBoxHeight(50.h),
CustomButton(text: 'Save changes', onPressed: () {}),
CustomButton(
text: 'Save changes',
onPressed: () {
if (bannerPath.isEmpty ||
communitynameController.text.isEmpty ||
_selectedtypecommunity.isEmpty ||
locationcontroller.text.isEmpty ||
selectedactivityid.isBlank!) {
utils.showToast('Please fill all fields');
}
// else if (filePath.isEmpty) {
// utils.showToast(
// 'Please add community profile picture');
// }
else {
print('done');
Uploadata();
}
}),
sizedBoxHeight(50.h),
],
),
@@ -585,6 +718,7 @@ class _EditCommunityState extends State<EditCommunity> {
)
]);
},
));
)),
);
}
}

View File

@@ -1,12 +1,26 @@
import 'dart:async';
import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:regroup/Common/CommonGlassmorphism.dart';
import 'package:regroup/Common/CommonWidget.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Utils/Common/CommonAppbar.dart';
import 'package:regroup/Utils/Common/CustomTextformfield.dart';
import 'package:regroup/Utils/Common/sized_box.dart';
import 'package:regroup/Utils/dialogs.dart';
import 'package:regroup/Utils/texts.dart';
import 'package:regroup/resources/routes/route_name.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/Model/communitymanageGroupsModel.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/view_model/getmethod.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/view_model/postmethod.dart';
import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart';
class ManageGroups extends StatefulWidget {
const ManageGroups({super.key});
@@ -16,63 +30,78 @@ class ManageGroups extends StatefulWidget {
}
class _ManageGroupsState extends State<ManageGroups> {
List groupData = [
{
"imagePath": "assets/images/png/img45.png",
"title": "Iron titans fitness crew",
"subtitle": "Lorem ipsum dummy text",
},
{
"imagePath": "assets/images/png/Rectangle 25.png",
"title": "Body blitz brigade",
"subtitle": "Lorem ipsum dummy text",
},
{
"imagePath": "assets/images/png/img2.png",
"title": "Fit fusion squad",
"subtitle": "Lorem ipsum dummy text",
},
{
"imagePath": "assets/images/png/img2.png",
"title": "Power pulse posse",
"subtitle": "Lorem ipsum dummy text",
},
{
"imagePath": "assets/images/png/img2.png",
"title": "Wellness warriors collective",
"subtitle": "Lorem ipsum dummy text",
},
];
int communityid = Get.arguments['communityid'];
StreamController<CommunityManageGroupsModel> searchcontroller =
StreamController();
@override
void initState() {
print(communityid);
var updata = communityid;
var updata2 = "";
Getcommunity().getCommunityManageGroupssearch(updata, updata2,
streamController: searchcontroller);
super.initState();
}
@override
void dispose() {
searchcontroller.close();
super.dispose();
}
int? removeid;
RemoveUploadata(int remove) async {
utils.loader();
Map<String, dynamic> updata = {
"manage_community_xid": communityid,
"manage_group_xid": removeid,
};
final data = await PostMethodCommunity().postGroupsRemove(updata);
if (data.status == ResponseStatus.SUCCESS) {
Get.back();
print("remove done");
return utils.showToast(data.message);
} else {
Get.back();
print("remove not done");
return utils.showToast(data.message);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
return GestureDetector(
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
child: Scaffold(
// key: _scaffoldKey1,
backgroundColor: Color(0xFF222935),
extendBody: true,
resizeToAvoidBottomInset: false,
appBar: CommonAppbar(
titleTxt: "Manage groups",
customActionWidget: InkWell(
onTap: () {},
child: Container(
height: 35.h,
width: 35.w,
decoration: BoxDecoration(
color: Color(0xFFD90B2E),
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Color(0x40000000),
offset: Offset(0, 6),
blurRadius: 8,
spreadRadius: 0,
),
],
),
child: Icon(Icons.add, color: Colors.white, weight: 2),
),
),
// customActionWidget: InkWell(
// onTap: () {},
// child: Container(
// height: 35.h,
// width: 35.w,
// decoration: BoxDecoration(
// color: Color(0xFFD90B2E),
// shape: BoxShape.circle,
// boxShadow: [
// BoxShadow(
// color: Color(0x40000000),
// offset: Offset(0, 6),
// blurRadius: 8,
// spreadRadius: 0,
// ),
// ],
// ),
// child: Icon(Icons.add, color: Colors.white, weight: 2),
// ),
// ),
),
body: Stack(children: [
Container(
@@ -81,8 +110,7 @@ class _ManageGroupsState extends State<ManageGroups> {
image: AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill)),
),
SingleChildScrollView(
child: Column(children: [
Column(children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Column(
@@ -102,6 +130,14 @@ class _ManageGroupsState extends State<ManageGroups> {
),
),
hintText: "Search groups",
inputFormatters: [
RemoveEmojiInputFormatter(),
],
onInput: (value) {
Getcommunity().getCommunityManageGroupssearch(
communityid, value,
streamController: searchcontroller);
},
),
sizedBoxHeight(25.h),
Row(
@@ -130,29 +166,264 @@ class _ManageGroupsState extends State<ManageGroups> {
],
),
sizedBoxHeight(30.h),
GestureDetector(
onTap: () async {
List<File?> filePath = [];
List<File?> bannerPath = [];
var result =
await Get.toNamed(RouteName.addgroup, arguments: {
'communityname': "",
'communitylocation': "",
'communitydescription': "",
'communitytype': 0,
'activityid': 0,
'communityprofilephoto': filePath,
'communitybannerimage': bannerPath,
'isedited': true,
'communityid': communityid.toString(),
});
if (result != null && result) {
setState(() {
Getcommunity().getCommunityManageGroupssearch(
communityid, '',
streamController: searchcontroller);
});
}
},
child: Row(
children: [
commonGlassUI(
opacity1: 0.24,
opacity2: 0.24,
width: 50.w,
height: 50.h,
borderRadius: BorderRadius.circular(100),
customWidget: Center(
child: Image.asset(
"assets/images/png/ion_add.png",
height: 30.h,
width: 30.w,
)),
borderwidth: 0.5),
sizedBoxWidth(8.w),
text18w400_FCFCFC("Add existing groups"),
Spacer(),
Icon(
Icons.arrow_forward_ios_outlined,
color: Colors.white,
size: 14.sp,
),
],
),
),
sizedBoxHeight(30.h),
text18w700white("Groups"),
sizedBoxHeight(20.h),
]),
),
ListView.builder(
Expanded(
child: StreamBuilder<CommunityManageGroupsModel>(
stream: searchcontroller.stream,
builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
// Display shimmer effect while waiting for data
return const Center(child: CircularProgressIndicator());
} else if (snapshot.hasError) {
// Handle error state
return Center(
child: Text(
'${snapshot.error} occurred',
style: const TextStyle(fontSize: 18),
),
);
} else {
// Data has been loaded, show actual UI
return communitymanagegroupsobj!.data.isEmpty
? _buildNoDataBody(context)
: ListView.separated(
physics: const ScrollPhysics(),
shrinkWrap: true,
itemCount: groupData.length,
itemCount: communitymanagegroupsobj!.data.length,
separatorBuilder:
(BuildContext context, int index) {
return commonDivider();
},
itemBuilder: (context, index) {
var mainGroupsData =
communitymanagegroupsobj!.data[index];
return Column(
children: [
groupWidget(
imagePath: groupData[index]["imagePath"],
title: groupData[index]["title"],
subtitle: groupData[index]["subtitle"]),
Padding(
padding: EdgeInsets.symmetric(
vertical: 16.h, horizontal: 16.w),
child: Row(
children: [
mainGroupsData.groupsData!
.groupImage ==
null ||
mainGroupsData.groupsData!
.groupImage!.isEmpty
? CircleAvatar(
backgroundImage: AssetImage(
'assets/images/png/img45.png'),
radius: 20.r,
)
: CircleAvatar(
backgroundImage:
CachedNetworkImageProvider(
mainGroupsData.groupsData!
.groupImage!,
),
radius: 25.r,
child: CachedNetworkImage(
cacheKey: mainGroupsData
.groupsData!.id
.toString(),
maxHeightDiskCache: 100,
maxWidthDiskCache: 100,
imageUrl: mainGroupsData
.groupsData!
.groupImage!,
placeholder:
(context, url) =>
Container(),
errorWidget:
(context, url, error) =>
Icon(Icons.error),
imageBuilder: (context,
imageProvider) =>
CircleAvatar(
backgroundImage:
imageProvider,
radius: 25.r,
),
),
),
sizedBoxWidth(10.w),
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
mainGroupsData.groupsData!
.title ==
null ||
mainGroupsData
.groupsData!
.title!
.isEmpty
? text16w400_FCFCFC(
'ReGroup')
:
// text16w400_FCFCFC( mainGroupsData.groupsData!.title!),
Text(
mainGroupsData
.groupsData!.title!,
overflow: TextOverflow
.ellipsis,
style: TextStyle(
fontSize: 16.sp,
color: const Color(
0xFFFCFCFC),
fontFamily:
'Helvetica',
fontWeight:
FontWeight
.w400),
),
sizedBoxHeight(4.h),
mainGroupsData.groupsData!
.description ==
null ||
mainGroupsData
.groupsData!
.description!
.isEmpty
? text12w400_FCFCFC_blur(
'ReGroup')
: Text(
mainGroupsData
.groupsData!
.description!,
overflow: TextOverflow
.ellipsis,
style: TextStyle(
fontSize: 12.sp,
color: const Color(
0xFFFCFCFC)
.withOpacity(
0.8),
fontFamily:
'Helvetica',
fontWeight:
FontWeight
.w400),
),
],
),
),
Spacer(),
InkWell(
onTap: () async {
setState(() {
removeid =
communitymanagegroupsobj!
.data[index]
.manageGroupXid ??
0;
communitymanagegroupsobj!.data
.removeWhere((item) =>
item.manageGroupXid ==
removeid);
print(removeid.toString());
RemoveUploadata(removeid!);
});
},
child: Image.asset(
'assets/images/png/Group 1000004149.png',
),
)
// Icon(
// Icons.clear,
// color: Color(0xFFFFFFFF),
// weight: 1.88,
// )
],
),
),
commonDivider(),
],
);
},
)
]),
)
]));
);
}
},
),
),
])
])),
);
}
}
Widget _buildNoDataBody(context) {
return Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"No Groups Found",
style: TextStyle(
color: Colors.white,
fontSize: 16.sp,
fontWeight: FontWeight.w600),
)
],
),
);
}
Widget groupWidget({
@@ -178,11 +449,14 @@ Widget groupWidget({
],
),
Spacer(),
Icon(
Icons.clear,
color: Color(0xFFFFFFFF),
weight: 1.88,
Image.asset(
'assets/images/png/Group 1000004149.png',
)
// Icon(
// Icons.clear,
// color: Color(0xFFFFFFFF),
// weight: 1.88,
// )
],
),
);

View File

@@ -19,6 +19,8 @@ class ManageTags extends StatefulWidget {
}
class _ManageTagsState extends State<ManageTags> {
int communityid = Get.arguments['communityid'];
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -26,7 +28,7 @@ class _ManageTagsState extends State<ManageTags> {
backgroundColor: Color(0xFF222935),
extendBody: true,
appBar: CommonAppbar(
titleTxt: "Manage tags",
titleTxt: "Manage interest",
),
resizeToAvoidBottomInset: false,
body: Stack(children: [
@@ -45,7 +47,7 @@ class _ManageTagsState extends State<ManageTags> {
child: Column(children: [
CommonTabBar(tabs: const [
Tab(
text: 'Tags',
text: 'Interest',
),
Tab(
text: 'Tag requests',
@@ -79,7 +81,9 @@ class _ManageTagsState extends State<ManageTags> {
),
child: FloatingActionButton(
onPressed: () {
Get.toNamed(RouteName.newtag);
Get.toNamed(RouteName.newtag, arguments: {
'communityid': communityid,
});
},
backgroundColor: Color(0xFFD90B2E),
autofocus: true,
@@ -102,7 +106,7 @@ Widget tagsTab() {
sizedBoxHeight(25.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: text16400white("Special Announcement Tags"),
child: text16400white("Special Announcement Interest"),
),
sizedBoxHeight(15.h),
ListView.builder(

View File

@@ -1,60 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:regroup/Utils/Common/CommonAppbar.dart';
import 'package:regroup/Utils/Common/CustomNextButton.dart';
import 'package:regroup/Utils/Common/CustomTextformfield.dart';
import 'package:regroup/Utils/Common/sized_box.dart';
import 'package:regroup/Utils/texts.dart';
class NewTag extends StatefulWidget {
const NewTag({super.key});
@override
State<NewTag> createState() => _NewTagState();
}
class _NewTagState extends State<NewTag> {
@override
Widget build(BuildContext context) {
return Scaffold(
// key: _scaffoldKey1,
backgroundColor: Color(0xFF222935),
extendBody: true,
appBar: CommonAppbar(
titleTxt: "New tag",
),
resizeToAvoidBottomInset: false,
body: Stack(children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill)),
),
SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.end,
children: [
sizedBoxHeight(30.h),
text16w400_FCFCFC("Tag name"),
sizedBoxHeight(16.h),
CustomTextFormField(
hintText: "",
validator: (val) {
if (val == null || val.isEmpty) {
return 'Enter a tag name';
}
return null;
},
),
sizedBoxHeight(80.h),
CustomButton(text: "Add", onPressed: () {})
]),
))
]));
}
}

View File

@@ -0,0 +1,143 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Utils/Common/CommonAppbar.dart';
import 'package:regroup/Utils/Common/CustomNextButton.dart';
import 'package:regroup/Utils/Common/CustomTextformfield.dart';
import 'package:regroup/Utils/Common/sized_box.dart';
import 'package:regroup/Utils/dialogs.dart';
import 'package:regroup/Utils/texts.dart';
import 'package:regroup/sidemenu/Community/Admin/PopupItem/Community%20settings/ManageTags.dart/ViewModel/maanageInterestApi.dart';
enum Interests { tag1, tag2 }
class NewTag extends StatefulWidget {
const NewTag({super.key});
@override
State<NewTag> createState() => _NewTagState();
}
class _NewTagState extends State<NewTag> {
int communityid = Get.arguments['communityid'];
Interests? _tags = Interests.tag1;
final interestController = TextEditingController();
addSuccess() async {
String isSpecialValue = _tags == Interests.tag1 ? "0" : "1";
Map<String, dynamic> updata = {
"manage_community_xid": communityid.toString(),
"name": interestController.text,
"is_special": isSpecialValue,
};
final data = await ManageInterestApi().postNewInterest(updata);
if (data.status == ResponseStatus.SUCCESS) {
print("success");
Get.back();
return utils.showToast(data.message);
} else {
// Get.back();
print("Failed");
return utils.showToast(data.message);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
// key: _scaffoldKey1,
backgroundColor: const Color(0xFF222935),
extendBody: true,
appBar: const CommonAppbar(
titleTxt: "New interest",
),
resizeToAvoidBottomInset: false,
body: Stack(children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill)),
),
SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.end,
children: [
sizedBoxHeight(30.h),
text16w400_FCFCFC("Interest name"),
sizedBoxHeight(16.h),
CustomTextFormField(
textEditingController: interestController,
hintText: "",
validator: (val) {
if (val == null || val.isEmpty) {
return 'Enter a interest name';
}
return null;
},
),
sizedBoxHeight(40.h),
text16w400_FCFCFC("Nature of interest"),
sizedBoxHeight(40.h),
Row(
children: [
Transform.scale(
scale: 1.2,
child: Radio<Interests>(
fillColor:
const MaterialStatePropertyAll(Color(0xFFD90B2E)),
activeColor: const Color(0xFFD90B2E),
value: Interests.tag1,
groupValue: _tags,
onChanged: (Interests? val) {
setState(() {
_tags = val;
});
},
),
),
text18w400white("Special Announcement Tag")
],
),
sizedBoxHeight(10.h),
Row(
children: [
Transform.scale(
scale: 1.2,
child: Radio<Interests>(
fillColor:
const MaterialStatePropertyAll(Color(0xFFD90B2E)),
activeColor: const Color(0xFFD90B2E),
value: Interests.tag2,
groupValue: _tags,
onChanged: (Interests? val) {
setState(() {
_tags = val;
});
},
),
),
text18w400white("Standard Tag")
],
),
sizedBoxHeight(80.h),
CustomButton(
text: "Add",
onPressed: () {
if (interestController.text.isBlank!) {
utils.showToast("Enter your interest");
} else {
addSuccess();
}
})
]),
))
]));
}
}

View File

@@ -0,0 +1,36 @@
// InviteComModel ? inviteComobj;
import 'package:regroup/Common/api_urls.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Common/controller/data/network/network_api.dart';
import 'package:regroup/Utils/dialogs.dart';
class ManageInterestApi {
Future<ResponseData<dynamic>> postNewInterest(updata) async {
print("updata is $updata");
final response = await NetworkApiServices().postApi(
updata,
ApiUrls.postnewinterest,
);
if (response.status == ResponseStatus.SUCCESS) {
if (response.data["status"] == "success") {
// likepostobj = LikepostModel.fromJson(response.data);
}
return ResponseData<dynamic>(
response.data['message'], ResponseStatus.SUCCESS,
data: response.data);
} else if (response.status == ResponseStatus.FAILED) {
if (response.data["status"] == "error") {
utils.showToast(response.message);
}
return ResponseData<dynamic>(
response.data['message'], ResponseStatus.FAILED,
data: response.data);
} else {
return ResponseData<dynamic>(
response.data['message'], ResponseStatus.FAILED);
}
}
}

View File

@@ -46,7 +46,9 @@ class _CommunityMembersState extends State<CommunityMembers> {
@override
Widget build(BuildContext context) {
return Scaffold(
return GestureDetector(
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
child: Scaffold(
backgroundColor: const Color(0xFF222935),
extendBody: true,
appBar: const CommonAppbar(
@@ -244,6 +246,7 @@ class _CommunityMembersState extends State<CommunityMembers> {
]),
)
]),
),
);
}

View File

@@ -65,6 +65,8 @@ class _AddGroupState extends State<AddGroup> {
String communitydescription = Get.arguments["communitydescription"];
List<File?> filepath = Get.arguments['communityprofilephoto'];
List<File?> bannerPath = Get.arguments['communitybannerimage'];
bool edited = Get.arguments['isedited'];
String communityid = Get.arguments['communityid'];
StreamController<CommunityAddgroupsModel> searchcontroller =
StreamController();
@@ -72,8 +74,8 @@ class _AddGroupState extends State<AddGroup> {
@override
void initState() {
var updata = "";
Getcommunity()
.getCommunityAddGroupsearch(updata, streamController: searchcontroller);
Getcommunity().getCommunityAddGroupsearch(updata, communityid,
streamController: searchcontroller);
super.initState();
}
@@ -150,9 +152,39 @@ class _AddGroupState extends State<AddGroup> {
}
}
ManageGroupsUploadata() async {
utils.loader();
String selectedIndicesString = '[${_selectedIndices.join(',')}]';
print('Selected Indices: $selectedIndicesString');
Map<String, dynamic> updata = {
"manage_community_xid": communityid,
"manage_groups_xid": selectedIndicesString,
};
print('updata is ${updata.toString()}');
log('log is ${updata.toString()}');
final data = await PostMethodCommunity().postmanageaddgroupscommunity(updata);
if (data.status == ResponseStatus.SUCCESS) {
Get.back();
print("groups added");
// Get.back();
return utils.showToast(data.message);
} else {
Get.back();
print("groups not added");
return utils.showToast(data.message);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
return WillPopScope(
onWillPop: () async {
edited == true ? Get.back(result: true) : Get.back();
return true;
},
child: GestureDetector(
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
child: Scaffold(
// key: _scaffoldKey1,
backgroundColor: Color(0xFF222935),
extendBody: true,
@@ -167,7 +199,8 @@ class _AddGroupState extends State<AddGroup> {
onPressed: () {
// Get.toNamed(RouteName.mycommunity);
print('selected groups are ${_selectedIndices.toString()}');
Uploadata();
edited == true ? ManageGroupsUploadata() : Uploadata();
},
),
),
@@ -200,7 +233,8 @@ class _AddGroupState extends State<AddGroup> {
),
hintText: "Search groups",
onInput: (value) {
Getcommunity().getCommunityAddGroupsearch(value,
Getcommunity().getCommunityAddGroupsearch(
value, communityid,
streamController: searchcontroller);
},
),
@@ -239,7 +273,8 @@ class _AddGroupState extends State<AddGroup> {
StreamBuilder<CommunityAddgroupsModel>(
stream: searchcontroller.stream,
builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
return const Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
@@ -269,8 +304,8 @@ class _AddGroupState extends State<AddGroup> {
return Column(
children: [
groupWidget(
index:
communityaddgroupobj!.data[index].id!,
index: communityaddgroupobj!
.data[index].id!,
imagePath: communityaddgroupobj!
.data[index].groupImage ??
'',
@@ -282,7 +317,8 @@ class _AddGroupState extends State<AddGroup> {
// isCheckedList[index],
onCheckedChanged: (bool? value) {
// isCheckedList[index] = value ?? false;
_onContainerTap(communityaddgroupobj!
_onContainerTap(
communityaddgroupobj!
.data[index].id!);
},
),
@@ -296,7 +332,9 @@ class _AddGroupState extends State<AddGroup> {
sizedBoxHeight(50.h),
]),
)
]));
])),
),
);
}
Widget _buildNoDataBody(context) {

View File

@@ -80,7 +80,7 @@ class Datum {
final bool? isILiked;
final bool? isIFollow;
final bool? isISaved;
final dynamic likeIcon;
final LikeIcon? likeIcon;
final int? totalComment;
final int? totalSave;
final List<int> tagsXid;
@@ -116,7 +116,8 @@ class Datum {
isILiked: json["is_i_liked"],
isIFollow: json["is_i_follow"],
isISaved: json["is_i_saved"],
likeIcon: json["likeIcon"],
// likeIcon: json["likeIcon"],
likeIcon: json["likeIcon"] == null ? null : LikeIcon.fromJson(json["likeIcon"]),
totalComment: json["total_comment"],
totalSave: json["total_save"],
tagsXid: json["tags_xid"] == null
@@ -164,6 +165,42 @@ class AttachTag {
}
}
class LikeIcon {
LikeIcon({
required this.likeIconsXid,
required this.likeIcon,
});
final int? likeIconsXid;
final LikeIconClass? likeIcon;
factory LikeIcon.fromJson(Map<String, dynamic> 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<String, dynamic> json){
return LikeIconClass(
id: json["id"],
image: json["image"],
);
}
}
class ManageTag {
ManageTag({
required this.id,

View File

@@ -0,0 +1,44 @@
class ActivitiesListsModel {
ActivitiesListsModel({
required this.status,
required this.statusCode,
required this.message,
required this.data,
});
final String? status;
final int? statusCode;
final String? message;
final List<Datum> data;
factory ActivitiesListsModel.fromJson(Map<String, dynamic> json){
return ActivitiesListsModel(
status: json["status"],
statusCode: json["status_code"],
message: json["message"],
data: json["data"] == null ? [] : List<Datum>.from(json["data"]!.map((x) => Datum.fromJson(x))),
);
}
}
class Datum {
Datum({
required this.id,
required this.title,
required this.image,
});
final int? id;
final String? title;
final String? image;
factory Datum.fromJson(Map<String, dynamic> json){
return Datum(
id: json["id"],
title: json["title"],
image: json["image"],
);
}
}

View File

@@ -0,0 +1,80 @@
class CommunityManageGroupsModel {
CommunityManageGroupsModel({
required this.status,
required this.statusCode,
required this.message,
required this.data,
});
final String? status;
final int? statusCode;
final String? message;
final List<Datum> data;
factory CommunityManageGroupsModel.fromJson(Map<String, dynamic> json){
return CommunityManageGroupsModel(
status: json["status"],
statusCode: json["status_code"],
message: json["message"],
data: json["data"] == null ? [] : List<Datum>.from(json["data"]!.map((x) => Datum.fromJson(x))),
);
}
}
class Datum {
Datum({
required this.id,
required this.manageCommunityXid,
required this.manageGroupXid,
required this.groupsData,
});
final int? id;
final int? manageCommunityXid;
final int? manageGroupXid;
final GroupsData? groupsData;
factory Datum.fromJson(Map<String, dynamic> json){
return Datum(
id: json["id"],
manageCommunityXid: json["manage_community_xid"],
manageGroupXid: json["manage_group_xid"],
groupsData: json["groups_data"] == null ? null : GroupsData.fromJson(json["groups_data"]),
);
}
}
class GroupsData {
GroupsData({
required this.id,
required this.manageGroupTypeXid,
required this.title,
required this.backgroundImage,
required this.groupImage,
required this.description,
required this.totalMember,
});
final int? id;
final int? manageGroupTypeXid;
final String? title;
final String? backgroundImage;
final String? groupImage;
final String? description;
final int? totalMember;
factory GroupsData.fromJson(Map<String, dynamic> json){
return GroupsData(
id: json["id"],
manageGroupTypeXid: json["manage_group_type_xid"],
title: json["title"],
backgroundImage: json["background_image"],
groupImage: json["group_image"],
description: json["description"],
totalMember: json["total_member"],
);
}
}

View File

@@ -2,17 +2,12 @@ import 'dart:developer';
import 'dart:io';
import 'dart:async';
import 'package:dio/dio.dart';
import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart' hide MultipartFile, FormData;
import 'package:get/get_connect/http/src/utils/utils.dart';
import 'package:regroup/Common/CommonButton.dart';
import 'package:regroup/Common/CommonGlassmorphism.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Main_Screens/ProfileTab/EditProfile/Model/InterestModel.dart'
as primaryactlist;
import 'package:regroup/Utils/Common/CommonAppbar.dart';
import 'package:regroup/Utils/Common/CommonDropdown.dart';
import 'package:regroup/Utils/Common/CustomNextButton.dart';
@@ -23,7 +18,8 @@ import 'package:regroup/Utils/Common/sized_box.dart';
import 'package:regroup/Utils/dialogs.dart';
import 'package:regroup/Utils/texts.dart';
import 'package:regroup/resources/routes/route_name.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/view_model/postmethod.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/Model/activitiesListModel.dart'
as primaryactlist;
import 'package:regroup/sidemenu/Community/MyCommunity/view_model/primaryactivity.dart';
import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart';
import 'package:path/path.dart' as path;
@@ -60,8 +56,8 @@ class _NewCommunityState extends State<NewCommunity> {
});
}
primaryactlist.InterestModel? abilityModel;
List<primaryactlist.Data> activity = [];
primaryactlist.ActivitiesListsModel? abilityModel;
List<primaryactlist.Datum> activity = [];
List<String> _activitydrop = [];
Future<void> fetchActivitylist() async {
@@ -69,11 +65,12 @@ class _NewCommunityState extends State<NewCommunity> {
ResponseData<dynamic> response = await abilityLsitAPI.getActivitylistApi();
if (response.status == ResponseStatus.SUCCESS) {
abilityModel = primaryactlist.InterestModel.fromJson(response.data!);
abilityModel =
primaryactlist.ActivitiesListsModel.fromJson(response.data!);
setState(() {
activity = abilityModel!.data ?? []; // Store the fetched cities
activity = abilityModel?.data ?? []; // Store the fetched cities
_activitydrop =
activity.map((platform) => platform.name.toString()).toList();
activity.map((platform) => platform.title.toString()).toList();
});
log(activity.toString());
} else {
@@ -89,7 +86,7 @@ class _NewCommunityState extends State<NewCommunity> {
// Find and add the ID of the selected ability
for (var activityItem in activity) {
if (selectedAbility == activityItem.name) {
if (selectedAbility == activityItem.title) {
selectedactivityid = activityItem.id!;
break; // Stop once the matching item is found
}
@@ -160,7 +157,7 @@ class _NewCommunityState extends State<NewCommunity> {
// key: _scaffoldKey1,
backgroundColor: Color(0xFF222935),
extendBody: true,
resizeToAvoidBottomInset: false,
resizeToAvoidBottomInset: true,
appBar: CommonAppbar(
titleTxt: "New community",
),
@@ -444,18 +441,21 @@ class _NewCommunityState extends State<NewCommunity> {
print('done');
// indiUploadata();
// Uploadata();
int communityTypeValue = _TypecommunityMap[_selectedtypecommunity] ?? 0;
int communityTypeValue =
_TypecommunityMap[_selectedtypecommunity] ?? 0;
Get.toNamed(RouteName.addgroup, arguments: {
'communityname': communitycontroller.text,
'communitylocation': locationcontroller.text,
'communitydescription' : communitydescrcontroller.text,
'communitydescription':
communitydescrcontroller.text,
'communitytype': communityTypeValue,
'activityid': selectedactivityid,
'communityprofilephoto': filePath,
'communitybannerimage': bannerPath,
'isedited' : false,
'communityid' : "",
});
}
},
),

View File

@@ -7,6 +7,9 @@ import 'package:regroup/Common/CommonTabBar.dart';
import 'package:regroup/Common/CommonWidget.dart';
import 'package:regroup/Common/ConvertServerDateToUserDate.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Common/controller/NormalPostCard.dart';
import 'package:regroup/Main_Screens/Community/Model/CommonDatumObjModel.dart';
import 'package:regroup/Main_Screens/Community/Model/fetchicons.dart';
import 'package:regroup/Main_Screens/Community/ViewModel/getmethod.dart';
@@ -91,7 +94,7 @@ class _CommunityDetailsState extends State<CommunityDetails> {
titleTxt: "",
customActionWidget: PopupMenuButton(
surfaceTintColor: const Color(0xFF222935),
constraints: BoxConstraints.tightFor(width: 180.w),
constraints: BoxConstraints.tightFor(width: 190.w),
offset: const Offset(0, 40),
color: const Color(0xFF222935),
tooltip: "",
@@ -601,15 +604,15 @@ class _CommunityDetailsState extends State<CommunityDetails> {
borderwidth: 1),
),
sizedBoxHeight(40.h),
Container(
height: 40.h,
width: 200.w,
decoration: BoxDecoration(
color: const Color(0xFFD90B2E),
borderRadius: BorderRadius.circular(30.r)),
child: Center(
child: text14w400white("Leave the community")),
),
// Container(
// height: 40.h,
// width: 200.w,
// decoration: BoxDecoration(
// color: const Color(0xFFD90B2E),
// borderRadius: BorderRadius.circular(30.r)),
// child: Center(
// child: text14w400white("Leave the community")),
// ),
sizedBoxHeight(50.h),
])),
DefaultTabController(
@@ -733,6 +736,7 @@ class _PostsTabState extends State<PostsTab> {
likeIcon: LikeIcon1(
likeIcon: LikeIconClass1(
id: e.likeIcon?.likeIcon?.id,
// likeIcon?.id,
image: e.likeIcon?.likeIcon?.image),
likeIconsXid: e.likeIcon?.likeIconsXid,
),
@@ -833,12 +837,13 @@ class _PostsTabState extends State<PostsTab> {
children: [
NormalCardTile(
tags: _sortTags(index),
create_at: timeAgo ?? '1 hour',
createAt: timeAgo ?? '1 hour',
commonObj: commonobjmodel!.data[index],
forWhichTab: 'popular',
reactions: _reactions,
selectedReactions: _selectedReactions,
currentIndex: index,
coachbool: true,
),
sizedBoxHeight(20.h)
],

View File

@@ -186,7 +186,8 @@ class _MyCommunityState extends State<MyCommunity> {
}
}
return myCommunityobj!.data.isEmpty
return myCommunityobj!.data!.isEmpty
? _buildNoDataBody(context)
: _buildBody(context);
},

View File

@@ -41,4 +41,15 @@ class CommunityDetail {
response.data['message'], ResponseStatus.FAILED);
}
}
Future<ResponseData<dynamic>> postLeaveCommunity(updata, comId) async {
final response = await NetworkApiServices().postApi(
updata,
"${ApiUrls.postleavecommunity}?manage_community_xid=$comId",
);
if (response.status == ResponseStatus.SUCCESS) {
}
return response;
}
}

View File

@@ -8,22 +8,24 @@ import 'package:regroup/sidemenu/Community/MyCommunity/Model/communityMebersMode
import 'package:regroup/sidemenu/Community/MyCommunity/Model/communityaddgroupsModel.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/Model/communityeditpageModel.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/Model/communitygroupsModel.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/Model/communitymanageGroupsModel.dart';
CommunityAddgroupsModel? communityaddgroupobj;
CommunitygroupsModel? communitygroupspobj;
CommunityMembersModel? communitymembersobj;
CommunityinfopageEditModel? communityeditobj;
CommunityManageGroupsModel? communitymanagegroupsobj;
class Getcommunity {
Future<ResponseData<dynamic>> getCommunityAddGroupsearch(updata,
Future<ResponseData<dynamic>> getCommunityAddGroupsearch(updata,community,
{required StreamController<CommunityAddgroupsModel> streamController}) async {
final response =
await NetworkApiServices().getApi(
"${ApiUrls.getcommunityaddgroups}?search=$updata",
"${ApiUrls.getcommunityaddgroups}?manage_community_xid=$community&search=$updata",
);
@@ -73,4 +75,19 @@ class Getcommunity {
return response;
}
Future<ResponseData<dynamic>> getCommunityManageGroupssearch(updata,updata2,
{required StreamController<CommunityManageGroupsModel> streamController}) async {
final response =
await NetworkApiServices().getApi(
"${ApiUrls.getcommunitymanagegroups}?manage_community_xid=$updata&search=$updata2",
);
if (response.status == ResponseStatus.SUCCESS) {
communitymanagegroupsobj = CommunityManageGroupsModel.fromJson(response.data);
if (!streamController.isClosed) streamController.sink.add(communitymanagegroupsobj!);
}
return response;
}
}

View File

@@ -15,4 +15,34 @@ class PostMethodCommunity {
print("response message is ${response.message}");
return response;
}
Future<ResponseData<dynamic>> postEditcommunity(updata) async {
print("updata is $updata");
final response = await NetworkApiServices().postApi(
updata,
ApiUrls.posteditcommunity,
);
print("response is ${response.data}");
print("response message is ${response.message}");
return response;
}
Future<ResponseData<dynamic>> postGroupsRemove(updata) async {
final response = await NetworkApiServices().postApi(
updata,
ApiUrls.postremovegroupscommunity,
);
return response;
}
Future<ResponseData<dynamic>> postmanageaddgroupscommunity(updata) async {
print("updata is $updata");
final response = await NetworkApiServices().postApi(
updata,
ApiUrls.postmanageaddgroupscommunity,
);
print("response is ${response.data}");
print("response message is ${response.message}");
return response;
}
}

View File

@@ -1,9 +1,9 @@
import 'package:regroup/Common/api_urls.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Common/controller/data/network/network_api.dart';
import 'package:regroup/Main_Screens/ProfileTab/EditProfile/Model/InterestModel.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/Model/activitiesListModel.dart';
InterestModel? interestlistobj;
ActivitiesListsModel? interestlistobj;
class PrimaryActivityListApi {
@@ -11,7 +11,7 @@ class PrimaryActivityListApi {
var data = "";
Future<ResponseData<dynamic>> getActivitylistApi() async {
final response = await NetworkApiServices().getApi(
ApiUrls.getinterestlist,
ApiUrls.getactivitieslist,
);
@@ -20,8 +20,8 @@ class PrimaryActivityListApi {
Map<String, dynamic>.from(response.data);
if (responseData['status'] == "success") {
print("success");
InterestModel interestlistobj =
InterestModel.fromJson(responseData);
ActivitiesListsModel interestlistobj =
ActivitiesListsModel.fromJson(responseData);
} else {
// return ResponseData<dynamic>(
// responseData['message'], ResponseStatus.FAILED);