file name update v1

This commit is contained in:
2024-09-17 15:29:16 +02:00
parent c59eb4a5f2
commit 1f65a14dfe
50 changed files with 206 additions and 207 deletions

View File

@@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
class MIHAction extends StatefulWidget {
final void Function()? onTap;
final double iconSize;
final IconData icon;
const MIHAction({
super.key,
required this.icon,
required this.iconSize,
required this.onTap,
});
@override
State<MIHAction> createState() => _MIHActionState();
}
class _MIHActionState extends State<MIHAction> {
@override
void dispose() {
super.dispose();
}
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Positioned(
top: 5,
left: 5,
width: 50,
height: 50,
child: Builder(
builder: (context) => IconButton(
padding: const EdgeInsets.all(0),
onPressed: widget.onTap,
icon: Icon(
widget.icon,
size: widget.iconSize,
),
),
),
);
}
}

View File

@@ -0,0 +1,244 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/appUser.dart';
import 'package:patient_manager/objects/arguments.dart';
import 'package:supertokens_flutter/supertokens.dart';
class MIHAppDrawer extends StatefulWidget {
final AppUser signedInUser;
final ImageProvider<Object>? propicFile;
const MIHAppDrawer({
super.key,
required this.signedInUser,
required this.propicFile,
});
@override
State<MIHAppDrawer> createState() => _MIHAppDrawerState();
}
class _MIHAppDrawerState extends State<MIHAppDrawer> {
late Widget profilePictureLoaded;
Future<bool> signOut() async {
await SuperTokens.signOut(completionHandler: (error) {
// handle error if any
});
return true;
}
Widget displayProPic() {
//print(widget.propicFile);
ImageProvider logoFrame =
MzanziInnovationHub.of(context)!.theme.logoFrame();
if (widget.propicFile != null) {
return GestureDetector(
onTap: () {
Navigator.of(context).pop();
Navigator.of(context).pushNamed(
'/user-profile',
arguments: AppProfileUpdateArguments(
widget.signedInUser, widget.propicFile),
);
},
child: Stack(
alignment: Alignment.center,
fit: StackFit.loose,
children: [
CircleAvatar(
backgroundColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
backgroundImage: widget.propicFile,
//'https://media.licdn.com/dms/image/D4D03AQGd1-QhjtWWpA/profile-displayphoto-shrink_400_400/0/1671698053061?e=2147483647&v=beta&t=a3dJI5yxs5-KeXjj10LcNCFuC9IOfa8nNn3k_Qyr0CA'),
radius: 27,
),
SizedBox(
width: 60,
child: Image(image: logoFrame),
)
],
),
);
} else {
return SizedBox(
width: 60,
child: Image(image: logoFrame),
);
}
}
@override
void dispose() {
super.dispose();
}
@override
void initState() {
setState(() {
profilePictureLoaded = displayProPic();
});
super.initState();
}
@override
Widget build(BuildContext context) {
// precacheImage(
// MzanziInnovationHub.of(context)!.theme.logoImage().image, context);
ImageProvider logoThemeSwitch =
MzanziInnovationHub.of(context)!.theme.logoImage();
return Drawer(
//backgroundColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
child: Stack(children: [
ListView(
padding: EdgeInsets.zero,
children: [
DrawerHeader(
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
child: SizedBox(
height: 400,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
profilePictureLoaded,
Text(
"${widget.signedInUser.fname} ${widget.signedInUser.lname}",
style: TextStyle(
fontWeight: FontWeight.bold,
color: MzanziInnovationHub.of(context)!
.theme
.primaryColor(),
),
),
Text(
"@${widget.signedInUser.username}",
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: MzanziInnovationHub.of(context)!
.theme
.primaryColor(),
),
),
Text(
widget.signedInUser.type.toUpperCase(),
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.bold,
color: MzanziInnovationHub.of(context)!
.theme
.primaryColor(),
),
),
],
),
),
),
ListTile(
title: Row(
mainAxisSize: MainAxisSize.max,
children: [
Icon(
Icons.home_outlined,
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
const SizedBox(width: 25.0),
Text(
"Home",
style: TextStyle(
//fontWeight: FontWeight.bold,
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
),
),
],
),
onTap: () {
Navigator.of(context)
.pushNamedAndRemoveUntil('/', (route) => false);
},
),
ListTile(
title: Row(
mainAxisSize: MainAxisSize.max,
children: [
Icon(
Icons.logout,
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
const SizedBox(width: 25.0),
Text(
"Sign Out",
style: TextStyle(
//fontWeight: FontWeight.bold,
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
),
),
],
),
onTap: () async {
await SuperTokens.signOut(completionHandler: (error) {
print(error);
});
if (await SuperTokens.doesSessionExist() == false) {
Navigator.of(context).popAndPushNamed('/');
}
},
)
],
),
Positioned(
top: 5,
right: 5,
width: 30,
height: 30,
child: InkWell(
onTap: () {
setState(() {
if (MzanziInnovationHub.of(context)?.theme.mode == "Dark") {
//darkm = !darkm;
MzanziInnovationHub.of(context)!.changeTheme(ThemeMode.light);
//print("Dark Mode: $darkm");
} else {
//darkm = !darkm;
MzanziInnovationHub.of(context)!.changeTheme(ThemeMode.dark);
//print("Dark Mode: $darkm");
}
Navigator.of(context).popAndPushNamed('/');
});
},
child: Image(image: logoThemeSwitch),
),
// IconButton(
// onPressed: () {
// setState(() {
// if (MzanziInnovationHub.of(context)?.theme.mode == "Dark") {
// //darkm = !darkm;
// MzanziInnovationHub.of(context)!.changeTheme(ThemeMode.light);
// //print("Dark Mode: $darkm");
// } else {
// //darkm = !darkm;
// MzanziInnovationHub.of(context)!.changeTheme(ThemeMode.dark);
// //print("Dark Mode: $darkm");
// }
// Navigator.of(context).popAndPushNamed('/');
// });
// },
// icon: Icon(
// Icons.light_mode,
// color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
// size: 35,
// ),
// ),
),
]),
);
}
}

View File

@@ -0,0 +1,82 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/main.dart';
class MIHBody extends StatefulWidget {
final bool borderOn;
final List<Widget> bodyItems;
const MIHBody({
super.key,
required this.borderOn,
required this.bodyItems,
});
@override
State<MIHBody> createState() => _MIHBodyState();
}
class _MIHBodyState extends State<MIHBody> {
//double paddingSize = 10;
double getPaddingSize() {
if (widget.borderOn) {
return 10;
} else {
return 0;
}
}
Decoration? getBoader() {
if (widget.borderOn) {
return BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 3.0),
);
} else {
return null;
}
}
@override
void dispose() {
super.dispose();
}
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
Size screenSize = MediaQuery.sizeOf(context);
return Padding(
padding: EdgeInsets.only(
left: getPaddingSize(),
right: getPaddingSize(),
bottom: getPaddingSize(),
top: 0,
),
child: Container(
padding: EdgeInsets.only(
left: 10,
right: 10,
bottom: 10,
top: getPaddingSize(),
),
width: screenSize.width,
height: screenSize.height,
decoration: getBoader(),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: widget.bodyItems,
),
),
),
);
}
}

View File

@@ -0,0 +1,39 @@
import 'package:flutter/material.dart';
class MIHHeader extends StatefulWidget {
final MainAxisAlignment headerAlignment;
final List<Widget> headerItems;
const MIHHeader({
super.key,
required this.headerAlignment,
required this.headerItems,
});
@override
State<MIHHeader> createState() => _MIHHeaderState();
}
class _MIHHeaderState extends State<MIHHeader> {
@override
void dispose() {
super.dispose();
}
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return SizedBox(
height: 60,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: widget.headerAlignment,
mainAxisSize: MainAxisSize.max,
children: widget.headerItems,
),
);
}
}

View File

@@ -0,0 +1,60 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/mih_components/MIH_Layout/mih_action.dart';
import 'package:patient_manager/mih_components/MIH_Layout/mih_body.dart';
import 'package:patient_manager/mih_components/MIH_Layout/mih_header.dart';
class MIHLayoutBuilder extends StatefulWidget {
final MIHAction actionButton;
final MIHHeader header;
final MIHBody body;
const MIHLayoutBuilder({
super.key,
required this.actionButton,
required this.header,
required this.body,
});
@override
State<MIHLayoutBuilder> createState() => _MIHLayoutBuilderState();
}
class _MIHLayoutBuilderState extends State<MIHLayoutBuilder> {
List<Widget> getList() {
List<Widget> temp = [];
temp.add(widget.header);
temp.add(widget.body);
return temp;
}
@override
void dispose() {
super.dispose();
}
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
Size screenSize = MediaQuery.sizeOf(context);
return Scaffold(
body: SizedBox(
width: screenSize.width,
height: screenSize.height,
child: Stack(
children: [
widget.actionButton,
Column(
children: [
widget.header,
Expanded(child: widget.body),
],
),
],
),
),
);
}
}

View File

@@ -0,0 +1,139 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/main.dart';
class MIHTile extends StatefulWidget {
final String tileName;
//final String tileDescription;
final Widget tileIcon;
final void Function() onTap;
// final Widget tileIcon;
final Color p;
final Color s;
const MIHTile({
super.key,
required this.onTap,
required this.tileName,
//required this.tileDescription,
required this.tileIcon,
required this.p,
required this.s,
});
@override
State<MIHTile> createState() => _MIHTileState();
}
class _MIHTileState extends State<MIHTile> {
late Color mainC;
late Color secondC;
@override
void dispose() {
// TODO: implement dispose
super.dispose();
}
@override
void initState() {
mainC = widget.p;
secondC = widget.s;
super.initState();
}
// Widget displayTile() {
// return FittedBox(
// child: Column(
// mainAxisSize: MainAxisSize.min,
// mainAxisAlignment: MainAxisAlignment.end,
// children: [
// GestureDetector(
// onTap: widget.onTap,
// onTapDown: (_) {
// setState(() {
// mainC = MzanziInnovationHub.of(context)!.theme.primaryColor();
// secondC =
// MzanziInnovationHub.of(context)!.theme.secondaryColor();
// });
// },
// onTapUp: (_) {
// setState(() {
// mainC = MzanziInnovationHub.of(context)!.theme.secondaryColor();
// secondC = MzanziInnovationHub.of(context)!.theme.primaryColor();
// });
// },
// child: Container(
// padding: const EdgeInsets.all(3.0),
// decoration: BoxDecoration(
// color: mainC,
// borderRadius: BorderRadius.circular(10.0),
// //border: Border.all(color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), width: 1.0),
// ),
// child: Icon(
// widget.tileIcon,
// color: secondC,
// ),
// ),
// ),
// const SizedBox(height: 1),
// Row(
// children: [
// Flexible(
// child: Text(
// widget.tileName,
// textAlign: TextAlign.center,
// softWrap: true,
// overflow: TextOverflow.visible,
// style: TextStyle(
// color: mainC,
// fontSize: 5.0,
// fontWeight: FontWeight.bold,
// ),
// ),
// ),
// ],
// )
// ],
// ),
// );
// }
@override
Widget build(BuildContext context) {
// print(
// "Tile Name: ${widget.tileName}\nTitle Type: ${widget.tileIcon.runtimeType.toString()}");
return FittedBox(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Material(
color: mainC,
borderRadius: BorderRadius.circular(80),
child: Ink(
padding: const EdgeInsets.all(20),
child: InkWell(
onTap: widget.onTap,
child: SizedBox(
height: 200,
width: 200,
child: widget.tileIcon,
),
),
),
),
const SizedBox(height: 10),
Text(
widget.tileName,
textAlign: TextAlign.center,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: 40.0,
fontWeight: FontWeight.bold,
),
)
],
),
);
}
}

View File

@@ -0,0 +1,63 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/mih_components/mih_inputs_and_buttons/mih_date_input.dart';
class Medcertinput extends StatefulWidget {
final startDateController;
final endDateTextController;
final retDateTextController;
const Medcertinput({
super.key,
required this.startDateController,
required this.endDateTextController,
required this.retDateTextController,
});
@override
State<Medcertinput> createState() => _MedcertinputState();
}
class _MedcertinputState extends State<Medcertinput> {
@override
void dispose() {
// TODO: implement dispose
super.dispose();
}
@override
Widget build(BuildContext context) {
return SizedBox(
//height: 325,
child: Column(
children: [
const SizedBox(height: 50.0),
SizedBox(
width: 700,
child: MIHDateField(
controller: widget.startDateController,
lableText: "From",
required: true,
),
),
const SizedBox(height: 10.0),
SizedBox(
width: 700,
child: MIHDateField(
controller: widget.endDateTextController,
lableText: "Up to Including",
required: true,
),
),
const SizedBox(height: 10.0),
SizedBox(
width: 700,
child: MIHDateField(
controller: widget.retDateTextController,
lableText: "Return",
required: true,
),
),
],
),
);
}
}

View File

@@ -0,0 +1,155 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:patient_manager/MIH_Packages/patient_profile/builder/buildMedList.dart';
import 'package:patient_manager/mih_components/mih_pop_up_messages/mihLoadingCircle.dart';
import 'package:patient_manager/mih_components/mih_pop_up_messages/mihErrorMessage.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/medicine.dart';
import 'package:supertokens_flutter/http.dart' as http;
class MedicineSearch extends StatefulWidget {
final TextEditingController searchVlaue;
const MedicineSearch({
super.key,
required this.searchVlaue,
});
@override
State<MedicineSearch> createState() => _MedicineSearchState();
}
class _MedicineSearchState extends State<MedicineSearch> {
final String endpointMeds = "${AppEnviroment.baseApiUrl}/users/medicine/";
//TextEditingController searchController = TextEditingController();
late Future<List<Medicine>> futueMeds;
//String searchString = "";
Future<List<Medicine>> getMedList(String endpoint) async {
final response = await http.get(Uri.parse(endpoint));
if (response.statusCode == 200) {
Iterable l = jsonDecode(response.body);
List<Medicine> medicines =
List<Medicine>.from(l.map((model) => Medicine.fromJson(model)));
// List<Medicine> meds = [];
// medicines.forEach((element) => meds.add(element.name));
return medicines;
} else {
internetConnectionPopUp();
throw Exception('failed to load medicine');
}
}
void internetConnectionPopUp() {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Internet Connection");
},
);
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
}
@override
void initState() {
futueMeds = getMedList(endpointMeds + widget.searchVlaue.text);
super.initState();
}
@override
Widget build(BuildContext context) {
return Dialog(
child: Stack(
children: [
Container(
padding: const EdgeInsets.all(10.0),
width: 700.0,
//height: 475.0,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 5.0),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Text(
"Select Medicine",
textAlign: TextAlign.center,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: 35.0,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 25.0),
FutureBuilder(
future: futueMeds,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const SizedBox(
height: 400,
child: Mihloadingcircle(),
);
} else if (snapshot.hasData && snapshot.data!.isNotEmpty) {
final medsList = snapshot.data!;
return SizedBox(
height: 400,
child: BuildMedicinesList(
contoller: widget.searchVlaue,
medicines: medsList,
//searchString: searchString,
),
);
} else {
return const SizedBox(
height: 400,
child: const Center(
child: Text(
"No Match Found\nPlease close and manually capture medicine",
style: TextStyle(fontSize: 25, color: Colors.grey),
textAlign: TextAlign.center,
),
),
);
}
},
),
],
),
),
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,
),
),
),
],
),
);
}
}

View File

@@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
class MIHButton extends StatefulWidget {
final void Function() onTap;
final String buttonText;
final Color buttonColor;
final Color textColor;
const MIHButton({
super.key,
required this.onTap,
required this.buttonText,
required this.buttonColor,
required this.textColor,
});
@override
State<MIHButton> createState() => _MIHButtonState();
}
class _MIHButtonState extends State<MIHButton> {
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: widget.onTap,
style: ElevatedButton.styleFrom(
backgroundColor: widget.buttonColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
),
),
child: Text(
widget.buttonText,
style: TextStyle(
//fontWeight: FontWeight.bold,
fontSize: 20,
color: widget.textColor,
fontWeight: FontWeight.bold,
),
),
);
}
}

View File

@@ -0,0 +1,152 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/main.dart';
class MIHDateField extends StatefulWidget {
final TextEditingController controller;
final String lableText;
final bool required;
const MIHDateField({
super.key,
required this.controller,
required this.lableText,
required this.required,
});
@override
State<MIHDateField> createState() => _MIHDateFieldState();
}
class _MIHDateFieldState extends State<MIHDateField> {
final FocusNode _focus = FocusNode();
bool startup = true;
// bool makeEditable() {
Future<void> _selectDate(BuildContext context) async {
DateTime? picked = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2000),
lastDate: DateTime(2100),
);
if (picked != null) {
setState(() {
widget.controller.text = picked.toString().split(" ")[0];
});
}
}
Widget setRequiredText() {
if (widget.required) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"*",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor()),
),
const SizedBox(
width: 8.0,
),
Text(widget.lableText,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor())),
],
);
} else {
return Text(widget.lableText,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()));
}
}
void _onFocusChange() {
setState(() {
startup = false;
});
}
String? get _errorText {
final text = widget.controller.text;
if (startup) {
return null;
}
if (!widget.required) {
return null;
}
if (text.isEmpty) {
return "${widget.lableText} is required";
}
return null;
}
@override
void dispose() {
_focus.dispose();
super.dispose();
}
@override
void initState() {
_focus.addListener(_onFocusChange);
super.initState();
}
@override
Widget build(BuildContext context) {
return TextField(
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
controller: widget.controller,
readOnly: true,
obscureText: false,
focusNode: _focus,
onChanged: (_) => setState(() {
startup = false;
}),
decoration: InputDecoration(
errorText: _errorText,
errorStyle: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontWeight: FontWeight.bold),
label: setRequiredText(),
//labelText: widget.lableText,
//labelStyle: const TextStyle(color: Colors.blueAccent),
prefixIcon: Icon(
Icons.calendar_today,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
fillColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
filled: true,
//hintText: hintText,
//hintStyle: TextStyle(color: Colors.blueGrey[400]),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 2.0,
),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 2.0,
),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 2.0,
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
),
),
onTap: () {
_selectDate(context);
},
);
}
}

View File

@@ -0,0 +1,213 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/main.dart';
class MIHDropdownField extends StatefulWidget {
final TextEditingController controller;
final String hintText;
final bool required;
final List<String> dropdownOptions;
final void Function(String?)? onSelect;
final bool editable;
const MIHDropdownField({
super.key,
required this.controller,
required this.hintText,
required this.dropdownOptions,
required this.required,
required this.editable,
this.onSelect,
});
@override
State<MIHDropdownField> createState() => _MIHDropdownFieldState();
}
class _MIHDropdownFieldState extends State<MIHDropdownField> {
//var dropbownItems = ["Dr.", "Assistant"];
bool startup = true;
final FocusNode _focus = FocusNode();
late List<DropdownMenuEntry<String>> menu;
Widget setRequiredText() {
if (widget.required) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"*",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor()),
),
const SizedBox(
width: 8.0,
),
Text(widget.hintText,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor())),
],
);
} else {
return Text(widget.hintText,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()));
}
}
void _onFocusChange() {
setState(() {
startup = false;
});
}
String? get _errorText {
final text = widget.controller.text;
if (startup) {
return null;
}
if (!widget.required) {
return null;
}
if (text.isEmpty) {
return "${widget.hintText} is required";
}
return null;
}
List<DropdownMenuEntry<String>> buidMenueOptions(List<String> options) {
List<DropdownMenuEntry<String>> menueList = [];
for (final i in options) {
menueList.add(DropdownMenuEntry(
value: i,
label: i,
style: ButtonStyle(
foregroundColor: WidgetStatePropertyAll(
MzanziInnovationHub.of(context)!.theme.secondaryColor()))));
}
return menueList;
}
@override
void dispose() {
_focus.dispose();
super.dispose();
}
@override
void initState() {
menu = buidMenueOptions(widget.dropdownOptions);
_focus.addListener(_onFocusChange);
super.initState();
}
// bool makeEditable() {
@override
Widget build(BuildContext context) {
return DropdownMenu(
enabled: widget.editable,
trailingIcon: Icon(
Icons.arrow_drop_down,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
selectedTrailingIcon: Icon(
Icons.arrow_drop_up,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
textStyle: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
menuHeight: 300,
controller: widget.controller,
expandedInsets: EdgeInsets.zero,
label: setRequiredText(),
errorText: _errorText,
focusNode: _focus,
onSelected: (_) {
setState(() {
startup = false;
});
// if (widget.editable == false) {
// return false;
// }
},
leadingIcon: IconButton(
onPressed: () {
setState(() {
startup = false;
});
widget.controller.clear();
},
icon: Icon(
Icons.delete_outline_rounded,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
menuStyle: MenuStyle(
backgroundColor: WidgetStatePropertyAll(
MzanziInnovationHub.of(context)!.theme.primaryColor()),
side: WidgetStatePropertyAll(
BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 2.0),
),
),
inputDecorationTheme: InputDecorationTheme(
filled: true,
errorStyle: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontWeight: FontWeight.bold),
fillColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 2.0,
),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 2.0,
),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 2.0,
),
),
disabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 2.0,
),
),
outlineBorder: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
),
dropdownMenuEntries: menu,
// const <DropdownMenuEntry<String>>[
// DropdownMenuEntry(value: "Dr.", label: "Dr."),
// DropdownMenuEntry(value: "Assistant", label: "Assistant"),
// ],
);
}
}
// filled: true,
// hintText: hintText,
// hintStyle: TextStyle(color: Colors.blueGrey[400]),
// enabledBorder: const OutlineInputBorder(
// borderSide: BorderSide(
// color: Colors.blueAccent,
// width: 2.0,
// ),
// ),
// focusedBorder: const OutlineInputBorder(
// borderSide: BorderSide(color: Colors.blue),

View File

@@ -0,0 +1,177 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/main.dart';
class MIHFileField extends StatefulWidget {
final TextEditingController controller;
final String hintText;
final bool editable;
final bool required;
final void Function() onPressed;
const MIHFileField({
super.key,
required this.controller,
required this.hintText,
required this.editable,
required this.required,
required this.onPressed,
});
@override
State<MIHFileField> createState() => _MIHFileFieldState();
}
class _MIHFileFieldState extends State<MIHFileField> {
bool startup = true;
final FocusNode _focus = FocusNode();
bool makeEditable() {
if (widget.editable) {
return false;
} else {
return true;
}
}
String? get _errorText {
final text = widget.controller.text;
String errorMessage = '';
if (startup) {
return null;
}
if (!widget.required) {
return null;
}
if (text.isEmpty) {
return "${widget.hintText} is required";
}
if (widget.hintText == "Email" && !isEmailValid(text)) {
errorMessage += "Enter a valid email address\n";
}
if (widget.hintText == "Username" && text.length < 8) {
errorMessage += "• Username must contain at least 8 characters.\n";
}
if (widget.hintText == "Username" && !isUsernameValid(text)) {
errorMessage += "• Username can only contain '_' special Chracters.\n";
}
if (errorMessage.isEmpty) {
return null;
}
// If there are no error messages, the password is valid
return errorMessage;
}
bool isUsernameValid(String username) {
return RegExp(r'^(?=[a-zA-Z0-9._]{8,20}$)(?!.*[_.]{2})[^_.].*[^_.]$')
.hasMatch(username);
}
bool isEmailValid(String email) {
return RegExp(r'^[\w-\.]+@[a-zA-Z]+\.[a-zA-Z]{2,}$').hasMatch(email);
}
void _onFocusChange() {
setState(() {
startup = false;
});
}
Widget setRequiredText() {
if (widget.required) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"*",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor()),
),
const SizedBox(
width: 8.0,
),
Text(widget.hintText,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor())),
],
);
} else {
return Text(widget.hintText,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()));
}
}
@override
void dispose() {
_focus.dispose();
super.dispose();
}
@override
void initState() {
_focus.addListener(_onFocusChange);
super.initState();
}
@override
Widget build(BuildContext context) {
return TextField(
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
controller: widget.controller,
focusNode: _focus,
readOnly: makeEditable(),
//enabled: !makeEditable(),
obscureText: false,
onChanged: (_) => setState(() {
startup = false;
}),
decoration: InputDecoration(
suffixIcon: IconButton(
icon: const Icon(Icons.attach_file),
onPressed: widget.onPressed,
),
label: setRequiredText(),
//labelStyle: TextStyle(color: MzanziInnovationHub.of(context)!.theme.primaryColor()),
fillColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
filled: true,
errorText: _errorText,
errorStyle: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontWeight: FontWeight.bold),
//errorBorder: const InputBorder(),
//hintText: hintText,
//hintStyle: TextStyle(color: Colors.blueGrey[400]),
disabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 2.0,
),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 2.0,
),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 2.0,
),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 2.0,
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
),
),
);
}
}

View File

@@ -0,0 +1,146 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/main.dart';
class MIHMLTextField extends StatefulWidget {
final TextEditingController controller;
final String hintText;
final bool editable;
final bool required;
const MIHMLTextField({
super.key,
required this.controller,
required this.hintText,
required this.editable,
required this.required,
});
@override
State<MIHMLTextField> createState() => _MIHMLTextFieldState();
}
class _MIHMLTextFieldState extends State<MIHMLTextField> {
bool startup = true;
final FocusNode _focus = FocusNode();
bool makeEditable() {
if (widget.editable) {
return false;
} else {
return true;
}
}
String? get _errorText {
final text = widget.controller.text;
if (startup) {
return null;
}
if (!widget.required) {
return null;
}
if (text.isEmpty) {
return "${widget.hintText} is required";
}
return null;
}
void _onFocusChange() {
setState(() {
startup = false;
});
}
Widget setRequiredText() {
if (widget.required) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"*",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor()),
),
const SizedBox(
width: 8.0,
),
Text(widget.hintText,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor())),
],
);
} else {
return Text(widget.hintText,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()));
}
}
@override
void dispose() {
_focus.dispose();
super.dispose();
}
@override
void initState() {
_focus.addListener(_onFocusChange);
super.initState();
}
@override
Widget build(BuildContext context) {
return TextField(
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
textAlign: TextAlign.start,
textAlignVertical: TextAlignVertical.top,
expands: true,
maxLines: null,
controller: widget.controller,
readOnly: makeEditable(),
obscureText: false,
focusNode: _focus,
onChanged: (_) => setState(() {
startup = false;
}),
decoration: InputDecoration(
label: setRequiredText(),
errorText: _errorText,
errorStyle: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontWeight: FontWeight.bold),
labelStyle: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
alignLabelWithHint: true,
fillColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
filled: true,
//hintText: hintText,
//hintStyle: TextStyle(color: Colors.blueGrey[400]),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 2.0,
),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 2.0,
),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 2.0,
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
),
),
);
}
}

View File

@@ -0,0 +1,188 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/main.dart';
class MIHPassField extends StatefulWidget {
final TextEditingController controller;
final String hintText;
final bool required;
final bool signIn;
const MIHPassField({
super.key,
required this.controller,
required this.hintText,
required this.required,
required this.signIn,
});
@override
State<MIHPassField> createState() => _MIHPassFieldState();
}
class _MIHPassFieldState extends State<MIHPassField> {
bool startup = true;
final textFieldFocusNode = FocusNode();
bool _obscured = true;
//bool valid = false;
void _toggleObscured() {
setState(() {
_obscured = !_obscured;
if (textFieldFocusNode.hasPrimaryFocus) {
return; // If focus is on text field, dont unfocus
}
textFieldFocusNode.canRequestFocus =
false; // Prevents focus if tap on eye
});
}
String? get _errorText {
final text = widget.controller.text;
String errorMessage = '';
if (startup) {
return null;
}
if (!widget.required) {
return null;
}
if (text.isEmpty) {
return "${widget.hintText} is required";
}
// Password length greater than 8
if (text.length <= 8 && !widget.signIn) {
errorMessage += '• Password must contain at least 8 characters.\n';
}
// Contains at least one uppercase letter
if (!text.contains(RegExp(r'[A-Z]')) && !widget.signIn) {
errorMessage += '• Uppercase letter is missing.\n';
}
// Contains at least one lowercase letter
if (!text.contains(RegExp(r'[a-z]')) && !widget.signIn) {
errorMessage += '• Lowercase letter is missing.\n';
}
// Contains at least one digit
if (!text.contains(RegExp(r'[0-9]')) && !widget.signIn) {
errorMessage += '• number is missing.\n';
}
// Contains at least one special character
if (!text.contains(RegExp(r'[!@#$%^&*]')) && !widget.signIn) {
errorMessage += '• Special character is missing - !@#\$%^&*\n';
}
// Contains no errors
if (errorMessage.isEmpty) {
return null;
}
// If there are no error messages, the password is valid
return errorMessage;
}
Widget setRequiredText() {
if (widget.required) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"*",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor()),
),
const SizedBox(
width: 8.0,
),
Text(widget.hintText,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor())),
],
);
} else {
return Text(widget.hintText,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()));
}
}
void _onFocusChange() {
setState(() {
startup = false;
});
}
@override
void dispose() {
textFieldFocusNode.dispose();
super.dispose();
}
@override
void initState() {
textFieldFocusNode.addListener(_onFocusChange);
super.initState();
}
@override
Widget build(BuildContext context) {
return TextField(
controller: widget.controller,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
obscureText: _obscured,
focusNode: textFieldFocusNode,
onChanged: (_) => setState(() {
startup = false;
}),
decoration: InputDecoration(
fillColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
filled: true,
label: setRequiredText(),
//labelStyle: const TextStyle(color: Colors.blueAccent),
errorText: _errorText,
errorStyle: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontWeight: FontWeight.bold),
//hintText: widget.hintText,
//hintStyle: TextStyle(color: Colors.blueGrey[400]),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 2.0,
),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 2.0,
),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 2.0,
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
),
suffixIcon: Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 4, 0),
child: GestureDetector(
onTap: _toggleObscured,
child: Icon(
_obscured
? Icons.visibility_rounded
: Icons.visibility_off_rounded,
size: 24,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
),
),
);
}
}

View File

@@ -0,0 +1,158 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/main.dart';
class MIHSearchField extends StatefulWidget {
final TextEditingController controller;
final String hintText;
final bool required;
final bool editable;
final void Function() onTap;
const MIHSearchField({
super.key,
required this.controller,
required this.hintText,
required this.required,
required this.editable,
required this.onTap,
});
@override
State<MIHSearchField> createState() => _MIHSearchFieldState();
}
class _MIHSearchFieldState extends State<MIHSearchField> {
bool startup = true;
final FocusNode _focus = FocusNode();
bool makeEditable() {
if (widget.editable) {
return false;
} else {
return true;
}
}
String? get _errorText {
final text = widget.controller.text;
if (startup) {
return null;
}
if (!widget.required) {
return null;
}
if (text.isEmpty) {
return "${widget.hintText} is required";
}
return null;
}
void _onFocusChange() {
setState(() {
startup = false;
});
}
Widget setRequiredText() {
if (widget.required) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"*",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor()),
),
const SizedBox(
width: 8.0,
),
Text(
widget.hintText,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
],
);
} else {
return Text(widget.hintText,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()));
}
}
@override
void dispose() {
_focus.dispose();
super.dispose();
}
@override
void initState() {
_focus.addListener(_onFocusChange);
super.initState();
}
@override
Widget build(BuildContext context) {
return TextField(
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
onChanged: (_) {
setState(() {
startup = false;
});
},
controller: widget.controller,
//style: TextStyle(color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
readOnly: makeEditable(),
focusNode: _focus,
obscureText: false,
decoration: InputDecoration(
fillColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
suffixIcon: IconButton(
icon: Icon(
Icons.search,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
onPressed: () {
setState(() {
startup = false;
});
if (widget.controller.text != "") {
widget.onTap();
}
},
),
filled: true,
label: setRequiredText(),
errorText: _errorText,
errorStyle: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontWeight: FontWeight.bold),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 2.0,
),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 2.0,
),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 2.0,
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
),
),
);
}
}

View File

@@ -0,0 +1,173 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/main.dart';
class MIHTextField extends StatefulWidget {
final TextEditingController controller;
final String hintText;
final bool editable;
final bool required;
const MIHTextField({
super.key,
required this.controller,
required this.hintText,
required this.editable,
required this.required,
});
@override
State<MIHTextField> createState() => _MIHTextFieldState();
}
class _MIHTextFieldState extends State<MIHTextField> {
bool startup = true;
final FocusNode _focus = FocusNode();
bool makeEditable() {
if (widget.editable) {
return false;
} else {
return true;
}
}
String? get _errorText {
final text = widget.controller.text;
String errorMessage = '';
if (startup) {
return null;
}
if (!widget.required) {
return null;
}
if (text.isEmpty) {
return "${widget.hintText} is required";
}
if (widget.hintText == "Email" && !isEmailValid(text)) {
errorMessage += "Enter a valid email address\n";
}
if (widget.hintText == "Username" && text.length < 8) {
errorMessage += "• Username must contain at least 8 characters.\n";
}
if (widget.hintText == "Username" && !isUsernameValid(text)) {
errorMessage += "• Username can only contain '_' special Chracters.\n";
}
if (errorMessage.isEmpty) {
return null;
}
// If there are no error messages, the password is valid
return errorMessage;
}
bool isUsernameValid(String username) {
return RegExp(r'^(?=[a-zA-Z0-9._]{8,20}$)(?!.*[_.]{2})[^_.].*[^_.]$')
.hasMatch(username);
}
bool isEmailValid(String email) {
var regex = RegExp(r'^[a-zA-Z0-9]+@[a-zA-Z.-]+\.[a-zA-Z]{2,}$');
return regex.hasMatch(email);
}
void _onFocusChange() {
setState(() {
startup = false;
});
}
Widget setRequiredText() {
if (widget.required) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"*",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor()),
),
const SizedBox(
width: 8.0,
),
Text(widget.hintText,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor())),
],
);
} else {
return Text(widget.hintText,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()));
}
}
@override
void dispose() {
_focus.dispose();
super.dispose();
}
@override
void initState() {
_focus.addListener(_onFocusChange);
super.initState();
}
@override
Widget build(BuildContext context) {
return TextField(
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
controller: widget.controller,
focusNode: _focus,
readOnly: makeEditable(),
//enabled: !makeEditable(),
obscureText: false,
onChanged: (_) => setState(() {
startup = false;
}),
decoration: InputDecoration(
label: setRequiredText(),
//labelStyle: TextStyle(color: MzanziInnovationHub.of(context)!.theme.primaryColor()),
fillColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
filled: true,
errorText: _errorText,
errorStyle: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontWeight: FontWeight.bold),
//errorBorder: const InputBorder(),
//hintText: hintText,
//hintStyle: TextStyle(color: Colors.blueGrey[400]),
disabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 2.0,
),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 2.0,
),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 2.0,
),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 2.0,
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
),
),
);
}
}

View File

@@ -0,0 +1,170 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/main.dart';
class MIHTimeField extends StatefulWidget {
final TextEditingController controller;
final String lableText;
final bool required;
const MIHTimeField({
super.key,
required this.controller,
required this.lableText,
required this.required,
});
@override
State<MIHTimeField> createState() => _MIHDateFieldState();
}
class _MIHDateFieldState extends State<MIHTimeField> {
final FocusNode _focus = FocusNode();
bool startup = true;
Future<void> _selectTime(BuildContext context) async {
TimeOfDay? picked = await showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
builder: (context, child) {
return MediaQuery(
data: MediaQuery.of(context).copyWith(alwaysUse24HourFormat: true),
child: child as Widget,
);
},
);
if (picked != null) {
String hours = "";
String minutes = "";
setState(() {
if (picked.hour <= 9) {
hours = "0${picked.hour}";
} else {
hours = "${picked.hour}";
}
if (picked.minute <= 9) {
minutes = "0${picked.minute}";
} else {
minutes = "${picked.minute}";
}
widget.controller.text = "$hours:$minutes";
});
}
}
Widget setRequiredText() {
if (widget.required) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"*",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor()),
),
const SizedBox(
width: 8.0,
),
Text(widget.lableText,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor())),
],
);
} else {
return Text(widget.lableText,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()));
}
}
void _onFocusChange() {
setState(() {
startup = false;
});
}
String? get _errorText {
final text = widget.controller.text;
if (startup) {
return null;
}
if (!widget.required) {
return null;
}
if (text.isEmpty) {
return "${widget.lableText} is required";
}
return null;
}
@override
void dispose() {
_focus.dispose();
super.dispose();
}
@override
void initState() {
_focus.addListener(_onFocusChange);
super.initState();
}
@override
Widget build(BuildContext context) {
return TextField(
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
controller: widget.controller,
readOnly: true,
obscureText: false,
focusNode: _focus,
onChanged: (_) => setState(() {
startup = false;
}),
decoration: InputDecoration(
errorText: _errorText,
errorStyle: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontWeight: FontWeight.bold),
label: setRequiredText(),
//labelText: widget.lableText,
//labelStyle: const TextStyle(color: Colors.blueAccent),
prefixIcon: Icon(
Icons.access_alarm,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
fillColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
filled: true,
//hintText: hintText,
//hintStyle: TextStyle(color: Colors.blueGrey[400]),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 2.0,
),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 2.0,
),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 2.0,
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
),
),
onTap: () {
_selectTime(context);
},
);
}
}

View File

@@ -0,0 +1,329 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/mih_components/mih_inputs_and_buttons/mih_button.dart';
import 'package:patient_manager/main.dart';
class MIHDeleteMessage extends StatefulWidget {
final String deleteType;
final void Function() onTap;
const MIHDeleteMessage({
super.key,
required this.deleteType,
required this.onTap,
});
@override
State<MIHDeleteMessage> createState() => _MIHDeleteMessageState();
}
class _MIHDeleteMessageState extends State<MIHDeleteMessage> {
var messageTypes = <String, Widget>{};
late double popUpWidth;
late double? popUpheight;
late double popUpTitleSize;
late double popUpSubtitleSize;
late double popUpBodySize;
late double popUpIconSize;
late double popUpPaddingSize;
late double width;
late double height;
void checkScreenSize() {
if (MzanziInnovationHub.of(context)!.theme.screenType == "desktop") {
setState(() {
popUpWidth = (width / 4) * 2;
popUpheight = null;
popUpTitleSize = 25.0;
popUpSubtitleSize = 20.0;
popUpBodySize = 15;
popUpPaddingSize = 25.0;
popUpIconSize = 100;
});
} else {
setState(() {
popUpWidth = width - (width * 0.1);
popUpheight = null;
popUpTitleSize = 20.0;
popUpSubtitleSize = 18.0;
popUpBodySize = 15;
popUpPaddingSize = 15.0;
popUpIconSize = 100;
});
}
}
void setDeleteNote() {
messageTypes["Note"] = Stack(
children: [
Container(
padding: EdgeInsets.all(popUpPaddingSize),
width: popUpWidth,
height: popUpheight,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 5.0),
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.warning_amber_rounded,
size: popUpIconSize,
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
//const SizedBox(height: 15),
Text(
"Are you sure you want to delete this?",
textAlign: TextAlign.center,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpTitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
Text(
"This note will be deleted permanently. Are you certain you want to delete it?",
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
SizedBox(
width: 300,
height: 50,
child: MIHButton(
onTap: widget.onTap,
buttonText: "Delete",
buttonColor: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
))
],
),
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
],
);
}
void setFileNote() {
messageTypes["File"] = Stack(
children: [
Container(
padding: EdgeInsets.all(popUpPaddingSize),
width: popUpWidth,
height: popUpheight,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 5.0),
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.warning_amber_rounded,
size: popUpIconSize,
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
//const SizedBox(height: 15),
Text(
"Are you sure you want to delete this?",
textAlign: TextAlign.center,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpTitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
Text(
"This file will be deleted permanently. Are you certain you want to delete it?",
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
SizedBox(
width: 300,
height: 50,
child: MIHButton(
onTap: widget.onTap,
buttonText: "Delete",
buttonColor: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
))
],
),
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
],
);
}
void setDeleteEmployee() {
messageTypes["Employee"] = Stack(
children: [
Container(
padding: EdgeInsets.all(popUpPaddingSize),
width: popUpWidth,
height: popUpheight,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 5.0),
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.warning_amber_rounded,
size: popUpIconSize,
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
//const SizedBox(height: 15),
Text(
"Are you sure you want to delete this?",
textAlign: TextAlign.center,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpTitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
Text(
"This team member will be deleted permanently from the business profile. Are you certain you want to delete it?",
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
SizedBox(
width: 300,
height: 50,
child: MIHButton(
onTap: widget.onTap,
buttonText: "Delete",
buttonColor: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
))
],
),
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
],
);
}
Widget? getDeleteMessage(String type) {
return messageTypes[type];
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
}
@override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
setState(() {
width = size.width;
height = size.height;
});
checkScreenSize();
setDeleteNote();
setFileNote();
setDeleteEmployee();
//print(size);
// setState(() {
// width = size.width;
// height = size.height;
// });
return Dialog(child: getDeleteMessage(widget.deleteType));
}
}

View File

@@ -0,0 +1,771 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/main.dart';
class MIHErrorMessage extends StatefulWidget {
final String errorType;
const MIHErrorMessage({
super.key,
required this.errorType,
});
@override
State<MIHErrorMessage> createState() => _MIHErrorMessageState();
}
class _MIHErrorMessageState extends State<MIHErrorMessage> {
var messageTypes = <String, Widget>{};
late double popUpWidth;
late double? popUpheight;
late double popUpTitleSize;
late double popUpSubtitleSize;
late double popUpBodySize;
late double popUpIconSize;
late double popUpPaddingSize;
Size? size;
void checkScreenSize() {
if (MzanziInnovationHub.of(context)!.theme.screenType == "desktop") {
setState(() {
popUpWidth = (size!.width / 4) * 2;
popUpheight = null;
popUpTitleSize = 25.0;
popUpSubtitleSize = 20.0;
popUpBodySize = 15;
popUpPaddingSize = 25.0;
popUpIconSize = 100;
});
} else {
setState(() {
popUpWidth = size!.width - (size!.width * 0.1);
popUpheight = null;
popUpTitleSize = 20.0;
popUpSubtitleSize = 18.0;
popUpBodySize = 15;
popUpPaddingSize = 15.0;
popUpIconSize = 100;
});
}
}
void setInputError() {
messageTypes["Input Error"] = Stack(
children: [
Container(
padding: EdgeInsets.all(popUpPaddingSize),
width: popUpWidth,
height: popUpheight,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 5.0),
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.warning_amber_rounded,
size: popUpIconSize,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
),
//const SizedBox(height: 5),
Text(
"Oops! Looks like some fields are missing.",
textAlign: TextAlign.center,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontSize: popUpTitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
Text(
"We noticed that some required fields are still empty. To ensure your request is processed smoothly, please fill out all the highlighted fields before submitting the form again.",
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 25),
RichText(
text: TextSpan(
style: TextStyle(
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
children: <TextSpan>[
TextSpan(
text: "Here's a quick tip: ",
style: TextStyle(
fontStyle: FontStyle.italic,
color: MzanziInnovationHub.of(context)!
.theme
.errorColor())),
const TextSpan(
text: "Look for fields with an asterisk ("),
TextSpan(
text: "*",
style: TextStyle(
color: MzanziInnovationHub.of(context)!
.theme
.errorColor())),
const TextSpan(
text: ") next to them, as these are mandatory."),
],
),
),
const SizedBox(height: 10),
],
),
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
],
);
}
void setPasswordRequirementsError() {
messageTypes["Password Requirements"] = Stack(
children: [
Container(
padding: EdgeInsets.all(popUpPaddingSize),
width: popUpWidth,
height: popUpheight,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 5.0),
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.warning_amber_rounded,
size: popUpIconSize,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
),
//const SizedBox(height: 15),
Text(
"Password Doesn't Meet Requirements",
textAlign: TextAlign.center,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontSize: popUpTitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
Text(
"Oops! Your password doesn't quite meet our standards. To keep your account secure, please make sure your password meets the following requirements",
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 25),
RichText(
text: TextSpan(
style: TextStyle(
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
fontSize: 15.0,
fontWeight: FontWeight.bold,
),
children: <TextSpan>[
TextSpan(
text: "Requirements:\n",
style: TextStyle(
fontStyle: FontStyle.italic,
fontSize: popUpBodySize,
color: MzanziInnovationHub.of(context)!
.theme
.errorColor())),
const TextSpan(
text: "1) Contailes at least 8 characters\n",
),
const TextSpan(
text: "2) Contains at least 1 uppercase letter (A-Z)\n",
),
const TextSpan(
text: "3) Contains at least 1 lowercase letter (a-z)\n",
),
const TextSpan(
text: "4) Contains at least 1 number (0-9)\n",
),
const TextSpan(
text:
"5) Contains at least 1 special character (!@#\$%^&*)\n",
),
],
),
),
const SizedBox(height: 10),
],
),
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
],
);
}
void setInvalidUsernameError() {
messageTypes["Invalid Username"] = Stack(
children: [
Container(
padding: EdgeInsets.all(popUpPaddingSize),
width: popUpWidth,
height: popUpheight,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 5.0),
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.warning_amber_rounded,
size: popUpIconSize,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
),
//const SizedBox(height: 15),
Text(
"Let's Fix That Username",
textAlign: TextAlign.center,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontSize: popUpTitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
Text(
"Your username needs a little adjustment. To make sure everyone has a unique username, please start your username with a letter or number and use only letters, numbers or underscores. Let's try that again!",
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 25),
],
),
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
],
);
}
void setInvalidEmailError() {
messageTypes["Invalid Email"] = Stack(
children: [
Container(
padding: EdgeInsets.all(popUpPaddingSize),
width: popUpWidth,
height: popUpheight,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 5.0),
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.warning_amber_rounded,
size: popUpIconSize,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
),
//const SizedBox(height: 15),
Text(
"Oops! Invalid Email",
textAlign: TextAlign.center,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontSize: popUpTitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
Text(
"Looks like there's a little hiccup with that email address. Please double-check that you've entered it correctly, including the \"@\" symbol and a domain (like example@email.com).",
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 25),
],
),
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
],
);
}
void setUserExistsError() {
messageTypes["User Exists"] = Stack(
children: [
Container(
padding: EdgeInsets.all(popUpPaddingSize),
width: popUpWidth,
height: popUpheight,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 5.0),
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.warning_amber_rounded,
size: popUpIconSize,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
),
//SizedBox(height: 15),
Text(
"Email Already Exists",
textAlign: TextAlign.center,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontSize: popUpTitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
Text(
"An account is already registered with this email address. Please try logging in or use a different email.",
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
Text(
"Here are some things to keep in mind:",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontSize: popUpSubtitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
Text(
"1) Are you sure you're using the correct email address associated with your account?\n2) Is your caps lock key on? Passwords are case-sensitive.\n3) If you've forgotten your password, no worries! Click on \"Forgot Password?\" to reset it.",
textAlign: TextAlign.left,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: 15.0,
fontWeight: FontWeight.bold,
),
),
],
),
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
],
);
}
void setPwdMatchError() {
messageTypes["Password Match"] = Stack(
children: [
Container(
padding: EdgeInsets.all(popUpPaddingSize),
width: popUpWidth,
height: popUpheight,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 5.0),
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.warning_amber_rounded,
size: popUpIconSize,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
),
//SizedBox(height: 15),
Text(
"Passwords Don't Match",
textAlign: TextAlign.center,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontSize: popUpTitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
Text(
"The password and confirm password fields do not match. Please make sure they are identical.",
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
Text(
"Here are some things to keep in mind:",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontSize: popUpSubtitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
Text(
"1) Are you sure you're using the correct email address associated with your account?\n2) Is your caps lock key on? Passwords are case-sensitive.\n3) If you've forgotten your password, no worries! Click on \"Forgot Password?\" to reset it.",
textAlign: TextAlign.left,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
],
),
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
],
);
}
void setinvalidCredError() {
messageTypes["Invalid Credentials"] = Stack(
children: [
Container(
padding: EdgeInsets.all(popUpPaddingSize),
width: popUpWidth,
height: popUpheight,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 5.0),
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.warning_amber_rounded,
size: popUpIconSize,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
),
//SizedBox(height: 15),
Text(
"Uh oh! Login attempt unsuccessful.",
textAlign: TextAlign.center,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontSize: popUpTitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
Text(
"The email address or password you entered doesn't seem to match our records. Please double-check your information and try again.",
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
Text(
"Here are some things to keep in mind:",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontSize: popUpSubtitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
Text(
"1) Are you sure you're using the correct email address associated with your account?\n2) Is your caps lock key on? Passwords are case-sensitive.\n3) If you've forgotten your password, no worries! Click on \"Forgot Password?\" to reset it.",
textAlign: TextAlign.left,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
],
),
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
],
);
}
void setInternetError() {
messageTypes["Internet Connection"] = Stack(
children: [
Container(
padding: EdgeInsets.all(popUpPaddingSize),
width: popUpWidth,
height: popUpheight,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
width: 5.0),
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.warning_amber_rounded,
size: popUpIconSize,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
),
//const SizedBox(height: 15),
Text(
"Internet Connection Lost!",
textAlign: TextAlign.center,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontSize: popUpTitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
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:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
Text(
"Here are a few things you can try:",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
fontSize: popUpSubtitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
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:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
],
),
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
],
);
}
Widget? getErrorMessage(String type) {
return messageTypes[type];
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
}
@override
Widget build(BuildContext context) {
size = MediaQuery.of(context).size;
checkScreenSize();
setInputError();
setinvalidCredError();
setInternetError();
setUserExistsError();
setPwdMatchError();
setPasswordRequirementsError();
setInvalidEmailError();
setInvalidUsernameError();
//print(size);
// setState(() {
// width = size.width;
// height = size.height;
// });
return Dialog(child: getErrorMessage(widget.errorType));
}
}

View File

@@ -0,0 +1,96 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/main.dart';
import 'package:gif/gif.dart';
class Mihloadingcircle extends StatefulWidget {
const Mihloadingcircle({super.key});
@override
State<Mihloadingcircle> createState() => _MihloadingcircleState();
}
class _MihloadingcircleState extends State<Mihloadingcircle>
with TickerProviderStateMixin {
late final GifController _controller;
late double popUpPaddingSize;
late double popUpWidth;
late double? popUpheight;
late double width;
late double height;
void checkScreenSize() {
if (MzanziInnovationHub.of(context)!.theme.screenType == "desktop") {
setState(() {
popUpWidth = 250;
popUpheight = 250;
popUpPaddingSize = 25.0;
});
} else {
setState(() {
popUpWidth = 250;
popUpheight = 250;
popUpPaddingSize = 15.0;
});
}
}
@override
void initState() {
_controller = GifController(vsync: this);
//_controller.animateTo(26);
super.initState();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
ImageProvider loading =
MzanziInnovationHub.of(context)!.theme.loadingImage();
var size = MediaQuery.of(context).size;
setState(() {
width = size.width;
height = size.height;
});
checkScreenSize();
return Dialog(
//backgroundColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
child: Container(
padding: EdgeInsets.all(popUpPaddingSize),
width: 250,
height: 250,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
width: 5.0),
),
child: Gif(
image: loading,
controller:
_controller, // if duration and fps is null, original gif fps will be used.
fps: 15,
//duration: const Duration(seconds: 3),
autostart: Autostart.loop,
placeholder: (context) => const Center(
child: CircularProgressIndicator(),
),
onFetchCompleted: () {
_controller.reset();
_controller.forward();
},
),
),
// Center(
// child: MzanziInnovationHub.of(context)!.theme.loadingImage()),
// ),
);
}
}

View File

@@ -0,0 +1,143 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/mih_components/mih_inputs_and_buttons/mih_button.dart';
import 'package:patient_manager/main.dart';
class MIHSuccessMessage extends StatefulWidget {
final String successType;
final String successMessage;
const MIHSuccessMessage({
super.key,
required this.successType,
required this.successMessage,
});
@override
State<MIHSuccessMessage> createState() => _MIHSuccessMessageState();
}
class _MIHSuccessMessageState extends State<MIHSuccessMessage> {
var messageTypes = <String, Widget>{};
late String message;
late double popUpWidth;
late double? popUpheight;
late double popUpTitleSize;
late double popUpSubtitleSize;
late double popUpBodySize;
late double popUpIconSize;
late double popUpPaddingSize;
late Size? size;
void checkScreenSize() {
if (MzanziInnovationHub.of(context)!.theme.screenType == "desktop") {
setState(() {
popUpWidth = (size!.width / 4) * 2;
popUpheight = null;
popUpTitleSize = 25.0;
popUpSubtitleSize = 20.0;
popUpBodySize = 15;
popUpPaddingSize = 25.0;
popUpIconSize = 100;
});
} else {
setState(() {
popUpWidth = size!.width - (size!.width * 0.1);
popUpheight = null;
popUpTitleSize = 20.0;
popUpSubtitleSize = 18.0;
popUpBodySize = 15;
popUpPaddingSize = 15.0;
popUpIconSize = 100;
});
}
}
void setSuccessmessage() {
messageTypes["Success"] = Stack(
children: [
Container(
padding: EdgeInsets.all(popUpPaddingSize),
width: popUpWidth,
height: popUpheight,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.successColor(),
width: 5.0),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.check_circle_outline_rounded,
size: popUpIconSize,
color: MzanziInnovationHub.of(context)!.theme.successColor(),
),
//const SizedBox(height: 15),
Text(
"Success!",
textAlign: TextAlign.center,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.successColor(),
fontSize: popUpTitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
Center(
child: Text(
message,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(height: 15),
SizedBox(
width: 300,
height: 50,
child: MIHButton(
onTap: () {
Navigator.pop(context);
},
buttonText: "Dismiss",
buttonColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
),
],
),
),
],
);
}
Widget? getSuccessMessage(String type) {
return messageTypes[type];
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
}
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
size = MediaQuery.of(context).size;
checkScreenSize();
message = widget.successMessage;
setSuccessmessage();
return Dialog(child: getSuccessMessage(widget.successType));
}
}

View File

@@ -0,0 +1,218 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/main.dart';
class MIHWarningMessage extends StatefulWidget {
final String warningType;
const MIHWarningMessage({
super.key,
required this.warningType,
});
@override
State<MIHWarningMessage> createState() => _MIHDeleteMessageState();
}
class _MIHDeleteMessageState extends State<MIHWarningMessage> {
var messageTypes = <String, Widget>{};
late double popUpWidth;
late double? popUpheight;
late double popUpTitleSize;
late double popUpSubtitleSize;
late double popUpBodySize;
late double popUpIconSize;
late double popUpPaddingSize;
late double width;
late double height;
void checkScreenSize() {
if (MzanziInnovationHub.of(context)!.theme.screenType == "desktop") {
setState(() {
popUpWidth = (width / 4) * 2;
popUpheight = null;
popUpTitleSize = 25.0;
popUpSubtitleSize = 20.0;
popUpBodySize = 15;
popUpPaddingSize = 25.0;
popUpIconSize = 100;
});
} else {
setState(() {
popUpWidth = width - (width * 0.1);
popUpheight = null;
popUpTitleSize = 20.0;
popUpSubtitleSize = 18.0;
popUpBodySize = 15;
popUpPaddingSize = 15.0;
popUpIconSize = 100;
});
}
}
void setNoAccess() {
messageTypes["No Access"] = Stack(
children: [
Container(
padding: EdgeInsets.all(popUpPaddingSize),
width: popUpWidth,
height: popUpheight,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 5.0),
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.warning_amber_rounded,
size: popUpIconSize,
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
//const SizedBox(height: 15),
Text(
"Access Pending",
textAlign: TextAlign.center,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpTitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
Text(
"Your access request is currently being reviewed.\nOnce approved, you'll be able to view patient data.\nPlease follow up with the patient to approve your access request.",
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
],
),
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
],
);
}
void setExpiredAccess() {
messageTypes["Expired Access"] = Stack(
children: [
Container(
padding: EdgeInsets.all(popUpPaddingSize),
width: popUpWidth,
height: popUpheight,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 5.0),
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.warning_amber_rounded,
size: popUpIconSize,
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
//const SizedBox(height: 15),
Text(
"Access Expired",
textAlign: TextAlign.center,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpTitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
Text(
"You no longer have access to this patient profile. The authorized access period has ended. Access to a patients profile is limited to 7 days from appointment date.",
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
],
),
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
],
);
}
Widget? getDeleteMessage(String type) {
return messageTypes[type];
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
}
@override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
setState(() {
width = size.width;
height = size.height;
});
checkScreenSize();
setNoAccess();
setExpiredAccess();
//print(size);
// setState(() {
// width = size.width;
// height = size.height;
// });
return Dialog(child: getDeleteMessage(widget.warningType));
}
}