forked from yaso_meth/mih-project
remove home border and use new icons
This commit is contained in:
@@ -101,7 +101,7 @@ class _MihAppState extends State<MihApp> with SingleTickerProviderStateMixin {
|
||||
drawer: widget.actionDrawer,
|
||||
body: SafeArea(
|
||||
bottom: false,
|
||||
minimum: EdgeInsets.only(bottom: 5),
|
||||
minimum: EdgeInsets.only(bottom: 0),
|
||||
child: Container(
|
||||
width: screenSize.width,
|
||||
height: screenSize.height,
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import '../../main.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class MIHProfilePicture extends StatefulWidget {
|
||||
final ImageProvider<Object>? profilePictureFile;
|
||||
final TextEditingController proPicController;
|
||||
|
||||
PlatformFile? proPic;
|
||||
final double width;
|
||||
final double radius;
|
||||
final bool drawerMode;
|
||||
final bool editable;
|
||||
final Color frameColor;
|
||||
final onChange;
|
||||
|
||||
MIHProfilePicture({
|
||||
super.key,
|
||||
required this.profilePictureFile,
|
||||
required this.proPicController,
|
||||
required this.proPic,
|
||||
required this.width,
|
||||
required this.radius,
|
||||
required this.drawerMode,
|
||||
required this.editable,
|
||||
required this.onChange,
|
||||
required this.frameColor,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MIHProfilePicture> createState() => _MIHProfilePictureState();
|
||||
}
|
||||
|
||||
class _MIHProfilePictureState extends State<MIHProfilePicture> {
|
||||
late ImageProvider<Object>? propicPreview;
|
||||
|
||||
Widget displayEditableProPic() {
|
||||
if (widget.profilePictureFile != null) {
|
||||
return Stack(
|
||||
alignment: Alignment.center,
|
||||
fit: StackFit.loose,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundColor:
|
||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
backgroundImage: propicPreview,
|
||||
//'https://media.licdn.com/dms/image/D4D03AQGd1-QhjtWWpA/profile-displayphoto-shrink_400_400/0/1671698053061?e=2147483647&v=beta&t=a3dJI5yxs5-KeXjj10LcNCFuC9IOfa8nNn3k_Qyr0CA'),
|
||||
radius: widget.radius,
|
||||
),
|
||||
SizedBox(
|
||||
width: widget.width,
|
||||
child: FittedBox(
|
||||
fit: BoxFit.fill,
|
||||
child: Icon(
|
||||
MihIcons.mihCircleFrame,
|
||||
color: widget.frameColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: widget.editable,
|
||||
child: Positioned(
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: IconButton.filled(
|
||||
onPressed: () async {
|
||||
try {
|
||||
// print(
|
||||
// "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(() {
|
||||
widget.onChange(selectedFile);
|
||||
widget.proPic = selectedFile;
|
||||
//print("MIH Profile Picture: ${widget.proPic}");
|
||||
propicPreview = MemoryImage(widget.proPic!.bytes!);
|
||||
});
|
||||
|
||||
setState(() {
|
||||
widget.proPicController.text = selectedFile.name;
|
||||
});
|
||||
} else {
|
||||
// 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),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return SizedBox(
|
||||
width: widget.width,
|
||||
child: Icon(
|
||||
MihIcons.mihCircleFrame,
|
||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
setState(() {
|
||||
propicPreview = widget.profilePictureFile;
|
||||
});
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return displayEditableProPic();
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import '../../mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import '../../mih_components/mih_pop_up_messages/mih_notification_message.dart';
|
||||
import '../../mih_components/mih_pop_up_messages/mih_success_message.dart';
|
||||
import '../../mih_components/mih_pop_up_messages/mih_warning_message.dart';
|
||||
import '../../mih_components/mih_profile_picture.dart';
|
||||
import '../../mih_env/env.dart';
|
||||
import '../../mih_objects/app_user.dart';
|
||||
import '../../mih_objects/arguments.dart';
|
||||
@@ -985,18 +984,18 @@ class _MIHHomeLegacyState extends State<MIHHomeLegacy> {
|
||||
return Builder(builder: (context) {
|
||||
return MIHAction(
|
||||
icon: Padding(
|
||||
padding: const EdgeInsets.only(left: 5.0),
|
||||
child: MIHProfilePicture(
|
||||
profilePictureFile: widget.propicFile,
|
||||
proPicController: proPicController,
|
||||
proPic: null,
|
||||
width: 45,
|
||||
radius: 21,
|
||||
drawerMode: false,
|
||||
editable: false,
|
||||
frameColor: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
onChange: (newProPic) {},
|
||||
),
|
||||
padding: const EdgeInsets.only(left: 5.0), child: Placeholder(),
|
||||
// MIHProfilePicture(
|
||||
// profilePictureFile: widget.propicFile,
|
||||
// proPicController: proPicController,
|
||||
// proPic: null,
|
||||
// width: 45,
|
||||
// radius: 21,
|
||||
// drawerMode: false,
|
||||
// editable: false,
|
||||
// frameColor: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
// onChange: (newProPic) {},
|
||||
// ),
|
||||
),
|
||||
// const Icon(Icons.apps),
|
||||
iconSize: 45,
|
||||
|
||||
@@ -190,7 +190,7 @@ class _MihBusinessHomeState extends State<MihBusinessHome>
|
||||
final double width = size.width;
|
||||
final double height = size.height;
|
||||
return MihAppToolBody(
|
||||
borderOn: true,
|
||||
borderOn: false,
|
||||
bodyItem: getBody(width, height),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -157,12 +157,9 @@ class _MihPersonalHomeState extends State<MihPersonalHome>
|
||||
);
|
||||
},
|
||||
appName: "Test",
|
||||
appIcon: Container(
|
||||
padding: const EdgeInsets.all(0.5),
|
||||
child: Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
),
|
||||
appIcon: Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
),
|
||||
iconSize: packageSize,
|
||||
primaryColor: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
@@ -238,7 +235,7 @@ class _MihPersonalHomeState extends State<MihPersonalHome>
|
||||
final double height = size.height;
|
||||
|
||||
return MihAppToolBody(
|
||||
borderOn: true,
|
||||
borderOn: false,
|
||||
bodyItem: getBody(width, height),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ import 'package:mzansi_innovation_hub/mih_components/mih_inputs_and_buttons/mih_
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_inputs_and_buttons/mih_text_input.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_single_child_scroll.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih-app_tool_body.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_circle_avatar.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_success_message.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_profile_picture.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_env/env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/arguments.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
@@ -350,13 +350,11 @@ class _MihBusinessProfileState extends State<MihBusinessProfile> {
|
||||
?.theme
|
||||
.secondaryColor()),
|
||||
const SizedBox(height: 10.0),
|
||||
MIHProfilePicture(
|
||||
profilePictureFile: logoPreview,
|
||||
proPicController: logonameController,
|
||||
proPic: logoFile,
|
||||
MihCircleAvatar(
|
||||
imageFile: logoPreview,
|
||||
fileNameController: logonameController,
|
||||
userSelectedfile: logoFile,
|
||||
width: 155,
|
||||
radius: 70,
|
||||
drawerMode: false,
|
||||
editable: true,
|
||||
frameColor:
|
||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
@@ -366,6 +364,8 @@ class _MihBusinessProfileState extends State<MihBusinessProfile> {
|
||||
});
|
||||
print("logoFile: ${logoFile?.bytes}");
|
||||
},
|
||||
backgroundColor:
|
||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MIHFileField(
|
||||
|
||||
Reference in New Issue
Block a user