|
|
|
|
@ -28,6 +28,7 @@ class UpdateAllergiesWidget extends StatefulWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _UpdateAllergiesWidgetState extends State<UpdateAllergiesWidget> {
|
|
|
|
|
|
|
|
|
|
TextEditingController remarkController = TextEditingController();
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -52,7 +53,9 @@ class _UpdateAllergiesWidgetState extends State<UpdateAllergiesWidget> {
|
|
|
|
|
// controller: messageController,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if (value == null)
|
|
|
|
|
return TranslationBase.of(context).emptyMessage;
|
|
|
|
|
return TranslationBase
|
|
|
|
|
.of(context)
|
|
|
|
|
.emptyMessage;
|
|
|
|
|
else
|
|
|
|
|
return null;
|
|
|
|
|
}),
|
|
|
|
|
@ -61,22 +64,31 @@ class _UpdateAllergiesWidgetState extends State<UpdateAllergiesWidget> {
|
|
|
|
|
height: 20,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.only(left: 15, right: 15, top: 15),
|
|
|
|
|
margin:
|
|
|
|
|
EdgeInsets.only(left: 15, right: 15, top: 15),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: widget.myAllergiesList.map((selectedAllergy) {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment:
|
|
|
|
|
MainAxisAlignment.spaceBetween,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
|
|
|
|
|
child: Expanded(
|
|
|
|
|
child: Texts(projectViewModel.isArabic ? selectedAllergy
|
|
|
|
|
.selectedAllergy.nameAr : selectedAllergy
|
|
|
|
|
.selectedAllergy.nameEn.toUpperCase(),
|
|
|
|
|
child: Texts(
|
|
|
|
|
projectViewModel.isArabic
|
|
|
|
|
? selectedAllergy.selectedAllergy.nameAr
|
|
|
|
|
: selectedAllergy.selectedAllergy.nameEn
|
|
|
|
|
.toUpperCase(),
|
|
|
|
|
variant: "bodyText",
|
|
|
|
|
textDecoration: selectedAllergy.isChecked
|
|
|
|
|
? null
|
|
|
|
|
: TextDecoration.lineThrough,
|
|
|
|
|
bold: true,
|
|
|
|
|
color: Colors.black),
|
|
|
|
|
),
|
|
|
|
|
@ -88,17 +100,21 @@ class _UpdateAllergiesWidgetState extends State<UpdateAllergiesWidget> {
|
|
|
|
|
.selectedAllergySeverity.nameEn
|
|
|
|
|
.toUpperCase(),
|
|
|
|
|
variant: "bodyText",
|
|
|
|
|
textDecoration: selectedAllergy.isChecked
|
|
|
|
|
? null
|
|
|
|
|
: TextDecoration.lineThrough,
|
|
|
|
|
bold: true,
|
|
|
|
|
color: AppGlobal.appPrimaryColor),
|
|
|
|
|
InkWell(
|
|
|
|
|
child: Icon(
|
|
|
|
|
FontAwesomeIcons.trash,
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
size: 20,
|
|
|
|
|
),
|
|
|
|
|
onTap: () => removeAllergy(selectedAllergy),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
if(selectedAllergy.isChecked)
|
|
|
|
|
InkWell(
|
|
|
|
|
child: Icon(
|
|
|
|
|
FontAwesomeIcons.trash,
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
size: 20,
|
|
|
|
|
),
|
|
|
|
|
onTap: () => removeAllergy(selectedAllergy),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 10,
|
|
|
|
|
@ -112,13 +128,22 @@ class _UpdateAllergiesWidgetState extends State<UpdateAllergiesWidget> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
removeAllergy(MySelectedAllergy mySelectedAllergy) {
|
|
|
|
|
Iterable<MySelectedAllergy> allergy =
|
|
|
|
|
widget.myAllergiesList.where((element) => mySelectedAllergy == element);
|
|
|
|
|
List<MySelectedAllergy> allergy =
|
|
|
|
|
// ignore: missing_return
|
|
|
|
|
widget.myAllergiesList.where((element) =>
|
|
|
|
|
mySelectedAllergy.selectedAllergySeverity.id ==
|
|
|
|
|
element.selectedAllergySeverity.id &&
|
|
|
|
|
mySelectedAllergy.selectedAllergy.id == element.selectedAllergy.id
|
|
|
|
|
).toList();
|
|
|
|
|
|
|
|
|
|
if (allergy.length > 0)
|
|
|
|
|
if (allergy.length > 0) {
|
|
|
|
|
setState(() {
|
|
|
|
|
widget.myAllergiesList.remove(allergy.first);
|
|
|
|
|
allergy[0].isChecked = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(allergy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openAllergiesList(BuildContext context) {
|
|
|
|
|
@ -130,14 +155,29 @@ class _UpdateAllergiesWidgetState extends State<UpdateAllergiesWidget> {
|
|
|
|
|
return AddAllergies(
|
|
|
|
|
addAllergiesFun: (MySelectedAllergy mySelectedAllergy) {
|
|
|
|
|
setState(() {
|
|
|
|
|
if (!widget.myAllergiesList.contains(mySelectedAllergy)) {
|
|
|
|
|
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 {
|
|
|
|
|
helpers.showErrorToast(TranslationBase
|
|
|
|
|
.of(context)
|
|
|
|
|
.itemExist);
|
|
|
|
|
allergy.first.selectedAllergy =
|
|
|
|
|
mySelectedAllergy.selectedAllergy;
|
|
|
|
|
allergy.first.selectedAllergySeverity =
|
|
|
|
|
mySelectedAllergy.selectedAllergySeverity;
|
|
|
|
|
allergy.first.remark = mySelectedAllergy.remark;
|
|
|
|
|
allergy.first.isChecked = mySelectedAllergy.isChecked;
|
|
|
|
|
|
|
|
|
|
// helpers.showErrorToast(TranslationBase
|
|
|
|
|
// .of(context)
|
|
|
|
|
// .itemExist);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
});
|
|
|
|
|
},);
|
|
|
|
|
});
|
|
|
|
|
@ -162,9 +202,9 @@ class _AddAllergiesState extends State<AddAllergies> {
|
|
|
|
|
TextEditingController remarkController = TextEditingController();
|
|
|
|
|
GlobalKey key = new GlobalKey<AutoCompleteTextFieldState<MasterKeyModel>>();
|
|
|
|
|
|
|
|
|
|
InputDecoration textFieldSelectorDecoration(
|
|
|
|
|
String hintText, String selectedText, bool isDropDown,
|
|
|
|
|
{IconData icon}) {
|
|
|
|
|
|
|
|
|
|
InputDecoration textFieldSelectorDecoration(String hintText,
|
|
|
|
|
String selectedText, bool isDropDown,{IconData icon}) {
|
|
|
|
|
return InputDecoration(
|
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
|
|
|
|
|
@ -204,166 +244,167 @@ class _AddAllergiesState extends State<AddAllergies> {
|
|
|
|
|
await model.getMasterLookup(MasterKeysService.AllergySeverity);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
builder: (_, model, w) => 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
|
|
|
|
|
builder: (_, model, w) =>
|
|
|
|
|
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;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
child: _selectedAllergy == null
|
|
|
|
|
? AutoCompleteTextField<MasterKeyModel>(
|
|
|
|
|
decoration: textFieldSelectorDecoration(
|
|
|
|
|
TranslationBase
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 16,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
height: screenSize.height * 0.070,
|
|
|
|
|
child: InkWell(
|
|
|
|
|
onTap: model.allergiesList != null
|
|
|
|
|
? () {
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectedAllergy = 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),
|
|
|
|
|
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(
|
|
|
|
|
TranslationBase
|
|
|
|
|
_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(
|
|
|
|
|
TranslationBase
|
|
|
|
|
.of(context)
|
|
|
|
|
.selectAllergy,
|
|
|
|
|
_selectedAllergy != null
|
|
|
|
|
? projectViewModel.isArabic?_selectedAllergy.nameAr: _selectedAllergy.nameEn
|
|
|
|
|
: null,
|
|
|
|
|
true,
|
|
|
|
|
icon: EvaIcons.search),
|
|
|
|
|
enabled: false,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 10,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
height: screenSize.height * 0.070,
|
|
|
|
|
child: InkWell(
|
|
|
|
|
onTap: model.allergySeverityList != null
|
|
|
|
|
? () {
|
|
|
|
|
MasterKeyDailog dialog = MasterKeyDailog(
|
|
|
|
|
list: model.allergySeverityList,
|
|
|
|
|
okText: TranslationBase.of(context).ok,
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectedAllergySeverity =
|
|
|
|
|
selectedValue;
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
showDialog(
|
|
|
|
|
barrierDismissible: false,
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
return dialog;
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
child: TextField(
|
|
|
|
|
decoration: textFieldSelectorDecoration(
|
|
|
|
|
TranslationBase
|
|
|
|
|
_selectedAllergy != null
|
|
|
|
|
? projectViewModel.isArabic?_selectedAllergy.nameAr: _selectedAllergy.nameEn
|
|
|
|
|
: null, true, icon: EvaIcons.search),
|
|
|
|
|
enabled: false,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 10,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
height: screenSize.height * 0.070,
|
|
|
|
|
child: InkWell(
|
|
|
|
|
onTap: model.allergySeverityList != null
|
|
|
|
|
? () {
|
|
|
|
|
MasterKeyDailog dialog = MasterKeyDailog(
|
|
|
|
|
list: model.allergySeverityList,
|
|
|
|
|
okText: TranslationBase
|
|
|
|
|
.of(context)
|
|
|
|
|
.ok,
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectedAllergySeverity =
|
|
|
|
|
selectedValue;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
showDialog(
|
|
|
|
|
barrierDismissible: false,
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
return dialog;
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
child: TextField(
|
|
|
|
|
decoration: textFieldSelectorDecoration(
|
|
|
|
|
TranslationBase
|
|
|
|
|
.of(context)
|
|
|
|
|
.selectSeverity,
|
|
|
|
|
_selectedAllergySeverity != null
|
|
|
|
|
? projectViewModel.isArabic?_selectedAllergySeverity.nameAr:_selectedAllergySeverity.nameEn
|
|
|
|
|
: null,
|
|
|
|
|
true),
|
|
|
|
|
enabled: false,
|
|
|
|
|
_selectedAllergySeverity != null
|
|
|
|
|
? projectViewModel.isArabic?_selectedAllergySeverity.nameAr:_selectedAllergySeverity.nameEn
|
|
|
|
|
: null,
|
|
|
|
|
true),
|
|
|
|
|
enabled: false,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 10,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.only(left: 0, right: 0, top: 15),
|
|
|
|
|
child: TextFields(
|
|
|
|
|
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: "Add".toUpperCase(),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
MySelectedAllergy mySelectedAllergy =
|
|
|
|
|
new MySelectedAllergy(
|
|
|
|
|
remark: remarkController.text,
|
|
|
|
|
selectedAllergy: _selectedAllergy,
|
|
|
|
|
selectedAllergySeverity:
|
|
|
|
|
_selectedAllergySeverity);
|
|
|
|
|
widget.addAllergiesFun(mySelectedAllergy);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
]),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 10,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
|
left: 0, right: 0, top: 15),
|
|
|
|
|
child: TextFields(
|
|
|
|
|
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: "Add".toUpperCase(),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
MySelectedAllergy mySelectedAllergy = new MySelectedAllergy(
|
|
|
|
|
remark: remarkController.text,
|
|
|
|
|
selectedAllergy: _selectedAllergy,
|
|
|
|
|
isChecked: true,
|
|
|
|
|
selectedAllergySeverity: _selectedAllergySeverity,);
|
|
|
|
|
widget.addAllergiesFun(mySelectedAllergy);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|