add profile preview package
This commit is contained in:
@@ -0,0 +1,76 @@
|
|||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profile/package_tools/mih_personal_profile_view.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class MzansiProfileView extends StatefulWidget {
|
||||||
|
final AppUser user;
|
||||||
|
const MzansiProfileView({
|
||||||
|
super.key,
|
||||||
|
required this.user,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MzansiProfileView> createState() => _MzansiProfileViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MzansiProfileViewState extends State<MzansiProfileView> {
|
||||||
|
int _selcetedIndex = 0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MihPackage(
|
||||||
|
appActionButton: getAction(),
|
||||||
|
appTools: getTools(),
|
||||||
|
appBody: getToolBody(),
|
||||||
|
appToolTitles: getToolTitle(),
|
||||||
|
selectedbodyIndex: _selcetedIndex,
|
||||||
|
onIndexChange: (newValue) {
|
||||||
|
setState(() {
|
||||||
|
_selcetedIndex = newValue;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
MihPackageAction getAction() {
|
||||||
|
return MihPackageAction(
|
||||||
|
icon: const Icon(Icons.arrow_back),
|
||||||
|
iconSize: 35,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
MihPackageTools getTools() {
|
||||||
|
Map<Widget, void Function()?> temp = {};
|
||||||
|
temp[const Icon(Icons.person)] = () {
|
||||||
|
setState(() {
|
||||||
|
_selcetedIndex = 0;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
return MihPackageTools(
|
||||||
|
tools: temp,
|
||||||
|
selcetedIndex: _selcetedIndex,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> getToolBody() {
|
||||||
|
List<Widget> toolBodies = [];
|
||||||
|
toolBodies.add(MihPersonalProfileView(
|
||||||
|
user: widget.user,
|
||||||
|
));
|
||||||
|
return toolBodies;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> getToolTitle() {
|
||||||
|
List<String> toolTitles = [
|
||||||
|
"Profile",
|
||||||
|
];
|
||||||
|
return toolTitles;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,198 @@
|
|||||||
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_circle_avatar.dart';
|
||||||
|
import 'package:file_picker/file_picker.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class MihPersonalProfileView extends StatefulWidget {
|
||||||
|
final AppUser user;
|
||||||
|
const MihPersonalProfileView({
|
||||||
|
super.key,
|
||||||
|
required this.user,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MihPersonalProfileView> createState() => _MihPersonalProfileViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MihPersonalProfileViewState extends State<MihPersonalProfileView> {
|
||||||
|
late Future<String> futureImageUrl;
|
||||||
|
PlatformFile? file;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
futureImageUrl =
|
||||||
|
MihFileApi.getMinioFileUrl(widget.user.pro_pic_path, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
double screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
return MihPackageToolBody(
|
||||||
|
borderOn: false,
|
||||||
|
innerHorizontalPadding: 10,
|
||||||
|
bodyItem: getBody(screenWidth),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getBody(double width) {
|
||||||
|
double profilePictureWidth = 150;
|
||||||
|
return MihSingleChildScroll(
|
||||||
|
child: Padding(
|
||||||
|
padding: MzanziInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||||
|
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
||||||
|
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
FutureBuilder(
|
||||||
|
future: futureImageUrl,
|
||||||
|
builder: (context, asyncSnapshot) {
|
||||||
|
if (asyncSnapshot.connectionState == ConnectionState.done &&
|
||||||
|
asyncSnapshot.hasData) {
|
||||||
|
if (asyncSnapshot.requireData != "") {
|
||||||
|
return MihCircleAvatar(
|
||||||
|
imageFile: NetworkImage(asyncSnapshot.requireData),
|
||||||
|
width: profilePictureWidth,
|
||||||
|
editable: false,
|
||||||
|
fileNameController: TextEditingController(),
|
||||||
|
userSelectedfile: file,
|
||||||
|
frameColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
backgroundColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
onChange: () {},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Icon(
|
||||||
|
MihIcons.iDontKnow,
|
||||||
|
size: profilePictureWidth,
|
||||||
|
color: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Icon(
|
||||||
|
MihIcons.mihRing,
|
||||||
|
size: profilePictureWidth,
|
||||||
|
color: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// return Center(
|
||||||
|
// child: MihCircleAvatar(
|
||||||
|
// imageFile: propicPreview,
|
||||||
|
// width: 150,
|
||||||
|
// editable: false,
|
||||||
|
// fileNameController: proPicController,
|
||||||
|
// userSelectedfile: proPic,
|
||||||
|
// frameColor: MzanziInnovationHub.of(context)!
|
||||||
|
// .theme
|
||||||
|
// .secondaryColor(),
|
||||||
|
// backgroundColor:
|
||||||
|
// MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
// onChange: (selectedImage) {
|
||||||
|
// setState(() {
|
||||||
|
// proPic = selectedImage;
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
}),
|
||||||
|
FittedBox(
|
||||||
|
child: Text(
|
||||||
|
widget.user.username.isNotEmpty
|
||||||
|
? widget.user.username
|
||||||
|
: "Username",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 35,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
FittedBox(
|
||||||
|
child: Text(
|
||||||
|
widget.user.fname.isNotEmpty
|
||||||
|
? "${widget.user.fname} ${widget.user.lname}"
|
||||||
|
: "Name Surname",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
FittedBox(
|
||||||
|
child: Text(
|
||||||
|
widget.user.type.toUpperCase(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Center(
|
||||||
|
child: SizedBox(
|
||||||
|
width: 700,
|
||||||
|
child: Text(
|
||||||
|
widget.user.purpose.isNotEmpty
|
||||||
|
? widget.user.purpose
|
||||||
|
: "No purpose added yet",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30.0),
|
||||||
|
// Center(
|
||||||
|
// child: MihButton(
|
||||||
|
// onPressed: () {
|
||||||
|
// // Connect with the user
|
||||||
|
// },
|
||||||
|
// buttonColor:
|
||||||
|
// MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||||
|
// width: 300,
|
||||||
|
// child: Text(
|
||||||
|
// widget.user.username.isEmpty
|
||||||
|
// ? "Set Up Profile"
|
||||||
|
// : "Edit Profile",
|
||||||
|
// style: TextStyle(
|
||||||
|
// color:
|
||||||
|
// MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
// fontSize: 20,
|
||||||
|
// fontWeight: FontWeight.bold,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user