forked from yaso_meth/mih-project
have path route show up in url bar & change routes to make logical sense
This commit is contained in:
@@ -43,7 +43,7 @@ class _HomeTileGridState extends State<HomeTileGrid> {
|
||||
tileList.add(HomeTile(
|
||||
onTap: () {
|
||||
Navigator.of(context)
|
||||
.pushNamed('/profile', arguments: widget.signedInUser);
|
||||
.pushNamed('/user-profile', arguments: widget.signedInUser);
|
||||
// Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
// '/profile',
|
||||
// (route) => false,
|
||||
@@ -62,7 +62,7 @@ class _HomeTileGridState extends State<HomeTileGrid> {
|
||||
tileList.add(HomeTile(
|
||||
onTap: () {
|
||||
Navigator.of(context).popAndPushNamed(
|
||||
'/business/add',
|
||||
'/business-profile/set-up',
|
||||
arguments: widget.signedInUser,
|
||||
);
|
||||
// Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
@@ -104,7 +104,7 @@ class _HomeTileGridState extends State<HomeTileGrid> {
|
||||
tileList.add(HomeTile(
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
'/patient-access-review',
|
||||
'/access-review',
|
||||
arguments: widget.signedInUser,
|
||||
);
|
||||
// Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
@@ -196,7 +196,7 @@ class _HomeTileGridState extends State<HomeTileGrid> {
|
||||
tileList.add(HomeTile(
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
'/business/add',
|
||||
'/business-profile/set-up',
|
||||
arguments: widget.signedInUser,
|
||||
);
|
||||
// Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
@@ -212,7 +212,7 @@ class _HomeTileGridState extends State<HomeTileGrid> {
|
||||
));
|
||||
tileList.add(HomeTile(
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed('/patient-manager/add',
|
||||
Navigator.of(context).pushNamed('/patient-profile/set-up',
|
||||
arguments: widget.signedInUser);
|
||||
// Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
// '/patient-manager/add',
|
||||
@@ -229,9 +229,8 @@ class _HomeTileGridState extends State<HomeTileGrid> {
|
||||
onTap: () {
|
||||
// Navigator.of(context)
|
||||
// .popAndPushNamed('/profile', arguments: widget.signedInUser);
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
'/profile',
|
||||
(route) => false,
|
||||
Navigator.of(context).pushNamed(
|
||||
'/user-profile',
|
||||
arguments: widget.signedInUser,
|
||||
);
|
||||
},
|
||||
|
||||
@@ -139,7 +139,7 @@ class _MIHAppDrawerState extends State<MIHAppDrawer> {
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context)
|
||||
.pushNamedAndRemoveUntil('/home', (route) => false);
|
||||
.pushNamedAndRemoveUntil('/', (route) => false);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
@@ -166,7 +166,7 @@ class _MIHAppDrawerState extends State<MIHAppDrawer> {
|
||||
onTap: () {
|
||||
//signedInUser = snapshot.data!;
|
||||
//print("MIHAppDrawer: ${signedInUser.runtimeType}");
|
||||
Navigator.of(context).popAndPushNamed('/profile',
|
||||
Navigator.of(context).popAndPushNamed('/user-profile',
|
||||
arguments: widget.signedInUser);
|
||||
},
|
||||
),
|
||||
@@ -219,7 +219,7 @@ class _MIHAppDrawerState extends State<MIHAppDrawer> {
|
||||
MzanziInnovationHub.of(context)!.changeTheme(ThemeMode.dark);
|
||||
//print("Dark Mode: $darkm");
|
||||
}
|
||||
Navigator.of(context).popAndPushNamed('/home');
|
||||
Navigator.of(context).popAndPushNamed('/');
|
||||
});
|
||||
},
|
||||
icon: Icon(
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:patient_manager/components/inputsAndButtons/mihTextInput.dart';
|
||||
import 'package:patient_manager/main.dart';
|
||||
import 'package:patient_manager/objects/appUser.dart';
|
||||
import 'package:patient_manager/objects/arguments.dart';
|
||||
import 'package:patient_manager/objects/patients.dart';
|
||||
|
||||
class PatientDetails extends StatefulWidget {
|
||||
final AppUser signedInUser;
|
||||
final Patient selectedPatient;
|
||||
final String type;
|
||||
const PatientDetails({
|
||||
super.key,
|
||||
required this.signedInUser,
|
||||
required this.selectedPatient,
|
||||
required this.type,
|
||||
});
|
||||
@@ -194,8 +198,9 @@ class _PatientDetailsState extends State<PatientDetails> {
|
||||
alignment: Alignment.topRight,
|
||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed('/patient-manager/patient/edit',
|
||||
arguments: widget.selectedPatient);
|
||||
Navigator.of(context).pushNamed('/patient-profile/edit',
|
||||
arguments: PatientEditArguments(
|
||||
widget.signedInUser, widget.selectedPatient));
|
||||
},
|
||||
)
|
||||
];
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter_native_splash/flutter_native_splash.dart';
|
||||
import 'package:patient_manager/env/env.dart';
|
||||
import 'package:patient_manager/main.dart';
|
||||
import 'package:supertokens_flutter/supertokens.dart';
|
||||
import 'package:url_strategy/url_strategy.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
|
||||
@@ -12,6 +13,8 @@ void main() async {
|
||||
apiDomain: AppEnviroment.baseApiUrl,
|
||||
apiBasePath: "/auth",
|
||||
);
|
||||
setPathUrlStrategy();
|
||||
();
|
||||
FlutterNativeSplash.remove();
|
||||
runApp(const MzanziInnovationHub());
|
||||
}
|
||||
|
||||
@@ -40,3 +40,13 @@ class PatientViewArguments {
|
||||
this.type,
|
||||
);
|
||||
}
|
||||
|
||||
class PatientEditArguments {
|
||||
final AppUser signedInUser;
|
||||
final Patient selectedPatient;
|
||||
|
||||
PatientEditArguments(
|
||||
this.signedInUser,
|
||||
this.selectedPatient,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,16 +10,19 @@ import 'package:patient_manager/components/inputsAndButtons/mihTextInput.dart';
|
||||
import 'package:patient_manager/components/inputsAndButtons/mihButton.dart';
|
||||
import 'package:patient_manager/env/env.dart';
|
||||
import 'package:patient_manager/main.dart';
|
||||
import 'package:patient_manager/objects/appUser.dart';
|
||||
import 'package:patient_manager/objects/arguments.dart';
|
||||
import 'package:patient_manager/objects/patients.dart';
|
||||
import 'package:supertokens_flutter/supertokens.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
|
||||
class EditPatient extends StatefulWidget {
|
||||
final Patient selectedPatient;
|
||||
|
||||
final AppUser signedInUser;
|
||||
const EditPatient({
|
||||
super.key,
|
||||
required this.selectedPatient,
|
||||
required this.signedInUser,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -101,7 +104,12 @@ class _EditPatientState extends State<EditPatient> {
|
||||
// print("Here4");
|
||||
// print(response.statusCode);
|
||||
if (response.statusCode == 200) {
|
||||
Navigator.of(context).pushNamed('/home');
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pushNamed('/patient-profile',
|
||||
arguments: PatientViewArguments(
|
||||
widget.signedInUser, null, null, null, "personal"));
|
||||
//Navigator.of(context).pushNamed('/');
|
||||
String message =
|
||||
"${fnameController.text} ${lnameController.text}'s information has been updated successfully! Their medical records and details are now current.";
|
||||
successPopUp(message);
|
||||
@@ -130,7 +138,11 @@ class _EditPatientState extends State<EditPatient> {
|
||||
//print("Here4");
|
||||
//print(response.statusCode);
|
||||
if (response.statusCode == 200) {
|
||||
Navigator.of(context).pushNamed('/home');
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).popAndPushNamed('/patient-profile',
|
||||
arguments: PatientViewArguments(
|
||||
widget.signedInUser, null, null, null, "personal"));
|
||||
String message =
|
||||
"${fnameController.text} ${lnameController.text}'s record has been deleted successfully. This means it will no longer be visible in patient manager and cannot be used for future appointments.";
|
||||
successPopUp(message);
|
||||
|
||||
@@ -60,6 +60,7 @@ class _PatientViewState extends State<PatientView> {
|
||||
Widget showSelection(int index) {
|
||||
if (index == 0) {
|
||||
return PatientDetails(
|
||||
signedInUser: widget.arguments.signedInUser,
|
||||
selectedPatient: widget.arguments.selectedPatient!,
|
||||
type: widget.arguments.type,
|
||||
);
|
||||
|
||||
@@ -38,6 +38,7 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
||||
final nameController = TextEditingController();
|
||||
final typeController = TextEditingController();
|
||||
final regController = TextEditingController();
|
||||
final addressController = TextEditingController();
|
||||
final logonameController = TextEditingController();
|
||||
final fnameController = TextEditingController();
|
||||
final lnameController = TextEditingController();
|
||||
@@ -87,7 +88,7 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
||||
);
|
||||
if (response.statusCode == 201) {
|
||||
uploadSelectedFile(selectedSignature, signtureController);
|
||||
Navigator.of(context).pushNamed('/home');
|
||||
Navigator.of(context).pushNamed('/');
|
||||
String message =
|
||||
"Your business profile is now live! You can now start connecting with customers and growing your business.";
|
||||
successPopUp(message);
|
||||
|
||||
@@ -149,7 +149,7 @@ class _ProfileBusinessUpdateState extends State<ProfileBusinessUpdate> {
|
||||
deleteFileApiCall(oldSigPath);
|
||||
}
|
||||
|
||||
Navigator.of(context).pushNamed('/home');
|
||||
Navigator.of(context).pushNamed('/');
|
||||
String message =
|
||||
"Your business profile is now live! You can now start connecting with customers and growing your business.";
|
||||
successPopUp(message);
|
||||
|
||||
@@ -2,12 +2,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:patient_manager/Authentication/authCheck.dart';
|
||||
import 'package:patient_manager/components/addOrViewPatient.dart';
|
||||
import 'package:patient_manager/components/mihAppBar.dart';
|
||||
import 'package:patient_manager/components/signInOrRegister.dart';
|
||||
import 'package:patient_manager/objects/appUser.dart';
|
||||
import 'package:patient_manager/objects/arguments.dart';
|
||||
import 'package:patient_manager/objects/patients.dart';
|
||||
import 'package:patient_manager/pages/fullScreenFile.dart';
|
||||
import 'package:patient_manager/pages/home.dart';
|
||||
import 'package:patient_manager/pages/patientAccessReview.dart';
|
||||
import 'package:patient_manager/pages/patientAdd.dart';
|
||||
import 'package:patient_manager/pages/patientEdit.dart';
|
||||
@@ -22,120 +19,132 @@ class RouteGenerator {
|
||||
final args = settings.arguments;
|
||||
|
||||
switch (settings.name) {
|
||||
// Home or Sign in or Register Pages
|
||||
case '/':
|
||||
return MaterialPageRoute(builder: (_) => const AuthCheck());
|
||||
return MaterialPageRoute(
|
||||
settings: settings, builder: (_) => const AuthCheck());
|
||||
//===============================================================
|
||||
|
||||
case '/home':
|
||||
return MaterialPageRoute(builder: (_) => const Home());
|
||||
|
||||
case '/patient-profile':
|
||||
if (args is PatientViewArguments) {
|
||||
//print("route generator: $args");
|
||||
return MaterialPageRoute(
|
||||
builder: (_) => AddOrViewPatient(
|
||||
arguments: args,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _errorRoute();
|
||||
|
||||
case '/patient-access-review':
|
||||
if (args is AppUser) {
|
||||
//print("route generator: $args");
|
||||
return MaterialPageRoute(
|
||||
builder: (_) => PatientAccessRequest(
|
||||
signedInUser: args,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _errorRoute();
|
||||
|
||||
case '/patient-manager':
|
||||
if (args is BusinessArguments) {
|
||||
//print("route generator: $args");
|
||||
return MaterialPageRoute(
|
||||
builder: (_) => PatientManager(
|
||||
arguments: args,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _errorRoute();
|
||||
|
||||
case '/patient-manager/add':
|
||||
if (args is AppUser) {
|
||||
return MaterialPageRoute(
|
||||
builder: (_) => AddPatient(
|
||||
signedInUser: args,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _errorRoute();
|
||||
|
||||
case '/patient-manager/patient':
|
||||
if (args is PatientViewArguments) {
|
||||
return MaterialPageRoute(
|
||||
builder: (_) => PatientView(
|
||||
arguments: args,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _errorRoute();
|
||||
|
||||
case '/patient-manager/patient/edit':
|
||||
if (args is Patient) {
|
||||
return MaterialPageRoute(
|
||||
builder: (_) => EditPatient(
|
||||
selectedPatient: args,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _errorRoute();
|
||||
|
||||
case '/profile':
|
||||
//User Profile
|
||||
case '/user-profile':
|
||||
if (args is AppUser) {
|
||||
return MaterialPageRoute(
|
||||
settings: settings,
|
||||
builder: (_) => ProfileUserUpdate(
|
||||
signedInUser: args,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _errorRoute();
|
||||
//===============================================================
|
||||
|
||||
case '/file-veiwer':
|
||||
if (args is FileViewArguments) {
|
||||
return MaterialPageRoute(
|
||||
builder: (_) => FullScreenFileViewer(
|
||||
arguments: args,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _errorRoute();
|
||||
|
||||
//Business Profile Pages
|
||||
case '/business-profile':
|
||||
if (args is BusinessArguments) {
|
||||
return MaterialPageRoute(
|
||||
settings: settings,
|
||||
builder: (_) => ProfileBusinessUpdate(
|
||||
arguments: args,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _errorRoute();
|
||||
|
||||
case '/business/add':
|
||||
case '/business-profile/set-up':
|
||||
if (args is AppUser) {
|
||||
return MaterialPageRoute(
|
||||
settings: settings,
|
||||
builder: (_) => ProfileBusinessAdd(
|
||||
signedInUser: args,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _errorRoute();
|
||||
case '/signin':
|
||||
return MaterialPageRoute(builder: (_) => const SignInOrRegister());
|
||||
// //case '/signIn':
|
||||
// // return MaterialPageRoute(builder: (_) => SignIn());
|
||||
// case '/auth':
|
||||
// return MaterialPageRoute(builder: (_) => const AuthPage());
|
||||
//===============================================================
|
||||
|
||||
// Patient Profile Pages
|
||||
case '/patient-profile':
|
||||
if (args is PatientViewArguments) {
|
||||
//print("route generator: $args");
|
||||
return MaterialPageRoute(
|
||||
settings: settings,
|
||||
builder: (_) => AddOrViewPatient(
|
||||
arguments: args,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _errorRoute();
|
||||
case '/patient-profile/set-up':
|
||||
if (args is AppUser) {
|
||||
return MaterialPageRoute(
|
||||
settings: settings,
|
||||
builder: (_) => AddPatient(
|
||||
signedInUser: args,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _errorRoute();
|
||||
case '/patient-profile/edit':
|
||||
if (args is PatientEditArguments) {
|
||||
return MaterialPageRoute(
|
||||
settings: settings,
|
||||
builder: (_) => EditPatient(
|
||||
signedInUser: args.signedInUser,
|
||||
selectedPatient: args.selectedPatient,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _errorRoute();
|
||||
//===============================================================
|
||||
|
||||
// Access Review Page
|
||||
case '/access-review':
|
||||
if (args is AppUser) {
|
||||
//print("route generator: $args");
|
||||
return MaterialPageRoute(
|
||||
settings: settings,
|
||||
builder: (_) => PatientAccessRequest(
|
||||
signedInUser: args,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _errorRoute();
|
||||
//===============================================================
|
||||
|
||||
//Patient Manager Pages
|
||||
case '/patient-manager':
|
||||
if (args is BusinessArguments) {
|
||||
//print("route generator: $args");
|
||||
return MaterialPageRoute(
|
||||
settings: settings,
|
||||
builder: (_) => PatientManager(
|
||||
arguments: args,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _errorRoute();
|
||||
case '/patient-manager/patient':
|
||||
if (args is PatientViewArguments) {
|
||||
return MaterialPageRoute(
|
||||
settings: settings,
|
||||
builder: (_) => PatientView(
|
||||
arguments: args,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _errorRoute();
|
||||
//===============================================================
|
||||
|
||||
//Full Screen File Viewer
|
||||
case '/file-veiwer':
|
||||
if (args is FileViewArguments) {
|
||||
return MaterialPageRoute(
|
||||
settings: settings,
|
||||
builder: (_) => FullScreenFileViewer(
|
||||
arguments: args,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _errorRoute();
|
||||
}
|
||||
throw '';
|
||||
}
|
||||
|
||||
@@ -1229,6 +1229,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.2"
|
||||
url_strategy:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: url_strategy
|
||||
sha256: "6eff69fa0900b731a23552b38b54389f399d247dbb0998f2cbdf25bef6790a7c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.0"
|
||||
uuid:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -49,6 +49,8 @@ dependencies:
|
||||
gif: ^2.3.0
|
||||
intl: ^0.19.0
|
||||
flutter_native_splash: ^2.4.1
|
||||
#google_maps_flutter_web: ^0.5.10
|
||||
url_strategy: ^0.3.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
This is a placeholder for base href that will be replaced by the value of
|
||||
the `--base-href` argument provided to `flutter build`.
|
||||
-->
|
||||
<base href="$FLUTTER_BASE_HREF">
|
||||
<base href="/">
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
|
||||
|
||||
Reference in New Issue
Block a user