You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
diplomatic-quarter/lib/pages/medical/reports/monthly_reports.dart

250 lines
11 KiB
Dart

import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/reports_monthly_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/medical/reports/user_agreement_page.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/input/custom_switch.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
class MonthlyReportsPage extends StatefulWidget {
@override
_MonthlyReportsPageState createState() => _MonthlyReportsPageState();
}
class _MonthlyReportsPageState extends State<MonthlyReportsPage> {
bool isAgree;
bool isSummary;
String email;
final formKey = GlobalKey<FormState>();
List<ImagesInfo> imagesInfo = List();
@override
void initState() {
imagesInfo.add(ImagesInfo(
imageEn: 'https://hmgwebservices.com/Images/MobileApp/imges-info/monthly-reports/en/0.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/imges-info/monthly-reports/ar/0.png'));
imagesInfo.add(ImagesInfo(
imageEn: 'https://hmgwebservices.com/Images/MobileApp/imges-info/monthly-reports/en/1.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/imges-info/monthly-reports/ar/1.png'));
super.initState();
}
@override
Widget build(BuildContext context) {
return BaseView<ReportsMonthlyViewModel>(builder: (_, model, w) {
if (isSummary == null) {
isSummary = model.receiveHealthSummaryReport;
}
if (isAgree == null) {
isAgree = model.receiveHealthSummaryReport;
}
if (email == null) {
email = model?.user?.emailAddress ?? "";
}
return AppScaffold(
isShowAppBar: true,
appBarTitle: TranslationBase.of(context).monthlyReports,
showNewAppBar: true,
showNewAppBarTitle: true,
backgroundColor: Color(0xffF7F7F7),
imagesInfo: imagesInfo,
description: TranslationBase.of(context).infoMonthReport,
body: SingleChildScrollView(
physics: BouncingScrollPhysics(),
padding: EdgeInsets.all(21),
child: Form(
key: formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.only(right: 12, left: 12, top: 14, bottom: 14),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(10.0),
),
boxShadow: [
BoxShadow(
color: Color(0xff000000).withOpacity(.05),
//spreadRadius: 5,
blurRadius: 27,
offset: Offset(0, -3),
),
],
color: Colors.white),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
TranslationBase.of(context).patientHealthSummaryReport,
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 25 / 16),
),
),
CustomSwitch(
value: isSummary,
activeColor: Color(0xffD02127),
inactiveColor: Color(0xff28323A).withOpacity(0.3),
onChanged: () async {
setState(() {
isSummary = !isSummary;
});
if (!isSummary) {
GifLoaderDialogUtils.showMyDialog(context);
await model.updatePatientHealthSummaryReport(message: TranslationBase.of(context).updateSuccessfully, isSummary: isSummary);
model.receiveHealthSummaryReport = isSummary;
isAgree = isSummary;
model.user.emailAddress = "";
GifLoaderDialogUtils.hideDialog(context);
}
},
)
],
),
),
SizedBox(
height: 15,
),
Container(
padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.white,
border: Border.all(
color: Color(0xffefefef),
width: 1,
),
),
child: Row(
children: [
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
TranslationBase.of(context).email,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,
color: Color(0xff2B353E),
letterSpacing: -0.44,
),
),
TextFormField(
scrollPadding: EdgeInsets.zero,
keyboardType: TextInputType.number,
// controller: _controller,
onChanged: (value) => {email = value},
initialValue: email,
style: TextStyle(
fontSize: 14,
height: 21 / 14,
fontWeight: FontWeight.w400,
color: Color(0xff2B353E),
letterSpacing: -0.44,
),
validator: (value) {
if (value.isEmpty)
return TranslationBase.of(context).enterEmail;
else
return null;
},
decoration: InputDecoration(
isDense: true,
hintText: "email@email.com",
hintStyle: TextStyle(
fontSize: 14,
height: 21 / 14,
fontWeight: FontWeight.w400,
color: Color(0xff575757),
letterSpacing: -0.56,
),
contentPadding: EdgeInsets.zero,
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
),
),
],
),
),
],
),
),
SizedBox(
height: 12,
),
RichText(
text: TextSpan(
text: TranslationBase.of(context).toViewTheTermsAndConditions + " ",
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: Color(0xff2B353E), letterSpacing: -0.64, height: 23 / 16),
children: [
TextSpan(
text: TranslationBase.of(context).clickHere,
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.blue, letterSpacing: -0.64, height: 23 / 16),
recognizer: new TapGestureRecognizer()
..onTap = () => Navigator.push(
context,
FadePage(
page: UserAgreementContent(),
),
),
)
]),
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Checkbox(
value: isAgree,
onChanged: (value) {
setState(() {
isAgree = !isAgree;
});
},
activeColor: Color(0xffD02127),
),
Text(
TranslationBase.of(context).iAgreeToTheTermsAndConditions,
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w400, color: Color(0xff2B353E), letterSpacing: -0.56, height: 21 / 14),
),
],
),
DefaultButton(
TranslationBase.of(context).save,
() async {
final form = formKey.currentState;
if (form.validate()) {
GifLoaderDialogUtils.showMyDialog(context);
await model.updatePatientHealthSummaryReport(
message: TranslationBase.of(context).updateSuccessfully, isSummary: isSummary, isUpdateEmail: true, email: email.isNotEmpty ? email : model.user.emailAddress);
model.receiveHealthSummaryReport = isSummary;
model.user.emailAddress = email.isNotEmpty ? email : model.user.emailAddress;
GifLoaderDialogUtils.hideDialog(context);
}
},
),
SizedBox(height: 12),
Text(
TranslationBase.of(context).instructionAgree,
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48, height: 18 / 12),
),
SizedBox(height: 12),
Center(child: Image.asset('assets/images/report.jpg'))
],
),
),
),
);
});
}
}