From 4e11cbcce58d9f4f7e2443bacf30545756997b3d Mon Sep 17 00:00:00 2001 From: Yasien Mac Mini Date: Thu, 20 Feb 2025 14:01:23 +0200 Subject: [PATCH] git ignore update and edit profile update --- .gitignore | 3 +- .../mih_components/mih_profile_picture.dart | 91 ++++++++++--------- 2 files changed, 50 insertions(+), 44 deletions(-) diff --git a/.gitignore b/.gitignore index b21e387a..888a52b6 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ Mzansi_Mail/ # database/#innodb_redo/#ib_redo* .venv google-chrome-stable_current_amd64.deb -.env \ No newline at end of file +.env +Frontend/android/app/.cxx \ No newline at end of file diff --git a/Frontend/lib/mih_components/mih_profile_picture.dart b/Frontend/lib/mih_components/mih_profile_picture.dart index 0f4807d3..26cc6a8d 100644 --- a/Frontend/lib/mih_components/mih_profile_picture.dart +++ b/Frontend/lib/mih_components/mih_profile_picture.dart @@ -66,58 +66,63 @@ class _MIHProfilePictureState extends State { right: 0, child: IconButton.filled( onPressed: () async { - FilePickerResult? result = - await FilePicker.platform.pickFiles( - type: FileType.custom, - allowedExtensions: ['jpg', 'png'], - ); - // print( - // "Platform: ${MzanziInnovationHub.of(context)!.theme.getPlatform()}"); - if (MzanziInnovationHub.of(context)!.theme.getPlatform() == - "Web") { - if (result == null) return; - final selectedFile = result.files.first; - setState(() { - widget.onChange(selectedFile); - widget.proPic = selectedFile; - //print("MIH Profile Picture: ${widget.proPic}"); - propicPreview = MemoryImage(widget.proPic!.bytes!); - }); - - setState(() { - widget.proPicController.text = selectedFile.name; - }); - } else { + try { // print( - // "================\nHere for Android\n========================"); - if (result != null) { - // print("here 1"); - File file = File(result.files.single.path!); - PlatformFile? androidFile = PlatformFile( - path: file.path, - name: file.path.split('/').last, - size: file.lengthSync(), - bytes: await file.readAsBytes(), // Read file bytes - //extension: fileExtension, - ); - // print("here 2"); + // "Platform: ${MzanziInnovationHub.of(context)!.theme.getPlatform()}"); + FilePickerResult? result = + await FilePicker.platform.pickFiles( + type: FileType.image, + ); + + if (MzanziInnovationHub.of(context)!.theme.getPlatform() == + "Web") { + if (result == null) return; + final selectedFile = result.files.first; setState(() { - // print("here 3"); - widget.onChange(androidFile); - // print("here 4"); - widget.proPic = androidFile; - // print("here 5"); + widget.onChange(selectedFile); + widget.proPic = selectedFile; //print("MIH Profile Picture: ${widget.proPic}"); - //print("bytes: ${widget.proPic!.bytes!}"); - propicPreview = FileImage(file); + propicPreview = MemoryImage(widget.proPic!.bytes!); }); setState(() { - widget.proPicController.text = widget.proPic!.name; + widget.proPicController.text = selectedFile.name; }); } else { - // User canceled the picker + // print( + // "================\nHere for Android & IOS\n========================"); + if (result != null) { + // print("here 1"); + File file = File(result.files.single.path!); + PlatformFile? androidFile = PlatformFile( + path: file.path, + name: file.path.split('/').last, + size: file.lengthSync(), + bytes: await file.readAsBytes(), // Read file bytes + //extension: fileExtension, + ); + // print("here 2"); + setState(() { + // print("here 3"); + widget.onChange(androidFile); + // print("here 4"); + widget.proPic = androidFile; + // print("here 5"); + //print("MIH Profile Picture: ${widget.proPic}"); + //print("bytes: ${widget.proPic!.bytes!}"); + propicPreview = FileImage(file); + }); + + setState(() { + widget.proPicController.text = widget.proPic!.name; + }); + } else { + print("here in else"); + // User canceled the picker + } } + } catch (e) { + print("Error: $e"); } }, icon: const Icon(Icons.edit),