update invoice
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pdfview/flutter_pdfview.dart';
|
||||
import 'package:image_downloader/image_downloader.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:share/share.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class PaymentPDFScreen extends StatefulWidget {
|
||||
final String path;
|
||||
@@ -41,14 +48,13 @@ class _PaymentPDFScreenState extends State<PaymentPDFScreen>
|
||||
IconButton(
|
||||
icon: Icon(Icons.file_download),
|
||||
onPressed: () async {
|
||||
print('image path => ${widget.path}');
|
||||
await ImageDownloader.downloadImage(widget.path,
|
||||
destination: AndroidDestinationType.directoryDownloads);
|
||||
// var _dir = (await getApplicationDocumentsDirectory()).path;
|
||||
// _downloadFile(widget.path, 'invoice.pdf', _dir);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.share),
|
||||
onPressed: () {},
|
||||
onPressed: () => _share(widget.path),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -72,18 +78,6 @@ class _PaymentPDFScreenState extends State<PaymentPDFScreen>
|
||||
isReady = true;
|
||||
});
|
||||
},
|
||||
// onError: (error) {
|
||||
// setState(() {
|
||||
// errorMessage = error.toString();
|
||||
// });
|
||||
// print(error.toString());
|
||||
// },
|
||||
// onPageError: (page, error) {
|
||||
// setState(() {
|
||||
// errorMessage = '$page: ${error.toString()}';
|
||||
// });
|
||||
// print('$page: ${error.toString()}');
|
||||
// },
|
||||
onViewCreated: (PDFViewController pdfViewController) {
|
||||
_controller.complete(pdfViewController);
|
||||
},
|
||||
@@ -97,32 +91,24 @@ class _PaymentPDFScreenState extends State<PaymentPDFScreen>
|
||||
});
|
||||
},
|
||||
),
|
||||
// errorMessage.isEmpty
|
||||
// ? !isReady
|
||||
// ? Center(
|
||||
// child: CircularProgressIndicator(),
|
||||
// )
|
||||
// : Container()
|
||||
// : Center(
|
||||
// child: Text(errorMessage),
|
||||
// )
|
||||
],
|
||||
),
|
||||
// floatingActionButton: FutureBuilder<PDFViewController>(
|
||||
// future: _controller.future,
|
||||
// builder: (context, AsyncSnapshot<PDFViewController> snapshot) {
|
||||
// if (snapshot.hasData) {
|
||||
// return FloatingActionButton.extended(
|
||||
// label: Text("Go to ${pages ~/ 2}"),
|
||||
// onPressed: () async {
|
||||
// await snapshot.data.setPage(pages ~/ 2);
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
// return Container();
|
||||
// },
|
||||
// ),
|
||||
);
|
||||
}
|
||||
|
||||
Future<File> _downloadFile(String url, String filename, String dir) async {
|
||||
var req = await http.Client().get(Uri.parse(url));
|
||||
var file = File('$dir/$filename');
|
||||
return file.writeAsBytes(req.bodyBytes);
|
||||
}
|
||||
|
||||
_share(String url) async {
|
||||
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
|
||||
String appUrl = mainModel.setting.appUrl;
|
||||
final RenderBox box = context.findRenderObject();
|
||||
await Share.share(
|
||||
"Join us on FCS Logistics App. Here is the link:\n $appUrl\n" + url,
|
||||
subject: "Invitation to FCS Logistics App",
|
||||
sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user