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.
78 lines
2.6 KiB
Dart
78 lines
2.6 KiB
Dart
import 'package:doctor_app_flutter/utils/utils.dart';
|
|
import 'package:doctor_app_flutter/utils/translations_delegate_base_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/cupertino.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 ?? null,
|
|
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.elementError : null,
|
|
enabled: false,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|