|
|
|
@ -1,3 +1,7 @@
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
import 'dart:typed_data';
|
|
|
|
|
|
|
|
|
|
import 'package:diplomaticquarterapp/config/config.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/reports/Reports.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/service/medical/reports_service.dart';
|
|
|
|
@ -14,6 +18,8 @@ import 'package:diplomaticquarterapp/widgets/dialogs/confirm_send_email_dialog.d
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/my_rich_text.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:open_file/open_file.dart';
|
|
|
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:rating_bar/rating_bar.dart';
|
|
|
|
|
|
|
|
|
@ -111,10 +117,22 @@ class ReportListWidget extends StatelessWidget {
|
|
|
|
|
if (reportList[index].status == 2)
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(right: 11.0, left: 11.0),
|
|
|
|
|
child: Text(TranslationBase.of(context).viewReport,
|
|
|
|
|
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, fontStyle: FontStyle.italic, color: CustomColors.accentColor, letterSpacing: -0.48, height: 18 / 12, decoration: TextDecoration.underline)),
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
getMedicalReportPDF(report);
|
|
|
|
|
},
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(right: 11.0, left: 11.0),
|
|
|
|
|
child: Text(TranslationBase.of(context).viewReport,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
fontStyle: FontStyle.italic,
|
|
|
|
|
color: CustomColors.accentColor,
|
|
|
|
|
letterSpacing: -0.48,
|
|
|
|
|
height: 18 / 12,
|
|
|
|
|
decoration: TextDecoration.underline)),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: Icon(Icons.email),
|
|
|
|
@ -155,6 +173,26 @@ class ReportListWidget extends StatelessWidget {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getMedicalReportPDF(Reports report) {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(AppGlobal.context);
|
|
|
|
|
ReportsService _reportsService = locator<ReportsService>();
|
|
|
|
|
_reportsService
|
|
|
|
|
.getMedicalReportPDF(report.projectName, report.clinicDescription, report.doctorName, DateUtil.convertDateToString(report.requestDate), report.invoiceNo.toString(), report.projectID,
|
|
|
|
|
DateUtil.convertDateToString(report.requestDate), report.setupId)
|
|
|
|
|
.then((value) async {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(AppGlobal.context);
|
|
|
|
|
try {
|
|
|
|
|
String path = await _createFileFromString(value["MedicalReportBase64"], "pdf");
|
|
|
|
|
OpenFile.open(path);
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
AppToast.showErrorToast(message: "Cannot open file.");
|
|
|
|
|
}
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(AppGlobal.context);
|
|
|
|
|
print(err);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sendReportEmail(Reports report) {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(AppGlobal.context);
|
|
|
|
|
ReportsService _reportsService = locator<ReportsService>();
|
|
|
|
@ -169,4 +207,12 @@ class ReportListWidget extends StatelessWidget {
|
|
|
|
|
print(err);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<String> _createFileFromString(String encodedStr, String ext) async {
|
|
|
|
|
Uint8List bytes = base64.decode(encodedStr);
|
|
|
|
|
String dir = (await getApplicationDocumentsDirectory()).path;
|
|
|
|
|
File file = File("$dir/" + DateTime.now().millisecondsSinceEpoch.toString() + "." + ext);
|
|
|
|
|
await file.writeAsBytes(bytes);
|
|
|
|
|
return file.path;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|