required modifications
This commit is contained in:
@@ -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,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user