Add Patient Manager Page

This commit is contained in:
2024-04-06 15:54:24 +02:00
parent e17b5e24aa
commit 491f854cf7
7 changed files with 60 additions and 31 deletions

View File

@@ -5,6 +5,8 @@ import 'package:patient_manager/pages/home.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
class AuthCheck extends StatelessWidget {
const AuthCheck({super.key});
@override
Widget build(BuildContext context) {
return StreamBuilder<AuthState>(
@@ -15,9 +17,11 @@ class AuthCheck extends StatelessWidget {
if (user == null) {
// User not authenticated, show login screen
return const SignInOrRegister();
//Navigator.of(context).pushNamed('/signin');
} else {
// User authenticated, show home screen
return const Home();
//Navigator.of(context).pushNamed('/homme');
}
}

View File

@@ -19,20 +19,22 @@ class HomeTileGrid extends StatelessWidget {
crossAxisCount: 3,
children: [
HomeTile(
onTap: navigateToPage,
onTap: () {
Navigator.of(context).pushNamed('/patient-manager');
},
tileName: "Patient Manager",
tileDescription:
"This is a digital solution for doctors Offices to manage their patients",
),
HomeTile(
onTap: navigateToPage,
tileName: "Patient Manager",
tileName: "Test",
tileDescription:
"This is a digital solution for doctors Offices to manage their patients",
),
HomeTile(
onTap: navigateToPage,
tileName: "Patient Manager",
tileName: "Test 1",
tileDescription:
"This is a digital solution for doctors Offices to manage their patients",
),

View File

@@ -29,7 +29,7 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
title: Text(
barTitle,
style: const TextStyle(
fontWeight: FontWeight.normal,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),

View File

@@ -20,9 +20,9 @@ class _HomeState extends State<Home> {
Future<void> getUserEmail() async {
final res = await client.auth.getUser();
if (res.user!.email != null) {
print("emai not null");
//print("emai not null");
useremail = res.user!.email!;
print(useremail);
//print(useremail);
}
}
@@ -32,18 +32,19 @@ class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
return FutureBuilder(
return Scaffold(
appBar: MyAppBar(barTitle: "Mzanzi Innovation Hub"),
body: HomeTileGrid(),
drawer: FutureBuilder(
future: getUserEmail(),
builder: (context, snapshot) {
builder: (contexts, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return Scaffold(
appBar: MyAppBar(barTitle: "Mzanzi Innovation Hub"),
body: HomeTileGrid(),
drawer: MyAppDrawer(drawerTitle: useremail),
);
return MyAppDrawer(drawerTitle: useremail);
} else {
return Center(child: CircularProgressIndicator());
}
});
},
),
);
}
}

View File

@@ -1,5 +1,7 @@
import 'package:flutter/material.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 {
const PatientManager({super.key});
@@ -9,15 +11,36 @@ class PatientManager extends StatefulWidget {
}
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
Widget build(BuildContext context) {
return const Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(50),
child: MyAppBar(
barTitle: "Mzanzi Innovation Hub",
),
),
return FutureBuilder(
future: getUserEmail(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return Scaffold(
appBar: const MyAppBar(barTitle: "Patient Manager"),
body: Center(child: Text(useremail)),
drawer: MyAppDrawer(drawerTitle: useremail),
);
} else {
return Center(child: CircularProgressIndicator());
}
},
);
}
}

View File

@@ -26,7 +26,7 @@ class _SignInState extends State<SignIn> {
password: passwordController.text,
);
if (response.session != null) {
Navigator.of(context).pushNamed('/homme', arguments: "Yaso");
Navigator.of(context).pushNamed('/homme');
}
} on AuthException catch (error) {
loginError(error.message);

View File

@@ -1,24 +1,23 @@
// ignore: file_names
import 'package:flutter/material.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/patientManager.dart';
class RouteGenerator {
static Route<dynamic> generateRoute(RouteSettings settings) {
final args = settings.arguments;
//final args = settings.arguments;
switch (settings.name) {
case '/':
return MaterialPageRoute(builder: (_) => AuthCheck());
case '/home':
if (args is String) {
return MaterialPageRoute(
builder: (_) => const Home(),
);
}
// case '/signin':
// return MaterialPageRoute(builder: (_) => const SignInOrRegister());
return MaterialPageRoute(builder: (_) => const Home());
case '/patient-manager':
return MaterialPageRoute(builder: (_) => const PatientManager());
case '/signin':
return MaterialPageRoute(builder: (_) => const SignInOrRegister());
// //case '/signIn':
// // return MaterialPageRoute(builder: (_) => SignIn());
// case '/auth':