|
|
|
|
@ -27,13 +27,13 @@ class AddBloodPressurePage extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
const AddBloodPressurePage(
|
|
|
|
|
{Key key,
|
|
|
|
|
this.bloodSugarDate,
|
|
|
|
|
this.measureTimeSelectedType,
|
|
|
|
|
this.isUpdate = false,
|
|
|
|
|
this.lineItemNo,
|
|
|
|
|
this.model,
|
|
|
|
|
this.bloodSystolicValue,
|
|
|
|
|
this.bloodDiastolicValue})
|
|
|
|
|
this.bloodSugarDate,
|
|
|
|
|
this.measureTimeSelectedType,
|
|
|
|
|
this.isUpdate = false,
|
|
|
|
|
this.lineItemNo,
|
|
|
|
|
this.model,
|
|
|
|
|
this.bloodSystolicValue,
|
|
|
|
|
this.bloodDiastolicValue})
|
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -42,10 +42,12 @@ class AddBloodPressurePage extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
|
|
|
|
|
TextEditingController _bloodSystolicValueController = TextEditingController();
|
|
|
|
|
TextEditingController _bloodDiastolicValueController = TextEditingController();
|
|
|
|
|
TextEditingController _bloodDiastolicValueController =
|
|
|
|
|
TextEditingController();
|
|
|
|
|
DateTime bloodSugarDate = DateTime.now();
|
|
|
|
|
DateTime timeSugarDate = DateTime.now();
|
|
|
|
|
int measuredArm = 1;
|
|
|
|
|
bool isButtonDisabled = false;
|
|
|
|
|
final List<String> measureTimeEnList = [
|
|
|
|
|
'Left',
|
|
|
|
|
'Right',
|
|
|
|
|
@ -69,6 +71,7 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
|
|
|
|
|
measuredArm = measureTimeArList.indexOf(widget.measureTimeSelectedType);
|
|
|
|
|
_bloodSystolicValueController.text = widget.bloodSystolicValue;
|
|
|
|
|
_bloodDiastolicValueController.text = widget.bloodDiastolicValue;
|
|
|
|
|
validateForm();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -78,38 +81,44 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
|
|
|
|
|
|
|
|
|
|
return AppScaffold(
|
|
|
|
|
isShowAppBar: true,
|
|
|
|
|
appBarTitle: widget.isUpdate ? TranslationBase.of(context).update : TranslationBase.of(context).add,
|
|
|
|
|
appBarTitle: widget.isUpdate
|
|
|
|
|
? TranslationBase.of(context).update
|
|
|
|
|
: TranslationBase.of(context).add,
|
|
|
|
|
appBarIcons: widget.isUpdate
|
|
|
|
|
? [
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: Icon(Icons.delete),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
ConfirmDialog dialog = new ConfirmDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
confirmMessage: 'Remove this measure',
|
|
|
|
|
okText: TranslationBase.of(context).ok,
|
|
|
|
|
cancelText: TranslationBase.of(context).cancel,
|
|
|
|
|
okFunction: () async {
|
|
|
|
|
ConfirmDialog.closeAlertDialog(context);
|
|
|
|
|
? [
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: Icon(Icons.delete),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
ConfirmDialog dialog = new ConfirmDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
confirmMessage: 'Remove this measure',
|
|
|
|
|
okText: TranslationBase.of(context).ok,
|
|
|
|
|
cancelText: TranslationBase.of(context).cancel,
|
|
|
|
|
okFunction: () async {
|
|
|
|
|
ConfirmDialog.closeAlertDialog(context);
|
|
|
|
|
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
widget.model.deactivateDiabeticStatus(lineItemNo: widget.lineItemNo).then((value) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
if (widget.model.state == ViewState.ErrorLocal)
|
|
|
|
|
AppToast.showErrorToast(message: widget.model.error);
|
|
|
|
|
else
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
}).catchError((e) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
AppToast.showErrorToast(message: widget.model.error);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
cancelFunction: () => {});
|
|
|
|
|
dialog.showAlertDialog(context);
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
widget.model
|
|
|
|
|
.deactivateDiabeticStatus(
|
|
|
|
|
lineItemNo: widget.lineItemNo)
|
|
|
|
|
.then((value) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
if (widget.model.state == ViewState.ErrorLocal)
|
|
|
|
|
AppToast.showErrorToast(
|
|
|
|
|
message: widget.model.error);
|
|
|
|
|
else
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
}).catchError((e) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
AppToast.showErrorToast(message: widget.model.error);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
cancelFunction: () => {});
|
|
|
|
|
dialog.showAlertDialog(context);
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
: null,
|
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
|
physics: BouncingScrollPhysics(),
|
|
|
|
|
@ -124,6 +133,8 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
|
|
|
|
|
hintText: TranslationBase.of(context).systolicAdd,
|
|
|
|
|
controller: _bloodSystolicValueController,
|
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
|
maxLength: 3,
|
|
|
|
|
onChanged: (value) => validateForm(),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
@ -132,19 +143,25 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
|
|
|
|
|
hintText: TranslationBase.of(context).diastolicAdd,
|
|
|
|
|
controller: _bloodDiastolicValueController,
|
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
|
maxLength: 3,
|
|
|
|
|
onChanged: (value) => validateForm(),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
confirmSelectMeasureTimeDialog(projectViewModel.isArabic ? measureTimeEnList : measureTimeArList);
|
|
|
|
|
confirmSelectMeasureTimeDialog(projectViewModel.isArabic
|
|
|
|
|
? measureTimeEnList
|
|
|
|
|
: measureTimeArList);
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: EdgeInsets.all(12),
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: 65,
|
|
|
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
color: Colors.white),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
@ -166,18 +183,22 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
|
|
|
|
|
showTitleActions: true,
|
|
|
|
|
minTime: DateTime(DateTime.now().year - 1, 1, 1),
|
|
|
|
|
maxTime: DateTime.now(), onConfirm: (date) {
|
|
|
|
|
setState(
|
|
|
|
|
() {
|
|
|
|
|
bloodSugarDate = date;
|
|
|
|
|
setState(
|
|
|
|
|
() {
|
|
|
|
|
bloodSugarDate = date;
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}, currentTime: bloodSugarDate, locale: projectViewModel.localeType);
|
|
|
|
|
currentTime: bloodSugarDate,
|
|
|
|
|
locale: projectViewModel.localeType);
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: EdgeInsets.all(12),
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: 65,
|
|
|
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
color: Colors.white),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
@ -192,22 +213,30 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
|
|
|
|
|
),
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
DatePicker.showTimePicker(context, showTitleActions: true, onConfirm: (date) {
|
|
|
|
|
setState(
|
|
|
|
|
() {
|
|
|
|
|
timeSugarDate = date;
|
|
|
|
|
DatePicker.showTimePicker(context, showTitleActions: true,
|
|
|
|
|
onConfirm: (date) {
|
|
|
|
|
setState(
|
|
|
|
|
() {
|
|
|
|
|
timeSugarDate = date;
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}, currentTime: timeSugarDate, locale: projectViewModel.localeType);
|
|
|
|
|
currentTime: timeSugarDate,
|
|
|
|
|
locale: projectViewModel.localeType);
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: EdgeInsets.all(12),
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: 65,
|
|
|
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
color: Colors.white),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [Texts(TranslationBase.of(context).time), Texts(getTime())],
|
|
|
|
|
children: [
|
|
|
|
|
Texts(TranslationBase.of(context).time),
|
|
|
|
|
Texts(getTime())
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -225,17 +254,23 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
|
|
|
|
|
loading: widget.model.state == ViewState.BusyLocal,
|
|
|
|
|
label: TranslationBase.of(context).save.toUpperCase(),
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
color: isButtonDisabled
|
|
|
|
|
? Colors.grey[900]
|
|
|
|
|
: Colors.grey,
|
|
|
|
|
onTap: () async {
|
|
|
|
|
if (_bloodSystolicValueController.text.isNotEmpty && _bloodDiastolicValueController.text.isNotEmpty) {
|
|
|
|
|
if (_bloodSystolicValueController.text.isNotEmpty &&
|
|
|
|
|
_bloodDiastolicValueController.text.isNotEmpty) {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
|
|
|
|
|
widget.model
|
|
|
|
|
.addORUpdateDiabtecResult(
|
|
|
|
|
isUpdate: widget.isUpdate,
|
|
|
|
|
bloodPressureDate:
|
|
|
|
|
'${bloodSugarDate.year}-${bloodSugarDate.month}-${bloodSugarDate.day} ${timeSugarDate.hour}:${timeSugarDate.minute}:00',
|
|
|
|
|
diastolicPressure: _bloodDiastolicValueController.text.toString(),
|
|
|
|
|
systolicePressure: _bloodSystolicValueController.text.toString(),
|
|
|
|
|
'${bloodSugarDate.year}-${bloodSugarDate.month}-${bloodSugarDate.day} ${timeSugarDate.hour}:${timeSugarDate.minute}:00',
|
|
|
|
|
diastolicPressure:
|
|
|
|
|
_bloodDiastolicValueController.text.toString(),
|
|
|
|
|
systolicePressure:
|
|
|
|
|
_bloodSystolicValueController.text.toString(),
|
|
|
|
|
measuredArm: measuredArm,
|
|
|
|
|
)
|
|
|
|
|
.then((value) {
|
|
|
|
|
@ -275,9 +310,43 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
|
|
|
|
|
setState(() {
|
|
|
|
|
measureTimeSelectedType = value;
|
|
|
|
|
measuredArm = list.indexOf(value);
|
|
|
|
|
validateForm();
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void validateForm() {
|
|
|
|
|
print("_bloodSystolicValueController "+_bloodSystolicValueController.text.length.toString());
|
|
|
|
|
if (measureTimeSelectedType != 'Left Arm' &&
|
|
|
|
|
_bloodSystolicValueController.text.length > 0 &&
|
|
|
|
|
_bloodDiastolicValueController.text.length > 0) {
|
|
|
|
|
setState(() {
|
|
|
|
|
isButtonDisabled = true;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
setState(() {
|
|
|
|
|
isButtonDisabled = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// if(measureTimeSelectedType == 'Left Arm'){
|
|
|
|
|
// setState(() {
|
|
|
|
|
// isButtonDisabled = false;
|
|
|
|
|
// });
|
|
|
|
|
// }else if(_bloodSystolicValueController.text.length < 0){
|
|
|
|
|
// setState(() {
|
|
|
|
|
// isButtonDisabled = false;
|
|
|
|
|
// });
|
|
|
|
|
// }else if(_bloodDiastolicValueController.text.length < 0){
|
|
|
|
|
// setState(() {
|
|
|
|
|
// isButtonDisabled = false;
|
|
|
|
|
// });
|
|
|
|
|
// }else{
|
|
|
|
|
// setState(() {
|
|
|
|
|
// isButtonDisabled = true;
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|