required modifications

This commit is contained in:
2024-07-01 15:00:47 +02:00
parent 4faa844eef
commit 543930fc4b
11 changed files with 294 additions and 23 deletions

View File

@@ -20,7 +20,7 @@ class _MedcertinputState extends State<Medcertinput> {
@override
Widget build(BuildContext context) {
return SizedBox(
height: 250,
height: 325,
child: Column(
children: [
const SizedBox(height: 50.0),
@@ -29,6 +29,7 @@ class _MedcertinputState extends State<Medcertinput> {
child: MyDateField(
controller: widget.startDateController,
LableText: "From",
required: true,
),
),
const SizedBox(height: 25.0),
@@ -37,6 +38,7 @@ class _MedcertinputState extends State<Medcertinput> {
child: MyDateField(
controller: widget.endDateTextController,
LableText: "Up to Including",
required: true,
),
),
const SizedBox(height: 25.0),
@@ -45,6 +47,7 @@ class _MedcertinputState extends State<Medcertinput> {
child: MyDateField(
controller: widget.retDateTextController,
LableText: "Return",
required: true,
),
),
],

View File

@@ -3,13 +3,13 @@ import 'package:flutter/material.dart';
class MyDateField extends StatefulWidget {
final controller;
final String LableText;
//final bool editable;
final bool required;
const MyDateField({
super.key,
required this.controller,
required this.LableText,
//required this.editable,
required this.required,
});
@override
@@ -17,6 +17,8 @@ class MyDateField extends StatefulWidget {
}
class _MyDateFieldState extends State<MyDateField> {
FocusNode _focus = FocusNode();
bool startup = true;
// bool makeEditable() {
Future<void> _selectDate(BuildContext context) async {
DateTime? picked = await showDatePicker(
@@ -33,6 +35,53 @@ class _MyDateFieldState extends State<MyDateField> {
}
}
Widget setRequiredText() {
if (widget.required) {
return Row(
children: [
const Text(
"*",
style: TextStyle(color: Colors.red),
),
const SizedBox(
width: 8.0,
),
Text(widget.LableText,
style: const TextStyle(color: Colors.blueAccent)),
],
);
} else {
return Text(widget.LableText,
style: const TextStyle(color: Colors.blueAccent));
}
}
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 initState() {
_focus.addListener(_onFocusChange);
super.initState();
}
@override
Widget build(BuildContext context) {
return Padding(
@@ -41,9 +90,19 @@ class _MyDateFieldState extends State<MyDateField> {
controller: widget.controller,
readOnly: true,
obscureText: false,
focusNode: _focus,
onChanged: (_) => setState(() {
startup = false;
}),
decoration: InputDecoration(
labelText: widget.LableText,
prefixIcon: const Icon(Icons.calendar_today),
errorText: _errorText,
label: setRequiredText(),
//labelText: widget.LableText,
//labelStyle: const TextStyle(color: Colors.blueAccent),
prefixIcon: const Icon(
Icons.calendar_today,
color: Colors.blueAccent,
),
fillColor: Colors.white,
filled: true,
//hintText: hintText,

View File

@@ -1,25 +1,82 @@
import 'package:flutter/material.dart';
class MyMLTextField extends StatelessWidget {
class MyMLTextField extends StatefulWidget {
final controller;
final String hintText;
final bool editable;
final bool required;
const MyMLTextField({
super.key,
required this.controller,
required this.hintText,
required this.editable,
required this.required,
});
@override
State<MyMLTextField> createState() => _MyMLTextFieldState();
}
class _MyMLTextFieldState extends State<MyMLTextField> {
bool startup = true;
FocusNode _focus = FocusNode();
bool makeEditable() {
if (editable) {
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(
children: [
const Text(
"*",
style: TextStyle(color: Colors.red),
),
const SizedBox(
width: 8.0,
),
Text(widget.hintText,
style: const TextStyle(color: Colors.blueAccent)),
],
);
} else {
return Text(widget.hintText,
style: const TextStyle(color: Colors.blueAccent));
}
}
@override
void initState() {
_focus.addListener(_onFocusChange);
super.initState();
}
@override
Widget build(BuildContext context) {
return Padding(
@@ -29,11 +86,16 @@ class MyMLTextField extends StatelessWidget {
textAlignVertical: TextAlignVertical.top,
expands: true,
maxLines: null,
controller: controller,
controller: widget.controller,
readOnly: makeEditable(),
obscureText: false,
focusNode: _focus,
onChanged: (_) => setState(() {
startup = false;
}),
decoration: InputDecoration(
label: Text(hintText),
label: setRequiredText(),
errorText: _errorText,
labelStyle: const TextStyle(color: Colors.blueAccent),
alignLabelWithHint: true,
fillColor: Colors.white,

View File

@@ -3,11 +3,13 @@ import 'package:flutter/material.dart';
class MyPassField extends StatefulWidget {
final controller;
final String hintText;
final bool required;
const MyPassField({
super.key,
required this.controller,
required this.hintText,
required this.required,
});
@override
@@ -15,6 +17,7 @@ class MyPassField extends StatefulWidget {
}
class _MyPassFieldState extends State<MyPassField> {
bool startup = true;
final textFieldFocusNode = FocusNode();
bool _obscured = true;
@@ -29,6 +32,53 @@ class _MyPassFieldState extends State<MyPassField> {
});
}
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;
}
Widget setRequiredText() {
if (widget.required) {
return Row(
children: [
const Text(
"*",
style: TextStyle(color: Colors.red),
),
const SizedBox(
width: 8.0,
),
Text(widget.hintText,
style: const TextStyle(color: Colors.blueAccent)),
],
);
} else {
return Text(widget.hintText,
style: const TextStyle(color: Colors.blueAccent));
}
}
void _onFocusChange() {
setState(() {
startup = false;
});
}
@override
void initState() {
textFieldFocusNode.addListener(_onFocusChange);
super.initState();
}
@override
Widget build(BuildContext context) {
return Padding(
@@ -36,11 +86,16 @@ class _MyPassFieldState extends State<MyPassField> {
child: TextField(
controller: widget.controller,
obscureText: _obscured,
focusNode: textFieldFocusNode,
onChanged: (_) => setState(() {
startup = false;
}),
decoration: InputDecoration(
fillColor: Colors.white,
filled: true,
label: Text(widget.hintText),
labelStyle: const TextStyle(color: Colors.blueAccent),
label: setRequiredText(),
//labelStyle: const TextStyle(color: Colors.blueAccent),
errorText: _errorText,
//hintText: widget.hintText,
//hintStyle: TextStyle(color: Colors.blueGrey[400]),
enabledBorder: const OutlineInputBorder(

View File

@@ -1,38 +1,100 @@
import 'package:flutter/material.dart';
class MyTextField extends StatelessWidget {
class MyTextField extends StatefulWidget {
final controller;
final String hintText;
final bool editable;
final bool required;
const MyTextField({
super.key,
required this.controller,
required this.hintText,
required this.editable,
required this.required,
});
@override
State<MyTextField> createState() => _MyTextFieldState();
}
class _MyTextFieldState extends State<MyTextField> {
bool startup = true;
FocusNode _focus = FocusNode();
bool makeEditable() {
if (editable) {
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(
children: [
const Text(
"*",
style: TextStyle(color: Colors.red),
),
const SizedBox(
width: 8.0,
),
Text(widget.hintText,
style: const TextStyle(color: Colors.blueAccent)),
],
);
} else {
return Text(widget.hintText,
style: const TextStyle(color: Colors.blueAccent));
}
}
@override
void initState() {
_focus.addListener(_onFocusChange);
super.initState();
}
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: TextField(
controller: controller,
controller: widget.controller,
focusNode: _focus,
readOnly: makeEditable(),
obscureText: false,
onChanged: (_) => setState(() {
startup = false;
}),
decoration: InputDecoration(
label: Text(hintText),
labelStyle: const TextStyle(color: Colors.blueAccent),
label: setRequiredText(),
//labelStyle: const TextStyle(color: Colors.blueAccent),
fillColor: Colors.white,
filled: true,
errorText: _errorText,
//hintText: hintText,
//hintStyle: TextStyle(color: Colors.blueGrey[400]),
enabledBorder: const OutlineInputBorder(

View File

@@ -1,6 +1,5 @@
import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
@@ -9,7 +8,7 @@ import 'package:patient_manager/components/medCertInput.dart';
import 'package:patient_manager/components/myTextInput.dart';
import 'package:patient_manager/components/mybutton.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/AppUser.dart';
import 'package:patient_manager/objects/appUser.dart';
import 'package:patient_manager/objects/files.dart';
import 'package:http/http.dart' as http;
@@ -207,6 +206,9 @@ class _PatientFilesState extends State<PatientFiles> {
),
TextButton(
onPressed: () {
startDateController.clear();
endDateTextController.clear();
retDateTextController.clear();
Navigator.pop(context);
},
child: const Text("Cancel"),
@@ -255,9 +257,11 @@ class _PatientFilesState extends State<PatientFiles> {
buttonText: "Select File"),
),
MyTextField(
controller: selectedFileController,
hintText: "Selected FIle",
editable: false)
controller: selectedFileController,
hintText: "Selected FIle",
editable: false,
required: true,
)
],
),
),

View File

@@ -132,6 +132,7 @@ class _PatientNotesState extends State<PatientNotes> {
controller: titleController,
hintText: "Title of Note",
editable: true,
required: true,
),
),
const SizedBox(
@@ -142,6 +143,7 @@ class _PatientNotesState extends State<PatientNotes> {
controller: noteTextController,
hintText: "Note Details",
editable: true,
required: true,
),
),
],

View File

@@ -3,9 +3,9 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:patient_manager/components/myTextInput.dart';
import 'package:patient_manager/components/mybutton.dart';
import 'package:patient_manager/objects/appUser.dart';
import '../components/myAppBar.dart';
import 'package:http/http.dart' as http;
import '../objects/AppUser.dart';
class AddPatient extends StatefulWidget {
final String userEmail;
@@ -116,6 +116,7 @@ class _AddPatientState extends State<AddPatient> {
controller: idController,
hintText: "13 digit ID Number or Passport",
editable: true,
required: true,
),
),
],
@@ -128,6 +129,7 @@ class _AddPatientState extends State<AddPatient> {
controller: fnameController,
hintText: "First Name",
editable: true,
required: false,
),
),
],
@@ -140,6 +142,7 @@ class _AddPatientState extends State<AddPatient> {
controller: lnameController,
hintText: "Last Name",
editable: true,
required: true,
),
),
],
@@ -152,6 +155,7 @@ class _AddPatientState extends State<AddPatient> {
controller: cellController,
hintText: "Cell Number",
editable: true,
required: true,
),
),
],
@@ -164,6 +168,7 @@ class _AddPatientState extends State<AddPatient> {
controller: emailController,
hintText: "Email",
editable: true,
required: true,
),
),
],
@@ -176,6 +181,7 @@ class _AddPatientState extends State<AddPatient> {
controller: addressController,
hintText: "Address",
editable: true,
required: true,
),
),
],
@@ -198,6 +204,7 @@ class _AddPatientState extends State<AddPatient> {
controller: medNoController,
hintText: "Medical Aid No.",
editable: true,
required: true,
),
),
],
@@ -210,6 +217,7 @@ class _AddPatientState extends State<AddPatient> {
controller: medNameController,
hintText: "Medical Aid Name",
editable: true,
required: true,
),
),
],
@@ -222,6 +230,7 @@ class _AddPatientState extends State<AddPatient> {
controller: medSchemeController,
hintText: "Medical Aid Scheme",
editable: true,
required: true,
),
),
],

View File

@@ -3,10 +3,10 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:patient_manager/components/myTextInput.dart';
import 'package:patient_manager/components/mybutton.dart';
import 'package:patient_manager/objects/appUser.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
import '../components/myAppBar.dart';
import 'package:http/http.dart' as http;
import '../objects/AppUser.dart';
import '../objects/patients.dart';
class EditPatient extends StatefulWidget {
@@ -234,6 +234,7 @@ class _EditPatientState extends State<EditPatient> {
controller: idController,
hintText: "13 digit ID Number or Passport",
editable: false,
required: true,
),
),
],
@@ -246,6 +247,7 @@ class _EditPatientState extends State<EditPatient> {
controller: fnameController,
hintText: "First Name",
editable: true,
required: true,
),
),
],
@@ -258,6 +260,7 @@ class _EditPatientState extends State<EditPatient> {
controller: lnameController,
hintText: "Last Name",
editable: true,
required: true,
),
),
],
@@ -270,6 +273,7 @@ class _EditPatientState extends State<EditPatient> {
controller: cellController,
hintText: "Cell Number",
editable: true,
required: true,
),
),
],
@@ -282,6 +286,7 @@ class _EditPatientState extends State<EditPatient> {
controller: emailController,
hintText: "Email",
editable: true,
required: true,
),
),
],
@@ -294,6 +299,7 @@ class _EditPatientState extends State<EditPatient> {
controller: addressController,
hintText: "Address",
editable: true,
required: true,
),
),
],
@@ -316,6 +322,7 @@ class _EditPatientState extends State<EditPatient> {
controller: medNoController,
hintText: "Medical Aid No.",
editable: true,
required: true,
),
),
],
@@ -328,6 +335,7 @@ class _EditPatientState extends State<EditPatient> {
controller: medNameController,
hintText: "Medical Aid Name",
editable: true,
required: true,
),
),
],
@@ -340,6 +348,7 @@ class _EditPatientState extends State<EditPatient> {
controller: medSchemeController,
hintText: "Medical Aid Scheme",
editable: true,
required: true,
),
),
],

View File

@@ -96,6 +96,7 @@ class _RegisterState extends State<Register> {
controller: officeID,
hintText: 'OfficeID',
editable: true,
required: true,
),
),
//spacer
@@ -107,6 +108,7 @@ class _RegisterState extends State<Register> {
controller: emailController,
hintText: 'Email',
editable: true,
required: true,
),
),
//spacer
@@ -117,6 +119,7 @@ class _RegisterState extends State<Register> {
child: MyPassField(
controller: passwordController,
hintText: 'Password',
required: true,
),
),
//spacer
@@ -127,6 +130,7 @@ class _RegisterState extends State<Register> {
child: MyPassField(
controller: confirmPasswordController,
hintText: 'Confirm Password',
required: true,
),
),
//spacer

View File

@@ -87,6 +87,7 @@ class _SignInState extends State<SignIn> {
controller: emailController,
hintText: 'Email',
editable: true,
required: true,
),
),
//spacer
@@ -97,6 +98,7 @@ class _SignInState extends State<SignIn> {
child: MyPassField(
controller: passwordController,
hintText: 'Password',
required: true,
),
),
//spacer