Add Patient Manager Page
This commit is contained in:
@@ -5,6 +5,8 @@ import 'package:patient_manager/pages/home.dart';
|
|||||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||||
|
|
||||||
class AuthCheck extends StatelessWidget {
|
class AuthCheck extends StatelessWidget {
|
||||||
|
const AuthCheck({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return StreamBuilder<AuthState>(
|
return StreamBuilder<AuthState>(
|
||||||
@@ -15,9 +17,11 @@ class AuthCheck extends StatelessWidget {
|
|||||||
if (user == null) {
|
if (user == null) {
|
||||||
// User not authenticated, show login screen
|
// User not authenticated, show login screen
|
||||||
return const SignInOrRegister();
|
return const SignInOrRegister();
|
||||||
|
//Navigator.of(context).pushNamed('/signin');
|
||||||
} else {
|
} else {
|
||||||
// User authenticated, show home screen
|
// User authenticated, show home screen
|
||||||
return const Home();
|
return const Home();
|
||||||
|
//Navigator.of(context).pushNamed('/homme');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,20 +19,22 @@ class HomeTileGrid extends StatelessWidget {
|
|||||||
crossAxisCount: 3,
|
crossAxisCount: 3,
|
||||||
children: [
|
children: [
|
||||||
HomeTile(
|
HomeTile(
|
||||||
onTap: navigateToPage,
|
onTap: () {
|
||||||
|
Navigator.of(context).pushNamed('/patient-manager');
|
||||||
|
},
|
||||||
tileName: "Patient Manager",
|
tileName: "Patient Manager",
|
||||||
tileDescription:
|
tileDescription:
|
||||||
"This is a digital solution for doctors Offices to manage their patients",
|
"This is a digital solution for doctors Offices to manage their patients",
|
||||||
),
|
),
|
||||||
HomeTile(
|
HomeTile(
|
||||||
onTap: navigateToPage,
|
onTap: navigateToPage,
|
||||||
tileName: "Patient Manager",
|
tileName: "Test",
|
||||||
tileDescription:
|
tileDescription:
|
||||||
"This is a digital solution for doctors Offices to manage their patients",
|
"This is a digital solution for doctors Offices to manage their patients",
|
||||||
),
|
),
|
||||||
HomeTile(
|
HomeTile(
|
||||||
onTap: navigateToPage,
|
onTap: navigateToPage,
|
||||||
tileName: "Patient Manager",
|
tileName: "Test 1",
|
||||||
tileDescription:
|
tileDescription:
|
||||||
"This is a digital solution for doctors Offices to manage their patients",
|
"This is a digital solution for doctors Offices to manage their patients",
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
title: Text(
|
title: Text(
|
||||||
barTitle,
|
barTitle,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.normal,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ class _HomeState extends State<Home> {
|
|||||||
Future<void> getUserEmail() async {
|
Future<void> getUserEmail() async {
|
||||||
final res = await client.auth.getUser();
|
final res = await client.auth.getUser();
|
||||||
if (res.user!.email != null) {
|
if (res.user!.email != null) {
|
||||||
print("emai not null");
|
//print("emai not null");
|
||||||
useremail = res.user!.email!;
|
useremail = res.user!.email!;
|
||||||
print(useremail);
|
//print(useremail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,18 +32,19 @@ class _HomeState extends State<Home> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FutureBuilder(
|
return Scaffold(
|
||||||
|
appBar: MyAppBar(barTitle: "Mzanzi Innovation Hub"),
|
||||||
|
body: HomeTileGrid(),
|
||||||
|
drawer: FutureBuilder(
|
||||||
future: getUserEmail(),
|
future: getUserEmail(),
|
||||||
builder: (context, snapshot) {
|
builder: (contexts, snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
return Scaffold(
|
return MyAppDrawer(drawerTitle: useremail);
|
||||||
appBar: MyAppBar(barTitle: "Mzanzi Innovation Hub"),
|
|
||||||
body: HomeTileGrid(),
|
|
||||||
drawer: MyAppDrawer(drawerTitle: useremail),
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
return Center(child: CircularProgressIndicator());
|
return Center(child: CircularProgressIndicator());
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:patient_manager/components/myAppBar.dart';
|
import 'package:patient_manager/components/myAppBar.dart';
|
||||||
|
import 'package:patient_manager/components/myAppDrawer.dart';
|
||||||
|
import 'package:patient_manager/main.dart';
|
||||||
|
|
||||||
class PatientManager extends StatefulWidget {
|
class PatientManager extends StatefulWidget {
|
||||||
const PatientManager({super.key});
|
const PatientManager({super.key});
|
||||||
@@ -9,15 +11,36 @@ class PatientManager extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PatientManagerState extends State<PatientManager> {
|
class _PatientManagerState extends State<PatientManager> {
|
||||||
|
String useremail = "";
|
||||||
|
|
||||||
|
Future<void> getUserEmail() async {
|
||||||
|
final res = await client.auth.getUser();
|
||||||
|
if (res.user!.email != null) {
|
||||||
|
//print("emai not null");
|
||||||
|
useremail = res.user!.email!;
|
||||||
|
//print(useremail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String getEmail() {
|
||||||
|
return useremail;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const Scaffold(
|
return FutureBuilder(
|
||||||
appBar: PreferredSize(
|
future: getUserEmail(),
|
||||||
preferredSize: Size.fromHeight(50),
|
builder: (context, snapshot) {
|
||||||
child: MyAppBar(
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
barTitle: "Mzanzi Innovation Hub",
|
return Scaffold(
|
||||||
),
|
appBar: const MyAppBar(barTitle: "Patient Manager"),
|
||||||
),
|
body: Center(child: Text(useremail)),
|
||||||
|
drawer: MyAppDrawer(drawerTitle: useremail),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Center(child: CircularProgressIndicator());
|
||||||
|
}
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class _SignInState extends State<SignIn> {
|
|||||||
password: passwordController.text,
|
password: passwordController.text,
|
||||||
);
|
);
|
||||||
if (response.session != null) {
|
if (response.session != null) {
|
||||||
Navigator.of(context).pushNamed('/homme', arguments: "Yaso");
|
Navigator.of(context).pushNamed('/homme');
|
||||||
}
|
}
|
||||||
} on AuthException catch (error) {
|
} on AuthException catch (error) {
|
||||||
loginError(error.message);
|
loginError(error.message);
|
||||||
|
|||||||
@@ -1,24 +1,23 @@
|
|||||||
// ignore: file_names
|
// ignore: file_names
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:patient_manager/Authentication/authCheck.dart';
|
import 'package:patient_manager/Authentication/authCheck.dart';
|
||||||
|
import 'package:patient_manager/components/signInOrRegister.dart';
|
||||||
import 'package:patient_manager/pages/home.dart';
|
import 'package:patient_manager/pages/home.dart';
|
||||||
|
import 'package:patient_manager/pages/patientManager.dart';
|
||||||
|
|
||||||
class RouteGenerator {
|
class RouteGenerator {
|
||||||
static Route<dynamic> generateRoute(RouteSettings settings) {
|
static Route<dynamic> generateRoute(RouteSettings settings) {
|
||||||
final args = settings.arguments;
|
//final args = settings.arguments;
|
||||||
|
|
||||||
switch (settings.name) {
|
switch (settings.name) {
|
||||||
case '/':
|
case '/':
|
||||||
return MaterialPageRoute(builder: (_) => AuthCheck());
|
return MaterialPageRoute(builder: (_) => AuthCheck());
|
||||||
case '/home':
|
case '/home':
|
||||||
if (args is String) {
|
return MaterialPageRoute(builder: (_) => const Home());
|
||||||
return MaterialPageRoute(
|
case '/patient-manager':
|
||||||
builder: (_) => const Home(),
|
return MaterialPageRoute(builder: (_) => const PatientManager());
|
||||||
);
|
case '/signin':
|
||||||
}
|
return MaterialPageRoute(builder: (_) => const SignInOrRegister());
|
||||||
|
|
||||||
// case '/signin':
|
|
||||||
// return MaterialPageRoute(builder: (_) => const SignInOrRegister());
|
|
||||||
// //case '/signIn':
|
// //case '/signIn':
|
||||||
// // return MaterialPageRoute(builder: (_) => SignIn());
|
// // return MaterialPageRoute(builder: (_) => SignIn());
|
||||||
// case '/auth':
|
// case '/auth':
|
||||||
|
|||||||
Reference in New Issue
Block a user