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.
PatientApp-KKUMC/lib/pages/vaccine/my_vaccines_screen.dart

362 lines
16 KiB
Dart

import 'dart:typed_data';
import 'dart:convert';
import 'package:diplomaticquarterapp/widgets/buttons/button.dart';
import 'package:flutter/material.dart';
import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:flutter/cupertino.dart';
import '../base/base_view.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/core/viewModels/vaccine_view_model.dart';
import 'package:diplomaticquarterapp/widgets/others/rounded_container.dart';
import 'package:flutter_email_sender/flutter_email_sender.dart';
import 'package:popup_box/popup_box.dart';
class MyVaccines extends StatefulWidget {
@override
_MyVaccinesState createState() => _MyVaccinesState();
}
class _MyVaccinesState extends State<MyVaccines> {
@override
Widget build(BuildContext context) {
return BaseView<VaccineViewModel>(
onModelReady: (model) => model.getVaccine(),
builder: (BuildContext context, VaccineViewModel model, Widget child) =>
AppScaffold(
isShowAppBar: true,
appBarTitle: 'My Vaccines',
baseViewModel: model,
body: Container(
margin: EdgeInsets.only(
left: SizeConfig.screenWidth * 0.004,
right: SizeConfig.screenWidth * 0.004,
top: SizeConfig.screenWidth * 0.04,
),
child: Column(
children: <Widget>[
RoundedContainer(
backgroundColor: Colors.white,
child: ExpansionTile(
title: Container(
height: 65.0,
child: Text('2018'),
),
children: <Widget>[
Container(
child: ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: model.vaccineList == null
? 0
: model.vaccineList.length,
itemBuilder: (BuildContext context, int index) {
return Column(
children: <Widget>[
RoundedContainer(
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.symmetric(
horizontal: 20.0,
vertical: 20.0),
child: Image.network(
model.vaccineList[index]
.doctorImageURL,
height: SizeConfig
.imageSizeMultiplier *
23,
width: SizeConfig
.imageSizeMultiplier *
20,
fit: BoxFit.fill,
),
),
],
),
Container(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Text(
model.vaccineList[index]
.doctorTitle +
model.vaccineList[index]
.doctorName,
style: TextStyle(
fontWeight: FontWeight.w900,
fontSize: 16.6,
),
),
SpaceBetweenTexts(space: 7.0),
Text(
model.vaccineList[index]
.projectName,
style: TextStyle(
fontSize: 17.0,
letterSpacing: 0.5,
),
),
SpaceBetweenTexts(space: 7.0),
Text(
model.vaccineList[index]
.vaccineName,
style: TextStyle(
fontSize: 17.0,
),
),
SpaceBetweenTexts(space: 7.0),
Text(
'Date Taken ' +
convertDateFormat(model
.vaccineList[index]
.invoiceDate),
style:
TextStyle(fontSize: 17.0),
),
],
),
),
],
),
],
),
),
],
);
}),
)
],
),
),
SpaceBetweenTexts(space: 165.0),
Flexible(
child: Container(
width: 350.0,
height: 80.0,
child: Button(
label: 'CHECK VACCINE AVAILABILITY',
backgroundColor: Color(0xff9EA3A4),
),
),
),
Flexible(
child: Container(
width: 350.0,
height: 80.0,
child: Button(
label: 'SEND EMAIL',
backgroundColor: Color(0xffF62426),
onTap: () async {
await PopupBox.showPopupBox(
context: context,
button: MaterialButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
color: Colors.white,
child: Text(
'CANCEL',
style: TextStyle(fontSize: 16.5),
),
onPressed: () {
Navigator.of(context).pop();
},
),
willDisplayWidget: Column(
children: <Widget>[
Text(
'Conform \nSend a copy of this report to the email' +
model.vaccineList[0].doctorName,
style: TextStyle(
fontSize: 20,
color: Colors.black26,
fontWeight: FontWeight.w900),
),
SizedBox(
height: 30.0,
),
],
));
},
),
),
),
],
),
// child: ListView.builder(
// itemCount: model.vaccineList == null ? 0 : model.vaccineList.length,
// itemBuilder: (BuildContext context, int index) {
// return Column(
// children: <Widget>[
// RoundedContainer(
// backgroundColor: Colors.white,
// child: Column(
// children: <Widget>[
// ExpansionTile(
// title: Container(
// height: 60.0,
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: <Widget>[
// Texts('2018'),
// ],
// ),
// ),
// children: <Widget>[
// Column(
// children: <Widget>[
// Row(
// children: <Widget>[
// Column(
// children: <Widget>[
// Padding(
// padding: EdgeInsets.symmetric(
// horizontal: 20.0, vertical: 20.0),
// child: Container(
// child: Image.network(
// model.vaccineList[index]
// .doctorImageURL,
// height: SizeConfig
// .imageSizeMultiplier *
// 23,
// width: SizeConfig
// .imageSizeMultiplier *
// 20,
// fit: BoxFit.fill,
// colorBlendMode:
// BlendMode.hardLight,
// ),
// ),
// )
// ],
// ),
// Container(
// child: Column(
// mainAxisAlignment:
// MainAxisAlignment.start,
// crossAxisAlignment:
// CrossAxisAlignment.start,
// children: <Widget>[
// Text(
// model.vaccineList[index]
// .doctorTitle +
// model.vaccineList[index]
// .doctorName,
// style: TextStyle(
// fontWeight: FontWeight.w900,
// fontSize: 17.5),
// ),
// Text(
// model
// .vaccineList[index].projectName,
// style: TextStyle(
// fontSize: 19.0,
// letterSpacing: 0.3,
// color: Colors.grey,
// fontWeight: FontWeight.bold),
// ),
// Text(
// model
// .vaccineList[index].vaccineName,
// style: TextStyle(
// fontSize: 19.0,
// color: Colors.grey,
// fontWeight: FontWeight.bold),
// ),
// Text(
// 'Date Taken ' +
// convertDateFormat(model
// .vaccineList[index]
// .invoiceDate),
// style: TextStyle(
// fontSize: 19.0,
// color: Colors.grey,
// fontWeight: FontWeight.bold),
// ),
// ],
// ),
// ),
// ],
// ),
// ],
// ),
// ],
// ),
// ],
// ),
// ),
// Container(
// width: 300,
// child: Button(
// label: 'CHECK VACCINE AVAILABILITY',
// backgroundColor: Color(0xff9EA3A4),
// ),
// ),
// Container(
// width: 300,
// child: Button(
// label: 'SEND EMAIL',
// backgroundColor: Color(0xff9EA3A4),
// ),
// ),
// ],
// );
// },
// ),
),
),
);
}
convertDateFormat(String Date) {
const start = "/Date(";
const end = "+0300)";
final startIndex = Date.indexOf(start);
final endIndex = Date.indexOf(end, startIndex + start.length);
var date = new DateTime.fromMillisecondsSinceEpoch(
int.parse(Date.substring(startIndex + start.length, endIndex)));
String newDate = date.year.toString() +
"-" +
date.month.toString().padLeft(2, '0') +
"-" +
date.day.toString().padLeft(2, '0');
return newDate.toString();
}
emailSender() async {
final Email email = Email(
body: 'Email body',
subject: 'Email subject',
recipients: ['example@example.com'],
cc: ['cc@example.com'],
bcc: ['bcc@example.com'],
attachmentPaths: ['/path/to/attachment.zip'],
isHTML: false,
);
await FlutterEmailSender.send(email);
}
}
class SpaceBetweenTexts extends StatelessWidget {
final double space;
SpaceBetweenTexts({this.space});
@override
Widget build(BuildContext context) {
return SizedBox(
height: space,
);
}
}