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:patient_manager/components/buildFilesList.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/mybutton.dart';
import 'package:patient_manager/main.dart';
@@ -87,10 +88,10 @@ class _PatientFilesState extends State<PatientFiles> {
String message = "Successfully added file";
messagePopUp(message);
} else {
messagePopUp("error response 2");
internetConnectionPopUp();
}
} else {
messagePopUp("error respose 1");
internetConnectionPopUp();
}
}
@@ -124,10 +125,10 @@ class _PatientFilesState extends State<PatientFiles> {
String message = "Successfully added file";
messagePopUp(message);
} else {
messagePopUp("error response 2");
internetConnectionPopUp();
}
} else {
messagePopUp("error respose 1");
internetConnectionPopUp();
}
}
@@ -139,6 +140,7 @@ class _PatientFilesState extends State<PatientFiles> {
appUser =
AppUser.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
} else {
internetConnectionPopUp();
throw Exception('Failed to load user');
}
}
@@ -163,6 +165,7 @@ class _PatientFilesState extends State<PatientFiles> {
List<PFile>.from(l.map((model) => PFile.fromJson(model)));
return files;
} else {
internetConnectionPopUp();
throw Exception('failed to load patients');
}
}
@@ -181,39 +184,76 @@ class _PatientFilesState extends State<PatientFiles> {
void medCertPopUp() {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Row(
mainAxisAlignment: MainAxisAlignment.center,
builder: (context) => Dialog(
child: Stack(
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() {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Row(
mainAxisAlignment: MainAxisAlignment.center,
builder: (context) => Dialog(
child: Stack(
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
void initState() {
futueFiles = fetchFiles(endpointFiles + widget.patientIndex.toString());

View File

@@ -2,23 +2,13 @@ import 'dart:convert';
import 'package:flutter/material.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/myTextInput.dart';
import 'package:patient_manager/components/mybutton.dart';
import 'package:patient_manager/objects/notes.dart';
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 {
final int patientIndex;
const PatientNotes({super.key, required this.patientIndex});
@@ -34,6 +24,20 @@ class _PatientNotesState extends State<PatientNotes> {
final noteTextController = TextEditingController();
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 {
var response = await http.post(
Uri.parse(apiUrlAddNote),
@@ -55,10 +59,19 @@ class _PatientNotesState extends State<PatientNotes> {
String message = "Successfully added Note";
messagePopUp(message);
} else {
messagePopUp("error");
internetConnectionPopUp();
}
}
void internetConnectionPopUp() {
showDialog(
context: context,
builder: (context) {
return const MyErrorMessage(errorType: "Internet Connection");
},
);
}
void messagePopUp(error) {
showDialog(
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
void initState() {
futueNotes = fetchNotes(endpoint + widget.patientIndex.toString());
@@ -115,61 +228,7 @@ class _PatientNotesState extends State<PatientNotes> {
),
IconButton(
onPressed: () {
showDialog(
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"),
)
],
),
);
addNotePopUp();
},
icon: const Icon(Icons.add),
)

View File

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

View File

@@ -149,102 +149,105 @@ class _EditPatientState extends State<EditPatient> {
);
}
Widget deletePatientPopUp() {
return Dialog(
child: Stack(
children: [
Container(
padding: const EdgeInsets.all(10.0),
width: 500.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 Icon(
Icons.warning_amber_rounded,
size: 100,
color: Colors.blueAccent,
),
const SizedBox(height: 15),
const Text(
"Are you sure you want to delete this?",
textAlign: TextAlign.center,
style: TextStyle(
void deletePatientPopUp() {
showDialog(
context: context,
builder: (context) => Dialog(
child: Stack(
children: [
Container(
padding: const EdgeInsets.all(10.0),
width: 500.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 Icon(
Icons.warning_amber_rounded,
size: 100,
color: Colors.blueAccent,
fontSize: 25.0,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
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:",
const SizedBox(height: 15),
const Text(
"Are you sure you want to delete this?",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black,
fontSize: 20.0,
color: Colors.blueAccent,
fontSize: 25.0,
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(height: 10),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 25.0),
child: SizedBox(
width: 450,
const SizedBox(height: 10),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: Text(
"1) Patient Profile Information.\n2) Patient Notes\n3) Patient Files.",
textAlign: TextAlign.left,
style: TextStyle(
"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,
),
),
),
),
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,
const SizedBox(height: 15),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 25.0),
child: Text(
"Here's what you'll be deleting:",
style: TextStyle(
color: Colors.black,
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(height: 10),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 25.0),
child: SizedBox(
width: 450,
child: Text(
"1) Patient Profile Information.\n2) Patient Notes\n3) Patient Files.",
textAlign: TextAlign.left,
style: TextStyle(
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),
alignment: Alignment.topRight,
onPressed: () {
showDialog(
context: context,
builder: (context) => deletePatientPopUp(),
);
deletePatientPopUp();
},
)
],