Merge pull request #68 from WDI-Ideas/confi26july

conflicts resolved in profile page
This commit is contained in:
Shubham Shetty
2024-07-26 19:24:59 +05:30
committed by GitHub
2 changed files with 162 additions and 58 deletions

View File

@@ -8,6 +8,7 @@ import 'package:get/get.dart' hide MultipartFile, FormData;
import 'package:regroup/Common/CommonButton.dart';
import 'package:regroup/Common/CommonWidget.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Common/controller/profileimagecontroller.dart';
import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/EditProfile/Model/GetEditProfileIndi.dart';
import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/EditProfile/Model/InterestModel.dart'
as interestlist;
@@ -18,6 +19,7 @@ import 'package:regroup/Utils/Common/CustomTextformfield.dart';
import 'package:regroup/Utils/Common/CommonAppbar.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:path/path.dart' as path;
@@ -185,9 +187,6 @@ class _EditProfileState extends State<EditProfile> {
weightController.text = getEditProfileIndi!.data!.weight ?? '70kg';
battingAvgController.text =
getEditProfileIndi!.data!.battingAverage ?? '372';
isOnce = false;
setState(() {});
}
@@ -205,13 +204,41 @@ class _EditProfileState extends State<EditProfile> {
// print("Interests String: $interestsString");
FormData? updata;
var imageFile;
String abilitiesIds = selectedinterestid.toString();
print("Interests String: $abilitiesIds");
if (editProfileImage.profilePicPath.value.isNotEmpty) {
imageFile = await MultipartFile.fromFile(
editProfileImage.profilePicPath.value,
filename: path.basename(profilePicture),
);
print(imageFile.toString());
}
// else {
// if (getEditProfileIndi?.data?.profilePhoto == null) {
// //
// imageFile = await Helper.assetImageToMultipartFile(
// "assets/images/png/cimg3.png", "profile");
// } else {
// imageFile = await Helper.networkImageToMultipartFile(
// getEditProfileIndi!.data!.profilePhoto!,
// );
// Utils.networkImageToMultipartFile(
// "${ApiUrls.baseImageUrl}/${profileController.profileInfoModel.value.data!.profilePhoto}",
// );
// }
// }
updata = FormData.fromMap({
// "email_address": "priyanka14@yopmail.com",
"full_name": fullNameController.text,
"profile_image": await convertFileToMultiPart1(profilePicture),
"profile_image":
editProfileImage.profilePicPath.isNotEmpty ? imageFile : null,
// await convertFileToMultiPart1(profilePicture),
// "profile_image": "ghjkk.png",
"user_name": userNameController.text,
@@ -227,6 +254,8 @@ class _EditProfileState extends State<EditProfile> {
"batting_average": battingAvgController.text,
"address_line1": battingAvgController.text,
});
log(updata.toString());
print(imageFile.toString());
final data = await EditProfileApi().postEditProfileIndividual(updata);
if (data.status == ResponseStatus.SUCCESS) {
@@ -242,7 +271,7 @@ class _EditProfileState extends State<EditProfile> {
// snackPosition: SnackPosition.BOTTOM,
// );
Get.toNamed(RouteName.profiletab);
Get.toNamed(RouteName.mainscreen, arguments: 4);
} else {
// btnController.reset();
Get.snackbar(
@@ -272,6 +301,9 @@ class _EditProfileState extends State<EditProfile> {
return selectedNames;
}
final ProfileImageController editProfileImage =
Get.put(ProfileImageController());
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -319,53 +351,113 @@ class _EditProfileState extends State<EditProfile> {
sizedBoxHeight(25.h),
Stack(
children: [
profilePicture != "" && isImageAdded
? ClipOval(
child: SizedBox.fromSize(
size: Size.fromRadius(50.r),
child: Image.file(
File(profilePicture),
fit: BoxFit.cover,
width: double.infinity,
errorBuilder: (BuildContext context,
Object exception,
StackTrace? stackTrace) {
return CircleAvatar(
backgroundImage: const AssetImage(
"assets/images/png/cimg3.png"),
radius: 50.r,
);
},
),
// profilePicture != "" && isImageAdded
// ? ClipOval(
// child: SizedBox.fromSize(
// size: Size.fromRadius(50.r),
// child: Image.file(
// File(profilePicture),
// fit: BoxFit.cover,
// width: double.infinity,
// errorBuilder: (BuildContext context,
// Object exception,
// StackTrace? stackTrace) {
// return CircleAvatar(
// backgroundImage: const AssetImage(
// "assets/images/png/cimg3.png"),
// radius: 50.r,
// );
// },
// ),
// ),
// )
// : getEditProfileIndi?.data?.profilePhoto !=
// null &&
// getEditProfileIndi!
// .data!.profilePhoto!.isNotEmpty
// ? Container(
// width: 100.w,
// height: 100.h,
// decoration: ShapeDecoration(
// image: DecorationImage(
// image: NetworkImage(
// getEditProfileIndi!
// .data!.profilePhoto!,
// ),
// fit: BoxFit.cover,
// // onError: (error, stackTrace) {
// // // Fallback to default image in case of error
// // return const AssetImage("assets/images/png/cimg3.png");
// // },
// ),
// shape: const OvalBorder(),
// ),
// )
// : CircleAvatar(
// backgroundImage: const AssetImage(
// "assets/images/png/cimg3.png"),
// radius: 50.r,
// ),
Obx(
() => editProfileImage.profilePicPath.value !=
''
? ClipOval(
child: SizedBox.fromSize(
size: Size.fromRadius(50.r),
child: editProfileImage
.profilePicPath
.value !=
''
? Image(
// File(profilePicture),
image: FileImage(
File(
editProfileImage
.profilePicPath
.value,
),
),
fit: BoxFit.cover,
width: double.infinity,
errorBuilder:
(BuildContext context,
Object exception,
StackTrace?
stackTrace) {
return CircleAvatar(
backgroundImage:
const AssetImage(
"assets/images/png/cimg3.png"),
radius: 50.r,
);
},
)
: Image.asset(
'assets/images/png/cimg3.png')),
)
: ClipOval(
child: SizedBox.fromSize(
size: Size.fromRadius(60.r),
child: getEditProfileIndi!
.data!.profilePhoto !=
null
? ClipOval(
child: SizedBox.fromSize(
size: Size.fromRadius(
25.r),
child: CircleAvatar(
backgroundImage: NetworkImage(
getEditProfileIndi!
.data!
.profilePhoto!),
radius: 25.r,
),
),
)
: Image.asset(
"assets/images/blank-profile-picture-973460_1280.png")),
),
)
: getEditProfileIndi?.data?.profilePhoto !=
null &&
getEditProfileIndi!
.data!.profilePhoto!.isNotEmpty
? Container(
width: 100.w,
height: 100.h,
decoration: ShapeDecoration(
image: DecorationImage(
image: NetworkImage(
getEditProfileIndi!
.data!.profilePhoto!,
),
fit: BoxFit.cover,
// onError: (error, stackTrace) {
// // Fallback to default image in case of error
// return const AssetImage("assets/images/png/cimg3.png");
// },
),
shape: const OvalBorder(),
),
)
: CircleAvatar(
backgroundImage: const AssetImage(
"assets/images/png/cimg3.png"),
radius: 50.r,
),
),
Positioned(
bottom: 0,
right: 0,
@@ -375,8 +467,15 @@ class _EditProfileState extends State<EditProfile> {
context,
true,
(result) {
// var filenameresult =
// extractFileName1(result);
editProfileImage
.profilePicPath.value = result;
var filenameresult =
extractFileName1(result);
print(
"File name is $filenameresult");
profilePicture = result;
isImageAdded = true;
@@ -567,7 +666,6 @@ class _EditProfileState extends State<EditProfile> {
initiallySelected: selctedNameList,
);
}),
sizedBoxHeight(20.h),
@@ -639,10 +737,12 @@ class _EditProfileState extends State<EditProfile> {
backgroundColor: Colors.red,
colorText: Colors.white,
);
} else if (profilePicture == "") {
utils.showToast(
'Upload edit profile picture!');
} else {
}
// else if (profilePicture == "") {
// utils.showToast(
// 'Upload edit profile picture!');
// }
else {
print(selectedinterestid.toString());
saveEditProfileInd();
}

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_reaction_button/flutter_reaction_button.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
@@ -394,12 +395,13 @@ class _ProfileTabState extends State<ProfileTab> {
),
sizedBoxWidth(12.w),
text14400whiteblur(
"Elm street london, United Kingdom"),
],
),
sizedBoxHeight(20.h),
Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
commonContainer(
width: 25.w,
@@ -416,7 +418,9 @@ class _ProfileTabState extends State<ProfileTab> {
)),
),
sizedBoxWidth(12.w),
text14400whiteblur(interestText ?? ''),
Flexible(
child: text14400whiteblur(
interestText ?? '')),
// interestText
// text14400whiteblur(getEditProfileIndi!
// .data!.interest!