3 July 2024

This commit is contained in:
2024-07-03 15:13:02 +02:00
parent 6f10fd8572
commit 8f0134a98f
62 changed files with 1101 additions and 343 deletions

View File

@@ -0,0 +1,43 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/main.dart';
class HomeAppDrawer extends StatefulWidget {
final String userEmail;
const HomeAppDrawer({super.key, required this.userEmail});
@override
State<HomeAppDrawer> createState() => _HomeAppDrawerState();
}
class _HomeAppDrawerState extends State<HomeAppDrawer> {
@override
Widget build(BuildContext context) {
return Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
DrawerHeader(
decoration: const BoxDecoration(
color: Colors.blueAccent,
),
child: Text(widget.userEmail),
),
ListTile(
title: const Row(
children: [
Icon(Icons.logout),
SizedBox(width: 25.0),
Text("Sign Out"),
],
),
onTap: () {
client.auth.signOut();
Navigator.of(context).pushNamed('/');
},
)
],
),
);
}
}

View File

@@ -23,24 +23,28 @@ class HomeTile extends StatelessWidget {
child: Column(
//mainAxisSize: MainAxisSize.min,
children: [
ListTile(
leading: const Icon(Icons.abc),
title: Text(
tileName,
style: const TextStyle(
fontWeight: FontWeight.bold,
Expanded(
child: ListTile(
leading: const Icon(Icons.abc),
title: Text(
tileName,
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
subtitle: Text(tileDescription),
),
subtitle: Text(tileDescription),
),
const Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: Icon(Icons.arrow_forward),
),
],
const Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: Icon(Icons.arrow_forward),
),
],
),
)
],
),

View File

@@ -19,6 +19,7 @@ class HomeTileGrid extends StatelessWidget {
children: [
HomeTile(
onTap: () {
//print("Home Tiles: $userEmail");
Navigator.of(context)
.pushNamed('/patient-manager', arguments: userEmail);
},

View File

@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/main.dart';
class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
@override
@@ -15,17 +14,17 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
backgroundColor: Colors.blueAccent,
elevation: 8,
shadowColor: Colors.black,
actions: [
IconButton(
onPressed: () {
client.auth.signOut();
Navigator.of(context).pushNamed('/');
},
icon: const Icon(Icons.logout),
iconSize: 35,
color: Colors.black,
),
],
// actions: [
// IconButton(
// onPressed: () {
// client.auth.signOut();
// Navigator.of(context).pushNamed('/');
// },
// icon: const Icon(Icons.logout),
// iconSize: 35,
// color: Colors.black,
// ),
// ],
title: Text(
barTitle,
style: const TextStyle(

View File

@@ -1,35 +0,0 @@
import 'package:flutter/material.dart';
class MyAppDrawer extends StatefulWidget {
final String drawerTitle;
const MyAppDrawer({super.key, required this.drawerTitle});
@override
State<MyAppDrawer> createState() => _MyAppDrawerState();
}
class _MyAppDrawerState extends State<MyAppDrawer> {
@override
Widget build(BuildContext context) {
return Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
DrawerHeader(
decoration: const BoxDecoration(
color: Colors.blueAccent,
),
child: Text(widget.drawerTitle),
),
ListTile(
title: const Text("Home"),
onTap: () {
Navigator.of(context).pushNamed('/home');
},
)
],
),
);
}
}

View File

@@ -191,6 +191,96 @@ class _MyErrorMessageState extends State<MyErrorMessage> {
);
}
void setInternetError() {
messageTypes["Internet Connection"] = Stack(
children: [
Container(
padding: const EdgeInsets.all(10.0),
width: 500.0,
height: 450.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(25.0),
border: Border.all(color: Colors.red, width: 5.0),
),
child: const Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.warning_amber_rounded,
size: 100,
color: Colors.red,
),
SizedBox(height: 15),
Text(
"Internet Connection Lost!",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.red,
fontSize: 25.0,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 10),
Padding(
padding: EdgeInsets.symmetric(horizontal: 25.0),
child: Text(
"We seem to be having some trouble connecting you to the internet. This could be due to a temporary outage or an issue with your device's connection.",
style: TextStyle(
color: Colors.black,
fontSize: 15.0,
fontWeight: FontWeight.bold,
),
),
),
SizedBox(height: 15),
Padding(
padding: EdgeInsets.symmetric(horizontal: 25.0),
child: Text(
"Here are a few things you can try:",
style: TextStyle(
color: Colors.black,
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
),
SizedBox(height: 10),
Padding(
padding: EdgeInsets.symmetric(horizontal: 25.0),
child: Text(
"1) Check your Wi-Fi signal strength or try connecting to a different network.\n2) Restart your device (computer, phone, etc.) and your router/modem.\n3) If you're using cellular data, ensure you have a strong signal and haven't reached your data limit.",
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black,
fontSize: 15.0,
fontWeight: FontWeight.bold,
),
),
),
],
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(
Icons.close,
color: Colors.red,
size: 35,
),
),
),
],
);
}
Widget? getErrorMessage(String type) {
return messageTypes[type];
}
@@ -199,6 +289,7 @@ class _MyErrorMessageState extends State<MyErrorMessage> {
void initState() {
setInputError();
setinvalidCredError();
setInternetError();
super.initState();
}

View File

@@ -0,0 +1,193 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:patient_manager/main.dart';
import 'package:http/http.dart' as http;
import 'package:patient_manager/objects/appUser.dart';
class PatManAppDrawer extends StatefulWidget {
final String userEmail;
const PatManAppDrawer({super.key, required this.userEmail});
@override
State<PatManAppDrawer> createState() => _PatManAppDrawerState();
}
class _PatManAppDrawerState extends State<PatManAppDrawer> {
String endpointUserData = "http://localhost:80/users/profile/";
late AppUser signedInUser;
Future<AppUser> getUserDetails() async {
//print("pat man drawer: " + endpointUserData + widget.userEmail);
var response =
await http.get(Uri.parse(endpointUserData + widget.userEmail));
//print(response.statusCode);
//print(response.body);
if (response.statusCode == 200) {
return AppUser.fromJson(
jsonDecode(response.body) as Map<String, dynamic>);
} else {
throw Exception("Error: GetUserData status code ${response.statusCode}");
}
}
@override
void initState() {
//signedInUser = getUserDetails();
super.initState();
}
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: getUserDetails(),
builder: (BuildContext context, AsyncSnapshot<AppUser> snapshot) {
return Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
DrawerHeader(
decoration: const BoxDecoration(
color: Colors.blueAccent,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
"Signed Is As:",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0,
),
),
const SizedBox(
height: 50.0,
),
Row(
children: [
const Text(
"Name: ",
style: TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(width: 15),
Text("${snapshot.data?.fname} ${snapshot.data?.lname}"),
],
),
Row(
children: [
const Text(
"Email: ",
style: TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(width: 16),
Text("${snapshot.data?.email}"),
],
),
],
),
),
ListTile(
title: const Row(
children: [
Icon(Icons.home_outlined),
SizedBox(width: 25.0),
Text("Home"),
],
),
onTap: () {
Navigator.of(context).pushNamed('/home');
},
),
ListTile(
title: const Row(
children: [
Icon(Icons.perm_identity),
SizedBox(width: 25.0),
Text("Profile"),
],
),
onTap: () {
//signedInUser = snapshot.data!;
//print("PatManAppDrawer: ${signedInUser.runtimeType}");
Navigator.of(context).pushNamed('/patient-manager/profile',
arguments: snapshot.data);
},
),
ListTile(
title: const Row(
children: [
Icon(Icons.logout),
SizedBox(width: 25.0),
Text("Sign Out"),
],
),
onTap: () {
client.auth.signOut();
Navigator.of(context).pushNamed('/');
},
)
],
),
);
},
);
}
// Drawer(
// child: ListView(
// padding: EdgeInsets.zero,
// children: [
// DrawerHeader(
// decoration: const BoxDecoration(
// color: Colors.blueAccent,
// ),
// child: Column(
// children: [
// const Text("Signed Is As:"),
// Text("Name: ${signedInUser.fname} ${signedInUser.lname}"),
// Text("Email: ${signedInUser.email}"),
// ],
// ),
// ),
// ListTile(
// title: const Row(
// children: [
// Icon(Icons.home_outlined),
// SizedBox(width: 25.0),
// Text("Home"),
// ],
// ),
// onTap: () {
// Navigator.of(context).pushNamed('/home');
// },
// ),
// ListTile(
// title: const Row(
// children: [
// Icon(Icons.perm_identity),
// SizedBox(width: 25.0),
// Text("Profile"),
// ],
// ),
// onTap: () {
// //Navigator.of(context).pushNamed('/home');
// },
// ),
// ListTile(
// title: const Row(
// children: [
// Icon(Icons.logout),
// SizedBox(width: 25.0),
// Text("Sign Out"),
// ],
// ),
// onTap: () {
// client.auth.signOut();
// Navigator.of(context).pushNamed('/');
// },
// )
// ],
// ),
// );
}

View File

@@ -30,7 +30,7 @@ class PatientFiles extends StatefulWidget {
class _PatientFilesState extends State<PatientFiles> {
String endpointFiles = "http://localhost:80/files/patients/";
String endpointUser = "http://localhost:80/docOffices/user/";
String endpointUser = "http://localhost:80/users/profile/";
String endpointGenFiles = "http://localhost:80/files/generate/med-cert/";
String endpointFileUpload = "http://localhost:80/files/upload/file/";
String endpointInsertFiles = "http://localhost:80/files/insert/";
@@ -278,6 +278,7 @@ class _PatientFilesState extends State<PatientFiles> {
),
TextButton(
onPressed: () {
selectedFileController.clear();
Navigator.pop(context);
},
child: const Text("Cancel"),

View File

@@ -0,0 +1,21 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/objects/appUser.dart';
class ProfileOfficeUpdate extends StatefulWidget {
final AppUser signedInUser;
//final String userEmail;
const ProfileOfficeUpdate({
super.key,
required this.signedInUser,
});
@override
State<ProfileOfficeUpdate> createState() => _ProfileOfficeUpdateState();
}
class _ProfileOfficeUpdateState extends State<ProfileOfficeUpdate> {
@override
Widget build(BuildContext context) {
return Center(child: Text("Office profile: ${widget.signedInUser.email}"));
}
}

View File

@@ -0,0 +1,100 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/components/myDropdownInput.dart';
import 'package:patient_manager/components/myTextInput.dart';
import 'package:patient_manager/components/mybutton.dart';
import 'package:patient_manager/objects/appUser.dart';
class ProfileUserUpdate extends StatefulWidget {
final AppUser signedInUser;
//final String userEmail;
const ProfileUserUpdate({
super.key,
required this.signedInUser,
});
@override
State<ProfileUserUpdate> createState() => _ProfileUserUpdateState();
}
class _ProfileUserUpdateState extends State<ProfileUserUpdate> {
final fnameController = TextEditingController();
final lnameController = TextEditingController();
final titleController = TextEditingController();
@override
void initState() {
fnameController.text = widget.signedInUser.fname;
lnameController.text = widget.signedInUser.lname;
titleController.text = widget.signedInUser.title;
super.initState();
}
@override
Widget build(BuildContext context) {
return Column(
children: [
const SizedBox(height: 15.0),
const Text(
"Update User profile:",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 25,
),
),
const SizedBox(height: 15.0),
MyTextField(
controller: fnameController,
hintText: "First Name",
editable: true,
required: true,
),
const SizedBox(height: 10.0),
MyTextField(
controller: lnameController,
hintText: "Last Name",
editable: true,
required: true,
),
const SizedBox(height: 10.0),
MyDropdownField(
controller: titleController,
signedInUser: widget.signedInUser,
dropdownOptions: const <DropdownMenuEntry<String>>[
DropdownMenuEntry(value: "Dr.", label: "Doctor"),
DropdownMenuEntry(value: "Assistant", label: "Assistant"),
],
),
const SizedBox(height: 10.0),
SizedBox(
width: 500.0,
height: 100.0,
child: MyButton(
onTap: () {
if (fnameController.text == "") {
showDialog<void>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Incomplete Field\\s'),
content: const Text(
'Please conplete all fields',
),
actions: <Widget>[
TextButton(
child: const Text('Disable'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
},
buttonText: "Update"),
),
],
);
}
}