add and remove allergy

pull/190/head
Elham Rababah 5 years ago
parent 405ad731c7
commit 52554d1aef

@ -25,7 +25,6 @@ class AddAllergiesWidget extends StatefulWidget {
}
class _AddAllergiesWidgetState extends State<AddAllergiesWidget> {
List<MySelectedAllergy> myAllergiesList;
TextEditingController remarkController = TextEditingController();
@ -73,35 +72,45 @@ class _AddAllergiesWidgetState extends State<AddAllergiesWidget> {
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Texts(selectedAllergy.selectedAllergy.nameEn
Texts(selectedAllergy.selectedAllergy.nameEn.toUpperCase(),
variant: "bodyText", bold: true, color: Colors.black),
Texts(
selectedAllergy.selectedAllergySeverity.nameEn
.toUpperCase(),
variant: "bodyText",
bold: true,
color: Colors.black),
Texts(selectedAllergy.selectedAllergySeverity.nameEn
.toUpperCase(),
variant: "bodyText",
bold: true,
color: AppGlobal.appPrimaryColor),
Icon(
FontAwesomeIcons.trash,
color: Colors.grey,
size: 20,
)
],
), SizedBox(
height: 20,
),
variant: "bodyText",
bold: true,
color: AppGlobal.appPrimaryColor),
InkWell(
child: Icon(
FontAwesomeIcons.trash,
color: Colors.grey,
size: 20,
),
onTap: () => removeAllergy(selectedAllergy),
)
],
);
}).toList()
),
),
SizedBox(
height: 10,
),
],
);
}).toList()),
)
],
);
}
removeAllergy(MySelectedAllergy mySelectedAllergy) {
Iterable<MySelectedAllergy> allergy =
widget.myAllergiesList.where((element) => mySelectedAllergy == element);
if (allergy.length > 0)
setState(() {
widget.myAllergiesList.remove(allergy.first);
});
}
openAllergiesList(BuildContext context) {
showModalBottomSheet(
backgroundColor: Colors.white,

@ -2,6 +2,7 @@ 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/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart';
import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/Text.dart';
@ -16,6 +17,10 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:hexcolor/hexcolor.dart';
class AddHistoryWidget extends StatefulWidget {
final List<MasterKeyModel> myHistoryList;
const AddHistoryWidget({Key key, this.myHistoryList}) : super(key: key);
@override
_AddHistoryWidgetState createState() => _AddHistoryWidgetState();
}
@ -69,54 +74,63 @@ class _AddHistoryWidgetState extends State<AddHistoryWidget>
margin:
EdgeInsets.only(left: 15, right: 15, top: 15),
child: Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Texts('Abdomen Pain',
variant: "bodyText",
bold: true,
color: Colors.black),
Icon(
FontAwesomeIcons.trash,
color: Colors.grey,
size: 20,
)
],
),
SizedBox(
height: 20,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: widget.myHistoryList.map((myHistory) {
return Column(
children: [
Texts('Back Pain',
variant: "bodyText",
bold: true,
color: Colors.black),
Icon(
FontAwesomeIcons.trash,
color: Colors.grey,
size: 20,
)
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(myHistory.nameEn,
variant: "bodyText", bold: true, color: Colors.black),
InkWell(
child: Icon(
FontAwesomeIcons.trash,
color: Colors.grey,
size: 20,
),
onTap: () => removeHistory(myHistory),
)
],
),
SizedBox(
height: 20,
),
],
),
],
);
}).toList(),
),
)
],
);
}
removeHistory(MasterKeyModel masterKey) {
Iterable<MasterKeyModel> history = widget.myHistoryList.where((element) =>
masterKey.id == element.id && masterKey.typeId == element.typeId);
if (history.length > 0)
setState(() {
widget.myHistoryList.remove(history.first);
});
}
openHistoryList(BuildContext context) {
showModalBottomSheet(
backgroundColor: Colors.white,
isScrollControlled: true,
context: context,
builder: (context) {
return AddHistoryDialog(changePageViewIndex:changePageViewIndex, controller: _controller,);
return AddHistoryDialog(
changePageViewIndex: changePageViewIndex,
controller: _controller,
myHistoryList: widget.myHistoryList,
addSelectedHistories: () {
setState(() {
Navigator.of(context).pop();
});
},
removeHistory: (masterKey) => removeHistory(masterKey),
);
});
}
}
@ -203,8 +217,12 @@ class _PriorityBarState extends State<PriorityBar> {
class AddHistoryDialog extends StatefulWidget {
final Function changePageViewIndex;
final PageController controller;
final List<MasterKeyModel> myHistoryList;
final Function addSelectedHistories;
final Function (MasterKeyModel) removeHistory;
const AddHistoryDialog({Key key, this.changePageViewIndex, this.controller})
const AddHistoryDialog(
{Key key, this.changePageViewIndex, this.controller, this.myHistoryList, this.addSelectedHistories, this.removeHistory})
: super(key: key);
@override
@ -286,12 +304,28 @@ class _AddHistoryDialogState extends State<AddHistoryDialog> {
Row(
children: [
Checkbox(
value: true,
value: isServiceSelected(
historyInfo),
activeColor:
Colors.red[800],
Colors.red[800],
onChanged:
(bool newValue) {
setState(() {});
setState(() {
if (isServiceSelected(
historyInfo
)) {
widget
.removeHistory(
historyInfo
);
}
else {
widget
.myHistoryList
.add(
historyInfo);
}
});
}),
Expanded(
child: Padding(
@ -325,8 +359,11 @@ class _AddHistoryDialogState extends State<AddHistoryDialog> {
),
if (model.state == ViewState.Idle)
AppButton(
title: "Add SELECTED HISTORIES".toUpperCase(),
onPressed: () {},
title: "Add SELECTED HISTORIES"
.toUpperCase(),
onPressed: () {
widget.addSelectedHistories();
},
),
],
),
@ -355,12 +392,29 @@ class _AddHistoryDialogState extends State<AddHistoryDialog> {
Row(
children: [
Checkbox(
value: true,
value: isServiceSelected(
historyInfo),
activeColor:
Colors.red[800],
onChanged:
(bool newValue) {
setState(() {});
(
bool newValue) {
setState(() {
if (isServiceSelected(
historyInfo
)) {
widget
.removeHistory(
historyInfo
);
}
else {
widget
.myHistoryList
.add(
historyInfo);
}
});
}),
Expanded(
child: Padding(
@ -394,8 +448,11 @@ class _AddHistoryDialogState extends State<AddHistoryDialog> {
),
if (model.state == ViewState.Idle)
AppButton(
title: "Add SELECTED HISTORIES".toUpperCase(),
onPressed: () {},
title: "Add SELECTED HISTORIES"
.toUpperCase(),
onPressed: () {
widget.addSelectedHistories();
},
),
],
),
@ -424,12 +481,29 @@ class _AddHistoryDialogState extends State<AddHistoryDialog> {
Row(
children: [
Checkbox(
value: true,
value: isServiceSelected(
historyInfo),
activeColor:
Colors.red[800],
onChanged:
(bool newValue) {
setState(() {});
(
bool newValue) {
setState(() {
if (isServiceSelected(
historyInfo
)) {
widget
.removeHistory(
historyInfo
);
}
else {
widget
.myHistoryList
.add(
historyInfo);
}
});
}),
Expanded(
child: Padding(
@ -463,8 +537,13 @@ class _AddHistoryDialogState extends State<AddHistoryDialog> {
),
if (model.state == ViewState.Idle)
AppButton(
title: "Add SELECTED HISTORIES".toUpperCase(),
onPressed: () {},
title: "Add SELECTED HISTORIES"
.toUpperCase(),
onPressed: () {
setState(() {
widget.addSelectedHistories();
});
},
),
],
),
@ -474,9 +553,22 @@ class _AddHistoryDialogState extends State<AddHistoryDialog> {
),
],
),
)),
)),
),
),
));
}
isServiceSelected(MasterKeyModel masterKey) {
Iterable<MasterKeyModel> history =
widget
.myHistoryList
.where((element) =>
masterKey.id == element.id && masterKey.typeId == element.typeId);
if (history.length > 0) {
return true;
}
return false;
}
}

@ -1,6 +1,7 @@
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/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';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
@ -30,6 +31,7 @@ class _SubjectivePageState extends State<SubjectivePage> {
bool isHistoryExpand = false;
bool isAllergiesExpand = false;
List<MySelectedAllergy> myAllergiesList = List();
List<MasterKeyModel> myHistoryList = List();
TextEditingController messageController = TextEditingController();
@override
@ -143,7 +145,7 @@ class _SubjectivePageState extends State<SubjectivePage> {
children: [
Row(
children: [
Texts('History',
Texts('History'.toUpperCase(),
variant: isHistoryExpand ? "bodyText" : '',
bold: isHistoryExpand ? true : false,
color: Colors.black),
@ -167,7 +169,7 @@ class _SubjectivePageState extends State<SubjectivePage> {
),
bodyWidget: Column(
children: [
AddHistoryWidget()
AddHistoryWidget(myHistoryList: myHistoryList)
],
),
isExpand: isHistoryExpand,
@ -189,7 +191,7 @@ class _SubjectivePageState extends State<SubjectivePage> {
children: [
Row(
children: [
Texts('Allergies',
Texts('Allergies'.toUpperCase(),
variant: isAllergiesExpand ? "bodyText" : '',
bold: isAllergiesExpand ? true : false,
color: Colors.black),
@ -238,6 +240,7 @@ class _SubjectivePageState extends State<SubjectivePage> {
.of(context)
.next,
onPressed: () {
print( myHistoryList.toString());
widget.changePageViewIndex(1);
},
),

Loading…
Cancel
Save