conflict resolved

This commit is contained in:
Dakshesh42
2024-08-16 12:00:01 +05:30
16 changed files with 1019 additions and 445 deletions

View File

@@ -174,6 +174,9 @@ class ApiUrls {
static const getcommunitymembers = "${baseUrl}fetch-community-all-members";
static const geteditcommunity = "${baseUrl}edit-community";
}

View File

@@ -8,6 +8,7 @@ import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Login/ViewModel/LoginApi.dart';
import 'package:regroup/Main_Screens/Community/ViewModel/getmethod.dart';
import 'package:regroup/Utils/Common/AppleOAuthService.dart';
import 'package:regroup/Utils/Common/CustomTextformfield.dart';
import 'package:regroup/Utils/Common/googleOAuthService.dart';
@@ -69,6 +70,7 @@ class _LoginScreenState extends State<LoginScreen> {
snackPosition: SnackPosition.BOTTOM,
);
// Get.toNamed(RouteName.mainscreen,arguments: 0);
await Communityallgetmethod().getLikeicons();
await Getuserdetails().Getuser().then((value) {
if (getuserobj?.data?.userData?.isProfileUpdated == 0) {
String? accountype =

View File

@@ -4,6 +4,7 @@ import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Common/controller/data/network/network_api.dart';
import 'package:regroup/Global.dart';
import 'package:regroup/Login/Model/LoginModel.dart';
import 'package:regroup/Main_Screens/Community/ViewModel/getmethod.dart';
import 'package:regroup/onboarding/Signup/view_model/getUserprofile.dart';
import 'package:regroup/resources/routes/route_name.dart';
import 'package:shared_preferences/shared_preferences.dart';
@@ -105,6 +106,7 @@ class LoginAPI {
return ResponseData<dynamic>(
"go-to-signin-via-oauth", ResponseStatus.SUCCESS);
} else {
await Communityallgetmethod().getLikeicons();
await Getuserdetails().Getuser().then((value) {
if (getuserobj?.data?.userData?.isProfileUpdated == 0) {
String? accountype =
@@ -143,6 +145,7 @@ class LoginAPI {
"go-to-signin-via-oauth", ResponseStatus.SUCCESS);
} else {
// Get.toNamed(RouteName.mainscreen);
await Communityallgetmethod().getLikeicons();
await Getuserdetails().Getuser().then((value) {
if (getuserobj?.data?.userData?.isProfileUpdated == 0) {
String? accountype =

View File

@@ -5,20 +5,18 @@ import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Common/controller/data/network/network_api.dart';
import 'package:regroup/Main_Screens/Community/Model/fetchicons.dart';
// FetchlikeIconsModel? likeiconsobj;
FetchlikeIconsModel? fetchlikeIconsModel;
class Communityallgetmethod {
Future<ResponseData<dynamic>> getLikeicons() async {
Future<ResponseData<dynamic>> getLikeicons() async {
final response = await NetworkApiServices().getApi(
ApiUrls.getLikeicons,
// optionalpar: false
);
if (response.status == ResponseStatus.SUCCESS) {
// likeiconsobj = FetchlikeIconsModel.fromJson(response.data);
fetchlikeIconsModel = FetchlikeIconsModel.fromJson(response.data);
// log(likeiconsobj!.data.toString());
}
return response;
}
}
}

View File

@@ -30,6 +30,7 @@ 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';
@@ -217,39 +218,29 @@ class _FeedTabState extends State<FeedTab> {
super.initState();
}
Future<void> _fetchIcons() async {
var response = await Communityallgetmethod().getLikeicons();
if (response.status == ResponseStatus.SUCCESS) {
var responseData = response.data as Map<String, dynamic>;
FetchlikeIconsModel fetchlikeIconsModel =
FetchlikeIconsModel.fromJson(responseData);
_fetchIcons() {
_reactions = fetchlikeIconsModel!.data ?? [];
for (var post in commonobjmodel!.data) {
//Check if post as a like icon
if (post.likeIcon?.likeIcon?.id != null) {
likeIconIdnew = post.likeIcon!.likeIconsXid;
_reactions = fetchlikeIconsModel.data ?? [];
for (var post in commonobjmodel!.data) {
//Check if post as a like icon
if (post.likeIcon != null) {
likeIconIdnew = post.likeIcon!.likeIconsXid;
final selectedReaction = _reactions.firstWhere(
(r) => r.id == likeIconIdnew,
orElse: () => _reactions.first,
);
final selectedReaction = _reactions.firstWhere(
(r) => r.id == likeIconIdnew,
orElse: () => _reactions.first,
);
_selectedReactions[post.id!] =
selectedReaction; // Set selected reaction for this post
} else {
_selectedReactions[post.id!] = null; // No reaction selected
print('No reaction selected for post $postId');
}
_selectedReactions[post.id!] =
selectedReaction; // Set selected reaction for this post
} else {
_selectedReactions[post.id!] = null; // No reaction selected
print('No reaction selected for post $postId');
}
setState(() {});
}
}
bool _isDataInitialized = true;
Future<void> setValues() async {
if (_isDataInitialized) {
setValues() {
if (mounted) {
combinedList.clear();
combinedListGlobal.clear();
combinedList.addAll(feedpostobj!.data!.pinnedCommunityPost);
@@ -258,10 +249,7 @@ class _FeedTabState extends State<FeedTab> {
combinedListGlobal.addAll(combinedList);
_setModel();
countersHelper.setListsPopular();
await _fetchIcons();
_isDataInitialized = false;
_fetchIcons();
}
}
@@ -335,92 +323,184 @@ class _FeedTabState extends State<FeedTab> {
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: feedfuture,
builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(
color: Colors.blue,
),
);
}
return Obx(
() => countersHelper.updateFeedsPage.value
? FutureBuilder(
future: FeedpostApi().getFeedPostApi(),
builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: ShimmerCommon());
}
if (snapshot.hasError) {
return Center(
child: Text(
'${snapshot.error} occurred',
style: TextStyle(fontSize: 18.spMin),
),
);
}
if (snapshot.hasError) {
return Center(
child: Text(
'${snapshot.error} occurred',
style: TextStyle(fontSize: 18.spMin),
),
);
}
if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData) {
setValues();
return Stack(
clipBehavior: Clip.none,
children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill),
),
),
combinedList.isEmpty
? Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"No posts are currently pinned",
style: TextStyle(
color: Colors.white,
fontSize: 16.sp,
fontWeight: FontWeight.w600),
)
],
),
)
: Column(
children: [
sizedBoxHeight(20.h),
Expanded(
child: ListView.builder(
shrinkWrap: true,
itemCount: commonobjmodel!.data.length,
itemBuilder: (context, index) {
var timeAgo = ConvertServerDateToUserDate()
.convertServerDateToReadableFormate(
commonobjmodel!.data[index].createdAt
.toString());
return Column(
children: [
NormalCardTile(
tags: _sortTags(index),
create_at: timeAgo ?? '1 hour',
commonObj: commonobjmodel!.data[index],
forWhichTab: 'feed',
reactions: _reactions,
selectedReactions: _selectedReactions,
currentIndex: index,
),
sizedBoxHeight(20.h)
],
);
},
),
if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData) {
log("TRUE");
setValues();
return Stack(
clipBehavior: Clip.none,
children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
"assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill),
),
],
)
],
);
}
return Container();
},
),
combinedList.isEmpty
? Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"No posts are currently pinned",
style: TextStyle(
color: Colors.white,
fontSize: 16.sp,
fontWeight: FontWeight.w600),
)
],
),
)
: Column(
children: [
sizedBoxHeight(20.h),
Expanded(
child: ListView.builder(
shrinkWrap: true,
itemCount: commonobjmodel!.data.length,
itemBuilder: (context, index) {
var timeAgo = ConvertServerDateToUserDate()
.convertServerDateToReadableFormate(
commonobjmodel!
.data[index].createdAt
.toString());
return Column(
children: [
NormalCardTile(
tags: _sortTags(index),
create_at: timeAgo ?? '1 hour',
commonObj:
commonobjmodel!.data[index],
forWhichTab: 'feed',
reactions: _reactions,
selectedReactions:
_selectedReactions,
currentIndex: index,
),
sizedBoxHeight(20.h)
],
);
},
),
),
],
)
],
);
}
return Container();
},
)
: FutureBuilder(
future: FeedpostApi().getFeedPostApi(),
builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: ShimmerCommon());
}
if (snapshot.hasError) {
return Center(
child: Text(
'${snapshot.error} occurred',
style: TextStyle(fontSize: 18.spMin),
),
);
}
if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData) {
log("FALSE");
setValues();
return Stack(
clipBehavior: Clip.none,
children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
"assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill),
),
),
combinedList.isEmpty
? Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"No posts are currently pinned",
style: TextStyle(
color: Colors.white,
fontSize: 16.sp,
fontWeight: FontWeight.w600),
)
],
),
)
: Column(
children: [
sizedBoxHeight(20.h),
Expanded(
child: ListView.builder(
shrinkWrap: true,
itemCount: commonobjmodel!.data.length,
itemBuilder: (context, index) {
var timeAgo = ConvertServerDateToUserDate()
.convertServerDateToReadableFormate(
commonobjmodel!
.data[index].createdAt
.toString());
return Column(
children: [
NormalCardTile(
tags: _sortTags(index),
create_at: timeAgo ?? '1 hour',
commonObj:
commonobjmodel!.data[index],
forWhichTab: 'feed',
reactions: _reactions,
selectedReactions:
_selectedReactions,
currentIndex: index,
),
sizedBoxHeight(20.h)
],
);
},
),
),
],
)
],
);
}
return Container();
},
),
);
}
}
@@ -560,6 +640,8 @@ class _NormalCardTileState extends State<NormalCardTile> {
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);
@@ -573,6 +655,10 @@ class _NormalCardTileState extends State<NormalCardTile> {
@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,
@@ -751,14 +837,16 @@ class _NormalCardTileState extends State<NormalCardTile> {
'currentIndex': widget.currentIndex
});
if (result) {
setState(() {});
setState(() {
});
}
},
child: Container(
child: SizedBox(
height: 360,
width: double.infinity,
child: CachedNetworkImage(
// cacheKey: "1st",
cacheKey: imgUrl,
imageUrl: widget.commonObj.image!,
fit: BoxFit.cover,
placeholder: (context, url) => const Center(
@@ -1081,31 +1169,23 @@ class _PopularTabState extends State<PopularTab> {
}
Future<void> _fetchIcons() async {
var response = await Communityallgetmethod().getLikeicons();
if (response.status == ResponseStatus.SUCCESS) {
var responseData = response.data as Map<String, dynamic>;
FetchlikeIconsModel fetchlikeIconsModel =
FetchlikeIconsModel.fromJson(responseData);
_reactions = fetchlikeIconsModel!.data ?? [];
for (var post in commonobjmodel!.data) {
//Check if post as a like icon
if (post.likeIcon?.likeIcon?.id != null) {
likeIconIdnew = post.likeIcon!.likeIconsXid;
_reactions = fetchlikeIconsModel.data ?? [];
for (var post in popularpostobj!.data) {
//Check if post as a like icon
if (post.likeIcon != null) {
likeIconIdnew = post.likeIcon!.likeIconsXid;
final selectedReaction = _reactions.firstWhere(
(r) => r.id == likeIconIdnew,
orElse: () => _reactions.first,
);
final selectedReaction = _reactions.firstWhere(
(r) => r.id == likeIconIdnew,
orElse: () => _reactions.first,
);
_selectedReactions[post.id!] =
selectedReaction; // Set selected reaction for this post
} else {
_selectedReactions[post.id!] = null; // No reaction selected
print('No reaction selected for post $postId');
}
_selectedReactions[post.id!] =
selectedReaction; // Set selected reaction for this post
} else {
_selectedReactions[post.id!] = null; // No reaction selected
print('No reaction selected for post $postId');
}
setState(() {});
}
}
@@ -1195,11 +1275,7 @@ class _PopularTabState extends State<PopularTab> {
future: popularfuture,
builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(
color: Colors.blue,
),
);
return const Center(child: ShimmerCommon());
}
if (snapshot.hasError) {
@@ -1301,32 +1377,24 @@ class _LatestTabState extends State<LatestTab> {
final CountersHelper countersHelper = Get.find<CountersHelper>();
int? likeIconIdnew;
Future<void> _fetchIcons() async {
var response = await Communityallgetmethod().getLikeicons();
if (response.status == ResponseStatus.SUCCESS) {
var responseData = response.data as Map<String, dynamic>;
FetchlikeIconsModel fetchlikeIconsModel =
FetchlikeIconsModel.fromJson(responseData);
_fetchIcons() {
_reactions = fetchlikeIconsModel!.data ?? [];
for (var post in commonobjmodel!.data) {
//Check if post as a like icon
if (post.likeIcon?.likeIcon?.id != null) {
likeIconIdnew = post.likeIcon!.likeIconsXid;
_reactions = fetchlikeIconsModel.data ?? [];
for (var post in latestpostobj!.data) {
//Check if post as a like icon
if (post.likeIcon != null) {
likeIconIdnew = post.likeIcon!.likeIconsXid;
final selectedReaction = _reactions.firstWhere(
(r) => r.id == likeIconIdnew,
orElse: () => _reactions.first,
);
final selectedReaction = _reactions.firstWhere(
(r) => r.id == likeIconIdnew,
orElse: () => _reactions.first,
);
_selectedReactions[post.id!] =
selectedReaction; // Set selected reaction for this post
} else {
_selectedReactions[post.id!] = null; // No reaction selected
print('No reaction selected for post $postId');
}
_selectedReactions[post.id!] =
selectedReaction; // Set selected reaction for this post
} else {
_selectedReactions[post.id!] = null; // No reaction selected
print('No reaction selected for post $postId');
}
setState(() {});
}
}
@@ -1336,7 +1404,7 @@ class _LatestTabState extends State<LatestTab> {
if (_isDataInitialized) {
_setModel();
countersHelper.setListsPopular();
await _fetchIcons();
_fetchIcons();
_isDataInitialized = false;
}
@@ -1416,13 +1484,7 @@ class _LatestTabState extends State<LatestTab> {
future: futureGroup.future,
builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return
// ShimmerCommon();
const Center(
child: CircularProgressIndicator(
color: Colors.blue,
),
);
return const Center(child: ShimmerCommon());
}
if (snapshot.hasError) {

View File

@@ -4,25 +4,21 @@ import 'package:regroup/Main_Screens/Community/Model/FeedPostModel.dart';
import 'package:regroup/Main_Screens/Community/ViewModel/LatestPost.dart';
List<PinnedPost> combinedListGlobal = [];
CommonDatumObjModel? commonobjmodel;
CommonDatumObjModel? commonobjmodel;
class CountersHelper extends GetxController {
RxList<int> likesCounterPopular = <int>[].obs;
RxList<int> commentsCounterPopular = <int>[].obs;
RxList<int> savePostCounterPopular = <int>[].obs;
RxList<bool> saveButtonPopular = <bool>[].obs;
RxList<bool> pinButtonPopular = <bool>[].obs;
setListsPopular() {
List<bool> pinButtonPopular = <bool>[];
RxBool updateFeedsPage = false.obs;
setListsPopular() {
likesCounterPopular.clear();
commentsCounterPopular.clear();
savePostCounterPopular.clear();
saveButtonPopular.clear();
pinButtonPopular.clear();
for (var i = 0; i < commonobjmodel!.data.length; i++) {
likesCounterPopular.add(commonobjmodel?.data[i].likecount ?? 0);
commentsCounterPopular

View File

@@ -66,4 +66,19 @@ class Helper {
);
}
}
static Future<File> networkImageToFile(String imageUrl) async {
Dio dio = Dio();
Response<Uint8List> response = await dio.get<Uint8List>(imageUrl,
options: Options(responseType: ResponseType.bytes));
final directory = await getTemporaryDirectory();
final filePath = '${directory.path}/${imageUrl.split('/').last}';
final file = File(filePath);
await file.writeAsBytes(response.data!);
return file;
}
}

View File

@@ -11,6 +11,7 @@ import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Global.dart';
import 'package:regroup/Main_Screens/Community/ViewModel/getmethod.dart';
import 'package:regroup/Main_Screens/ProfileTab/EditProfile/ViewModel/InterestApiList.dart';
import 'package:regroup/Utils/Common/NoInternet.dart';
import 'package:regroup/Utils/dialogs.dart';
@@ -46,6 +47,7 @@ class _SplashScreenState extends State<SplashScreen> {
if (token == null || token!.isEmpty) {
Get.toNamed(RouteName.onboarding1);
} else {
await Communityallgetmethod().getLikeicons();
await InterestListApi().getinterestlistApi();
await Uploadata(deviceName);
await Getuserdetails().Getuser().then((value) {

View File

@@ -16,6 +16,8 @@ class CommunitySetting extends StatefulWidget {
}
class _CommunitySettingState extends State<CommunitySetting> {
int communityid = Get.arguments['communityid'];
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -37,7 +39,11 @@ class _CommunitySettingState extends State<CommunitySetting> {
sizedBoxHeight(30.h),
GestureDetector(
onTap: () {
Get.toNamed(RouteName.editcommunity);
Get.toNamed(RouteName.editcommunity,
arguments: {
'communityid' : communityid,
}
);
},
child: rowTile(text: 'Edit community info')),
commonDivider(),

View File

@@ -1,18 +1,27 @@
import 'dart:developer';
import 'dart:io';
import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:regroup/Common/CommonDropDown.dart';
import 'package:get/get.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';
import 'package:regroup/Utils/Common/ImageUpload.dart';
import 'package:regroup/Utils/Common/sized_box.dart';
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/view_model/getmethod.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/view_model/primaryactivity.dart';
import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart';
class EditCommunity extends StatefulWidget {
const EditCommunity({super.key});
@@ -24,12 +33,19 @@ class EditCommunity extends StatefulWidget {
class _EditCommunityState extends State<EditCommunity> {
TextEditingController communitynameController = TextEditingController();
TextEditingController descriptionController = TextEditingController();
TextEditingController locationcontroller = TextEditingController();
TextEditingController websitelinkcontroller = TextEditingController();
late Future myfuture;
int communityid = Get.arguments['communityid'];
@override
void initState() {
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 .";
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();
}
@@ -37,6 +53,93 @@ class _EditCommunityState extends State<EditCommunity> {
List<File?> bannerPath = [];
bool isImageAdded = false;
bool isbannerAdded = false;
String? bannerimage;
bool isBannerLoaded = false;
bool isactivityLoaded = false;
Future<void> _loadBannerImage() async {
if (bannerimage!.isNotEmpty) {
File bannerFile = await Helper.networkImageToFile(bannerimage!);
setState(() {
bannerPath.add(bannerFile);
isbannerAdded = true;
isBannerLoaded = true;
});
}
}
bool isValidWebBannerLink(String link) {
RegExp urlRegExp = RegExp(
r"^(http(s)?://)?"
r"((([a-zA-Z0-9-]+)\.)+[a-zA-Z]{2,}|"
r"((\d{1,3}\.){3}\d{1,3}))"
r"(:\d{1,5})?(/([a-zA-Z0-9-._?,'+&%\$#=~])*)?$",
);
return urlRegExp.hasMatch(link);
}
final Map<String, int> _typeCommunityMap = {
'Public': 1,
'Private - Request to join': 2,
'Secret': 3,
};
String _selectedtypecommunity = '';
void _onItemSelected(String value) {
setState(() {
_selectedtypecommunity = value;
print('selected community is $_selectedtypecommunity');
});
}
primaryactlist.InterestModel? abilityModel;
List<primaryactlist.Data> activity = [];
List<String> _activitydrop = [];
String? selectedActivityName;
Future<void> fetchActivitylist() async {
PrimaryActivityListApi abilityListAPI = PrimaryActivityListApi();
ResponseData<dynamic> response = await abilityListAPI.getActivitylistApi();
if (response.status == ResponseStatus.SUCCESS) {
abilityModel = primaryactlist.InterestModel.fromJson(response.data!);
setState(() {
activity = abilityModel!.data ?? [];
_activitydrop =
activity.map((platform) => platform.name.toString()).toList();
});
// Ensure dropdown list updates after setting the initial value
setState(() {
// Set the initial selected activity if data is available
int activitiesXids =
communityeditobj!.data!.communityData!.activityData!.id!;
selectedactivityid = activitiesXids;
selectedActivityName = activity
.firstWhere((item) => item.id == activitiesXids,
orElse: () => activity.first)
.name;
isactivityLoaded = true;
});
log(activity.toString());
} else {
print('Failed to fetch abilities');
}
}
int? selectedactivityid;
void getCatIdFromName(String selectedAbility) {
selectedactivityid = activity
.firstWhere((item) => item.name == selectedAbility,
orElse: () => activity.first)
.id;
print('Selected activity ID is $selectedactivityid');
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -47,261 +150,441 @@ class _EditCommunityState extends State<EditCommunity> {
titleTxt: "Edit community info",
),
resizeToAvoidBottomInset: false,
body: Stack(children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill)),
),
SingleChildScrollView(
child: Column(children: [
sizedBoxHeight(30.h),
Stack(
clipBehavior: Clip.none,
body: FutureBuilder(
future: myfuture,
builder: (ctx, snapshot) {
if (snapshot.data == null) {
return const Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
height: 100.h,
width: 100.w,
decoration: BoxDecoration(
shape: BoxShape.circle,
border:
Border.all(color: Color(0xFF434A53), width: 0.5.w),
Center(
child: CircularProgressIndicator(
color: Color(0xFFC18948),
),
child: Center(
child: filePath.isNotEmpty
? ClipOval(
child: SizedBox.fromSize(
size: Size.fromRadius(50.r),
child: Image.file(
filePath[0]!,
fit: BoxFit.cover,
width: double.infinity,
),
),
)
: Image.asset('assets/images/png/Ellipse 37.png',
fit: BoxFit.cover),
),
),
Positioned(
right: -10,
bottom: 0,
child: InkWell(
onTap: () {
ImageUploadBottomSheet().showModal(
context,
true,
(result) {
var file = File(result);
filePath.add(file);
isImageAdded = true;
setState(() {});
},
);
},
child: Container(
height: 35.h,
width: 35.w,
decoration: BoxDecoration(
color: Color(0xFFD90B2E),
shape: BoxShape.circle,
border: Border.all(
color: Color(0xFFD90B2E), width: 0.5.w)),
child: Center(
child: Image.asset(
'assets/images/png/cameraicon.png',
height: 14.h,
width: 15.w,
),
),
),
))
)
],
),
sizedBoxHeight(25.h),
text16w400_white("Edit community profile picture"),
sizedBoxHeight(30.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text16w400_FCFCFC("Community banner image"),
sizedBoxHeight(16.h),
GestureDetector(
onTap: () {
ImageUploadBottomSheet().showModal(
context,
false,
(result) {
var file = File(result);
);
}
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
return Center(
child: Text(
'${snapshot.error} occured',
style: TextStyle(fontSize: 18.spMin),
),
);
}
}
if (!isBannerLoaded) {
bannerimage =
communityeditobj!.data!.communityData!.communityBannerImage!;
_loadBannerImage(); // Call only if not already loaded
}
communitynameController.text =
communityeditobj!.data!.communityData!.communityName!;
descriptionController.text =
communityeditobj!.data!.communityData!.communityDescription!;
locationcontroller.text =
communityeditobj!.data!.communityData!.communityLocation!;
websitelinkcontroller.text =
communityeditobj!.data!.communityData!.communityDescription!;
var communityType =
communityeditobj!.data!.communityData!.communityTypeData!.name;
if (_selectedtypecommunity.isEmpty) {
_selectedtypecommunity = communityType ?? 'Public';
}
if (!isactivityLoaded) {
fetchActivitylist();
}
bannerPath.add(file);
isbannerAdded = true;
setState(() {});
},
);
},
child: DottedBorder(
strokeWidth: 1,
dashPattern: [7, 4],
borderType: BorderType.RRect,
radius: Radius.circular(14.r),
color: Color(0xFF434A53),
child: commonGlassUI(
borderwidth: 0,
width: double.infinity,
height: 150.h,
borderRadius: BorderRadius.circular( 10.r),
customWidget: bannerPath.isNotEmpty && isbannerAdded
? Stack(children: [
Image.file(
bannerPath[0]!,
fit: BoxFit.cover,
width: double.infinity,
),
Positioned(
right: 5,
bottom: 5,
child: GestureDetector(
onTap: () {
bannerPath.clear();
isbannerAdded = false;
setState(() {});
},
child: Container(
width: 27,
height: 27,
decoration: ShapeDecoration(
color: Color(0xFF7E7E7E),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(5)),
),
child: Icon(
Icons.delete_outline_outlined,
color: Colors.white,
))),
),
])
: Padding(
padding: EdgeInsets.symmetric(vertical: 16.h),
child: Column(
children: [
Image.asset(
"assets/images/png/cameraicon2.png",
height: 36.h,
width: 36.w,
),
sizedBoxHeight(10.h),
text14w400white('Upload banner image'),
sizedBoxHeight(8.h),
SizedBox(
width: 270.w,
child: text10w400_whiteCenter(
"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s"),
),
],
),
),
return Stack(children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill)),
),
SingleChildScrollView(
child: Column(children: [
// sizedBoxHeight(30.h),
Stack(
clipBehavior: Clip.none,
children: [
Container(
height: 100.h,
width: 100.w,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Color(0xFF434A53), width: 0.5.w),
),
child: Center(
child: filePath.isNotEmpty
? ClipOval(
child: SizedBox.fromSize(
size: Size.fromRadius(50.r),
child: filePath.isNotEmpty
? Image.file(
filePath[0]!,
fit: BoxFit.cover,
width: double.infinity,
)
: Image.asset(
'assets/images/png/Ellipse 37.png',
fit: BoxFit.cover),
),
)
: ClipOval(
child: SizedBox.fromSize(
size: Size.fromRadius(50.r),
child: communityeditobj!
.data!
.communityData!
.communityProfilePhoto!
.isNotEmpty
? Image.network(
communityeditobj!
.data!
.communityData!
.communityProfilePhoto!,
fit: BoxFit.cover,
errorBuilder:
(context, error, stackTrace) {
// Error handling when image fails to load
return Image.asset(
"assets/images/png/Ellipse 37.png",
fit: BoxFit.cover,
);
},
)
: Image.asset(
'assets/images/png/Ellipse 37.png',
fit: BoxFit.cover),
),
)),
),
),
sizedBoxHeight(16.w),
commonGlassUI(
width: double.infinity,
height: 60.h,
borderRadius: BorderRadius.circular( 10.r),
customWidget: Center(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(children: [
Container(
height: 40.h,
width: 40.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.r)),
Positioned(
right: -10,
bottom: 0,
child: InkWell(
onTap: () {
ImageUploadBottomSheet().showModal(
context,
false,
(result) {
if (result != null && result.isNotEmpty) {
var file = File(result);
filePath.cast();
filePath.add(file);
isImageAdded = true;
setState(() {});
if (Platform.isAndroid) {
Get.back();
}
} else {
filePath.clear();
isImageAdded = false;
setState(() {});
}
},
);
},
child: Container(
height: 35.h,
width: 35.w,
decoration: BoxDecoration(
color: Color(0xFFD90B2E),
shape: BoxShape.circle,
border: Border.all(
color: Color(0xFFD90B2E), width: 0.5.w)),
child: Center(
child: Image.asset(
"assets/images/png/img2.png",
fit: BoxFit.cover,
'assets/images/png/cameraicon.png',
height: 14.h,
width: 15.w,
),
),
sizedBoxWidth(8.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
text14400white("group1.png"),
sizedBoxHeight(2.h),
text12w400_FCFCFC_blur("10 kb")
],
),
Spacer(),
Image.asset(
'assets/images/png/cancelicon.png',
height: 20.h,
width: 20.w,
)
]),
),
))
],
),
sizedBoxHeight(25.h),
text16w400_white("Edit community profile picture"),
sizedBoxHeight(30.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text16w400_FCFCFC("Community banner image"),
sizedBoxHeight(16.h),
DottedBorder(
strokeWidth: 1,
dashPattern: [7, 4],
borderType: BorderType.RRect,
radius: Radius.circular(14.r),
color: Color(0xFF434A53),
child: commonGlassUI(
borderwidth: 0,
width: double.infinity,
height: 150.h,
borderRadius: BorderRadius.circular(10.r),
customWidget: bannerPath.isNotEmpty && isbannerAdded
? Stack(
children: [
Image.file(
bannerPath[0]!,
fit: BoxFit.cover,
width: double.infinity,
),
// Positioned(
// right: 5,
// bottom: 5,
// child: InkWell(
// onTap: () {
// setState(() {
// bannerPath.clear();
// isbannerAdded = false;
// });
// },
// child: Container(
// width: 27,
// height: 27,
// decoration: ShapeDecoration(
// color: Color(0xFF7E7E7E),
// shape: RoundedRectangleBorder(
// borderRadius:
// BorderRadius.circular(5),
// ),
// ),
// child: Icon(
// Icons.delete_outline_outlined,
// color: Colors.white,
// ),
// ),
// ),
// ),
],
)
: GestureDetector(
onTap: () {
ImageUploadBottomSheet().showModal(
context,
false,
(result) {
if (result != null &&
result.isNotEmpty) {
var file = File(result);
// Check if the file size exceeds 10 MB
int fileSizeInBytes =
file.lengthSync();
double fileSizeInMB =
fileSizeInBytes / (1024 * 1024);
if (fileSizeInMB > 10) {
// Show toast message if the file size exceeds 10 MB
utils.showToast(
"The selected file is too large. Max file size is 10 MB.");
} else {
// Clear the existing image and add the new one
bannerPath.clear();
bannerPath.add(file);
isbannerAdded = true;
setState(() {});
}
} else {
// Handle case where no image is selected
bannerPath.clear();
isbannerAdded = false;
setState(() {});
}
if (Platform.isAndroid) {
Get.back();
}
},
);
},
child: Padding(
padding:
EdgeInsets.symmetric(vertical: 16.h),
child: Column(
children: [
Image.asset(
"assets/images/png/cameraicon2.png",
height: 36.h,
width: 36.w,
),
SizedBox(height: 10.h),
text14w400white(
'Upload banner image'),
SizedBox(height: 8.h),
SizedBox(
width: 270.w,
child: text8w400_8A8A8A(
"Allowed file extensions: jpg, png, gif Max file size: 10 MB"),
),
],
),
),
),
),
),
borderwidth: 1),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Community name"),
sizedBoxHeight(14.h),
CustomTextFormField(
textEditingController: communitynameController,
validator: (val) {
if (val == null || val.isEmpty) {
return 'Enter Community name';
}
return null;
},
sizedBoxHeight(16.w),
bannerPath.isNotEmpty && isbannerAdded
? commonGlassUI(
width: double.infinity,
height: 60.h,
borderRadius: BorderRadius.circular(10.r),
customWidget: Center(
child: Padding(
padding:
EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
// Conditionally render image or placeholder
if (bannerPath.isNotEmpty &&
isbannerAdded)
Container(
height: 40.h,
width: 40.w,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(5.r),
),
child: Image.file(
bannerPath[0]!,
fit: BoxFit.cover,
width: double.infinity,
),
)
else
Container(
height: 40.h,
width: 40.w,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(5.r),
),
child: Image.asset(
'assets/images/png/img2.png',
fit: BoxFit.cover,
width: double.infinity,
),
),
SizedBox(width: 8.w),
Spacer(),
InkWell(
onTap: () {
setState(() {
// Clear the image and update the state
bannerPath.clear();
isbannerAdded = false;
});
// Optionally debug state values
print("bannerPath: $bannerPath");
print(
"isbannerAdded: $isbannerAdded");
},
child: Image.asset(
'assets/images/png/cancelicon.png',
height: 20.h,
width: 20.w,
),
),
],
),
),
),
borderwidth: 1,
)
: SizedBox(),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Community name*"),
sizedBoxHeight(14.h),
CustomTextFormField(
textEditingController: communitynameController,
validator: (val) {
if (val == null || val.isEmpty) {
return 'Enter Community name';
}
return null;
},
hintText: 'Enter type of community',
),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Group description"),
sizedBoxHeight(14.h),
CustomTextFormField(
// maxlines: 3,
hintText: 'Enter description',
textEditingController: descriptionController,
),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Type of community*"),
sizedBoxHeight(14.h),
CustomDropDownRadio(
header: "",
title: "",
listData: _typeCommunityMap.keys.toList(),
onItemSelected: _onItemSelected,
leadingImage: SizedBox(),
initialSelectedValue: _selectedtypecommunity,
),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Location*"),
sizedBoxHeight(14.h),
CustomTextFormField(
textEditingController: locationcontroller,
inputFormatters: [
RemoveEmojiInputFormatter(),
// FilteringTextInputFormatter.allow(RegExp('[a-zA-Z ]'))
],
hintText: 'Enter location',
validator: (val) {
if (val == null || val.isEmpty) {
return 'Enter location';
}
return null;
},
),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Primary activity*"),
sizedBoxHeight(14.h),
CustomDropDownRadio(
showOtherOption: true,
header: "",
title: "",
listData: _activitydrop,
onItemSelected: getCatIdFromName,
leadingImage: SizedBox(),
initialSelectedValue: selectedActivityName.toString(),
),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Website link"),
sizedBoxHeight(14.h),
CustomTextFormField(
textEditingController: websitelinkcontroller,
validator: (val) {
if (!isValidWebBannerLink(val)) {
return 'Please enter a valid web banner link.';
}
return null;
},
hintText: 'Enter website link',
),
sizedBoxHeight(25.h),
sizedBoxHeight(50.h),
CustomButton(text: 'Save changes', onPressed: () {}),
sizedBoxHeight(50.h),
],
),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Group description"),
sizedBoxHeight(14.h),
CustomTextFormField2(
maxlines: 3,
textEditingController: descriptionController,
),
text16w400_FCFCFC("Type of community"),
sizedBoxHeight(14.h),
CustomDropDownRadio(
header: "",
title: "",
listData: ["Public", "Private - Request to join"],
onItemSelected: (p0) {},
leadingImage: SizedBox()),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Location*"),
sizedBoxHeight(14.h),
CustomDropDownRadio(
header: "",
title: "",
listData: ["Public", "Private", "Secret"],
onItemSelected: (p0) {},
leadingImage: SizedBox()),
sizedBoxHeight(25.h),
text16w400_FCFCFC("Primary activity*"),
sizedBoxHeight(14.h),
CustomDropDownRadio(
showOtherOption: true,
header: "",
title: "",
listData: ["Sports", "Hobby"],
onItemSelected: (p0) {},
leadingImage: SizedBox()),
sizedBoxHeight(50.h),
CustomButton(text: 'Save changes', onPressed: () {}),
sizedBoxHeight(50.h),
],
),
)
]),
)
]),
)
]));
]);
},
));
}
}

View File

@@ -200,18 +200,18 @@ class _CommunityMembersState extends State<CommunityMembers> {
CrossAxisAlignment.start,
children: [
mainFollowersData.iamPrincipal!
.userName ==
.fullName ==
null ||
mainFollowersData
.iamPrincipal!
.userName!
.fullName!
.isEmpty ==
true
? text16w400_FCFCFC("Regroup")
: text16w400_FCFCFC(
mainFollowersData
.iamPrincipal!
.userName!),
.fullName!),
sizedBoxHeight(4.h),
mainFollowersData.iamPrincipal!
.userName ==

View File

@@ -51,6 +51,7 @@ class IamPrincipal {
required this.id,
required this.principalTypeXid,
required this.userName,
required this.fullName,
required this.profilePhoto,
required this.isUserPinned,
});
@@ -58,6 +59,7 @@ class IamPrincipal {
final int? id;
final int? principalTypeXid;
final String? userName;
final String? fullName;
final String? profilePhoto;
final bool? isUserPinned;
@@ -66,6 +68,7 @@ class IamPrincipal {
id: json["id"],
principalTypeXid: json["principal_type_xid"],
userName: json["user_name"],
fullName: json["full_name"],
profilePhoto: json["profile_photo"],
isUserPinned: json["is_user_pinned"],
);

View File

@@ -0,0 +1,185 @@
class CommunityinfopageEditModel {
CommunityinfopageEditModel({
required this.status,
required this.statusCode,
required this.message,
required this.data,
});
final String? status;
final int? statusCode;
final String? message;
final Data? data;
factory CommunityinfopageEditModel.fromJson(Map<String, dynamic> json){
return CommunityinfopageEditModel(
status: json["status"],
statusCode: json["status_code"],
message: json["message"],
data: json["data"] == null ? null : Data.fromJson(json["data"]),
);
}
}
class Data {
Data({
required this.typesOfCommunity,
required this.communityData,
});
final List<TypesOfCommunity> typesOfCommunity;
final CommunityData? communityData;
factory Data.fromJson(Map<String, dynamic> json){
return Data(
typesOfCommunity: json["typesOfCommunity"] == null ? [] : List<TypesOfCommunity>.from(json["typesOfCommunity"]!.map((x) => TypesOfCommunity.fromJson(x))),
communityData: json["communityData"] == null ? null : CommunityData.fromJson(json["communityData"]),
);
}
}
class CommunityData {
CommunityData({
required this.id,
required this.communityProfilePhoto,
required this.communityBannerImage,
required this.communityName,
required this.communityLocation,
required this.communityDescription,
required this.communityTypeXid,
required this.activityXid,
required this.isActive,
required this.totalGroup,
required this.totalAnnouncements,
required this.activityData,
required this.communityTypeData,
});
final int? id;
final String? communityProfilePhoto;
final String? communityBannerImage;
final String? communityName;
final String? communityLocation;
final String? communityDescription;
final int? communityTypeXid;
final int? activityXid;
final int? isActive;
final int? totalGroup;
final int? totalAnnouncements;
final ActivityData? activityData;
final CommunityTypeData? communityTypeData;
factory CommunityData.fromJson(Map<String, dynamic> json){
return CommunityData(
id: json["id"],
communityProfilePhoto: json["community_profile_photo"],
communityBannerImage: json["community_banner_image"],
communityName: json["community_name"],
communityLocation: json["community_location"],
communityDescription: json["community_description"],
communityTypeXid: json["community_type_xid"],
activityXid: json["activity_xid"],
isActive: json["is_active"],
totalGroup: json["total_group"],
totalAnnouncements: json["total_announcements"],
activityData: json["activity_data"] == null ? null : ActivityData.fromJson(json["activity_data"]),
communityTypeData: json["community_type_data"] == null ? null : CommunityTypeData.fromJson(json["community_type_data"]),
);
}
}
class ActivityData {
ActivityData({
required this.id,
required this.title,
required this.description,
required this.image,
required this.deletedAt,
required this.createdAt,
required this.updatedAt,
});
final int? id;
final String? title;
final String? description;
final String? image;
final dynamic deletedAt;
final DateTime? createdAt;
final DateTime? updatedAt;
factory ActivityData.fromJson(Map<String, dynamic> json){
return ActivityData(
id: json["id"],
title: json["title"],
description: json["description"],
image: json["image"],
deletedAt: json["deleted_at"],
createdAt: DateTime.tryParse(json["created_at"] ?? ""),
updatedAt: DateTime.tryParse(json["updated_at"] ?? ""),
);
}
}
class CommunityTypeData {
CommunityTypeData({
required this.id,
required this.name,
required this.image,
required this.description,
required this.isActive,
required this.createdBy,
required this.modifiedBy,
required this.deletedAt,
required this.createdAt,
required this.updatedAt,
});
final int? id;
final String? name;
final dynamic image;
final dynamic description;
final int? isActive;
final dynamic createdBy;
final dynamic modifiedBy;
final dynamic deletedAt;
final dynamic createdAt;
final dynamic updatedAt;
factory CommunityTypeData.fromJson(Map<String, dynamic> json){
return CommunityTypeData(
id: json["id"],
name: json["name"],
image: json["image"],
description: json["description"],
isActive: json["is_active"],
createdBy: json["created_by"],
modifiedBy: json["modified_by"],
deletedAt: json["deleted_at"],
createdAt: json["created_at"],
updatedAt: json["updated_at"],
);
}
}
class TypesOfCommunity {
TypesOfCommunity({
required this.id,
required this.name,
});
final int? id;
final String? name;
factory TypesOfCommunity.fromJson(Map<String, dynamic> json){
return TypesOfCommunity(
id: json["id"],
name: json["name"],
);
}
}

View File

@@ -196,8 +196,8 @@ class _NewCommunityState extends State<NewCommunity> {
}
} else {
// Handle case where no image is selected
bannerPath.clear();
isbannerAdded = false;
filePath.clear();
isImageAdded = false;
setState(() {});
}
},

View File

@@ -153,7 +153,9 @@ class _CommunityDetailsState extends State<CommunityDetails> {
PopupMenuDivider(),
PopupMenuItem(
onTap: () {
Get.toNamed(RouteName.communitysetting);
Get.toNamed(RouteName.communitysetting,arguments: {
'communityid' : CommunityId,
});
},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8.w),

View File

@@ -6,11 +6,13 @@ import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Common/controller/data/network/network_api.dart';
import 'package:regroup/sidemenu/Community/MyCommunity/Model/communityMebersModel.dart';
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';
CommunityAddgroupsModel? communityaddgroupobj;
CommunitygroupsModel? communitygroupspobj;
CommunityMembersModel? communitymembersobj;
CommunityinfopageEditModel? communityeditobj;
@@ -59,4 +61,16 @@ class Getcommunity {
return response;
}
Future<ResponseData<dynamic>> getCommunityeditpage(updata) async {
final response = await NetworkApiServices().getApi(
"${ApiUrls.geteditcommunity}?community_id=$updata",
// optionalpar: false
);
if (response.status == ResponseStatus.SUCCESS) {
communityeditobj = CommunityinfopageEditModel.fromJson(response.data);
log(communityeditobj!.data.toString());
}
return response;
}
}