Merge pull request #134 from WDI-Ideas/editcom

communities edit changes done and also some fixes
This commit is contained in:
Shubham Shetty
2024-08-20 17:54:45 +05:30
committed by GitHub
11 changed files with 240 additions and 96 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -180,6 +180,9 @@ class ApiUrls {
static const posteditcommunity = "${baseUrl}update-community";
static const getactivitieslist = "${baseUrl}get_activity";
}

View File

@@ -236,7 +236,7 @@ class _FeedTabState extends State<FeedTab> {
}
}
setValues() {
Future<void> setValues() async {
if (mounted) {
combinedList.clear();
combinedListGlobal.clear();
@@ -246,7 +246,7 @@ class _FeedTabState extends State<FeedTab> {
combinedListGlobal.addAll(combinedList);
_setModel();
countersHelper.setListsPopular();
_fetchIcons();
await _fetchIcons();
}
}
@@ -658,7 +658,7 @@ class _NormalCardTileState extends State<NormalCardTile> {
.last;
return commonGlassUI(
width: double.infinity,
height: 765.h,
height: 769.h,
mainOpacity: 1,
borderRadius: BorderRadius.circular(1),
customWidget: Column(
@@ -864,6 +864,7 @@ class _NormalCardTileState extends State<NormalCardTile> {
child: Column(children: [
SizedBox(
height: 30.h,
width: double.infinity,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,

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

@@ -8,8 +8,6 @@ import 'package:flutter_screenutil/flutter_screenutil.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';
@@ -20,6 +18,8 @@ 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';
@@ -94,8 +94,8 @@ class _EditCommunityState extends State<EditCommunity> {
});
}
primaryactlist.InterestModel? abilityModel;
List<primaryactlist.Data> activity = [];
primaryactlist.ActivitiesListsModel? abilityModel;
List<primaryactlist.Datum> activity = [];
List<String> _activitydrop = [];
String? selectedActivityName = '';
@@ -109,15 +109,16 @@ class _EditCommunityState extends State<EditCommunity> {
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.name.toString(),
"name": platform.title.toString(),
};
}).toList();
});
@@ -164,53 +165,79 @@ class _EditCommunityState extends State<EditCommunity> {
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(
file!.path,
filename: path.basename(file.path),
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
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;
}
} 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,
@@ -649,19 +676,19 @@ class _EditCommunityState extends State<EditCommunity> {
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),
// 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',

View File

@@ -53,26 +53,26 @@ class _ManageGroupsState extends State<ManageGroups> {
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(
@@ -111,7 +111,7 @@ class _ManageGroupsState extends State<ManageGroups> {
opacity2: 0.24,
width: 50.w,
height: 50.h,
borderRadius: BorderRadius.circular( 100),
borderRadius: BorderRadius.circular(100),
customWidget: Center(
child: Image.asset(
"assets/images/png/Black.png",
@@ -178,11 +178,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

@@ -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

@@ -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,7 @@ 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 +55,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 +64,11 @@ 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 +84,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
}

View File

@@ -182,6 +182,28 @@ class _CommunityDetailsState extends State<CommunityDetails> {
),
),
),
PopupMenuDivider(),
PopupMenuItem(
onTap: () {
Get.toNamed(RouteName.communitysetting, arguments: {
'communityid': CommunityId,
});
},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8.w),
child: Row(
children: [
text14w400white("Edit community"),
Spacer(),
Image.asset(
"assets/images/png/setting2.png",
height: 18.h,
width: 18.w,
)
],
),
),
),
],
child: Image.asset(
'assets/images/png/Group 1000004071.png',
@@ -436,10 +458,10 @@ class _CommunityDetailsState extends State<CommunityDetails> {
GestureDetector(
onTap: () {
// Get.toNamed(RouteName.addgroup);
Get.toNamed(RouteName.group, arguments: {
'id': CommunityId,
'iscommunity': true,
});
Get.toNamed(RouteName.group, arguments: {
'id': CommunityId,
'iscommunity': true,
});
},
child: commonGlassUI(
width: double.infinity,
@@ -591,7 +613,7 @@ class _PostsTabState extends State<PostsTab> {
super.initState();
}
_fetchIcons() {
_fetchIcons() {
_reactions = fetchlikeIconsModel!.data ?? [];
for (var post in commonobjmodel!.data) {
//Check if post as a like icon
@@ -659,6 +681,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,
),

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);