@ -24,6 +24,7 @@ import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import ' package:open_filex/open_filex.dart ' ;
import ' package:path_provider/path_provider.dart ' ;
import ' package:provider/provider.dart ' ;
import ' package:share_plus/share_plus.dart ' ;
class ReportListWidget extends StatelessWidget {
final List < Reports > reportList ;
@ -131,31 +132,48 @@ class ReportListWidget extends StatelessWidget {
if ( reportList [ index ] . status = = 2 )
Row (
children: [
/ / 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 ) ,
color: Color ( 0xff28323A ) ,
constraints: BoxConstraints ( ) ,
padding: EdgeInsets . zero ,
onPressed: ( ) {
showConfirmMessage ( reportList [ index ] ) ;
} )
InkWell (
onTap: ( ) {
getMedicalReportPDF ( report , false ) ;
} ,
child: Padding (
padding: const EdgeInsets . only ( right: 11.0 , left: 11.0 ) ,
child: Text ( TranslationBase . of ( context ) . download ,
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 , true ) ;
} ,
child: Padding (
padding: const EdgeInsets . only ( right: 11.0 , left: 11.0 ) ,
child: Text ( TranslationBase . of ( context ) . share ,
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 ) ,
/ / color: Color ( 0xff28323A ) ,
/ / constraints: BoxConstraints ( ) ,
/ / padding: EdgeInsets . zero ,
/ / onPressed: ( ) {
/ / showConfirmMessage ( reportList [ index ] ) ;
/ / } )
] ,
) ,
] ,
@ -187,7 +205,7 @@ class ReportListWidget extends StatelessWidget {
) ;
}
void getMedicalReportPDF ( Reports report ) {
void getMedicalReportPDF ( Reports report , bool isShare ) {
GifLoaderDialogUtils . showMyDialog ( AppGlobal . context ) ;
ReportsService _reportsService = locator < ReportsService > ( ) ;
_reportsService
@ -195,11 +213,15 @@ class ReportListWidget extends StatelessWidget {
DateUtil . convertDateToString ( report . requestDate ! ) , report . setupId ! )
. then ( ( value ) async {
GifLoaderDialogUtils . hideDialog ( AppGlobal . context ) ;
try {
String path = await _createFileFromString ( value [ " MedicalReportBase64 " ] , " pdf " ) ;
OpenFilex . open ( path ) ;
} catch ( ex ) {
AppToast . showErrorToast ( message: " Cannot open file. " ) ;
String path = await _createFileFromString ( value [ " MedicalReportBase64 " ] , " pdf " ) ;
if ( isShare ) {
Share . shareXFiles ( [ XFile ( path ) ] , text: " Medical Report " ) ;
} else {
try {
OpenFilex . open ( path ) ;
} catch ( ex ) {
AppToast . showErrorToast ( message: " Cannot open file. " ) ;
}
}
} ) . catchError ( ( err ) {
GifLoaderDialogUtils . hideDialog ( AppGlobal . context ) ;