use new home logic
This commit is contained in:
@@ -35,10 +35,7 @@ class _PackageTestState extends State<PackageTest> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: true,
|
||||||
true,
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
// Navigator.of(context).pop();
|
// Navigator.of(context).pop();
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.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.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_action.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||||
@@ -59,10 +58,7 @@ class _AboutMihState extends State<AboutMih> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: true,
|
||||||
true,
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.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.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_action.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||||
@@ -44,10 +43,7 @@ class _MihAccessState extends State<MihAccess> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: true,
|
||||||
true,
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'dart:convert';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||||
@@ -186,10 +185,7 @@ class _ForgotPasswordState extends State<ForgotPassword> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: true,
|
||||||
true,
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
buttonColor: MihColors.getGreenColor(
|
buttonColor: MihColors.getGreenColor(
|
||||||
@@ -246,10 +242,7 @@ class _ForgotPasswordState extends State<ForgotPassword> {
|
|||||||
// Navigator.of(context).pop();
|
// Navigator.of(context).pop();
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: true,
|
||||||
true,
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.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.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_action.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||||
@@ -46,10 +45,7 @@ class _MIHCalculatorState extends State<MIHCalculator> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: widget.personalSelected,
|
||||||
widget.personalSelected,
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -45,10 +45,7 @@ class _MzansiCalendarState extends State<MzansiCalendar> {
|
|||||||
// Navigator.of(context).pop();
|
// Navigator.of(context).pop();
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: true,
|
||||||
true,
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_tile.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.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_package_tool_body.dart';
|
||||||
@@ -62,10 +61,7 @@ class _MihSignInState extends State<MihSignIn> {
|
|||||||
if (successfulSignIn) {
|
if (successfulSignIn) {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: true,
|
||||||
true,
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,10 +268,7 @@ class _MIHAppDrawerState extends State<MIHAppDrawer> {
|
|||||||
false) {
|
false) {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: true,
|
||||||
true,
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
// Navigator.of(context).pop();
|
// Navigator.of(context).pop();
|
||||||
// Navigator.of(context).popAndPushNamed(
|
// Navigator.of(context).popAndPushNamed(
|
||||||
|
|||||||
@@ -1,44 +1,45 @@
|
|||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.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.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_action.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_circle_avatar.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_circle_avatar.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_user.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/notification.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patients.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mih_home/components/mih_app_drawer.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mih_home/components/mih_app_drawer.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mih_home/mih_home_error.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mih_home/package_tools/mih_business_home.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mih_home/package_tools/mih_business_home.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mih_home/package_tools/mih_personal_home.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mih_home/package_tools/mih_personal_home.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_service_calls.dart';
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
class MihHome extends StatefulWidget {
|
class MihHome extends StatefulWidget {
|
||||||
final AppUser signedInUser;
|
// final AppUser signedInUser;
|
||||||
final BusinessUser? businessUser;
|
// final BusinessUser? businessUser;
|
||||||
final Business? business;
|
// final Business? business;
|
||||||
final Patient? patient;
|
// final Patient? patient;
|
||||||
final List<MIHNotification> notifications;
|
// final List<MIHNotification> notifications;
|
||||||
final ImageProvider<Object>? propicFile;
|
// final ImageProvider<Object>? propicFile;
|
||||||
final bool isUserNew;
|
// final bool isUserNew;
|
||||||
final bool isBusinessUser;
|
// final bool isBusinessUser;
|
||||||
final bool isBusinessUserNew;
|
// final bool isBusinessUserNew;
|
||||||
final bool isDevActive;
|
// final bool isDevActive;
|
||||||
bool personalSelected;
|
final bool personalSelected;
|
||||||
MihHome({
|
const MihHome({
|
||||||
super.key,
|
super.key,
|
||||||
required this.signedInUser,
|
// required this.signedInUser,
|
||||||
required this.businessUser,
|
// required this.businessUser,
|
||||||
required this.business,
|
// required this.business,
|
||||||
required this.patient,
|
// required this.patient,
|
||||||
required this.notifications,
|
// required this.notifications,
|
||||||
required this.propicFile,
|
// required this.propicFile,
|
||||||
required this.isUserNew,
|
// required this.isUserNew,
|
||||||
required this.isBusinessUser,
|
// required this.isBusinessUser,
|
||||||
required this.isBusinessUserNew,
|
// required this.isBusinessUserNew,
|
||||||
required this.isDevActive,
|
// required this.isDevActive,
|
||||||
required this.personalSelected,
|
required this.personalSelected,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -50,6 +51,7 @@ class _MihHomeState extends State<MihHome> {
|
|||||||
final proPicController = TextEditingController();
|
final proPicController = TextEditingController();
|
||||||
late int _selcetedIndex;
|
late int _selcetedIndex;
|
||||||
late bool _personalSelected;
|
late bool _personalSelected;
|
||||||
|
late Future<HomeArguments> profileData;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
@@ -59,7 +61,7 @@ class _MihHomeState extends State<MihHome> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
profileData = MIHApiCalls().getProfile(10, context);
|
||||||
if (widget.personalSelected == true) {
|
if (widget.personalSelected == true) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selcetedIndex = 0;
|
_selcetedIndex = 0;
|
||||||
@@ -83,12 +85,27 @@ class _MihHomeState extends State<MihHome> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
return FutureBuilder(
|
||||||
|
future: profileData,
|
||||||
|
builder: (context, asyncSnapshot) {
|
||||||
|
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
||||||
|
return Scaffold(
|
||||||
|
body: const Mihloadingcircle(
|
||||||
|
message: "Getting your Data...",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else if (asyncSnapshot.connectionState == ConnectionState.done &&
|
||||||
|
asyncSnapshot.hasData) {
|
||||||
return MihPackage(
|
return MihPackage(
|
||||||
appActionButton: getAction(),
|
appActionButton: getAction(asyncSnapshot.data!.profilePicUrl),
|
||||||
appTools: getTools(),
|
appTools:
|
||||||
appBody: getToolBody(),
|
getTools(asyncSnapshot.data!.signedInUser.type != "personal"),
|
||||||
|
appBody: getToolBody(asyncSnapshot.data!),
|
||||||
appToolTitles: getToolTitle(),
|
appToolTitles: getToolTitle(),
|
||||||
actionDrawer: getActionDrawer(),
|
actionDrawer: getActionDrawer(
|
||||||
|
asyncSnapshot.data!.signedInUser,
|
||||||
|
asyncSnapshot.data!.profilePicUrl,
|
||||||
|
),
|
||||||
selectedbodyIndex: _selcetedIndex,
|
selectedbodyIndex: _selcetedIndex,
|
||||||
onIndexChange: (newValue) {
|
onIndexChange: (newValue) {
|
||||||
if (_selcetedIndex == 0) {
|
if (_selcetedIndex == 0) {
|
||||||
@@ -104,15 +121,24 @@ class _MihHomeState extends State<MihHome> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return MihHomeError(
|
||||||
|
errorMessage: asyncSnapshot.hasError
|
||||||
|
? asyncSnapshot.error.toString()
|
||||||
|
: "An unknown error occurred",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getAction() {
|
Widget getAction(String proPicUrl) {
|
||||||
return Builder(builder: (context) {
|
return Builder(builder: (context) {
|
||||||
return MihPackageAction(
|
return MihPackageAction(
|
||||||
icon: Padding(
|
icon: Padding(
|
||||||
padding: const EdgeInsets.only(left: 5.0),
|
padding: const EdgeInsets.only(left: 5.0),
|
||||||
child: MihCircleAvatar(
|
child: MihCircleAvatar(
|
||||||
imageFile: widget.propicFile,
|
imageFile: proPicUrl != "" ? NetworkImage(proPicUrl) : null,
|
||||||
width: 50,
|
width: 50,
|
||||||
editable: false,
|
editable: false,
|
||||||
fileNameController: proPicController,
|
fileNameController: proPicController,
|
||||||
@@ -147,14 +173,14 @@ class _MihHomeState extends State<MihHome> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
MIHAppDrawer getActionDrawer() {
|
MIHAppDrawer getActionDrawer(AppUser signedInUser, String proPicUrl) {
|
||||||
return MIHAppDrawer(
|
return MIHAppDrawer(
|
||||||
signedInUser: widget.signedInUser,
|
signedInUser: signedInUser,
|
||||||
propicFile: widget.propicFile,
|
propicFile: proPicUrl != "" ? NetworkImage(proPicUrl) : null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
MihPackageTools getTools() {
|
MihPackageTools getTools(bool isBusinessUser) {
|
||||||
Map<Widget, void Function()?> temp = {};
|
Map<Widget, void Function()?> temp = {};
|
||||||
temp[const Icon(Icons.person)] = () {
|
temp[const Icon(Icons.person)] = () {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -162,7 +188,7 @@ class _MihHomeState extends State<MihHome> {
|
|||||||
_personalSelected = true;
|
_personalSelected = true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
if (widget.isBusinessUser) {
|
if (isBusinessUser) {
|
||||||
temp[const Icon(Icons.business_center)] = () {
|
temp[const Icon(Icons.business_center)] = () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selcetedIndex = 1;
|
_selcetedIndex = 1;
|
||||||
@@ -176,27 +202,29 @@ class _MihHomeState extends State<MihHome> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getToolBody() {
|
List<Widget> getToolBody(HomeArguments profData) {
|
||||||
List<Widget> toolBodies = [];
|
List<Widget> toolBodies = [];
|
||||||
toolBodies.add(
|
toolBodies.add(
|
||||||
MihPersonalHome(
|
MihPersonalHome(
|
||||||
signedInUser: widget.signedInUser,
|
signedInUser: profData.signedInUser,
|
||||||
personalSelected: _personalSelected,
|
personalSelected: _personalSelected,
|
||||||
business: widget.business,
|
business: profData.business,
|
||||||
businessUser: widget.businessUser,
|
businessUser: profData.businessUser,
|
||||||
propicFile: widget.propicFile,
|
propicFile: profData.profilePicUrl != ""
|
||||||
isUserNew: widget.isUserNew,
|
? NetworkImage(profData.profilePicUrl)
|
||||||
isDevActive: widget.isDevActive,
|
: null,
|
||||||
|
isDevActive: AppEnviroment.getEnv() == "Dev",
|
||||||
|
isUserNew: profData.signedInUser.username == "",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (widget.isBusinessUser) {
|
if (profData.signedInUser.type != "personal") {
|
||||||
toolBodies.add(
|
toolBodies.add(
|
||||||
MihBusinessHome(
|
MihBusinessHome(
|
||||||
signedInUser: widget.signedInUser,
|
signedInUser: profData.signedInUser,
|
||||||
personalSelected: _personalSelected,
|
personalSelected: _personalSelected,
|
||||||
businessUser: widget.businessUser,
|
businessUser: profData.businessUser,
|
||||||
business: widget.business,
|
business: profData.business,
|
||||||
isBusinessUserNew: widget.isBusinessUserNew,
|
isBusinessUserNew: profData.businessUser == null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
150
Frontend/lib/mih_packages/mih_home/mih_home_error.dart
Normal file
150
Frontend/lib/mih_packages/mih_home/mih_home_error.dart
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.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_tool_body.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
|
|
||||||
|
class MihHomeError extends StatefulWidget {
|
||||||
|
final String errorMessage;
|
||||||
|
const MihHomeError({
|
||||||
|
super.key,
|
||||||
|
required this.errorMessage,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MihHomeError> createState() => _MihHomeErrorState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MihHomeErrorState extends State<MihHomeError> {
|
||||||
|
int _selcetedIndex = 0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MihPackage(
|
||||||
|
appActionButton: getErrorAction(),
|
||||||
|
appTools: getErrorTools(),
|
||||||
|
appBody: getErrorToolBody(widget.errorMessage),
|
||||||
|
selectedbodyIndex: _selcetedIndex,
|
||||||
|
onIndexChange: (newValue) {
|
||||||
|
setState(() {
|
||||||
|
_selcetedIndex = newValue;
|
||||||
|
});
|
||||||
|
//print("Index: $_selcetedIndex");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
MihPackageAction getErrorAction() {
|
||||||
|
return MihPackageAction(
|
||||||
|
icon: const Icon(Icons.refresh),
|
||||||
|
iconSize: 35,
|
||||||
|
onTap: () {
|
||||||
|
context.goNamed(
|
||||||
|
'mihHome',
|
||||||
|
extra: true,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
MihPackageTools getErrorTools() {
|
||||||
|
Map<Widget, void Function()?> temp = {};
|
||||||
|
temp[const Icon(Icons.power_off_outlined)] = () {
|
||||||
|
setState(() {
|
||||||
|
_selcetedIndex = 0;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
return MihPackageTools(
|
||||||
|
tools: temp,
|
||||||
|
selcetedIndex: _selcetedIndex,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> getErrorToolBody(String error) {
|
||||||
|
List<Widget> toolBodies = [
|
||||||
|
MihPackageToolBody(
|
||||||
|
borderOn: true,
|
||||||
|
bodyItem: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Connection Error",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
fontSize: 35,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Icon(
|
||||||
|
Icons.power_off_outlined,
|
||||||
|
size: 150,
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 500,
|
||||||
|
child: Text(
|
||||||
|
"Looks like we ran into an issue getting your data.\nPlease check you internet connection and try again.",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
MihButton(
|
||||||
|
onPressed: () {
|
||||||
|
context.goNamed(
|
||||||
|
'mihHome',
|
||||||
|
extra: true,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
buttonColor: MihColors.getGreenColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
width: 300,
|
||||||
|
child: Text(
|
||||||
|
"Refresh",
|
||||||
|
style: TextStyle(
|
||||||
|
color: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(10.0),
|
||||||
|
child: SizedBox(
|
||||||
|
width: 500,
|
||||||
|
child: SelectionArea(
|
||||||
|
child: Text(
|
||||||
|
"Error: $error",
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
style: TextStyle(
|
||||||
|
color: MihColors.getRedColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
];
|
||||||
|
return toolBodies;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -75,7 +75,6 @@ class _MIHProfileGetterState extends State<MIHProfileGetter> {
|
|||||||
_selcetedIndex = 0;
|
_selcetedIndex = 0;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return MihPackageTools(
|
return MihPackageTools(
|
||||||
tools: temp,
|
tools: temp,
|
||||||
selcetedIndex: _selcetedIndex,
|
selcetedIndex: _selcetedIndex,
|
||||||
@@ -244,18 +243,18 @@ class _MIHProfileGetterState extends State<MIHProfileGetter> {
|
|||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
return MihHome(
|
return MihHome(
|
||||||
signedInUser: snapshot.requireData.signedInUser,
|
// signedInUser: snapshot.requireData.signedInUser,
|
||||||
businessUser: snapshot.data!.businessUser,
|
// businessUser: snapshot.data!.businessUser,
|
||||||
business: snapshot.data!.business,
|
// business: snapshot.data!.business,
|
||||||
patient: snapshot.data!.patient,
|
// patient: snapshot.data!.patient,
|
||||||
notifications: snapshot.data!.notifi,
|
// notifications: snapshot.data!.notifi,
|
||||||
propicFile: snapshot.data!.profilePicUrl != ""
|
// propicFile: snapshot.data!.profilePicUrl != ""
|
||||||
? NetworkImage(snapshot.data!.profilePicUrl)
|
// ? NetworkImage(snapshot.data!.profilePicUrl)
|
||||||
: null,
|
// : null,
|
||||||
isUserNew: isUserNew(snapshot.requireData.signedInUser),
|
// isUserNew: isUserNew(snapshot.requireData.signedInUser),
|
||||||
isBusinessUser: isBusinessUser(snapshot.requireData.signedInUser),
|
// isBusinessUser: isBusinessUser(snapshot.requireData.signedInUser),
|
||||||
isBusinessUserNew: isBusinessUserNew(snapshot.data!.businessUser),
|
// isBusinessUserNew: isBusinessUserNew(snapshot.data!.businessUser),
|
||||||
isDevActive: isDevActive(),
|
// isDevActive: isDevActive(),
|
||||||
personalSelected: widget.personalSelected,
|
personalSelected: widget.personalSelected,
|
||||||
);
|
);
|
||||||
// return MIHHomeLegacy(
|
// return MIHHomeLegacy(
|
||||||
|
|||||||
@@ -31,10 +31,7 @@ class _MzansiAiState extends State<MzansiAi> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: true,
|
||||||
true,
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -100,10 +100,7 @@ class _MzansiDirectoryState extends State<MzansiDirectory> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: true,
|
||||||
true,
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -45,10 +45,7 @@ class _MzansiProfileState extends State<MzansiProfile> {
|
|||||||
// Navigator.of(context).pop();
|
// Navigator.of(context).pop();
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: true,
|
||||||
true,
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -182,10 +182,7 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: stayOnPersonalSide,
|
||||||
stayOnPersonalSide,
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
buttonColor: MihColors.getGreenColor(
|
buttonColor: MihColors.getGreenColor(
|
||||||
|
|||||||
@@ -55,10 +55,7 @@ class _MihWalletState extends State<MihWallet> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: true,
|
||||||
true,
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -525,10 +525,7 @@ class _AddPatientState extends State<AddPatient> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: true,
|
||||||
true,
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -45,10 +45,7 @@ class _PatientProfileState extends State<PatientProfile> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: true,
|
||||||
true,
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.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_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_loading_circle.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||||
@@ -102,10 +103,10 @@ class MihAuthenticationServices {
|
|||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
var userSignedin = jsonDecode(response.body);
|
var userSignedin = jsonDecode(response.body);
|
||||||
if (userSignedin["status"] == "OK") {
|
if (userSignedin["status"] == "OK") {
|
||||||
Navigator.of(context).pop();
|
context.pop();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Navigator.of(context).pop();
|
context.pop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'dart:convert';
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
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_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_button.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.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_error_message.dart';
|
||||||
@@ -52,10 +51,7 @@ class MihUserServices {
|
|||||||
if (response.statusCode == 201) {
|
if (response.statusCode == 201) {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: true,
|
||||||
true,
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
internetConnectionPopUp(context);
|
internetConnectionPopUp(context);
|
||||||
@@ -262,10 +258,7 @@ class MihUserServices {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
extra: AuthArguments(
|
extra: true,
|
||||||
true,
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
buttonColor: MihColors.getGreenColor(
|
buttonColor: MihColors.getGreenColor(
|
||||||
|
|||||||
Reference in New Issue
Block a user