fix allergies

merge-requests/452/head
Elham Rababah 4 years ago
parent fe39a22481
commit 1330d680ab

@ -13,6 +13,8 @@ import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/dialogs/master_key_dailog.dart';
import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart';
import 'package:doctor_app_flutter/widgets/shared/master_key_checkbox_search_allergies_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
@ -193,42 +195,9 @@ class _UpdateAllergiesWidgetState extends State<UpdateAllergiesWidget> {
context: context,
builder: (context) {
return AddAllergies(
addAllergiesFun: (MySelectedAllergy mySelectedAllergy) {
if (mySelectedAllergy.selectedAllergySeverity == null ||
mySelectedAllergy.selectedAllergy == null) {
helpers.showErrorToast(TranslationBase
.of(context)
.requiredMsg);
} else {
setState(() {
List<MySelectedAllergy> allergy =
// ignore: missing_return
widget.myAllergiesList
.where((element) =>
mySelectedAllergy.selectedAllergy.id ==
element.selectedAllergy.id)
.toList();
if (allergy.isEmpty) {
widget.myAllergiesList.add(mySelectedAllergy);
Navigator.of(context).pop();
} else {
allergy.first.selectedAllergy =
mySelectedAllergy.selectedAllergy;
allergy.first.selectedAllergySeverity =
mySelectedAllergy.selectedAllergySeverity;
allergy.first.remark = mySelectedAllergy.remark;
allergy.first.isChecked = mySelectedAllergy.isChecked;
Navigator.of(context).pop();
// helpers.showErrorToast(TranslationBase
// .of(context)
// .itemExist);
}
});
}
},);
myAllergiesList: widget.myAllergiesList,
addAllergiesFun: (){}
);
});
}
@ -236,8 +205,9 @@ class _UpdateAllergiesWidgetState extends State<UpdateAllergiesWidget> {
class AddAllergies extends StatefulWidget {
final Function addAllergiesFun;
final List<MySelectedAllergy> myAllergiesList;
const AddAllergies({Key key, this.addAllergiesFun}) : super(key: key);
const AddAllergies({Key key, this.addAllergiesFun, this.myAllergiesList}) : super(key: key);
@override
_AddAllergiesState createState() => _AddAllergiesState();
@ -251,7 +221,13 @@ class _AddAllergiesState extends State<AddAllergies> {
TextEditingController remarkController = TextEditingController();
TextEditingController severityController = TextEditingController();
TextEditingController allergyController = TextEditingController();
List<MySelectedAllergy> myAllergiesListLocal;
@override
initState(){
super.initState();
myAllergiesListLocal = [...widget.myAllergiesList];
}
GlobalKey key = new GlobalKey<AutoCompleteTextFieldState<MasterKeyModel>>();
bool isFormSubmitted = false;
@ -291,7 +267,7 @@ class _AddAllergiesState extends State<AddAllergies> {
.of(context)
.size;
return FractionallySizedBox(
heightFactor: 0.7,
heightFactor: 1,
child: BaseView<SOAPViewModel>(
onModelReady: (model) async {
if (model.allergiesList.length == 0) {
@ -305,220 +281,336 @@ class _AddAllergiesState extends State<AddAllergies> {
AppScaffold(
baseViewModel: model,
isShowAppBar: false,
body: SingleChildScrollView(
child: Center(
child: FractionallySizedBox(
widthFactor: 0.9,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 16,
),
AppText(
TranslationBase
.of(context)
.addAllergies,
fontWeight: FontWeight.bold,
fontSize: 16,
),
SizedBox(
height: 16,
),
Container(
height: screenSize.height * 0.070,
child: InkWell(
onTap: model.allergiesList != null
? () {
setState(() {
_selectedAllergy = null;
allergyController.text = null;
});
}
: null,
child: _selectedAllergy==null? AutoCompleteTextField<MasterKeyModel>(
decoration: textFieldSelectorDecoration(
TranslationBase
.of(context)
.selectAllergy,
_selectedAllergy != null
? _selectedAllergy.nameEn
: null, true, icon: EvaIcons.search),
itemSubmitted: (item) =>
setState(() {
_selectedAllergy = item;
allergyController.text =
projectViewModel.isArabic
? _selectedAllergy
.nameAr
: _selectedAllergy
.nameEn;
}),
key: key,
suggestions: model.allergiesList,
itemBuilder: (context, suggestion) =>
new Padding(
child: Texts(
projectViewModel.isArabic ? suggestion
.nameAr : suggestion.nameEn),
padding: EdgeInsets.all(2.0)),
itemSorter: (a, b) => 1,
itemFilter: (suggestion, input) =>
suggestion.nameAr.toLowerCase().startsWith(
input.toLowerCase()) ||
suggestion.nameEn.toLowerCase()
.startsWith(input.toLowerCase()),
) :
TextFields(
onTapTextFields: model.allergiesList != null
? () {
setState(() {
_selectedAllergy = null;
allergyController.text = null;
});
}
: null,
hasLabelText: allergyController.text !=
'' ? true : false,
showLabelText: true,
hintText: TranslationBase
.of(context)
.selectAllergy,
fontSize: 13.5,
readOnly: true,
fontWeight: FontWeight.w600,
maxLines: 2,
minLines: 1,
controller: allergyController,
suffixIcon: EvaIcons.search,
validator: (value) {
if (value == null)
return TranslationBase
.of(context)
.emptyMessage;
else
return null;
})
),
),
if(isFormSubmitted && _selectedAllergy == null)
CustomValidationError(),
SizedBox(
height: 10,
),
TextFields(
onTapTextFields: model
.allergySeverityList != null
? () {
MasterKeyDailog dialog = MasterKeyDailog(
list: model.allergySeverityList,
okText: TranslationBase
.of(context)
.ok,
okFunction: (selectedValue) {
setState(() {
_selectedAllergySeverity =
selectedValue;
severityController.text =
projectViewModel.isArabic
? _selectedAllergySeverity
.nameAr
: _selectedAllergySeverity
.nameEn;
});
},
);
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return dialog;
},
);
}
: null,
hasLabelText: severityController.text !=
'' ? true : false,
showLabelText: true,
hintText: TranslationBase
.of(context)
.selectSeverity,
fontSize: 13.5,
readOnly: true,
// hintColor: Colors.black,
fontWeight: FontWeight.w600,
maxLines: 2,
minLines: 1,
controller: severityController,
validator: (value) {
if (value == null)
return TranslationBase
.of(context)
.emptyMessage;
else
return null;
}), SizedBox(
height: 5,
),
if(isFormSubmitted &&
_selectedAllergySeverity == null)
CustomValidationError(),
body: Center(
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 10,
Container(
padding: EdgeInsets.only(
left: 0, right: 5, bottom: 5, top: 5),
decoration: BoxDecoration(
color: Colors.white,
),
Container(
margin: EdgeInsets.only(
left: 0, right: 0, top: 15),
child: TextFields(
hasLabelText: remarkController.text != ''?true:false,
showLabelText: true,
hintText: TranslationBase.of(context).remarks,
fontSize: 13.5,
// hintColor: Colors.black,
fontWeight: FontWeight.w600,
maxLines: 25,
minLines: 10,
controller: remarkController,
validator: (value) {
if (value == null)
return TranslationBase
.of(context)
.emptyMessage;
else
return null;
}),
), SizedBox(
height: 10,
height: 115,
child: Container(
padding: EdgeInsets.only(
left: 10, right: 10),
margin: EdgeInsets.only(top: 40),
child: Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
RichText(
text: TextSpan(
style: TextStyle(
fontSize:20,
color: Colors.black),
children: <TextSpan>[
new TextSpan(
text: TranslationBase.of(context).
addAllergies,
style: TextStyle(
color: Color(0xFF2B353E),
fontWeight: FontWeight.bold,
fontFamily: 'Poppins',
fontSize: 20)),
],
),
),
InkWell(
onTap: () {
Navigator.pop(context);
},
child: Icon(FontAwesomeIcons.times,
size: 30,
color: Color(0xFF2B353E)))
],
),
],
),
),
AppButton(
title: TranslationBase.of(context).add.toUpperCase(),
onPressed: () {
setState(() {
isFormSubmitted = true;
});
if(_selectedAllergy !=null && _selectedAllergySeverity !=null) {
MySelectedAllergy mySelectedAllergy = new MySelectedAllergy(
remark: remarkController.text,
selectedAllergy: _selectedAllergy,
isChecked: true,
selectedAllergySeverity: _selectedAllergySeverity,);
widget.addAllergiesFun(mySelectedAllergy);
}
},
),
SizedBox(
height: 10,
),
SizedBox(
height: 16,
),
Expanded(
child: Center(
child: FractionallySizedBox(
widthFactor: 0.9,
child: Center(
child: NetworkBaseView(
baseViewModel: model,
child: MasterKeyCheckboxSearchAllergiesWidget(
model: model,
masterList: model.allergiesList,
removeAllergy: (history){
setState(() {
// widget.allergie(history);
});
},
addAllergy: (MySelectedAllergy mySelectedAllergy){
AddAllergyLocally(mySelectedAllergy);
},
addSelectedAllergy: (){
// widget.addSelectedHistories();
},
isServiceSelected: (master) =>isServiceSelected(master),
),
),
),
),
),
]
),
// Container(
// height: screenSize.height * 0.070,
// child: InkWell(
// onTap: model.allergiesList != null
// ? () {
// setState(() {
// _selectedAllergy = null;
// allergyController.text = null;
// });
// }
// : null,
// child: _selectedAllergy==null? AutoCompleteTextField<MasterKeyModel>(
// decoration: textFieldSelectorDecoration(
// TranslationBase
// .of(context)
// .selectAllergy,
// _selectedAllergy != null
// ? _selectedAllergy.nameEn
// : null, true, icon: EvaIcons.search),
// itemSubmitted: (item) =>
// setState(() {
// _selectedAllergy = item;
// allergyController.text =
// projectViewModel.isArabic
// ? _selectedAllergy
// .nameAr
// : _selectedAllergy
// .nameEn;
// }),
// key: key,
// suggestions: model.allergiesList,
// itemBuilder: (context, suggestion) =>
// new Padding(
// child: Texts(
// projectViewModel.isArabic ? suggestion
// .nameAr : suggestion.nameEn),
// padding: EdgeInsets.all(2.0)),
// itemSorter: (a, b) => 1,
// itemFilter: (suggestion, input) =>
// suggestion.nameAr.toLowerCase().startsWith(
// input.toLowerCase()) ||
// suggestion.nameEn.toLowerCase()
// .startsWith(input.toLowerCase()),
// ) :
// TextFields(
// onTapTextFields: model.allergiesList != null
// ? () {
// setState(() {
// _selectedAllergy = null;
// allergyController.text = null;
// });
// }
// : null,
// hasLabelText: allergyController.text !=
// '' ? true : false,
// showLabelText: true,
// hintText: TranslationBase
// .of(context)
// .selectAllergy,
// fontSize: 13.5,
// readOnly: true,
// fontWeight: FontWeight.w600,
// maxLines: 2,
// minLines: 1,
// controller: allergyController,
// suffixIcon: EvaIcons.search,
// validator: (value) {
// if (value == null)
// return TranslationBase
// .of(context)
// .emptyMessage;
// else
// return null;
// })
// ),
// ),
// if(isFormSubmitted && _selectedAllergy == null)
// CustomValidationError(),
// SizedBox(
// height: 10,
// ),
// TextFields(
// onTapTextFields: model
// .allergySeverityList != null
// ? () {
// MasterKeyDailog dialog = MasterKeyDailog(
// list: model.allergySeverityList,
// okText: TranslationBase
// .of(context)
// .ok,
// okFunction: (selectedValue) {
// setState(() {
// _selectedAllergySeverity =
// selectedValue;
//
// severityController.text =
// projectViewModel.isArabic
// ? _selectedAllergySeverity
// .nameAr
// : _selectedAllergySeverity
// .nameEn;
// });
// },
// );
// showDialog(
// barrierDismissible: false,
// context: context,
// builder: (BuildContext context) {
// return dialog;
// },
// );
// }
// : null,
// hasLabelText: severityController.text !=
// '' ? true : false,
// showLabelText: true,
// hintText: TranslationBase
// .of(context)
// .selectSeverity,
// fontSize: 13.5,
// readOnly: true,
// // hintColor: Colors.black,
// fontWeight: FontWeight.w600,
// maxLines: 2,
// minLines: 1,
// controller: severityController,
// validator: (value) {
// if (value == null)
// return TranslationBase
// .of(context)
// .emptyMessage;
// else
// return null;
// }), SizedBox(
// height: 5,
// ),
// if(isFormSubmitted &&
// _selectedAllergySeverity == null)
// CustomValidationError(),
//
// SizedBox(
// height: 10,
// ),
// Container(
// margin: EdgeInsets.only(
// left: 0, right: 0, top: 15),
// child: TextFields(
// hasLabelText: remarkController.text != ''?true:false,
// showLabelText: true,
// hintText: TranslationBase.of(context).remarks,
// fontSize: 13.5,
// // hintColor: Colors.black,
// fontWeight: FontWeight.w600,
// maxLines: 25,
// minLines: 10,
// controller: remarkController,
// validator: (value) {
// if (value == null)
// return TranslationBase
// .of(context)
// .emptyMessage;
// else
// return null;
// }),
// ), SizedBox(
// height: 10,
// ),
// AppButton(
// title: TranslationBase.of(context).add.toUpperCase(),
// onPressed: () {
// setState(() {
// isFormSubmitted = true;
// });
// if(_selectedAllergy !=null && _selectedAllergySeverity !=null) {
// MySelectedAllergy mySelectedAllergy = new MySelectedAllergy(
// remark: remarkController.text,
// selectedAllergy: _selectedAllergy,
// isChecked: true,
// selectedAllergySeverity: _selectedAllergySeverity,);
// widget.addAllergiesFun(mySelectedAllergy);
// }
//
// },
// ),
]
),
),
),
)),
)
),
),
);
}
isServiceSelected(MasterKeyModel masterKey) {
Iterable<MySelectedAllergy> history =
myAllergiesListLocal.where((element) =>
masterKey.id == element.selectedAllergy.id &&
masterKey.typeId == element.selectedAllergy.typeId &&
element.isChecked);
if (history.length > 0) {
return true;
}
return false;
}
AddAllergyLocally(MySelectedAllergy mySelectedAllergy) {
if (
mySelectedAllergy.selectedAllergy == null) {
helpers.showErrorToast(TranslationBase
.of(context)
.requiredMsg);
} else {
setState(() {
List<MySelectedAllergy> allergy =
// ignore: missing_return
myAllergiesListLocal
.where((element) =>
mySelectedAllergy.selectedAllergy.id ==
element.selectedAllergy.id)
.toList();
if (allergy.isEmpty) {
myAllergiesListLocal.add(mySelectedAllergy);
// Navigator.of(context).pop();
} else {
allergy.first.selectedAllergy =
mySelectedAllergy.selectedAllergy;
allergy.first.selectedAllergySeverity =
mySelectedAllergy.selectedAllergySeverity;
allergy.first.remark = mySelectedAllergy.remark;
allergy.first.isChecked = mySelectedAllergy.isChecked;
// Navigator.of(context).pop();
// helpers.showErrorToast(TranslationBase
// .of(context)
// .itemExist);
}
});
}}
}

@ -0,0 +1,499 @@
import 'package:doctor_app_flutter/core/enum/viewstate.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/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/TextFields.dart';
import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'app_texts_widget.dart';
import 'dialogs/master_key_dailog.dart';
class MasterKeyCheckboxSearchAllergiesWidget extends StatefulWidget {
final SOAPViewModel model;
final Function addSelectedAllergy;
final Function(MasterKeyModel) removeAllergy;
final Function(MySelectedAllergy mySelectedAllergy) addAllergy;
final bool Function(MasterKeyModel) isServiceSelected;
final List<MasterKeyModel> masterList;
final String buttonName;
final String hintSearchText;
MasterKeyCheckboxSearchAllergiesWidget(
{Key key,
this.model,
this.addSelectedAllergy,
this.removeAllergy,
this.masterList,
this.addAllergy,
this.isServiceSelected,
this.buttonName,
this.hintSearchText})
: super(key: key);
@override
_MasterKeyCheckboxSearchAllergiesWidgetState createState() =>
_MasterKeyCheckboxSearchAllergiesWidgetState();
}
class _MasterKeyCheckboxSearchAllergiesWidgetState
extends State<MasterKeyCheckboxSearchAllergiesWidget> {
List<MasterKeyModel> items = List();
MasterKeyModel _selectedAllergySeverity;
@override
void initState() {
items.addAll(widget.masterList);
super.initState();
}
@override
Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
return Container(
child: Column(
children: [
Expanded(
child: Container(
height: MediaQuery.of(context).size.height * 0.62,
child: Center(
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white),
child: Column(
children: [
TextFields(
hintText: widget.hintSearchText ??
TranslationBase.of(context).selectAllergy,
borderWidth: 0.0,
padding: EdgeInsets.all(20),
borderRadius: 0,
suffixIcon: EvaIcons.search,
onChanged: (value) {
filterSearchResults(value);
},
),
SizedBox(
height: 10,
),
FractionallySizedBox(
widthFactor: 0.9,
child: Container(
height: MediaQuery.of(context).size.height * 0.60,
child: ListView.builder(
itemCount: items.length,
itemBuilder: (context, index) {
TextEditingController remarkController = TextEditingController(text: items[index].remarks);
TextEditingController severityController = TextEditingController(text: _selectedAllergySeverity!= null ?projectViewModel
.isArabic
? _selectedAllergySeverity
.nameAr
: _selectedAllergySeverity
.nameEn: null);
return Column(
children: [
InkWell(
onTap: () {
setState(() {
if (widget.isServiceSelected(
items[index])) {
widget
.removeAllergy(items[index]);
} else {
// TODO add Allergy
MySelectedAllergy
mySelectedAllergy =
new MySelectedAllergy(
selectedAllergy:
items[index],
selectedAllergySeverity:
_selectedAllergySeverity, remark: "fdfdf", isChecked: true);
widget.addAllergy(mySelectedAllergy);
}
});
},
child: Column(
children: [
Row(
children: [
Checkbox(
value: widget
.isServiceSelected(
items[index]),
activeColor:
Colors.red[800],
onChanged: (bool newValue) {
// setState(() {
// if (widget
// .isServiceSelected(items[index])) {
// widget.removeHistory(items[index]);
// } else {
// widget.addHistory(items[index]);
// }
// });
}),
Expanded(
child: Padding(
padding: const EdgeInsets
.symmetric(
horizontal: 10,
vertical: 0),
child: AppText(
projectViewModel.isArabic
? items[index]
.nameAr !=
""
? items[index]
.nameAr
: items[index]
.nameEn
: items[index].nameEn,
color: Color(0xFF575757),
fontSize: 16,
fontWeight:
FontWeight.w600,
),
),
),
],
),
if(widget
.isServiceSelected(
items[index]))
Column(children: [
TextFields(
onTapTextFields: widget.model
.allergySeverityList !=
null
? () {
MasterKeyDailog dialog =
MasterKeyDailog(
list: widget.model
.allergySeverityList,
okText:
TranslationBase.of(
context)
.ok,
okFunction:
(selectedValue) {
setState(() {
_selectedAllergySeverity =
selectedValue;
severityController
.text = projectViewModel
.isArabic
? _selectedAllergySeverity
.nameAr
: _selectedAllergySeverity
.nameEn;
});
},
);
showDialog(
barrierDismissible:
false,
context: context,
builder: (BuildContext
context) {
return dialog;
},
);
}
: null,
hasLabelText:
severityController.text !=
''
? true
: false,
showLabelText: true,
hintText:
TranslationBase.of(context)
.selectSeverity,
fontSize: 13.5,
readOnly: true,
// hintColor: Colors.black,
fontWeight: FontWeight.w600,
maxLines: 2,
minLines: 1,
controller: severityController,
validator: (value) {
if (value == null)
return TranslationBase.of(
context)
.emptyMessage;
else
return null;
}),
SizedBox(
height: 5,
),
// if(isFormSubmitted &&
// _selectedAllergySeverity == null)
// CustomValidationError(),
SizedBox(
height: 10,
),
Container(
margin: EdgeInsets.only(
left: 0, right: 0, top: 15),
child: TextFields(
hasLabelText:
remarkController.text !=
''
? true
: false,
showLabelText: true,
hintText: TranslationBase.of(
context)
.remarks,
fontSize: 13.5,
// hintColor: Colors.black,
fontWeight: FontWeight.w600,
maxLines: 25,
minLines: 10,
controller: remarkController,
validator: (value) {
if (value == null)
return TranslationBase.of(
context)
.emptyMessage;
else
return null;
}),
),
SizedBox(
height: 10,
),
],)
],
),
),
// DividerWithSpacesAround(),
],
);
},
),
),
),
],
)
// ListView(
// children: [
// TextFields(
// hintText: widget.hintSearchText ??
// TranslationBase.of(context).searchHistory,
// borderWidth: 0.0,
// padding: EdgeInsets.all(20),
// borderRadius: 0,
// suffixIcon: EvaIcons.search,
// onChanged: (value) {
// filterSearchResults(value);
// },
// ),
// // SizedBox(height: 15,),
// DividerWithSpacesAround(),
//
//
// // Container(
// // // padding:EdgeInsets.all(20),
// // child: Column(
// // children: items.map((historyInfo) {
// // return Column(
// // children: [
// // InkWell(
// // onTap:(){
// //
// // setState(() {
// // if (widget
// // .isServiceSelected(historyInfo)) {
// // widget.removeHistory(historyInfo);
// // } else {
// // widget.addHistory(historyInfo);
// // }
// // });
// // },
// //
// // child: Column(
// // children: [
// // Row(
// // children: [
// // Checkbox(
// // value:true,
// // // widget.isServiceSelected(historyInfo),
// // activeColor: Colors.red[800],
// // onChanged: (bool newValue) {
// // // setState(() {
// // // if (widget
// // // .isServiceSelected(historyInfo)) {
// // // widget.removeHistory(historyInfo);
// // // } else {
// // // widget.addHistory(historyInfo);
// // // }
// // // });
// // }),
// // Expanded(
// // child: Padding(
// // padding: const EdgeInsets.symmetric(
// // horizontal: 10, vertical: 0),
// // child: AppText(projectViewModel.isArabic
// // ? historyInfo.nameAr!=""?historyInfo.nameAr:historyInfo.nameEn
// // : historyInfo.nameEn,
// // color: Color(0xFF575757),
// // fontSize: 16,
// // fontWeight:FontWeight.w600,
// // ),
// // ),
// // ),
// // ],
// // ),
// // TextFields(
// // onTapTextFields: widget.model
// // .allergySeverityList != null
// // ? () {
// // MasterKeyDailog dialog = MasterKeyDailog(
// // list: widget.model.allergySeverityList,
// // okText: TranslationBase
// // .of(context)
// // .ok,
// // okFunction: (selectedValue) {
// // // setState(() {
// // // _selectedAllergySeverity =
// // // selectedValue;
// // //
// // // severityController.text =
// // // projectViewModel.isArabic
// // // ? _selectedAllergySeverity
// // // .nameAr
// // // : _selectedAllergySeverity
// // // .nameEn;
// // // });
// // },
// // );
// // showDialog(
// // barrierDismissible: false,
// // context: context,
// // builder: (BuildContext context) {
// // return dialog;
// // },
// // );
// // }
// // : null,
// // hasLabelText: severityController.text !=
// // '' ? true : false,
// // showLabelText: true,
// // hintText: TranslationBase
// // .of(context)
// // .selectSeverity,
// // fontSize: 13.5,
// // readOnly: true,
// // // hintColor: Colors.black,
// // fontWeight: FontWeight.w600,
// // maxLines: 2,
// // minLines: 1,
// // controller: severityController,
// // validator: (value) {
// // if (value == null)
// // return TranslationBase
// // .of(context)
// // .emptyMessage;
// // else
// // return null;
// // }), SizedBox(
// // height: 5,
// // ),
// // // if(isFormSubmitted &&
// // // _selectedAllergySeverity == null)
// // // CustomValidationError(),
// //
// // SizedBox(
// // height: 10,
// // ),
// // Container(
// // margin: EdgeInsets.only(
// // left: 0, right: 0, top: 15),
// // child: TextFields(
// // hasLabelText: remarkController.text != ''?true:false,
// // showLabelText: true,
// // hintText: TranslationBase.of(context).remarks,
// // fontSize: 13.5,
// // // hintColor: Colors.black,
// // fontWeight: FontWeight.w600,
// // maxLines: 25,
// // minLines: 10,
// // controller: remarkController,
// // validator: (value) {
// // if (value == null)
// // return TranslationBase
// // .of(context)
// // .emptyMessage;
// // else
// // return null;
// // }),
// // ), SizedBox(
// // height: 10,
// // ),
// // ],
// // ),
// // ),
// // // DividerWithSpacesAround(),
// // ],
// // );
// // }).toList(),
// // ),
// // ),
// ],
// ),
)),
),
),
SizedBox(
height: 10,
),
if (widget.model.state == ViewState.Idle)
AppButton(
title: widget.buttonName ??
TranslationBase.of(context).addSelectedHistories,
padding: 10,
color: Color(0xFF359846),
onPressed: () {
widget.addSelectedAllergy();
},
),
],
),
);
}
void filterSearchResults(String query) {
List<MasterKeyModel> dummySearchList = List();
dummySearchList.addAll(widget.masterList);
if (query.isNotEmpty) {
List<MasterKeyModel> dummyListData = List();
dummySearchList.forEach((items) {
if (items.nameAr.toLowerCase().contains(query.toLowerCase()) ||
items.nameEn.toLowerCase().contains(query.toLowerCase())) {
dummyListData.add(items);
}
});
setState(() {
items.clear();
items.addAll(dummyListData);
});
return;
} else {
setState(() {
items.clear();
items.addAll(widget.masterList);
});
}
}
}
Loading…
Cancel
Save