Update PDF
This commit is contained in:
parent
bda512d863
commit
347a1ac605
|
|
@ -42,7 +42,7 @@ android {
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.invoiceninja.client"
|
applicationId "com.invoiceninja.client"
|
||||||
minSdkVersion 16
|
minSdkVersion 19
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ android {
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.invoiceninja.client"
|
applicationId "com.invoiceninja.client"
|
||||||
minSdkVersion 16
|
minSdkVersion 19
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,9 @@ class InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
||||||
//showPerformanceOverlay: true,
|
//showPerformanceOverlay: true,
|
||||||
localizationsDelegates: [
|
localizationsDelegates: [
|
||||||
const AppLocalizationsDelegate(),
|
const AppLocalizationsDelegate(),
|
||||||
GlobalMaterialLocalizations.delegate,
|
GlobalCupertinoLocalizations.delegate,
|
||||||
|
GlobalWidgetsLocalizations.delegate,
|
||||||
|
GlobalMaterialLocalizations.delegate
|
||||||
],
|
],
|
||||||
home: state.uiState.requireAuthentication && !_authenticated
|
home: state.uiState.requireAuthentication && !_authenticated
|
||||||
? Material(
|
? Material(
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart';
|
import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/resources/cached_image.dart';
|
import 'package:invoiceninja_flutter/ui/app/resources/cached_image.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/upgrade_dialog.dart';
|
import 'package:invoiceninja_flutter/ui/app/upgrade_dialog.dart';
|
||||||
|
import 'package:invoiceninja_flutter/utils/pdf.dart';
|
||||||
import 'package:redux/redux.dart';
|
import 'package:redux/redux.dart';
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
|
|
@ -475,6 +476,8 @@ class SidebarFooter extends StatelessWidget {
|
||||||
Icons.warning,
|
Icons.warning,
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
),
|
),
|
||||||
|
onPressed: () => viewPdf(InvoiceEntity(), context),
|
||||||
|
/*
|
||||||
onPressed: () => showDialog<ErrorDialog>(
|
onPressed: () => showDialog<ErrorDialog>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
|
|
@ -483,6 +486,7 @@ class SidebarFooter extends StatelessWidget {
|
||||||
clearErrorOnDismiss: true,
|
clearErrorOnDismiss: true,
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
*/
|
||||||
),
|
),
|
||||||
if (!Platform.isIOS &&
|
if (!Platform.isIOS &&
|
||||||
isHosted(context) &&
|
isHosted(context) &&
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:typed_data';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/invoice_model.dart';
|
import 'package:invoiceninja_flutter/data/models/invoice_model.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/loading_indicator.dart';
|
import 'package:invoiceninja_flutter/ui/app/loading_indicator.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:flutter_pdfview/flutter_pdfview.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
import 'package:native_pdf_renderer/native_pdf_renderer.dart';
|
||||||
|
|
||||||
Future<Null> viewPdf(InvoiceEntity invoice, BuildContext context) async {
|
Future<Null> viewPdf(InvoiceEntity invoice, BuildContext context) async {
|
||||||
final localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
|
|
@ -46,7 +47,8 @@ Future<Null> viewPdf(InvoiceEntity invoice, BuildContext context) async {
|
||||||
),
|
),
|
||||||
body: FutureBuilder(
|
body: FutureBuilder(
|
||||||
future: createFileOfPdfUrl(invoice.invitationDownloadLink),
|
future: createFileOfPdfUrl(invoice.invitationDownloadLink),
|
||||||
builder: (BuildContext context, AsyncSnapshot<File> snapshot) {
|
builder:
|
||||||
|
(BuildContext context, AsyncSnapshot<PDFPageImage> snapshot) {
|
||||||
switch (snapshot.connectionState) {
|
switch (snapshot.connectionState) {
|
||||||
case ConnectionState.none:
|
case ConnectionState.none:
|
||||||
case ConnectionState.active:
|
case ConnectionState.active:
|
||||||
|
|
@ -56,7 +58,14 @@ Future<Null> viewPdf(InvoiceEntity invoice, BuildContext context) async {
|
||||||
if (snapshot.hasError)
|
if (snapshot.hasError)
|
||||||
return Text('Error: ${snapshot.error}');
|
return Text('Error: ${snapshot.error}');
|
||||||
else
|
else
|
||||||
return PDFView(filePath: snapshot.data.path);
|
return Container(
|
||||||
|
color: Colors.white,
|
||||||
|
width: double.infinity,
|
||||||
|
child: Image(
|
||||||
|
height: double.infinity,
|
||||||
|
image: MemoryImage(snapshot.data.bytes),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return null; // unreachable
|
return null; // unreachable
|
||||||
}),
|
}),
|
||||||
|
|
@ -64,13 +73,27 @@ Future<Null> viewPdf(InvoiceEntity invoice, BuildContext context) async {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<File> createFileOfPdfUrl(String url) async {
|
Future<PDFPageImage> createFileOfPdfUrl(String url) async {
|
||||||
final filename = url.substring(url.lastIndexOf('/') + 1);
|
final filename = url.substring(url.lastIndexOf('/') + 1);
|
||||||
|
|
||||||
|
url =
|
||||||
|
'https://staging.invoiceninja.com/download/gj5d2udwzowatfsjibarq4eyo4k0cvpd';
|
||||||
|
|
||||||
final request = await HttpClient().getUrl(Uri.parse(url));
|
final request = await HttpClient().getUrl(Uri.parse(url));
|
||||||
final response = await request.close();
|
final response = await request.close();
|
||||||
final bytes = await consolidateHttpClientResponseBytes(response);
|
final bytes = await consolidateHttpClientResponseBytes(response);
|
||||||
|
|
||||||
|
final document = await PDFDocument.openData(bytes);
|
||||||
|
final page = await document.getPage(1);
|
||||||
|
final pageImage = await page.render(width: page.width, height: page.height);
|
||||||
|
await page.close();
|
||||||
|
|
||||||
|
return pageImage;
|
||||||
|
|
||||||
|
/*
|
||||||
final dir = (await getApplicationDocumentsDirectory()).path;
|
final dir = (await getApplicationDocumentsDirectory()).path;
|
||||||
final file = new File('$dir/$filename');
|
final file = new File('$dir/$filename');
|
||||||
await file.writeAsBytes(bytes);
|
await file.writeAsBytes(bytes);
|
||||||
return file;
|
return file;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
||||||
21
pubspec.lock
21
pubspec.lock
|
|
@ -176,6 +176,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.9"
|
version: "1.2.9"
|
||||||
|
extension:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: extension
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.0.5"
|
||||||
faker:
|
faker:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
|
|
@ -233,13 +240,6 @@ packages:
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
flutter_pdfview:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: flutter_pdfview
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "1.0.0+9"
|
|
||||||
flutter_redux:
|
flutter_redux:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
@ -432,6 +432,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.2"
|
version: "1.0.2"
|
||||||
|
native_pdf_renderer:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: native_pdf_renderer
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.5.0"
|
||||||
node_preamble:
|
node_preamble:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
name: invoiceninja_flutter
|
name: invoiceninja_flutter
|
||||||
description: Mobile app for Invoice Ninja
|
description: Client for Invoice Ninja
|
||||||
version: 2.0.0+0
|
version: 2.0.0+0
|
||||||
author: Hillel Coren
|
author: Hillel Coren
|
||||||
homepage: https://www.invoiceninja.com
|
homepage: https://www.invoiceninja.com
|
||||||
|
|
@ -34,7 +34,7 @@ dependencies:
|
||||||
local_auth: ^0.5.2+4
|
local_auth: ^0.5.2+4
|
||||||
sentry: ^2.2.0
|
sentry: ^2.2.0
|
||||||
image_picker: ^0.6.1+4
|
image_picker: ^0.6.1+4
|
||||||
flutter_pdfview: ^1.0.0+9
|
native_pdf_renderer: any
|
||||||
#quick_actions: ^0.2.1
|
#quick_actions: ^0.2.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue