1) Update search field to cater for ontap of icon and required and editable parameters.
2) remove Unnesasay signed in user from widget, add menu height. 3) add medicine object to cater for results of med api call. 4) update search input to cater for new parameters. 5) create prescriotion popUp widget. 6) Create medicine search pop Up widget
This commit is contained in:
parent
3bacfe27ba
commit
b18f8dd1d0
34 changed files with 605 additions and 20 deletions
|
|
@ -1,36 +1,113 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class MySearchField extends StatelessWidget {
|
||||
final controller;
|
||||
class MySearchField extends StatefulWidget {
|
||||
final TextEditingController controller;
|
||||
final String hintText;
|
||||
final bool required;
|
||||
final bool editable;
|
||||
final void Function(String)? onChanged;
|
||||
final void Function() onTap;
|
||||
|
||||
const MySearchField({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.hintText,
|
||||
required this.onChanged,
|
||||
required this.required,
|
||||
required this.editable,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MySearchField> createState() => _MySearchFieldState();
|
||||
}
|
||||
|
||||
class _MySearchFieldState extends State<MySearchField> {
|
||||
bool startup = true;
|
||||
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: [
|
||||
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(
|
||||
onChanged: onChanged,
|
||||
controller: controller,
|
||||
onChanged: widget.onChanged,
|
||||
controller: widget.controller,
|
||||
readOnly: makeEditable(),
|
||||
focusNode: _focus,
|
||||
obscureText: false,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
prefixIcon: const Icon(
|
||||
Icons.search,
|
||||
color: Colors.blueAccent,
|
||||
prefixIcon: IconButton(
|
||||
icon: const Icon(
|
||||
Icons.search,
|
||||
color: Colors.blueAccent,
|
||||
),
|
||||
onPressed: () {
|
||||
if (widget.controller.text != "") {
|
||||
widget.onTap();
|
||||
}
|
||||
},
|
||||
),
|
||||
filled: true,
|
||||
label: Text(hintText),
|
||||
labelStyle: const TextStyle(color: Colors.blueAccent),
|
||||
//hintText: hintText,
|
||||
//hintStyle: TextStyle(color: Colors.blueGrey[400]),
|
||||
label: setRequiredText(),
|
||||
errorText: _errorText,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.blueAccent,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue