You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
doctor_app_flutter/lib/screens/prescription/prescription_text_filed.dart

82 lines
3.2 KiB
Dart

4 years ago
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
2 years ago
import 'package:doctor_app_flutter/utils/utils.dart';
import 'package:doctor_app_flutter/widgets/shared/dialogs/dailog-list-select.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart';
import 'package:flutter/material.dart';
class PrescriptionTextFiled extends StatefulWidget {
dynamic element;
final String? elementError;
final List<dynamic>? elementList;
final String? keyName;
final String? keyId;
final String? hintText;
final double? width;
final Function(dynamic)? okFunction;
PrescriptionTextFiled({Key? key, required this.element, required this.elementError, this.width, this.elementList, this.keyName, this.keyId, this.hintText, this.okFunction}) : super(key: key);
@override
_PrescriptionTextFiledState createState() => _PrescriptionTextFiledState();
}
class _PrescriptionTextFiledState extends State<PrescriptionTextFiled> {
@override
Widget build(BuildContext context) {
return Container(
width: widget.width,
child: InkWell(
onTap: widget.elementList != null
? () {
// Utils.hideKeyboard(context);
// ListSelectDialog dialog = ListSelectDialog(
// list: widget.elementList!,
// attributeName: '${widget.keyName}',
// attributeValueId: widget.elementList!.length == 1 ? widget.elementList![0]['${widget.keyId}'].toString() : '${widget.keyId}',
// okText: TranslationBase.of(context).ok,
// okFunction: (selectedValue) => widget.okFunction!(selectedValue),
// );
// showDialog(
// barrierDismissible: false,
// context: context,
// builder: (BuildContext context) {
// return dialog;
// },
// );
}
: null,
child: AppTextFieldCustom(
hintText: widget.hintText!,
dropDownText: widget.elementList!.length == 1
? widget.elementList![0]['${widget.keyName}']
: widget.element != null
? widget.element['${widget.keyName}']
: null,
isTextFieldHasSuffix: true,
validationError: widget.elementList!.length != 1 || widget.elementList!.length!=2 ? widget.elementError : "",
enabled: false,
onClick: () {
Utils.hideKeyboard(context);
ListSelectDialog dialog = ListSelectDialog(
list: widget.elementList!,
attributeName: '${widget.keyName}',
attributeValueId: widget.elementList!.length == 1 ? widget.elementList![0]['${widget.keyId}'].toString() : '${widget.keyId}',
okText: TranslationBase.of(context).ok,
okFunction: (selectedValue) => widget.okFunction!(selectedValue),
);
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return dialog;
},
);
},
2 years ago
onChanged: (value) {},
onFieldSubmitted: () {},
),
),
);
}
}