pop up design alignment

This commit is contained in:
2024-07-03 15:58:16 +02:00
parent 8f0134a98f
commit b25583ddf3
4 changed files with 415 additions and 264 deletions

View File

@@ -5,6 +5,7 @@ import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:patient_manager/components/buildFilesList.dart'; import 'package:patient_manager/components/buildFilesList.dart';
import 'package:patient_manager/components/medCertInput.dart'; import 'package:patient_manager/components/medCertInput.dart';
import 'package:patient_manager/components/myErrorMessage.dart';
import 'package:patient_manager/components/myTextInput.dart'; import 'package:patient_manager/components/myTextInput.dart';
import 'package:patient_manager/components/mybutton.dart'; import 'package:patient_manager/components/mybutton.dart';
import 'package:patient_manager/main.dart'; import 'package:patient_manager/main.dart';
@@ -87,10 +88,10 @@ class _PatientFilesState extends State<PatientFiles> {
String message = "Successfully added file"; String message = "Successfully added file";
messagePopUp(message); messagePopUp(message);
} else { } else {
messagePopUp("error response 2"); internetConnectionPopUp();
} }
} else { } else {
messagePopUp("error respose 1"); internetConnectionPopUp();
} }
} }
@@ -124,10 +125,10 @@ class _PatientFilesState extends State<PatientFiles> {
String message = "Successfully added file"; String message = "Successfully added file";
messagePopUp(message); messagePopUp(message);
} else { } else {
messagePopUp("error response 2"); internetConnectionPopUp();
} }
} else { } else {
messagePopUp("error respose 1"); internetConnectionPopUp();
} }
} }
@@ -139,6 +140,7 @@ class _PatientFilesState extends State<PatientFiles> {
appUser = appUser =
AppUser.fromJson(jsonDecode(response.body) as Map<String, dynamic>); AppUser.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
} else { } else {
internetConnectionPopUp();
throw Exception('Failed to load user'); throw Exception('Failed to load user');
} }
} }
@@ -163,6 +165,7 @@ class _PatientFilesState extends State<PatientFiles> {
List<PFile>.from(l.map((model) => PFile.fromJson(model))); List<PFile>.from(l.map((model) => PFile.fromJson(model)));
return files; return files;
} else { } else {
internetConnectionPopUp();
throw Exception('failed to load patients'); throw Exception('failed to load patients');
} }
} }
@@ -181,39 +184,76 @@ class _PatientFilesState extends State<PatientFiles> {
void medCertPopUp() { void medCertPopUp() {
showDialog( showDialog(
context: context, context: context,
builder: (context) => AlertDialog( builder: (context) => Dialog(
title: const Row( child: Stack(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text("Create Medical Certificate"), Container(
padding: const EdgeInsets.all(10.0),
width: 700.0,
//height: 475.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(25.0),
border: Border.all(color: Colors.blueAccent, width: 5.0),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text(
"Create Medical Certificate",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.blueAccent,
fontSize: 35.0,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 25.0),
Medcertinput(
startDateController: startDateController,
endDateTextController: endDateTextController,
retDateTextController: retDateTextController,
),
SizedBox(
width: 300,
height: 100,
child: MyButton(
onTap: () {
if (isMedCertFieldsFilled()) {
generateMedCert();
Navigator.pop(context);
} else {
showDialog(
context: context,
builder: (context) {
return const MyErrorMessage(
errorType: "Input Error");
},
);
}
},
buttonText: "Add Note"))
],
),
),
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,
),
),
),
], ],
), ),
content: Medcertinput(
startDateController: startDateController,
endDateTextController: endDateTextController,
retDateTextController: retDateTextController,
),
actions: [
TextButton(
onPressed: () {
generateMedCert();
Navigator.pop(context);
},
child: const Text(
"Generate",
style: TextStyle(fontWeight: FontWeight.bold),
),
),
TextButton(
onPressed: () {
startDateController.clear();
endDateTextController.clear();
retDateTextController.clear();
Navigator.pop(context);
},
child: const Text("Cancel"),
)
],
), ),
); );
} }
@@ -221,73 +261,126 @@ class _PatientFilesState extends State<PatientFiles> {
void uploudFilePopUp() { void uploudFilePopUp() {
showDialog( showDialog(
context: context, context: context,
builder: (context) => AlertDialog( builder: (context) => Dialog(
title: const Row( child: Stack(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text("Upload File"), Container(
padding: const EdgeInsets.all(10.0),
width: 700.0,
//height: 475.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(25.0),
border: Border.all(color: Colors.blueAccent, width: 5.0),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text(
"Upload File",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.blueAccent,
fontSize: 35.0,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 25.0),
SizedBox(
width: 700,
child: MyButton(
onTap: () async {
FilePickerResult? result =
await FilePicker.platform.pickFiles();
if (result == null) return;
final selectedFile = result.files.first;
setState(() {
selected = selectedFile;
});
setState(() {
selectedFileController.text = selectedFile.name;
});
},
buttonText: "Select File"),
),
MyTextField(
controller: selectedFileController,
hintText: "Selected FIle",
editable: false,
required: true,
),
SizedBox(
width: 300,
height: 100,
child: MyButton(
onTap: () {
if (isFileFieldsFilled()) {
uploadSelectedFile(selected);
Navigator.pop(context);
} else {
showDialog(
context: context,
builder: (context) {
return const MyErrorMessage(
errorType: "Input Error");
},
);
}
},
buttonText: "Add Note"))
],
),
),
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,
),
),
),
], ],
), ),
content: SizedBox(
width: 700,
height: 250,
child: Column(
children: [
SizedBox(
width: 700,
child: MyButton(
onTap: () async {
FilePickerResult? result =
await FilePicker.platform.pickFiles();
if (result == null) return;
final selectedFile = result.files.first;
//selectedFile
// print("Name: ${selectedFile.name}");
// print("Extension: ${selectedFile.extension}");
// print("Content: ${selectedFile.bytes}");
setState(() {
selected = selectedFile;
});
setState(() {
selectedFileController.text = selectedFile.name;
});
},
buttonText: "Select File"),
),
MyTextField(
controller: selectedFileController,
hintText: "Selected FIle",
editable: false,
required: true,
)
],
),
),
actions: [
TextButton(
onPressed: () {
uploadSelectedFile(selected);
Navigator.pop(context);
},
child: const Text(
"Upload",
style: TextStyle(fontWeight: FontWeight.bold),
),
),
TextButton(
onPressed: () {
selectedFileController.clear();
Navigator.pop(context);
},
child: const Text("Cancel"),
)
],
), ),
); );
} }
void internetConnectionPopUp() {
showDialog(
context: context,
builder: (context) {
return const MyErrorMessage(errorType: "Internet Connection");
},
);
}
bool isMedCertFieldsFilled() {
if (startDateController.text.isEmpty ||
endDateTextController.text.isEmpty ||
retDateTextController.text.isEmpty) {
return false;
} else {
return true;
}
}
bool isFileFieldsFilled() {
if (selectedFileController.text.isEmpty) {
return false;
} else {
return true;
}
}
@override @override
void initState() { void initState() {
futueFiles = fetchFiles(endpointFiles + widget.patientIndex.toString()); futueFiles = fetchFiles(endpointFiles + widget.patientIndex.toString());

View File

@@ -2,23 +2,13 @@ import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:patient_manager/components/buildNotesList.dart'; import 'package:patient_manager/components/buildNotesList.dart';
import 'package:patient_manager/components/myErrorMessage.dart';
import 'package:patient_manager/components/myMLTextInput.dart'; import 'package:patient_manager/components/myMLTextInput.dart';
import 'package:patient_manager/components/myTextInput.dart'; import 'package:patient_manager/components/myTextInput.dart';
import 'package:patient_manager/components/mybutton.dart';
import 'package:patient_manager/objects/notes.dart'; import 'package:patient_manager/objects/notes.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
Future<List<Note>> fetchNotes(String endpoint) async {
final response = await http.get(Uri.parse(endpoint));
if (response.statusCode == 200) {
Iterable l = jsonDecode(response.body);
List<Note> notes = List<Note>.from(l.map((model) => Note.fromJson(model)));
//print("Here notes");
return notes;
} else {
throw Exception('failed to load patients');
}
}
class PatientNotes extends StatefulWidget { class PatientNotes extends StatefulWidget {
final int patientIndex; final int patientIndex;
const PatientNotes({super.key, required this.patientIndex}); const PatientNotes({super.key, required this.patientIndex});
@@ -34,6 +24,20 @@ class _PatientNotesState extends State<PatientNotes> {
final noteTextController = TextEditingController(); final noteTextController = TextEditingController();
late Future<List<Note>> futueNotes; late Future<List<Note>> futueNotes;
Future<List<Note>> fetchNotes(String endpoint) async {
final response = await http.get(Uri.parse(endpoint));
if (response.statusCode == 200) {
Iterable l = jsonDecode(response.body);
List<Note> notes =
List<Note>.from(l.map((model) => Note.fromJson(model)));
//print("Here notes");
return notes;
} else {
internetConnectionPopUp();
throw Exception('failed to load patients');
}
}
Future<void> addPatientNoteAPICall() async { Future<void> addPatientNoteAPICall() async {
var response = await http.post( var response = await http.post(
Uri.parse(apiUrlAddNote), Uri.parse(apiUrlAddNote),
@@ -55,10 +59,19 @@ class _PatientNotesState extends State<PatientNotes> {
String message = "Successfully added Note"; String message = "Successfully added Note";
messagePopUp(message); messagePopUp(message);
} else { } else {
messagePopUp("error"); internetConnectionPopUp();
} }
} }
void internetConnectionPopUp() {
showDialog(
context: context,
builder: (context) {
return const MyErrorMessage(errorType: "Internet Connection");
},
);
}
void messagePopUp(error) { void messagePopUp(error) {
showDialog( showDialog(
context: context, context: context,
@@ -70,6 +83,106 @@ class _PatientNotesState extends State<PatientNotes> {
); );
} }
void addNotePopUp() {
showDialog(
context: context,
builder: (context) => Dialog(
child: Stack(
children: [
Container(
padding: const EdgeInsets.all(10.0),
width: 700.0,
//height: 475.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(25.0),
border: Border.all(color: Colors.blueAccent, width: 5.0),
),
child: Column(
//mainAxisSize: MainAxisSize.max,
children: [
const Text(
"Add Note",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.blueAccent,
fontSize: 35.0,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 25.0),
SizedBox(
width: 700,
child: MyTextField(
controller: titleController,
hintText: "Title of Note",
editable: true,
required: true,
),
),
const SizedBox(height: 25.0),
Expanded(
child: MyMLTextField(
controller: noteTextController,
hintText: "Note Details",
editable: true,
required: true,
),
),
SizedBox(
width: 300,
height: 100,
child: MyButton(
onTap: () {
if (isFieldsFilled()) {
addPatientNoteAPICall();
Navigator.pop(context);
} else {
showDialog(
context: context,
builder: (context) {
return const MyErrorMessage(
errorType: "Input Error");
},
);
}
},
buttonText: "Add Note"))
],
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
titleController.clear();
noteTextController.clear();
},
icon: const Icon(
Icons.close,
color: Colors.red,
size: 35,
),
),
),
],
),
),
);
}
bool isFieldsFilled() {
if (titleController.text.isEmpty || noteTextController.text.isEmpty) {
return false;
} else {
return true;
}
}
@override @override
void initState() { void initState() {
futueNotes = fetchNotes(endpoint + widget.patientIndex.toString()); futueNotes = fetchNotes(endpoint + widget.patientIndex.toString());
@@ -115,61 +228,7 @@ class _PatientNotesState extends State<PatientNotes> {
), ),
IconButton( IconButton(
onPressed: () { onPressed: () {
showDialog( addNotePopUp();
context: context,
builder: (context) => AlertDialog(
title: const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Add Note"),
],
),
content: Column(
children: [
SizedBox(
width: 700,
child: MyTextField(
controller: titleController,
hintText: "Title of Note",
editable: true,
required: true,
),
),
const SizedBox(
height: 25.0,
),
Expanded(
child: MyMLTextField(
controller: noteTextController,
hintText: "Note Details",
editable: true,
required: true,
),
),
],
),
actions: [
TextButton(
onPressed: () {
addPatientNoteAPICall();
Navigator.pop(context);
//print(widget.patientIndex);
},
child: const Text(
"Submit",
style: TextStyle(
fontWeight: FontWeight.bold),
),
),
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text("Cancel"),
)
],
),
);
}, },
icon: const Icon(Icons.add), icon: const Icon(Icons.add),
) )

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:patient_manager/components/myDropdownInput.dart'; import 'package:patient_manager/components/myDropdownInput.dart';
import 'package:patient_manager/components/myErrorMessage.dart';
import 'package:patient_manager/components/myTextInput.dart'; import 'package:patient_manager/components/myTextInput.dart';
import 'package:patient_manager/components/mybutton.dart'; import 'package:patient_manager/components/mybutton.dart';
import 'package:patient_manager/objects/appUser.dart'; import 'package:patient_manager/objects/appUser.dart';
@@ -21,6 +22,16 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate> {
final lnameController = TextEditingController(); final lnameController = TextEditingController();
final titleController = TextEditingController(); final titleController = TextEditingController();
bool isFieldsFilled() {
if (fnameController.text.isEmpty ||
lnameController.text.isEmpty ||
titleController.text.isEmpty) {
return false;
} else {
return true;
}
}
@override @override
void initState() { void initState() {
fnameController.text = widget.signedInUser.fname; fnameController.text = widget.signedInUser.fname;
@@ -70,24 +81,12 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate> {
height: 100.0, height: 100.0,
child: MyButton( child: MyButton(
onTap: () { onTap: () {
if (fnameController.text == "") { if (isFieldsFilled()) {
showDialog<void>( } else {
showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (context) {
return AlertDialog( return const MyErrorMessage(errorType: "Input Error");
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();
},
),
],
);
}, },
); );
} }

View File

@@ -149,102 +149,105 @@ class _EditPatientState extends State<EditPatient> {
); );
} }
Widget deletePatientPopUp() { void deletePatientPopUp() {
return Dialog( showDialog(
child: Stack( context: context,
children: [ builder: (context) => Dialog(
Container( child: Stack(
padding: const EdgeInsets.all(10.0), children: [
width: 500.0, Container(
height: 475.0, padding: const EdgeInsets.all(10.0),
decoration: BoxDecoration( width: 500.0,
color: Colors.white, height: 475.0,
borderRadius: BorderRadius.circular(25.0), decoration: BoxDecoration(
border: Border.all(color: Colors.blueAccent, width: 5.0), color: Colors.white,
), borderRadius: BorderRadius.circular(25.0),
child: Column( border: Border.all(color: Colors.blueAccent, width: 5.0),
//mainAxisSize: MainAxisSize.max, ),
children: [ child: Column(
const Icon( //mainAxisSize: MainAxisSize.max,
Icons.warning_amber_rounded, children: [
size: 100, const Icon(
color: Colors.blueAccent, Icons.warning_amber_rounded,
), size: 100,
const SizedBox(height: 15),
const Text(
"Are you sure you want to delete this?",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.blueAccent, color: Colors.blueAccent,
fontSize: 25.0,
fontWeight: FontWeight.bold,
), ),
), const SizedBox(height: 15),
const SizedBox(height: 10), const Text(
Padding( "Are you sure you want to delete this?",
padding: const EdgeInsets.symmetric(horizontal: 25.0), textAlign: TextAlign.center,
child: Text(
"This action is permanent! Deleting ${fnameController.text} ${lnameController.text} will remove him\\her from your account. You won't be able to recover it once it's gone.",
style: const TextStyle(
color: Colors.black,
fontSize: 15.0,
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(height: 15),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 25.0),
child: Text(
"Here's what you'll be deleting:",
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.blueAccent,
fontSize: 20.0, fontSize: 25.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
), const SizedBox(height: 10),
const SizedBox(height: 10), Padding(
const Padding( padding: const EdgeInsets.symmetric(horizontal: 25.0),
padding: EdgeInsets.symmetric(horizontal: 25.0),
child: SizedBox(
width: 450,
child: Text( child: Text(
"1) Patient Profile Information.\n2) Patient Notes\n3) Patient Files.", "This action is permanent! Deleting ${fnameController.text} ${lnameController.text} will remove him\\her from your account. You won't be able to recover it once it's gone.",
textAlign: TextAlign.left, style: const TextStyle(
style: TextStyle(
color: Colors.black, color: Colors.black,
fontSize: 15.0, fontSize: 15.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
), ),
), const SizedBox(height: 15),
SizedBox( const Padding(
width: 300, padding: EdgeInsets.symmetric(horizontal: 25.0),
height: 100, child: Text(
child: MyButton( "Here's what you'll be deleting:",
onTap: deletePatientApiCall, buttonText: "Delete")) style: TextStyle(
], color: Colors.black,
), fontSize: 20.0,
), fontWeight: FontWeight.bold,
Positioned( ),
top: 5, ),
right: 5, ),
width: 50, const SizedBox(height: 10),
height: 50, const Padding(
child: IconButton( padding: EdgeInsets.symmetric(horizontal: 25.0),
onPressed: () { child: SizedBox(
Navigator.pop(context); width: 450,
}, child: Text(
icon: const Icon( "1) Patient Profile Information.\n2) Patient Notes\n3) Patient Files.",
Icons.close, textAlign: TextAlign.left,
color: Colors.red, style: TextStyle(
size: 35, color: Colors.black,
fontSize: 15.0,
fontWeight: FontWeight.bold,
),
),
),
),
SizedBox(
width: 300,
height: 100,
child: MyButton(
onTap: deletePatientApiCall, buttonText: "Delete"))
],
), ),
), ),
), 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,
),
),
),
],
),
), ),
); );
} }
@@ -315,10 +318,7 @@ class _EditPatientState extends State<EditPatient> {
icon: const Icon(Icons.delete), icon: const Icon(Icons.delete),
alignment: Alignment.topRight, alignment: Alignment.topRight,
onPressed: () { onPressed: () {
showDialog( deletePatientPopUp();
context: context,
builder: (context) => deletePatientPopUp(),
);
}, },
) )
], ],