Bug PAP-884 fixed, email was not updating.

merge-update-with-lab-changes
Sikander Saleem 5 years ago
parent d0c8c4f017
commit 38f134b6ff

@ -14,6 +14,10 @@ class ReportsMonthlyViewModel extends BaseViewModel {
ReportsService _reportsService = locator<ReportsService>(); ReportsService _reportsService = locator<ReportsService>();
String get userAgreementContent => _reportsService.userAgreementContent; String get userAgreementContent => _reportsService.userAgreementContent;
bool get receiveHealthSummaryReport => _reportsService?.user?.receiveHealthSummaryReport ?? false;
set receiveHealthSummaryReport(bool val) {
_reportsService?.user?.receiveHealthSummaryReport = val;
}
getUserTermsAndConditions() async { getUserTermsAndConditions() async {
setState(ViewState.Busy); setState(ViewState.Busy);
@ -26,14 +30,9 @@ class ReportsMonthlyViewModel extends BaseViewModel {
} }
} }
updatePatientHealthSummaryReport( updatePatientHealthSummaryReport({String message, bool isSummary, bool isUpdateEmail = false, String email}) async {
{String message,
bool isSummary,
bool isUpdateEmail = false,
String email}) async {
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
await _reportsService.updatePatientHealthSummaryReport( await _reportsService.updatePatientHealthSummaryReport(isSummary: isSummary);
isSummary: isSummary);
if (_reportsService.hasError) { if (_reportsService.hasError) {
error = _reportsService.error; error = _reportsService.error;
AppToast.showErrorToast(message: error); AppToast.showErrorToast(message: error);

@ -19,15 +19,24 @@ class MonthlyReportsPage extends StatefulWidget {
} }
class _MonthlyReportsPageState extends State<MonthlyReportsPage> { class _MonthlyReportsPageState extends State<MonthlyReportsPage> {
bool isAgree = false; bool isAgree;
bool isSummary = false; bool isSummary;
String email = ""; String email;
final formKey = GlobalKey<FormState>(); final formKey = GlobalKey<FormState>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<ReportsMonthlyViewModel>( return BaseView<ReportsMonthlyViewModel>(builder: (_, model, w) {
builder: (_, model, w) => AppScaffold( if (isSummary == null) {
isSummary = model.receiveHealthSummaryReport;
}
if (isAgree == null) {
isAgree = model.receiveHealthSummaryReport;
}
if (email == null) {
email = model?.user?.emailAddress ?? "";
}
return AppScaffold(
isShowAppBar: true, isShowAppBar: true,
appBarTitle: TranslationBase.of(context).monthlyReports, appBarTitle: TranslationBase.of(context).monthlyReports,
body: SingleChildScrollView( body: SingleChildScrollView(
@ -41,15 +50,10 @@ class _MonthlyReportsPageState extends State<MonthlyReportsPage> {
Container( Container(
padding: EdgeInsets.all(9), padding: EdgeInsets.all(9),
height: 55, height: 55,
decoration: BoxDecoration( decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(8)), shape: BoxShape.rectangle, border: Border.all(color: Colors.grey)),
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(8)),
shape: BoxShape.rectangle,
border: Border.all(color: Colors.grey)),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Texts( Texts(
TranslationBase.of(context).patientHealthSummaryReport, TranslationBase.of(context).patientHealthSummaryReport,
bold: true, bold: true,
@ -62,12 +66,12 @@ class _MonthlyReportsPageState extends State<MonthlyReportsPage> {
setState(() { setState(() {
isSummary = !isSummary; isSummary = !isSummary;
}); });
if(!isSummary) { if (!isSummary) {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
await model.updatePatientHealthSummaryReport( await model.updatePatientHealthSummaryReport(message: TranslationBase.of(context).updateSuccessfully, isSummary: isSummary);
message: TranslationBase model.receiveHealthSummaryReport = isSummary;
.of(context) isAgree = isSummary;
.updateSuccessfully, isSummary: isSummary); model.user.emailAddress = "";
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
} }
}, },
@ -80,11 +84,11 @@ class _MonthlyReportsPageState extends State<MonthlyReportsPage> {
), ),
Container( Container(
margin: EdgeInsets.all(8), margin: EdgeInsets.all(8),
child: TextFields( child: TextFields(
fillColor: Colors.red, fillColor: Colors.red,
hintText: 'email@email.com', hintText: 'email@email.com',
fontSize: 20, fontSize: 20,
initialValue: model.user.emailAddress, initialValue: email,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
onChanged: (text) { onChanged: (text) {
email = text; email = text;
@ -111,8 +115,7 @@ class _MonthlyReportsPageState extends State<MonthlyReportsPage> {
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Expanded( Expanded(
child: Texts(TranslationBase.of(context) child: Texts(TranslationBase.of(context).toViewTheTermsAndConditions),
.toViewTheTermsAndConditions),
), ),
InkWell( InkWell(
onTap: () { onTap: () {
@ -156,19 +159,15 @@ class _MonthlyReportsPageState extends State<MonthlyReportsPage> {
child: SecondaryButton( child: SecondaryButton(
textColor: Colors.white, textColor: Colors.white,
label: TranslationBase.of(context).save, label: TranslationBase.of(context).save,
disabled: (!isAgree || !isSummary ), disabled: (!isAgree || !isSummary),
onTap: () async { onTap: () async {
final form = formKey.currentState; final form = formKey.currentState;
if (form.validate()) { if (form.validate()) {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
await model.updatePatientHealthSummaryReport( await model.updatePatientHealthSummaryReport(
message: TranslationBase message: TranslationBase.of(context).updateSuccessfully, isSummary: isSummary, isUpdateEmail: true, email: email.isNotEmpty ? email : model.user.emailAddress);
.of(context) model.receiveHealthSummaryReport = isSummary;
.updateSuccessfully, model.user.emailAddress = email.isNotEmpty ? email : model.user.emailAddress;
isSummary: isSummary,
isUpdateEmail: true,
email: email.isNotEmpty ? email : model.user
.emailAddress);
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
} }
}, },
@ -177,8 +176,7 @@ class _MonthlyReportsPageState extends State<MonthlyReportsPage> {
Padding( Padding(
padding: const EdgeInsets.all(5.0), padding: const EdgeInsets.all(5.0),
child: Texts( child: Texts(
TranslationBase.of(context) TranslationBase.of(context).instructionAgree,
.instructionAgree,
fontWeight: FontWeight.normal, fontWeight: FontWeight.normal,
), ),
), ),
@ -191,7 +189,7 @@ class _MonthlyReportsPageState extends State<MonthlyReportsPage> {
), ),
), ),
), ),
), );
); });
} }
} }

Loading…
Cancel
Save