diff --git a/Frontend/lib/mih_components/mih_package_components/Example/package_tools/package_tool_one.dart b/Frontend/lib/mih_components/mih_package_components/Example/package_tools/package_tool_one.dart index ea56d9f5..04adcb92 100644 --- a/Frontend/lib/mih_components/mih_package_components/Example/package_tools/package_tool_one.dart +++ b/Frontend/lib/mih_components/mih_package_components/Example/package_tools/package_tool_one.dart @@ -125,6 +125,8 @@ class _PackageToolOneState extends State { userSelectedfile: file, frameColor: MzanziInnovationHub.of(context)!.theme.secondaryColor(), + backgroundColor: + MzanziInnovationHub.of(context)!.theme.primaryColor(), onChange: (selectedImage) { setState(() { file = selectedImage; diff --git a/Frontend/lib/mih_components/mih_package_components/assets/images/i-dont-know-dark.png b/Frontend/lib/mih_components/mih_package_components/assets/images/i-dont-know-dark.png new file mode 100644 index 00000000..a9e5cff9 Binary files /dev/null and b/Frontend/lib/mih_components/mih_package_components/assets/images/i-dont-know-dark.png differ diff --git a/Frontend/lib/mih_components/mih_package_components/assets/images/i-dont-know-2.png b/Frontend/lib/mih_components/mih_package_components/assets/images/i-dont-know-light.png similarity index 100% rename from Frontend/lib/mih_components/mih_package_components/assets/images/i-dont-know-2.png rename to Frontend/lib/mih_components/mih_package_components/assets/images/i-dont-know-light.png diff --git a/Frontend/lib/mih_components/mih_package_components/mih_circle_avatar.dart b/Frontend/lib/mih_components/mih_package_components/mih_circle_avatar.dart index 61674c4c..6c729ab6 100644 --- a/Frontend/lib/mih_components/mih_package_components/mih_circle_avatar.dart +++ b/Frontend/lib/mih_components/mih_package_components/mih_circle_avatar.dart @@ -13,6 +13,7 @@ class MihCircleAvatar extends StatefulWidget { final onChange; final PlatformFile? userSelectedfile; final Color frameColor; + final Color? backgroundColor; const MihCircleAvatar({ super.key, required this.imageFile, @@ -21,6 +22,7 @@ class MihCircleAvatar extends StatefulWidget { required this.fileNameController, required this.userSelectedfile, required this.frameColor, + required this.backgroundColor, required this.onChange, }); @@ -31,11 +33,29 @@ class MihCircleAvatar extends StatefulWidget { class _MihCircleAvatarState extends State { late ImageProvider? imagePreview; + ImageProvider? getAvatar() { + Color dark = const Color(0XFF3A4454); + if (widget.imageFile == null) { + if (widget.backgroundColor == dark) { + print("here in light icon"); + return const AssetImage( + 'lib/mih_components/mih_package_components/assets/images/i-dont-know-light.png'); + } else { + print("here in dark icon"); + return const AssetImage( + 'lib/mih_components/mih_package_components/assets/images/i-dont-know-dark.png'); + } + } else { + return widget.imageFile; + } + } + @override void initState() { super.initState(); + print("Avatar started"); setState(() { - imagePreview = widget.imageFile; + imagePreview = getAvatar(); }); } @@ -51,7 +71,7 @@ class _MihCircleAvatarState extends State { children: [ CircleAvatar( radius: widget.width / 2.2, - backgroundColor: widget.frameColor, + backgroundColor: widget.backgroundColor, backgroundImage: imagePreview, ), FittedBox( diff --git a/Frontend/lib/mih_packages/mih_home/components/mih_app_drawer.dart b/Frontend/lib/mih_packages/mih_home/components/mih_app_drawer.dart index a7c92dd5..39df30a0 100644 --- a/Frontend/lib/mih_packages/mih_home/components/mih_app_drawer.dart +++ b/Frontend/lib/mih_packages/mih_home/components/mih_app_drawer.dart @@ -41,63 +41,56 @@ class _MIHAppDrawerState extends State { // onChange: (newProPic) {}, // ), //print(widget.propicFile); - ImageProvider logoFrame = - MzanziInnovationHub.of(context)!.theme.logoFrame(); - if (widget.propicFile != null) { - return GestureDetector( - onTap: () { - Navigator.of(context).pop(); - Navigator.of(context).pushNamed( - '/mzansi-profile', - arguments: AppProfileUpdateArguments( - widget.signedInUser, widget.propicFile), - ); - }, - child: MihCircleAvatar( - imageFile: widget.propicFile, - width: 60, - editable: false, - fileNameController: proPicController, - onChange: (_) {}, - userSelectedfile: null, - frameColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), - ), - // MIHProfilePicture( - // profilePictureFile: widget.propicFile, - // proPicController: proPicController, - // proPic: null, - // width: 60, - // radius: 27, - // drawerMode: true, - // editable: false, - // frameColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), - // onChange: (newProPic) {}, - // ), - - // Stack( - // alignment: Alignment.center, - // fit: StackFit.loose, - // children: [ - // CircleAvatar( - // backgroundColor: - // MzanziInnovationHub.of(context)!.theme.primaryColor(), - // backgroundImage: widget.propicFile, - // //'https://media.licdn.com/dms/image/D4D03AQGd1-QhjtWWpA/profile-displayphoto-shrink_400_400/0/1671698053061?e=2147483647&v=beta&t=a3dJI5yxs5-KeXjj10LcNCFuC9IOfa8nNn3k_Qyr0CA'), - // radius: 27, - // ), - // SizedBox( - // width: 60, - // child: Image(image: logoFrame), - // ) - // ], - // ), - ); - } else { - return SizedBox( + return GestureDetector( + onTap: () { + Navigator.of(context).pop(); + Navigator.of(context).pushNamed( + '/mzansi-profile', + arguments: + AppProfileUpdateArguments(widget.signedInUser, widget.propicFile), + ); + }, + child: MihCircleAvatar( + imageFile: widget.propicFile, width: 60, - child: Image(image: logoFrame), - ); - } + editable: false, + fileNameController: proPicController, + onChange: (_) {}, + userSelectedfile: null, + frameColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), + backgroundColor: + MzanziInnovationHub.of(context)!.theme.secondaryColor(), + ), + // MIHProfilePicture( + // profilePictureFile: widget.propicFile, + // proPicController: proPicController, + // proPic: null, + // width: 60, + // radius: 27, + // drawerMode: true, + // editable: false, + // frameColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), + // onChange: (newProPic) {}, + // ), + + // Stack( + // alignment: Alignment.center, + // fit: StackFit.loose, + // children: [ + // CircleAvatar( + // backgroundColor: + // MzanziInnovationHub.of(context)!.theme.primaryColor(), + // backgroundImage: widget.propicFile, + // //'https://media.licdn.com/dms/image/D4D03AQGd1-QhjtWWpA/profile-displayphoto-shrink_400_400/0/1671698053061?e=2147483647&v=beta&t=a3dJI5yxs5-KeXjj10LcNCFuC9IOfa8nNn3k_Qyr0CA'), + // radius: 27, + // ), + // SizedBox( + // width: 60, + // child: Image(image: logoFrame), + // ) + // ], + // ), + ); } @override diff --git a/Frontend/lib/mih_packages/mih_home/mih_home.dart b/Frontend/lib/mih_packages/mih_home/mih_home.dart index b4628fdd..003b6b02 100644 --- a/Frontend/lib/mih_packages/mih_home/mih_home.dart +++ b/Frontend/lib/mih_packages/mih_home/mih_home.dart @@ -109,6 +109,8 @@ class _MihHomeState extends State { userSelectedfile: null, // frameColor: frameColor, frameColor: MzanziInnovationHub.of(context)!.theme.secondaryColor(), + backgroundColor: + MzanziInnovationHub.of(context)!.theme.primaryColor(), onChange: (_) {}, ), // MIHProfilePicture( diff --git a/Frontend/lib/mih_packages/mih_home/mih_profile_getter.dart b/Frontend/lib/mih_packages/mih_home/mih_profile_getter.dart index 95fb57c2..0d203d96 100644 --- a/Frontend/lib/mih_packages/mih_home/mih_profile_getter.dart +++ b/Frontend/lib/mih_packages/mih_home/mih_profile_getter.dart @@ -35,17 +35,6 @@ class _MIHProfileGetterState extends State { ImageProvider? propicFile; int _selcetedIndex = 0; - ImageProvider? isPictureAvailable(String url) { - if (url == "") { - return const AssetImage( - 'lib/mih_components/mih_package_components/assets/images/i-dont-know-2.png'); - } else if (url != "") { - return NetworkImage(url); - } else { - return null; - } - } - bool isUserNew(AppUser signedInUser) { if (signedInUser.fname == "") { return true; @@ -249,7 +238,9 @@ class _MIHProfileGetterState extends State { business: snapshot.data!.business, patient: snapshot.data!.patient, notifications: snapshot.data!.notifi, - propicFile: isPictureAvailable(snapshot.data!.profilePicUrl), + propicFile: snapshot.data!.profilePicUrl != "" + ? NetworkImage(snapshot.data!.profilePicUrl) + : null, isUserNew: isUserNew(snapshot.requireData.signedInUser), isBusinessUser: isBusinessUser(snapshot.requireData.signedInUser), isBusinessUserNew: isBusinessUserNew(snapshot.data!.businessUser),