NEW: Mzansi Directory Provider Setup

This commit is contained in:
2025-10-22 14:43:01 +02:00
parent b0d38b4b11
commit 9bd039ca25
28 changed files with 2007 additions and 1928 deletions

View File

@@ -1,6 +1,4 @@
import 'package:go_router/go_router.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.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';
@@ -8,10 +6,8 @@ import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profi
import 'package:flutter/material.dart';
class MzansiProfileView extends StatefulWidget {
final AppUser user;
const MzansiProfileView({
super.key,
required this.user,
});
@override
@@ -42,13 +38,7 @@ class _MzansiProfileViewState extends State<MzansiProfileView> {
icon: const Icon(Icons.arrow_back),
iconSize: 35,
onTap: () {
context.goNamed(
"mzansiDirectory",
extra: MzansiDirectoryArguments(
personalSearch: true,
startSearchText: widget.user.username,
),
);
context.pop();
FocusScope.of(context).unfocus();
},
);
@@ -69,9 +59,9 @@ class _MzansiProfileViewState extends State<MzansiProfileView> {
List<Widget> getToolBody() {
List<Widget> toolBodies = [];
toolBodies.add(MihPersonalProfileView(
user: widget.user,
));
toolBodies.add(
MihPersonalProfileView(),
);
return toolBodies;
}

View File

@@ -1,6 +1,6 @@
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_components/mih_providers/mzansi_directory_provider.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_colors.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';
@@ -8,12 +8,11 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
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';
import 'package:provider/provider.dart';
class MihPersonalProfileView extends StatefulWidget {
final AppUser user;
const MihPersonalProfileView({
super.key,
required this.user,
});
@override
@@ -32,8 +31,10 @@ class _MihPersonalProfileViewState extends State<MihPersonalProfileView> {
@override
void initState() {
super.initState();
futureImageUrl =
MihFileApi.getMinioFileUrl(widget.user.pro_pic_path, context);
MzansiDirectoryProvider directoryProvider =
context.read<MzansiDirectoryProvider>();
futureImageUrl = MihFileApi.getMinioFileUrl(
directoryProvider.selectedUser!.pro_pic_path, context);
}
@override
@@ -48,152 +49,123 @@ class _MihPersonalProfileViewState extends State<MihPersonalProfileView> {
Widget getBody(double width) {
double profilePictureWidth = 150;
return MihSingleChildScroll(
child: Padding(
padding: MzansiInnovationHub.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: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
backgroundColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
onChange: () {},
);
} else {
return Icon(
MihIcons.iDontKnow,
size: profilePictureWidth,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
);
}
} else {
return Icon(
MihIcons.mihRing,
size: profilePictureWidth,
return Consumer<MzansiDirectoryProvider>(
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
Widget? child) {
return MihSingleChildScroll(
child: Padding(
padding:
MzansiInnovationHub.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: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
backgroundColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
onChange: () {},
);
} else {
return Icon(
MihIcons.iDontKnow,
size: profilePictureWidth,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
);
}
} else {
return Icon(
MihIcons.mihRing,
size: profilePictureWidth,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
);
}
}),
FittedBox(
child: Text(
directoryProvider.selectedUser!.username.isNotEmpty
? directoryProvider.selectedUser!.username
: "Username",
style: TextStyle(
fontSize: 35,
fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
);
}
// return Center(
// child: MihCircleAvatar(
// imageFile: propicPreview,
// width: 150,
// editable: false,
// fileNameController: proPicController,
// userSelectedfile: proPic,
// frameColor: MzansiInnovationHub.of(context)!
// .theme
// .secondaryColor(),
// backgroundColor:
// MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
// onChange: (selectedImage) {
// setState(() {
// proPic = selectedImage;
// });
// },
// ),
// );
}),
FittedBox(
child: Text(
widget.user.username.isNotEmpty
? widget.user.username
: "Username",
style: TextStyle(
fontSize: 35,
fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
),
),
FittedBox(
child: Text(
widget.user.fname.isNotEmpty
? "${widget.user.fname} ${widget.user.lname}"
: "Name Surname",
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
),
),
FittedBox(
child: Text(
widget.user.type.toUpperCase(),
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
),
),
const SizedBox(height: 10.0),
Center(
child: SizedBox(
width: 700,
child: Text(
widget.user.purpose.isNotEmpty
? widget.user.purpose
: "No Personal Mission added yet",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
),
),
),
FittedBox(
child: Text(
directoryProvider.selectedUser!.fname.isNotEmpty
? "${directoryProvider.selectedUser!.fname} ${directoryProvider.selectedUser!.lname}"
: "Name Surname",
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
),
),
FittedBox(
child: Text(
directoryProvider.selectedUser!.type.toUpperCase(),
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
),
),
const SizedBox(height: 10.0),
Center(
child: SizedBox(
width: 700,
child: Text(
directoryProvider.selectedUser!.purpose.isNotEmpty
? directoryProvider.selectedUser!.purpose
: "No Personal Mission added yet",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
),
),
),
const SizedBox(height: 30.0),
],
),
const SizedBox(height: 30.0),
// Center(
// child: MihButton(
// onPressed: () {
// // Connect with the user
// },
// buttonColor:
// MihColors.getGreenColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
// width: 300,
// child: Text(
// widget.user.username.isEmpty
// ? "Set Up Profile"
// : "Edit Profile",
// style: TextStyle(
// color:
// MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
// fontSize: 20,
// fontWeight: FontWeight.bold,
// ),
// ),
// ),
// ),
],
),
),
),
);
},
);
}
}