@ -1,6 +1,8 @@
import ' package:autocomplete_textfield/autocomplete_textfield.dart ' ;
import ' package:doctor_app_flutter/config/config.dart ' ;
import ' package:doctor_app_flutter/core/enum/master_lookup_key.dart ' ;
import ' package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart ' ;
import ' package:doctor_app_flutter/core/viewModel/project_view_model.dart ' ;
import ' package:doctor_app_flutter/models/SOAP/master_key_model.dart ' ;
import ' package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart ' ;
import ' package:doctor_app_flutter/screens/base/base_view.dart ' ;
@ -14,6 +16,7 @@ import 'package:doctor_app_flutter/widgets/shared/dialogs/master_key_dailog.dart
import ' package:eva_icons_flutter/eva_icons_flutter.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:font_awesome_flutter/font_awesome_flutter.dart ' ;
import ' package:provider/provider.dart ' ;
class UpdateAllergiesWidget extends StatefulWidget {
final List < MySelectedAllergy > myAllergiesList ;
@ -144,10 +147,11 @@ class _AddAllergiesState extends State<AddAllergies> {
MasterKeyModel _selectedAllergySeverity ;
MasterKeyModel _selectedAllergy ;
TextEditingController remarkController = TextEditingController ( ) ;
GlobalKey key = new GlobalKey < AutoCompleteTextFieldState < MasterKeyModel > > ( ) ;
InputDecoration textFieldSelectorDecoration ( String hintText ,
String selectedText , bool isDropDown ) {
String selectedText , bool isDropDown ,{ IconData icon } ) {
return InputDecoration (
focusedBorder: OutlineInputBorder (
borderSide: BorderSide ( color: Color ( 0xFFCCCCCC ) , width: 2.0 ) ,
@ -162,7 +166,7 @@ class _AddAllergiesState extends State<AddAllergies> {
borderRadius: BorderRadius . circular ( 8 ) ,
) ,
hintText: selectedText ! = null ? selectedText : hintText ,
suffixIcon: isDropDown ? Icon ( Icons. arrow_drop_down ) : null ,
suffixIcon: isDropDown ? Icon ( icon ? ? Icons. arrow_drop_down ) : null ,
hintStyle: TextStyle (
fontSize: 14 ,
color: Colors . grey . shade600 ,
@ -172,6 +176,7 @@ class _AddAllergiesState extends State<AddAllergies> {
@ override
Widget build ( BuildContext context ) {
ProjectViewModel projectViewModel = Provider . of ( context ) ;
final screenSize = MediaQuery
. of ( context )
. size ;
@ -214,40 +219,32 @@ class _AddAllergiesState extends State<AddAllergies> {
child: InkWell (
onTap: model . allergiesList ! = null
? ( ) {
MasterKeyDailog dialog = MasterKeyDailog (
list: model . allergiesList ,
okText: TranslationBase
. of ( context )
. ok ,
okFunction: ( MasterKeyModel selectedValue ) {
setState ( ( ) {
_selectedAllergy = selectedValue ;
} ) ;
} ,
) ;
showDialog (
barrierDismissible: false ,
context: context ,
builder: ( BuildContext context ) {
return dialog ;
} ,
) ;
setState ( ( ) {
_selectedAllergy = null ;
} ) ;
}
: null ,
child: TextField (
decoration: textFieldSelectorDecoration (
" Select Allergy " ,
_selectedAllergy ! = null
? _selectedAllergy . nameEn
: null ,
true ) ,
child: _selectedAllergy = = null ? AutoCompleteTextField < MasterKeyModel > (
decoration: textFieldSelectorDecoration ( " Select Allergy " , _selectedAllergy ! = null ? _selectedAllergy . nameEn : null , true , icon: EvaIcons . search ) ,
itemSubmitted: ( item ) = > setState ( ( ) = > _selectedAllergy = item ) ,
key: key ,
suggestions: model . allergiesList ,
itemBuilder: ( context , suggestion ) = > new Padding (
child: Texts ( projectViewModel . isArabic ? suggestion . nameAr: suggestion . nameEn ) ,
padding: EdgeInsets . all ( 8.0 ) ) ,
itemSorter: ( a , b ) = > 1 ,
itemFilter: ( suggestion , input ) = >
suggestion . nameAr . toLowerCase ( ) . startsWith ( input . toLowerCase ( ) ) | | suggestion . nameEn . toLowerCase ( ) . startsWith ( input . toLowerCase ( ) ) ,
) : TextField (
decoration: textFieldSelectorDecoration ( " Select Allergy " , _selectedAllergy ! = null ? _selectedAllergy . nameEn : null , true , icon: EvaIcons . search ) ,
enabled: false ,
) ,
) ,
) ,
SizedBox (
height: 10 ,
) , Container (
) ,
Container (
height: screenSize . height * 0.070 ,
child: InkWell (
onTap: model . allergySeverityList ! = null