From 0c40888907b021c88d7e6f8b56ad5bf92c185c18 Mon Sep 17 00:00:00 2001 From: yaso-meth Date: Wed, 3 Jul 2024 16:33:52 +0200 Subject: [PATCH] Update mybutton widget to take in buttonColor & TextColour. Add Success message pop up message. Update all buttons to include button color and text colors. --- .../lib/components/mySuccessMessage.dart | 98 ++++++++++++++++ .../lib/components/mybutton.dart | 16 ++- .../lib/components/patientFiles.dart | 109 ++++++++++-------- .../lib/components/patientNotes.dart | 40 ++++--- .../lib/components/profileUserUpdate.dart | 27 +++-- Frontend/patient_manager/lib/pages/home.dart | 8 +- .../patient_manager/lib/pages/patientAdd.dart | 2 + .../lib/pages/patientEdit.dart | 8 +- .../patient_manager/lib/pages/register.dart | 4 +- .../patient_manager/lib/pages/signin.dart | 2 + 10 files changed, 226 insertions(+), 88 deletions(-) create mode 100644 Frontend/patient_manager/lib/components/mySuccessMessage.dart diff --git a/Frontend/patient_manager/lib/components/mySuccessMessage.dart b/Frontend/patient_manager/lib/components/mySuccessMessage.dart new file mode 100644 index 00000000..d0488d6d --- /dev/null +++ b/Frontend/patient_manager/lib/components/mySuccessMessage.dart @@ -0,0 +1,98 @@ +import 'package:flutter/material.dart'; +import 'package:patient_manager/components/mybutton.dart'; + +class MySuccessMessage extends StatefulWidget { + final String successType; + final String successMessage; + const MySuccessMessage({ + super.key, + required this.successType, + required this.successMessage, + }); + + @override + State createState() => _MySuccessMessageState(); +} + +class _MySuccessMessageState extends State { + var messageTypes = {}; + late String message; + + void setSuccessmessage() { + messageTypes["Success"] = Stack( + children: [ + Container( + padding: const EdgeInsets.all(10.0), + width: 500.0, + // height: 375.0, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(25.0), + border: Border.all(color: Colors.green, width: 5.0), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon( + Icons.check_circle_outline_rounded, + size: 100, + color: Colors.green, + ), + const SizedBox(height: 15), + const Text( + "Success!", + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.green, + fontSize: 25.0, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 10), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 25.0), + child: Text( + message, + style: const TextStyle( + color: Colors.black, + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 10), + SizedBox( + width: 300, + height: 100, + child: MyButton( + onTap: () { + Navigator.pop(context); + }, + buttonText: "Dismiss", + buttonColor: Colors.green, + textColor: Colors.white, + ), + ), + ], + ), + ), + ], + ); + } + + Widget? getSuccessMessage(String type) { + return messageTypes[type]; + } + + @override + void initState() { + message = widget.successMessage; + setSuccessmessage(); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Dialog(child: getSuccessMessage(widget.successType)); + } +} diff --git a/Frontend/patient_manager/lib/components/mybutton.dart b/Frontend/patient_manager/lib/components/mybutton.dart index e7753b24..7723e6e3 100644 --- a/Frontend/patient_manager/lib/components/mybutton.dart +++ b/Frontend/patient_manager/lib/components/mybutton.dart @@ -3,8 +3,16 @@ import 'package:flutter/material.dart'; class MyButton extends StatelessWidget { final void Function() onTap; final String buttonText; + final Color buttonColor; + final Color textColor; - const MyButton({super.key, required this.onTap, required this.buttonText}); + const MyButton({ + super.key, + required this.onTap, + required this.buttonText, + required this.buttonColor, + required this.textColor, + }); @override Widget build(BuildContext context) { @@ -13,17 +21,17 @@ class MyButton extends StatelessWidget { child: ElevatedButton( onPressed: onTap, style: ElevatedButton.styleFrom( - backgroundColor: Colors.blueAccent, + backgroundColor: buttonColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12.0), ), ), child: Text( buttonText, - style: const TextStyle( + style: TextStyle( //fontWeight: FontWeight.bold, fontSize: 20, - color: Colors.white, + color: textColor, ), ), ), diff --git a/Frontend/patient_manager/lib/components/patientFiles.dart b/Frontend/patient_manager/lib/components/patientFiles.dart index 24b85302..e9b8f118 100644 --- a/Frontend/patient_manager/lib/components/patientFiles.dart +++ b/Frontend/patient_manager/lib/components/patientFiles.dart @@ -215,24 +215,28 @@ class _PatientFilesState extends State { 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")) + 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", + buttonColor: Colors.blueAccent, + textColor: Colors.white, + ), + ) ], ), ), @@ -289,20 +293,23 @@ class _PatientFilesState extends State { 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; - }); + 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"), + setState(() { + selectedFileController.text = selectedFile.name; + }); + }, + buttonText: "Select File", + buttonColor: Colors.blueAccent, + textColor: Colors.white, + ), ), MyTextField( controller: selectedFileController, @@ -311,24 +318,28 @@ class _PatientFilesState extends State { 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")) + 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", + buttonColor: Colors.blueAccent, + textColor: Colors.white, + ), + ) ], ), ), diff --git a/Frontend/patient_manager/lib/components/patientNotes.dart b/Frontend/patient_manager/lib/components/patientNotes.dart index ebb6537c..5be30b1e 100644 --- a/Frontend/patient_manager/lib/components/patientNotes.dart +++ b/Frontend/patient_manager/lib/components/patientNotes.dart @@ -130,24 +130,28 @@ class _PatientNotesState extends State { ), ), 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")) + 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", + buttonColor: Colors.blueAccent, + textColor: Colors.white, + ), + ) ], ), ), diff --git a/Frontend/patient_manager/lib/components/profileUserUpdate.dart b/Frontend/patient_manager/lib/components/profileUserUpdate.dart index 237d0f16..1affbc37 100644 --- a/Frontend/patient_manager/lib/components/profileUserUpdate.dart +++ b/Frontend/patient_manager/lib/components/profileUserUpdate.dart @@ -80,18 +80,21 @@ class _ProfileUserUpdateState extends State { width: 500.0, height: 100.0, child: MyButton( - onTap: () { - if (isFieldsFilled()) { - } else { - showDialog( - context: context, - builder: (context) { - return const MyErrorMessage(errorType: "Input Error"); - }, - ); - } - }, - buttonText: "Update"), + onTap: () { + if (isFieldsFilled()) { + } else { + showDialog( + context: context, + builder: (context) { + return const MyErrorMessage(errorType: "Input Error"); + }, + ); + } + }, + buttonText: "Update", + buttonColor: Colors.blueAccent, + textColor: Colors.white, + ), ), ], ); diff --git a/Frontend/patient_manager/lib/pages/home.dart b/Frontend/patient_manager/lib/pages/home.dart index 580a38bc..5df06001 100644 --- a/Frontend/patient_manager/lib/pages/home.dart +++ b/Frontend/patient_manager/lib/pages/home.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:patient_manager/components/homeTileGrid.dart'; import 'package:patient_manager/components/myAppBar.dart'; import 'package:patient_manager/components/homeAppDrawer.dart'; -import 'package:patient_manager/components/myErrorMessage.dart'; +import 'package:patient_manager/components/mySuccessMessage.dart'; import 'package:patient_manager/main.dart'; class Home extends StatefulWidget { @@ -54,8 +54,10 @@ class _HomeState extends State { // .pushNamed('/patient-manager/add', arguments: widget.userEmail); showDialog( context: context, - builder: (context) => const MyErrorMessage( - errorType: "Internet Connection", + builder: (context) => const MySuccessMessage( + successType: "Success", + successMessage: + "This is the message when something successful happened.", ), ); }, diff --git a/Frontend/patient_manager/lib/pages/patientAdd.dart b/Frontend/patient_manager/lib/pages/patientAdd.dart index 6d5b0144..11d2873a 100644 --- a/Frontend/patient_manager/lib/pages/patientAdd.dart +++ b/Frontend/patient_manager/lib/pages/patientAdd.dart @@ -284,6 +284,8 @@ class _AddPatientState extends State { } }, buttonText: "Add", + buttonColor: Colors.blueAccent, + textColor: Colors.white, ), ), ], diff --git a/Frontend/patient_manager/lib/pages/patientEdit.dart b/Frontend/patient_manager/lib/pages/patientEdit.dart index 9fd0882a..a8f6a9f0 100644 --- a/Frontend/patient_manager/lib/pages/patientEdit.dart +++ b/Frontend/patient_manager/lib/pages/patientEdit.dart @@ -226,7 +226,11 @@ class _EditPatientState extends State { width: 300, height: 100, child: MyButton( - onTap: deletePatientApiCall, buttonText: "Delete")) + onTap: deletePatientApiCall, + buttonText: "Delete", + buttonColor: Colors.blueAccent, + textColor: Colors.white, + )) ], ), ), @@ -471,6 +475,8 @@ class _EditPatientState extends State { } }, buttonText: "Update", + buttonColor: Colors.blueAccent, + textColor: Colors.white, ), ), ], diff --git a/Frontend/patient_manager/lib/pages/register.dart b/Frontend/patient_manager/lib/pages/register.dart index 4d6d34fe..5c30024e 100644 --- a/Frontend/patient_manager/lib/pages/register.dart +++ b/Frontend/patient_manager/lib/pages/register.dart @@ -156,8 +156,10 @@ class _RegisterState extends State { SizedBox( width: 500.0, child: MyButton( - onTap: signUserUp, + onTap: () {}, buttonText: "Sign Up", + buttonColor: Colors.blueAccent, + textColor: Colors.white, ), ), //spacer diff --git a/Frontend/patient_manager/lib/pages/signin.dart b/Frontend/patient_manager/lib/pages/signin.dart index abf64c4b..4b64d3d9 100644 --- a/Frontend/patient_manager/lib/pages/signin.dart +++ b/Frontend/patient_manager/lib/pages/signin.dart @@ -126,6 +126,8 @@ class _SignInState extends State { } }, buttonText: "Sign In", + buttonColor: Colors.blueAccent, + textColor: Colors.white, ), ), //spacer