diff --git a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/BusEditProfile.dart b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/BusEditProfile.dart index 5e32246..2654bfa 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/BusEditProfile.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/BusEditProfile.dart @@ -9,6 +9,7 @@ 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/View/ProfileTab.dart'; +import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/EditProfile/View/picturecontroller/profileimagecontoller.dart'; import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart'; import 'package:regroup/Utils/Common/CommonAppbar.dart'; import 'package:regroup/Utils/Common/CommonDropdown.dart'; @@ -92,9 +93,9 @@ class _BusEditProfileState extends State { void saveEditProfileBus() async { var imageFile; - if (editProfileImage.profilePicPath.value.isNotEmpty) { + if (editProfileImage.usserprofilePicPath.value.isNotEmpty) { imageFile = await MultipartFile.fromFile( - editProfileImage.profilePicPath.value, + editProfileImage.usserprofilePicPath.value, filename: path.basename(profilePicture), ); print(imageFile.toString()); @@ -130,7 +131,7 @@ class _BusEditProfileState extends State { "business_location": locationController.text, "bio": bioController.text, "business_profile": - editProfileImage.profilePicPath.isNotEmpty ? imageFile : null, + editProfileImage.usserprofilePicPath.isNotEmpty ? imageFile : null, // await convertFileToMultiPart(profilePicture), }); @@ -170,8 +171,8 @@ class _BusEditProfileState extends State { } } - final ProfileImageController editProfileImage = - Get.put(ProfileImageController()); + final UserProfileImageController editProfileImage = + Get.put(UserProfileImageController()); @override Widget build(BuildContext context) { @@ -263,13 +264,13 @@ class _BusEditProfileState extends State { // ), Obx( - () => editProfileImage.profilePicPath.value != + () => editProfileImage.usserprofilePicPath.value != '' ? ClipOval( child: SizedBox.fromSize( size: Size.fromRadius(50.r), child: editProfileImage - .profilePicPath + .usserprofilePicPath .value != '' ? Image( @@ -277,7 +278,7 @@ class _BusEditProfileState extends State { image: FileImage( File( editProfileImage - .profilePicPath + .usserprofilePicPath .value, ), ), @@ -304,7 +305,7 @@ class _BusEditProfileState extends State { size: Size.fromRadius(60.r), child: getEditProfileBus!.data! - .businessLogo + .businessProfileImage != null ? ClipOval( @@ -314,7 +315,7 @@ class _BusEditProfileState extends State { child: CircleAvatar( backgroundImage: NetworkImage( getEditProfileBus!.data! - .businessLogo!), + .businessProfileImage!), radius: 25.r, ), ), @@ -333,7 +334,7 @@ class _BusEditProfileState extends State { true, (result) { editProfileImage - .profilePicPath.value = result; + .usserprofilePicPath.value = result; var filenameresult = extractFileName(result); diff --git a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/EditProfile.dart b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/EditProfile.dart index 1edeb28..d03f584 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/EditProfile.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/EditProfile.dart @@ -8,10 +8,9 @@ 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; +import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/EditProfile/View/picturecontroller/indiprofileimagecontroller.dart'; import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart'; import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/EditProfile/ViewModel/InterestApiList.dart'; import 'package:regroup/Utils/Common/CommonDropdown.dart'; @@ -241,9 +240,9 @@ class _EditProfileState extends State { String abilitiesIds = selectedinterestid.toString(); print("Interests String: $abilitiesIds"); - if (editProfileImage.profilePicPath.value.isNotEmpty) { + if (editProfileImage.usserprofilePicPath.value.isNotEmpty) { imageFile = await MultipartFile.fromFile( - editProfileImage.profilePicPath.value, + editProfileImage.usserprofilePicPath.value, filename: path.basename(profilePicture), ); print(imageFile.toString()); @@ -269,15 +268,19 @@ class _EditProfileState extends State { // "email_address": "priyanka14@yopmail.com", "full_name": fullNameController.text, "profile_image": - editProfileImage.profilePicPath.isNotEmpty ? imageFile : null, - // await convertFileToMultiPart1(profilePicture), + editProfileImage.usserprofilePicPath.isNotEmpty ? imageFile : null, + // profilePicture.isNotEmpty + // ? await convertFileToMultiPart1(profilePicture) + // : null, // "profile_image": "ghjkk.png", "user_name": userNameController.text, "date_of_birth": dateController.text, "gender": _selectedgenderType, // "interest": "selectedSportsIds", - "interest": abilitiesIds, + "interest": + // '[1,2,3,4]', + abilitiesIds, "about": aboutController.text, "position": positionController.text, "training_scores": trainingScoresController.text, @@ -335,13 +338,13 @@ class _EditProfileState extends State { return selectedNames; } - final ProfileImageController editProfileImage = - Get.put(ProfileImageController()); + final UserIndiProfileImageController editProfileImage = + Get.put(UserIndiProfileImageController()); @override Widget build(BuildContext context) { return GestureDetector( - onTap: () => FocusManager.instance.primaryFocus?.unfocus(), + onTap: () => FocusManager.instance.primaryFocus?.unfocus(), child: Scaffold( // key: _scaffoldKey1, backgroundColor: const Color(0xFF222935), @@ -359,7 +362,7 @@ class _EditProfileState extends State { ), ); } - + if (snapshot.hasError) { return Center( child: Text( @@ -368,7 +371,7 @@ class _EditProfileState extends State { ), ); } - + if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { print("Data fetched-->"); @@ -395,9 +398,10 @@ class _EditProfileState extends State { // File(profilePicture), // fit: BoxFit.cover, // width: double.infinity, - // errorBuilder: (BuildContext context, - // Object exception, - // StackTrace? stackTrace) { + // errorBuilder: + // (BuildContext context, + // Object exception, + // StackTrace? stackTrace) { // return CircleAvatar( // backgroundImage: const AssetImage( // "assets/images/png/cimg3.png"), @@ -407,10 +411,11 @@ class _EditProfileState extends State { // ), // ), // ) - // : getEditProfileIndi?.data?.profilePhoto != + // : getEditProfileIndi + // ?.data?.profilePhoto != // null && - // getEditProfileIndi! - // .data!.profilePhoto!.isNotEmpty + // getEditProfileIndi!.data! + // .profilePhoto!.isNotEmpty // ? Container( // width: 100.w, // height: 100.h, @@ -435,13 +440,14 @@ class _EditProfileState extends State { // radius: 50.r, // ), Obx( - () => editProfileImage.profilePicPath.value != + () => editProfileImage + .usserprofilePicPath.value != '' ? ClipOval( child: SizedBox.fromSize( size: Size.fromRadius(50.r), child: editProfileImage - .profilePicPath + .usserprofilePicPath .value != '' ? Image( @@ -449,15 +455,17 @@ class _EditProfileState extends State { image: FileImage( File( editProfileImage - .profilePicPath + .usserprofilePicPath .value, ), ), fit: BoxFit.cover, width: double.infinity, errorBuilder: - (BuildContext context, - Object exception, + (BuildContext + context, + Object + exception, StackTrace? stackTrace) { return CircleAvatar( @@ -474,18 +482,20 @@ class _EditProfileState extends State { : ClipOval( child: SizedBox.fromSize( size: Size.fromRadius(60.r), - child: getEditProfileIndi! - .data!.profilePhoto != + child: getEditProfileIndi!.data! + .profilePhoto != null ? ClipOval( - child: SizedBox.fromSize( + child: + SizedBox.fromSize( size: Size.fromRadius( 25.r), child: CircleAvatar( - backgroundImage: NetworkImage( - getEditProfileIndi! - .data! - .profilePhoto!), + backgroundImage: + NetworkImage( + getEditProfileIndi! + .data! + .profilePhoto!), radius: 25.r, ), ), @@ -506,13 +516,14 @@ class _EditProfileState extends State { // var filenameresult = // extractFileName1(result); editProfileImage - .profilePicPath.value = result; - + .usserprofilePicPath + .value = result; + var filenameresult = extractFileName1(result); print( "File name is $filenameresult"); - + profilePicture = result; isImageAdded = true; setState(() {}); @@ -601,7 +612,7 @@ class _EditProfileState extends State { ), ), ), - + sizedBoxHeight(20.h), text16400white("Gender"), sizedBoxHeight(16.h), @@ -648,7 +659,8 @@ class _EditProfileState extends State { ), ), ), - hintText: "Elm street london, United Kingdom", + hintText: + "Elm street london, United Kingdom", ), sizedBoxHeight(20.h), Row( @@ -686,24 +698,23 @@ class _EditProfileState extends State { // showOtherOption: true, // initiallySelected: _selectedSports, // ), - - Obx(() { - return CustomDropDownChexkBox( - header: 'Select interest', - title: "", - listData: _interestdrop, - onItemSelected: getCatIdFromName, - leadingImage: Image.asset( - "assets/images/png/Vector (4).png", - width: 18.w, - height: 17.h, - ), - // showOtherOption: true, - initiallySelected: selectedNameList, - ); - }), - - + + // Obx(() { + // return CustomDropDownChexkBox( + // header: 'Select interest', + // title: "", + // listData: _interestdrop, + // onItemSelected: getCatIdFromName, + // leadingImage: Image.asset( + // "assets/images/png/Vector (4).png", + // width: 18.w, + // height: 17.h, + // ), + // // showOtherOption: true, + // initiallySelected: selectedNameList, + // ); + // }), + sizedBoxHeight(20.h), text16400white("About"), sizedBoxHeight(16.h), @@ -714,7 +725,7 @@ class _EditProfileState extends State { maxlines: 3, ), // sizedBoxHeight(20.h), - + text16400white("Position"), sizedBoxHeight(16.h), CustomTextFormField( diff --git a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/picturecontroller/indiprofileimagecontroller.dart b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/picturecontroller/indiprofileimagecontroller.dart new file mode 100644 index 0000000..fd01570 --- /dev/null +++ b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/picturecontroller/indiprofileimagecontroller.dart @@ -0,0 +1,47 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:image_cropper/image_cropper.dart'; + +class UserIndiProfileImageController extends GetxController { + RxString usserprofilePicPath = "".obs; + + void getImage(ImageSource imgSource) async { + final ImagePicker picker = ImagePicker(); + print('profilePicPath $usserprofilePicPath'); + final XFile? pickedImg = await picker.pickImage(source: imgSource); + if (pickedImg != null) { + final CroppedFile? croppedImg = await ImageCropper().cropImage( + sourcePath: pickedImg.path, + aspectRatio: const CropAspectRatio(ratioX: 1, ratioY: 1), + compressFormat: ImageCompressFormat.jpg, + maxHeight: 512, + maxWidth: 512, + compressQuality: 100, + cropStyle: CropStyle.circle, + aspectRatioPresets: [ + CropAspectRatioPreset.square, + ], + uiSettings: [ + AndroidUiSettings( + toolbarTitle: "Crop Image", + toolbarColor: Get.theme.appBarTheme.backgroundColor, + backgroundColor: Colors.black, + activeControlsWidgetColor: Colors.red, + cropFrameColor: Colors.white, + cropGridColor: Colors.white, // Ensure this matches the theme + cropGridColumnCount: 2, // Add to make the grid lines prominent + cropGridRowCount: 2, // Add to make the grid lines prominent + lockAspectRatio: true, // Ensure the aspect ratio is locked + ), + IOSUiSettings( + title: 'Crop Image', + ), + ], + ); + if (croppedImg != null) { + usserprofilePicPath.value = croppedImg.path; + } + } +} +} diff --git a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/picturecontroller/profileimagecontoller.dart b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/picturecontroller/profileimagecontoller.dart new file mode 100644 index 0000000..2913eb4 --- /dev/null +++ b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/picturecontroller/profileimagecontoller.dart @@ -0,0 +1,47 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:image_cropper/image_cropper.dart'; + +class UserProfileImageController extends GetxController { + RxString usserprofilePicPath = "".obs; + + void getImage(ImageSource imgSource) async { + final ImagePicker picker = ImagePicker(); + print('profilePicPath $usserprofilePicPath'); + final XFile? pickedImg = await picker.pickImage(source: imgSource); + if (pickedImg != null) { + final CroppedFile? croppedImg = await ImageCropper().cropImage( + sourcePath: pickedImg.path, + aspectRatio: const CropAspectRatio(ratioX: 1, ratioY: 1), + compressFormat: ImageCompressFormat.jpg, + maxHeight: 512, + maxWidth: 512, + compressQuality: 100, + cropStyle: CropStyle.circle, + aspectRatioPresets: [ + CropAspectRatioPreset.square, + ], + uiSettings: [ + AndroidUiSettings( + toolbarTitle: "Crop Image", + toolbarColor: Get.theme.appBarTheme.backgroundColor, + backgroundColor: Colors.black, + activeControlsWidgetColor: Colors.red, + cropFrameColor: Colors.white, + cropGridColor: Colors.white, // Ensure this matches the theme + cropGridColumnCount: 2, // Add to make the grid lines prominent + cropGridRowCount: 2, // Add to make the grid lines prominent + lockAspectRatio: true, // Ensure the aspect ratio is locked + ), + IOSUiSettings( + title: 'Crop Image', + ), + ], + ); + if (croppedImg != null) { + usserprofilePicPath.value = croppedImg.path; + } + } +} +}