|
|
|
@ -1,12 +1,11 @@
|
|
|
|
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
|
|
|
|
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
|
|
|
|
import 'package:doctor_app_flutter/models/SOAP/selected_items/my_selected_allergy.dart';
|
|
|
|
import 'package:doctor_app_flutter/models/SOAP/selected_items/my_selected_allergy.dart';
|
|
|
|
|
|
|
|
import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/remove_button.dart';
|
|
|
|
import 'package:doctor_app_flutter/util/helpers.dart';
|
|
|
|
import 'package:doctor_app_flutter/util/helpers.dart';
|
|
|
|
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
|
|
|
|
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
|
|
|
|
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
|
|
|
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
|
|
|
import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart';
|
|
|
|
import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
|
|
|
|
|
|
import 'package:hexcolor/hexcolor.dart';
|
|
|
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import '../../shared_soap_widgets/SOAP_open_items.dart';
|
|
|
|
import '../../shared_soap_widgets/SOAP_open_items.dart';
|
|
|
|
@ -14,7 +13,7 @@ import 'add_allergies.dart';
|
|
|
|
|
|
|
|
|
|
|
|
// ignore: must_be_immutable
|
|
|
|
// ignore: must_be_immutable
|
|
|
|
class UpdateAllergiesWidget extends StatefulWidget {
|
|
|
|
class UpdateAllergiesWidget extends StatefulWidget {
|
|
|
|
List<MySelectedAllergy> myAllergiesList;
|
|
|
|
List<MySelectedAllergy> myAllergiesList;
|
|
|
|
|
|
|
|
|
|
|
|
UpdateAllergiesWidget({Key key, this.myAllergiesList});
|
|
|
|
UpdateAllergiesWidget({Key key, this.myAllergiesList});
|
|
|
|
|
|
|
|
|
|
|
|
@ -27,28 +26,28 @@ class _UpdateAllergiesWidgetState extends State<UpdateAllergiesWidget> {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
|
|
changeAllState() {
|
|
|
|
changeAllState() {
|
|
|
|
setState(() {
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
SOAPOpenItems(label: "${TranslationBase.of(context).addAllergies}",onTap: () {
|
|
|
|
SOAPOpenItems(
|
|
|
|
openAllergiesList(context, changeAllState, removeAllergy);
|
|
|
|
label: "${TranslationBase.of(context).addAllergies}",
|
|
|
|
},),
|
|
|
|
onTap: () {
|
|
|
|
|
|
|
|
openAllergiesList(context, changeAllState, removeAllergy);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
SizedBox(
|
|
|
|
height: 20,
|
|
|
|
height: 20,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
Container(
|
|
|
|
margin:
|
|
|
|
margin: EdgeInsets.only(left: 15, right: 15, top: 15),
|
|
|
|
EdgeInsets.only(left: 15, right: 15, top: 15),
|
|
|
|
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
children: widget.myAllergiesList.map((selectedAllergy) {
|
|
|
|
children: widget.myAllergiesList.map((selectedAllergy) {
|
|
|
|
return Column(
|
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Column(
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
@ -61,53 +60,41 @@ class _UpdateAllergiesWidgetState extends State<UpdateAllergiesWidget> {
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
AppText(
|
|
|
|
AppText(
|
|
|
|
projectViewModel.isArabic
|
|
|
|
projectViewModel.isArabic
|
|
|
|
? selectedAllergy.selectedAllergy.nameAr
|
|
|
|
? selectedAllergy.selectedAllergy.nameAr
|
|
|
|
: selectedAllergy.selectedAllergy.nameEn
|
|
|
|
: selectedAllergy.selectedAllergy.nameEn
|
|
|
|
.toUpperCase(),
|
|
|
|
.toUpperCase(),
|
|
|
|
textDecoration: selectedAllergy.isChecked
|
|
|
|
textDecoration: selectedAllergy.isChecked
|
|
|
|
? null
|
|
|
|
? null
|
|
|
|
: TextDecoration.lineThrough,
|
|
|
|
: TextDecoration.lineThrough,
|
|
|
|
bold: true,
|
|
|
|
bold: true,
|
|
|
|
color: Color(0xFF2B353E)),
|
|
|
|
color: Color(0xFF2B353E),
|
|
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
|
|
|
letterSpacing: -0.48,
|
|
|
|
|
|
|
|
// fontHeight:0.18 ,
|
|
|
|
|
|
|
|
),
|
|
|
|
AppText(
|
|
|
|
AppText(
|
|
|
|
projectViewModel.isArabic
|
|
|
|
projectViewModel.isArabic
|
|
|
|
? selectedAllergy.selectedAllergySeverity
|
|
|
|
? selectedAllergy
|
|
|
|
.nameAr
|
|
|
|
.selectedAllergySeverity.nameAr
|
|
|
|
: selectedAllergy.selectedAllergySeverity
|
|
|
|
: selectedAllergy
|
|
|
|
.nameEn
|
|
|
|
.selectedAllergySeverity.nameEn
|
|
|
|
.toUpperCase(),
|
|
|
|
.toUpperCase(),
|
|
|
|
textDecoration: selectedAllergy.isChecked
|
|
|
|
textDecoration: selectedAllergy.isChecked
|
|
|
|
? null
|
|
|
|
? null
|
|
|
|
: TextDecoration.lineThrough,
|
|
|
|
: TextDecoration.lineThrough,
|
|
|
|
color: Color(0xFFCC9B14)),
|
|
|
|
color: Color(0xFFCC9B14),
|
|
|
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
|
|
|
letterSpacing: -0.48,
|
|
|
|
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
width: MediaQuery
|
|
|
|
width: MediaQuery.of(context).size.width * 0.5,
|
|
|
|
.of(context)
|
|
|
|
|
|
|
|
.size
|
|
|
|
|
|
|
|
.width * 0.5,
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedAllergy.isChecked)
|
|
|
|
if (selectedAllergy.isChecked)
|
|
|
|
InkWell(
|
|
|
|
RemoveButton(
|
|
|
|
child: Row(
|
|
|
|
|
|
|
|
children: [Container(
|
|
|
|
|
|
|
|
child: AppText(
|
|
|
|
|
|
|
|
TranslationBase
|
|
|
|
|
|
|
|
.of(context)
|
|
|
|
|
|
|
|
.remove,
|
|
|
|
|
|
|
|
fontSize: 15,
|
|
|
|
|
|
|
|
variant: "bodyText",
|
|
|
|
|
|
|
|
color: HexColor("#B8382C"),),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Icon(
|
|
|
|
|
|
|
|
FontAwesomeIcons.times,
|
|
|
|
|
|
|
|
color: HexColor("#B8382C"),
|
|
|
|
|
|
|
|
size: 20,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
onTap: () => removeAllergy(selectedAllergy),
|
|
|
|
onTap: () => removeAllergy(selectedAllergy),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
],
|
|
|
|
],
|
|
|
|
@ -120,8 +107,10 @@ class _UpdateAllergiesWidgetState extends State<UpdateAllergiesWidget> {
|
|
|
|
width: MediaQuery.of(context).size.width * 0.55,
|
|
|
|
width: MediaQuery.of(context).size.width * 0.55,
|
|
|
|
child: AppText(
|
|
|
|
child: AppText(
|
|
|
|
selectedAllergy.remark ?? '',
|
|
|
|
selectedAllergy.remark ?? '',
|
|
|
|
|
|
|
|
color: Color(0xFF575757),
|
|
|
|
fontSize: 10,
|
|
|
|
fontSize: 10,
|
|
|
|
color: Colors.grey,
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
|
|
|
letterSpacing: -0.4,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
@ -143,15 +132,17 @@ class _UpdateAllergiesWidgetState extends State<UpdateAllergiesWidget> {
|
|
|
|
|
|
|
|
|
|
|
|
removeAllergy(MySelectedAllergy mySelectedAllergy) {
|
|
|
|
removeAllergy(MySelectedAllergy mySelectedAllergy) {
|
|
|
|
List<MySelectedAllergy> allergy =
|
|
|
|
List<MySelectedAllergy> allergy =
|
|
|
|
// ignore: missing_return
|
|
|
|
// ignore: missing_return
|
|
|
|
widget.myAllergiesList.where((element) =>
|
|
|
|
widget.myAllergiesList
|
|
|
|
mySelectedAllergy.selectedAllergySeverity.id ==
|
|
|
|
.where((element) =>
|
|
|
|
element.selectedAllergySeverity.id &&
|
|
|
|
mySelectedAllergy.selectedAllergySeverity.id ==
|
|
|
|
mySelectedAllergy.selectedAllergy.id == element.selectedAllergy.id
|
|
|
|
element.selectedAllergySeverity.id &&
|
|
|
|
).toList();
|
|
|
|
mySelectedAllergy.selectedAllergy.id ==
|
|
|
|
|
|
|
|
element.selectedAllergy.id)
|
|
|
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
|
|
if (allergy.length > 0) {
|
|
|
|
if (allergy.length > 0) {
|
|
|
|
if(allergy.first.isLocal) {
|
|
|
|
if (allergy.first.isLocal) {
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
widget.myAllergiesList.remove(allergy.first);
|
|
|
|
widget.myAllergiesList.remove(allergy.first);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -162,7 +153,8 @@ class _UpdateAllergiesWidgetState extends State<UpdateAllergiesWidget> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
openAllergiesList(BuildContext context, Function changeParentState, removeAllergy) {
|
|
|
|
openAllergiesList(
|
|
|
|
|
|
|
|
BuildContext context, Function changeParentState, removeAllergy) {
|
|
|
|
showModalBottomSheet(
|
|
|
|
showModalBottomSheet(
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
isScrollControlled: true,
|
|
|
|
isScrollControlled: true,
|
|
|
|
@ -170,7 +162,7 @@ class _UpdateAllergiesWidgetState extends State<UpdateAllergiesWidget> {
|
|
|
|
context: context,
|
|
|
|
context: context,
|
|
|
|
builder: (context) {
|
|
|
|
builder: (context) {
|
|
|
|
return AddAllergies(
|
|
|
|
return AddAllergies(
|
|
|
|
myAllergiesList: widget.myAllergiesList,
|
|
|
|
myAllergiesList: widget.myAllergiesList,
|
|
|
|
addAllergiesFun: (List<MySelectedAllergy> mySelectedAllergy) {
|
|
|
|
addAllergiesFun: (List<MySelectedAllergy> mySelectedAllergy) {
|
|
|
|
bool isAllDataFilled = true;
|
|
|
|
bool isAllDataFilled = true;
|
|
|
|
mySelectedAllergy.forEach((element) {
|
|
|
|
mySelectedAllergy.forEach((element) {
|
|
|
|
@ -181,19 +173,28 @@ class _UpdateAllergiesWidgetState extends State<UpdateAllergiesWidget> {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (isAllDataFilled) {
|
|
|
|
if (isAllDataFilled) {
|
|
|
|
mySelectedAllergy.forEach((element) {
|
|
|
|
mySelectedAllergy.forEach((element) {
|
|
|
|
if ((widget.myAllergiesList.singleWhere((it) => it.selectedAllergy.id == element.selectedAllergy.id,
|
|
|
|
if ((widget.myAllergiesList.singleWhere(
|
|
|
|
orElse: () => null)) == null) {
|
|
|
|
(it) =>
|
|
|
|
|
|
|
|
it.selectedAllergy.id ==
|
|
|
|
|
|
|
|
element.selectedAllergy.id,
|
|
|
|
|
|
|
|
orElse: () => null)) ==
|
|
|
|
|
|
|
|
null) {
|
|
|
|
widget.myAllergiesList.add(element);
|
|
|
|
widget.myAllergiesList.add(element);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/// remove items.
|
|
|
|
/// remove items.
|
|
|
|
List<MySelectedAllergy> removedList= [];
|
|
|
|
List<MySelectedAllergy> removedList = [];
|
|
|
|
widget.myAllergiesList.forEach((element) {
|
|
|
|
widget.myAllergiesList.forEach((element) {
|
|
|
|
if ((mySelectedAllergy.singleWhere((it) => it.selectedAllergy.id == element.selectedAllergy.id,
|
|
|
|
if ((mySelectedAllergy.singleWhere(
|
|
|
|
orElse: () => null)) == null) {
|
|
|
|
(it) =>
|
|
|
|
|
|
|
|
it.selectedAllergy.id ==
|
|
|
|
|
|
|
|
element.selectedAllergy.id,
|
|
|
|
|
|
|
|
orElse: () => null)) ==
|
|
|
|
|
|
|
|
null) {
|
|
|
|
removedList.add(element);
|
|
|
|
removedList.add(element);
|
|
|
|
}});
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
removedList.forEach((element) {
|
|
|
|
removedList.forEach((element) {
|
|
|
|
removeAllergy(element);
|
|
|
|
removeAllergy(element);
|
|
|
|
@ -201,18 +202,11 @@ class _UpdateAllergiesWidgetState extends State<UpdateAllergiesWidget> {
|
|
|
|
changeParentState();
|
|
|
|
changeParentState();
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Helpers.showErrorToast(TranslationBase
|
|
|
|
Helpers.showErrorToast(
|
|
|
|
.of(context)
|
|
|
|
TranslationBase.of(context).requiredMsg);
|
|
|
|
.requiredMsg);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|