Fix go router to work with web and ios nav

This commit is contained in:
2026-05-26 13:19:34 +02:00
parent e85bf2d577
commit aee6497ccb
14 changed files with 230 additions and 226 deletions
+213 -209
View File
@@ -42,29 +42,29 @@ class MihGoRouterPaths {
static const String mihAuthentication = '/mih-authentication'; static const String mihAuthentication = '/mih-authentication';
static const String mihHome = '/'; static const String mihHome = '/';
static const String notifications = '/notifications'; static const String notifications = '/notifications';
static const String forgotPassword = '/mih-authentication/forgot-password'; static const String forgotPassword = 'forgot-password';
static const String aboutMih = '/about'; static const String aboutMih = 'about';
static const String mzansiProfileManage = '/mzansi-profile'; static const String mzansiProfileManage = 'mzansi-profile';
static const String mzansiProfileView = '/mzansi-profile/view'; static const String mzansiProfileView = 'mzansi-profile/view';
static const String businessProfileSetup = '/business-profile/set-up'; static const String businessProfileSetup = 'business-profile/set-up';
static const String businessProfileManage = '/business-profile/manage'; static const String businessProfileManage = 'business-profile/manage';
static const String businessProfileView = '/business-profile/view'; static const String businessProfileView = 'business-profile/view';
static const String patientProfile = '/patient-profile'; static const String patientProfile = 'patient-profile';
static const String patientProfileSetup = '/patient-profile/set-up'; static const String patientProfileSetup = 'patient-profile/set-up';
static const String mzansiWallet = '/mzansi-wallet'; static const String mzansiWallet = 'mzansi-wallet';
static const String mzansiDirectory = '/mzansi-directory'; static const String mzansiDirectory = 'mzansi-directory';
static const String mihAccess = '/mih-access'; static const String mihAccess = 'mih-access';
static const String calendar = '/calendar'; static const String calendar = 'calendar';
static const String appointments = '/appointments'; static const String appointments = 'appointments';
static const String patientManager = '/patient-manager'; static const String patientManager = 'patient-manager';
static const String patientManagerPatient = '/patient-manager/patient'; static const String patientManagerPatient = 'patient-manager/patient';
static const String fileViewer = '/file-veiwer'; static const String fileViewer = '/file-veiwer';
static const String printPreview = '/file-veiwer/print-preview'; static const String printPreview = '/file-veiwer/print-preview';
static const String barcodeScanner = '/scanner'; static const String barcodeScanner = '/scanner';
static const String calculator = '/calculator'; static const String calculator = 'calculator';
static const String mzansiAi = '/mzansi-ai'; static const String mzansiAi = 'mzansi-ai';
static const String mihMineSweeper = '/mih-minesweeper'; static const String mihMineSweeper = 'mih-minesweeper';
static const String packageDevTest = '/package-dev'; static const String packageDevTest = 'package-dev';
} }
class MihGoRouter { class MihGoRouter {
@@ -74,9 +74,9 @@ class MihGoRouter {
final bool isUserSignedIn = await SuperTokens.doesSessionExist(); final bool isUserSignedIn = await SuperTokens.doesSessionExist();
final unauthenticatedPaths = [ final unauthenticatedPaths = [
MihGoRouterPaths.mihAuthentication, MihGoRouterPaths.mihAuthentication,
MihGoRouterPaths.forgotPassword, "${MihGoRouterPaths.mihAuthentication}/${MihGoRouterPaths.forgotPassword}",
MihGoRouterPaths.resetPassword, MihGoRouterPaths.resetPassword,
MihGoRouterPaths.aboutMih, "/${MihGoRouterPaths.aboutMih}",
MihGoRouterPaths.businessProfileView, MihGoRouterPaths.businessProfileView,
]; ];
KenLogger.success( KenLogger.success(
@@ -101,14 +101,16 @@ class MihGoRouter {
KenLogger.success("MihGoRouter: mihAuthentication"); KenLogger.success("MihGoRouter: mihAuthentication");
return MihAuthentication(); return MihAuthentication();
}, },
), routes: [
GoRoute( GoRoute(
name: "forgotPassword", name: "forgotPassword",
path: MihGoRouterPaths.forgotPassword, path: MihGoRouterPaths.forgotPassword,
builder: (BuildContext context, GoRouterState state) { builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: forgotPassword"); KenLogger.success("MihGoRouter: forgotPassword");
return const MihAuthForgotPassword(); return const MihAuthForgotPassword();
}, },
),
],
), ),
GoRoute( GoRoute(
name: "resetPassword", name: "resetPassword",
@@ -136,115 +138,187 @@ class MihGoRouter {
key: UniqueKey(), key: UniqueKey(),
); );
}, },
), routes: [
// ========================== About MIH ================================== // ========================== About MIH ==================================
GoRoute( GoRoute(
name: "aboutMih", name: "aboutMih",
path: MihGoRouterPaths.aboutMih, path: MihGoRouterPaths.aboutMih,
builder: (BuildContext context, GoRouterState state) { builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: aboutMih"); KenLogger.success("MihGoRouter: aboutMih");
return AboutMih(); return AboutMih();
}, },
), ),
// ========================== Mzansi Profile Personal ================================== // ========================== Mzansi Profile Personal ==================================
GoRoute( GoRoute(
name: "mzansiProfileManage", name: "mzansiProfileManage",
path: MihGoRouterPaths.mzansiProfileManage, path: MihGoRouterPaths.mzansiProfileManage,
builder: (BuildContext context, GoRouterState state) { builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: mzansiProfileManage"); KenLogger.success("MihGoRouter: mzansiProfileManage");
return MzansiProfile(); return MzansiProfile();
}, },
), ),
GoRoute( GoRoute(
name: "mzansiProfileView", name: "mzansiProfileView",
path: MihGoRouterPaths.mzansiProfileView, path: MihGoRouterPaths.mzansiProfileView,
builder: (BuildContext context, GoRouterState state) { builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: mzansiProfileView"); KenLogger.success("MihGoRouter: mzansiProfileView");
MzansiDirectoryProvider directoryProvider = MzansiDirectoryProvider directoryProvider =
context.read<MzansiDirectoryProvider>(); context.read<MzansiDirectoryProvider>();
if (directoryProvider.selectedUser == null) { if (directoryProvider.selectedUser == null) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
context.go(MihGoRouterPaths.mihHome); context.go(MihGoRouterPaths.mihHome);
}); });
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
return MzansiProfileView(); return MzansiProfileView();
}, },
), ),
// ========================== Mzansi Profile Business ================================== // ========================== Mzansi Profile Business ==================================
GoRoute( GoRoute(
name: "businessProfileManage", name: "businessProfileManage",
path: MihGoRouterPaths.businessProfileManage, path: MihGoRouterPaths.businessProfileManage,
builder: (BuildContext context, GoRouterState state) { builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: businessProfileManage"); KenLogger.success("MihGoRouter: businessProfileManage");
return BusinesProfile(); return BusinesProfile();
}, },
), ),
GoRoute( GoRoute(
name: "businessProfileView", name: "businessProfileView",
path: MihGoRouterPaths.businessProfileView, path: MihGoRouterPaths.businessProfileView,
builder: (BuildContext context, GoRouterState state) { builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: businessProfileView"); KenLogger.success("MihGoRouter: businessProfileView");
String? businessId = state.uri.queryParameters['business_id']; String? businessId = state.uri.queryParameters['business_id'];
KenLogger.success("businessId: $businessId"); KenLogger.success("businessId: $businessId");
MzansiDirectoryProvider directoryProvider = MzansiDirectoryProvider directoryProvider =
context.read<MzansiDirectoryProvider>(); context.read<MzansiDirectoryProvider>();
if (directoryProvider.selectedBusiness == null && if (directoryProvider.selectedBusiness == null &&
businessId == null) { businessId == null) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
context.go(MihGoRouterPaths.mihHome); context.go(MihGoRouterPaths.mihHome);
}); });
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
return MzansiBusinessProfileView( return MzansiBusinessProfileView(
businessId: businessId, businessId: businessId,
fromMzansiDirectory: businessId == null, fromMzansiDirectory: businessId == null,
); );
}, },
), ),
GoRoute( GoRoute(
name: "businessProfileSetup", name: "businessProfileSetup",
path: MihGoRouterPaths.businessProfileSetup, path: MihGoRouterPaths.businessProfileSetup,
builder: (BuildContext context, GoRouterState state) { builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: businessProfileSetup"); KenLogger.success("MihGoRouter: businessProfileSetup");
return MzansiSetUpBusinessProfile(); return MzansiSetUpBusinessProfile();
}, },
), ),
// ========================== MIH Calculator ================================== // ========================== MIH Calculator ==================================
GoRoute( GoRoute(
name: "mihCalculator", name: "mihCalculator",
path: MihGoRouterPaths.calculator, path: MihGoRouterPaths.calculator,
builder: (BuildContext context, GoRouterState state) { builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: mihCalculator"); KenLogger.success("MihGoRouter: mihCalculator");
return MIHCalculator(); return MIHCalculator();
}, },
), ),
// ========================== MIH Calculator ================================== // ========================== MIH Calculator ==================================
GoRoute( GoRoute(
name: "mihCalendar", name: "mihCalendar",
path: MihGoRouterPaths.calendar, path: MihGoRouterPaths.calendar,
builder: (BuildContext context, GoRouterState state) { builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: mihCalendar"); KenLogger.success("MihGoRouter: mihCalendar");
return MzansiCalendar(); return MzansiCalendar();
}, },
), ),
// ========================== Mzansi AI ================================== // ========================== Mzansi AI ==================================
GoRoute( GoRoute(
name: "mzansiAi", name: "mzansiAi",
path: MihGoRouterPaths.mzansiAi, path: MihGoRouterPaths.mzansiAi,
builder: (BuildContext context, GoRouterState state) { builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: mzansiAi"); KenLogger.success("MihGoRouter: mzansiAi");
return MzansiAi(); return MzansiAi();
}, },
), ),
// ========================== Mzansi Wallet ================================== // ========================== Mzansi Wallet ==================================
GoRoute( GoRoute(
name: "mzansiWallet", name: "mzansiWallet",
path: MihGoRouterPaths.mzansiWallet, path: MihGoRouterPaths.mzansiWallet,
builder: (BuildContext context, GoRouterState state) { builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: mzansiWallet"); KenLogger.success("MihGoRouter: mzansiWallet");
return MihWallet(); return MihWallet();
}, },
),
// ========================== MIH Access Controls ==================================
GoRoute(
name: "mihAccess",
path: MihGoRouterPaths.mihAccess,
builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: mihAccess");
return MihAccess();
},
),
// ========================== Test Package ==================================
GoRoute(
name: "testPackage",
path: MihGoRouterPaths.packageDevTest,
builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: testPackage");
return PackageTest();
},
),
// ========================== Mzansi Directory ==================================
GoRoute(
name: "mzansiDirectory",
path: MihGoRouterPaths.mzansiDirectory,
builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: mzansiDirectory");
return MzansiDirectory();
},
),
// ========================== MIH Minesweeper ==================================
GoRoute(
name: "mihMinesweeper",
path: MihGoRouterPaths.mihMineSweeper,
builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: mihMineSweeper");
return MihMineSweeper();
},
),
// ========================== Patient Profile ==================================
GoRoute(
name: "patientProfile",
path: MihGoRouterPaths.patientProfile,
builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: patientProfile");
return PatientProfile();
},
),
GoRoute(
name: "patientProfileSetup",
path: MihGoRouterPaths.patientProfileSetup,
builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: patientProfileSetup");
return PatientSetUp();
},
),
GoRoute(
name: "patientManager",
path: MihGoRouterPaths.patientManager,
builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: patientManager");
return PatManager();
},
),
GoRoute(
name: "patientManagerPatient",
path: MihGoRouterPaths.patientManagerPatient,
builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: patientManagerPatient");
return PatientProfile();
},
),
// ========================== End ==================================
],
), ),
GoRoute( GoRoute(
name: "barcodeScanner", name: "barcodeScanner",
@@ -262,67 +336,6 @@ class MihGoRouter {
return MihBarcodeScanner(cardNumberController: args); return MihBarcodeScanner(cardNumberController: args);
}, },
), ),
// ========================== Test Package ==================================
GoRoute(
name: "testPackage",
path: MihGoRouterPaths.packageDevTest,
builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: testPackage");
return PackageTest();
},
),
// ========================== MIH Access Controls ==================================
GoRoute(
name: "mihAccess",
path: MihGoRouterPaths.mihAccess,
builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: mihAccess");
return MihAccess();
},
),
// ========================== Patient Profile ==================================
GoRoute(
name: "patientProfile",
path: MihGoRouterPaths.patientProfile,
builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: patientProfile");
return PatientProfile();
},
),
GoRoute(
name: "patientProfileSetup",
path: MihGoRouterPaths.patientProfileSetup,
builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: patientProfileSetup");
return PatientSetUp();
},
),
GoRoute(
name: "patientManager",
path: MihGoRouterPaths.patientManager,
builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: patientManager");
return PatManager();
},
),
GoRoute(
name: "patientManagerPatient",
path: MihGoRouterPaths.patientManagerPatient,
builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: patientManagerPatient");
return PatientProfile();
},
),
// ========================== Mzansi Directory ==================================
GoRoute(
name: "mzansiDirectory",
path: MihGoRouterPaths.mzansiDirectory,
builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: mzansiDirectory");
return MzansiDirectory();
},
),
// ========================== End ==================================
GoRoute( GoRoute(
name: "fileViewer", name: "fileViewer",
path: MihGoRouterPaths.fileViewer, path: MihGoRouterPaths.fileViewer,
@@ -347,15 +360,6 @@ class MihGoRouter {
return MIHPrintPreview(arguments: args); return MIHPrintPreview(arguments: args);
}, },
), ),
// ========================== MIH Minesweeper ==================================
GoRoute(
name: "mihMinesweeper",
path: MihGoRouterPaths.mihMineSweeper,
builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: mihMineSweeper");
return MihMineSweeper();
},
),
// ========================== End ================================== // ========================== End ==================================
// GoRoute( // GoRoute(
// name: "notifications", // name: "notifications",
@@ -18,7 +18,7 @@ class _AboutMihTileState extends State<AboutMihTile> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MihPackageTile( return MihPackageTile(
onTap: () { onTap: () {
context.pushNamed( context.goNamed(
"aboutMih", "aboutMih",
); );
// Navigator.of(context).pushNamed( // Navigator.of(context).pushNamed(
@@ -20,7 +20,7 @@ class _MihAccessTileState extends State<MihAccessTile> {
return MihPackageTile( return MihPackageTile(
authenticateUser: true, authenticateUser: true,
onTap: () { onTap: () {
context.pushNamed( context.goNamed(
"mihAccess", "mihAccess",
); );
// Navigator.of(context).pushNamed( // Navigator.of(context).pushNamed(
@@ -30,7 +30,7 @@ class _MihAccessTileState extends State<MihAccessTile> {
}, },
packageName: "Access Controls", packageName: "Access Controls",
packageIcon: Icon( packageIcon: Icon(
MihIcons.accessControl, MihIcons.mihAccessControls,
color: MihColors.secondary(), color: MihColors.secondary(),
// size: widget.packageSize, // size: widget.packageSize,
), ),
@@ -19,13 +19,13 @@ class _MihCalculatorTileState extends State<MihCalculatorTile> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MihPackageTile( return MihPackageTile(
onTap: () { onTap: () {
context.pushNamed( context.goNamed(
"mihCalculator", "mihCalculator",
); );
}, },
packageName: "Calculator", packageName: "Calculator",
packageIcon: Icon( packageIcon: Icon(
MihIcons.calculator, MihIcons.mihCalculator,
color: MihColors.secondary(), color: MihColors.secondary(),
// size: widget.packageSize, // size: widget.packageSize,
), ),
@@ -19,7 +19,7 @@ class _MzansiCalendarTileState extends State<MzansiCalendarTile> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MihPackageTile( return MihPackageTile(
onTap: () { onTap: () {
context.pushNamed( context.goNamed(
"mihCalendar", "mihCalendar",
); );
// Navigator.of(context).pushNamed( // Navigator.of(context).pushNamed(
@@ -29,7 +29,7 @@ class _MzansiCalendarTileState extends State<MzansiCalendarTile> {
}, },
packageName: "Calendar", packageName: "Calendar",
packageIcon: Icon( packageIcon: Icon(
MihIcons.calendar, MihIcons.mihCalendar,
color: MihColors.secondary(), color: MihColors.secondary(),
// size: widget.packageSize, // size: widget.packageSize,
), ),
@@ -75,7 +75,7 @@ class _MihAuthenticationState extends State<MihAuthentication> {
iconColor: MihColors.secondary(), iconColor: MihColors.secondary(),
iconSize: 45, iconSize: 45,
onTap: () { onTap: () {
context.goNamed("aboutMih", extra: true); context.pushNamed("aboutMih", extra: true);
}, },
), ),
); );
@@ -18,13 +18,13 @@ class _MihMineSweeperTileState extends State<MihMineSweeperTile> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MihPackageTile( return MihPackageTile(
onTap: () { onTap: () {
context.pushNamed( context.goNamed(
"mihMinesweeper", "mihMinesweeper",
); );
}, },
packageName: "Minesweeper", packageName: "Minesweeper",
packageIcon: Icon( packageIcon: Icon(
MihIcons.mineSweeper, MihIcons.mihMinesweeper,
color: MihColors.secondary(), color: MihColors.secondary(),
// size: widget.packageSize, // size: widget.packageSize,
), ),
@@ -19,7 +19,7 @@ class _MzansiAiTileState extends State<MzansiAiTile> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MihPackageTile( return MihPackageTile(
onTap: () { onTap: () {
context.pushNamed( context.goNamed(
'mzansiAi', 'mzansiAi',
); );
// Navigator.of(context).pushNamed( // Navigator.of(context).pushNamed(
@@ -18,7 +18,7 @@ class _MzansiDirectoryTileState extends State<MzansiDirectoryTile> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MihPackageTile( return MihPackageTile(
onTap: () { onTap: () {
context.pushNamed( context.goNamed(
"mzansiDirectory", "mzansiDirectory",
); );
// Navigator.of(context).pushNamed( // Navigator.of(context).pushNamed(
@@ -19,7 +19,7 @@ class _MzansiBusinessProfileTileState extends State<MzansiBusinessProfileTile> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MihPackageTile( return MihPackageTile(
onTap: () { onTap: () {
context.pushNamed( context.goNamed(
"businessProfileManage", "businessProfileManage",
); );
// Navigator.of(context).pushNamed( // Navigator.of(context).pushNamed(
@@ -20,7 +20,7 @@ class _MzansiProfileTileState extends State<MzansiProfileTile> {
// ImageProvider logo = MzansiInnovationHub.of(context)!.theme.logoImage(); // ImageProvider logo = MzansiInnovationHub.of(context)!.theme.logoImage();
return MihPackageTile( return MihPackageTile(
onTap: () { onTap: () {
context.pushNamed( context.goNamed(
'mzansiProfileManage', 'mzansiProfileManage',
); );
}, },
@@ -20,7 +20,7 @@ class _MihWalletTileState extends State<MihWalletTile> {
return MihPackageTile( return MihPackageTile(
// authenticateUser: true, // authenticateUser: true,
onTap: () { onTap: () {
context.pushNamed( context.goNamed(
'mzansiWallet', 'mzansiWallet',
); );
// Navigator.of(context).pushNamed( // Navigator.of(context).pushNamed(
@@ -22,7 +22,7 @@ class _PatManagerTileState extends State<PatManagerTile> {
return MihPackageTile( return MihPackageTile(
authenticateUser: true, authenticateUser: true,
onTap: () { onTap: () {
context.pushNamed( context.goNamed(
'patientManager', 'patientManager',
); );
// Navigator.of(context).pushNamed( // Navigator.of(context).pushNamed(
@@ -25,7 +25,7 @@ class _PatientProfileTileState extends State<PatientProfileTile> {
PatientManagerProvider patManProvider = PatientManagerProvider patManProvider =
context.read<PatientManagerProvider>(); context.read<PatientManagerProvider>();
patManProvider.setPersonalMode(true); patManProvider.setPersonalMode(true);
context.pushNamed("patientProfile"); context.goNamed("patientProfile");
}, },
packageName: "Patient Profile", packageName: "Patient Profile",
packageIcon: Icon( packageIcon: Icon(