PDF support
This commit is contained in:
parent
e1490c8aa1
commit
9d7ab7279f
|
|
@ -14,6 +14,7 @@ abstract class LocaleCodeAware {
|
||||||
mixin LocalizationsProvider on LocaleCodeAware {
|
mixin LocalizationsProvider on LocaleCodeAware {
|
||||||
static final Map<String, Map<String, String>> _localizedValues = {
|
static final Map<String, Map<String, String>> _localizedValues = {
|
||||||
'en': {
|
'en': {
|
||||||
|
'pdf_min_requirements': 'The PDF renderer requires :version',
|
||||||
'adjust_fee_percent': 'Adjust Fee Percent',
|
'adjust_fee_percent': 'Adjust Fee Percent',
|
||||||
'adjust_fee_percent_help': 'Ensure client fee matches the gateway fee',
|
'adjust_fee_percent_help': 'Ensure client fee matches the gateway fee',
|
||||||
'configure_settings': 'Configure Settings',
|
'configure_settings': 'Configure Settings',
|
||||||
|
|
@ -15866,6 +15867,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
||||||
|
|
||||||
String get adjustFeePercentHelp => _localizedValues[localeCode]['adjust_fee_percent_help'];
|
String get adjustFeePercentHelp => _localizedValues[localeCode]['adjust_fee_percent_help'];
|
||||||
|
|
||||||
|
String get pdfMinRequirements => _localizedValues[localeCode]['pdf_min_requirements'];
|
||||||
|
|
||||||
String lookup(String key) {
|
String lookup(String key) {
|
||||||
final lookupKey = toSnakeCase(key);
|
final lookupKey = toSnakeCase(key);
|
||||||
return _localizedValues[localeCode][lookupKey] ??
|
return _localizedValues[localeCode][lookupKey] ??
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,11 @@ import 'package:invoiceninja_flutter/data/models/invoice_model.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.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:invoiceninja_flutter/utils/platforms.dart';
|
||||||
|
import 'package:native_pdf_view/native_pdf_view.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
import 'package:native_pdf_renderer/native_pdf_renderer.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);
|
||||||
if (Platform.isIOS) {
|
if (Platform.isIOS) {
|
||||||
|
|
@ -56,7 +57,8 @@ Future<Null> viewPdf(InvoiceEntity invoice, BuildContext context) async {
|
||||||
return LoadingIndicator();
|
return LoadingIndicator();
|
||||||
case ConnectionState.done:
|
case ConnectionState.done:
|
||||||
if (snapshot.hasError)
|
if (snapshot.hasError)
|
||||||
return Text('Error: ${snapshot.error}');
|
return Text(
|
||||||
|
'${getPdfRequirements(context)} - Error: ${snapshot.error}');
|
||||||
else
|
else
|
||||||
return snapshot.data.length == 1
|
return snapshot.data.length == 1
|
||||||
? Center(
|
? Center(
|
||||||
|
|
@ -80,10 +82,11 @@ Future<Null> viewPdf(InvoiceEntity invoice, BuildContext context) async {
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: Image(
|
child: ExtendedImage.memory(
|
||||||
image:
|
page.bytes,
|
||||||
MemoryImage(page.bytes),
|
fit: BoxFit.fitHeight,
|
||||||
height: double.infinity),
|
mode: ExtendedImageMode.gesture,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
))
|
))
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import 'package:flutter_redux/flutter_redux.dart';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/ui/pref_state.dart';
|
import 'package:invoiceninja_flutter/redux/ui/pref_state.dart';
|
||||||
|
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||||
|
|
||||||
bool isAndroid(BuildContext context) =>
|
bool isAndroid(BuildContext context) =>
|
||||||
Theme.of(context).platform == TargetPlatform.android;
|
Theme.of(context).platform == TargetPlatform.android;
|
||||||
|
|
@ -15,6 +16,16 @@ String getLegacyAppURL(BuildContext context) => isAndroid(context)
|
||||||
? 'https://play.google.com/store/apps/details?id=com.invoiceninja.invoiceninja'
|
? 'https://play.google.com/store/apps/details?id=com.invoiceninja.invoiceninja'
|
||||||
: 'https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1220337560&mt=8';
|
: 'https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1220337560&mt=8';
|
||||||
|
|
||||||
|
String getPdfRequirements(BuildContext context) {
|
||||||
|
final localization = AppLocalization.of(context);
|
||||||
|
if (isMobile(context)) {
|
||||||
|
final version = isAndroid(context) ? 'Android 5.0+' : 'iOS 11.0+';
|
||||||
|
return localization.pdfMinRequirements.replaceFirst(':version', version);
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String getPlatform(BuildContext context) =>
|
String getPlatform(BuildContext context) =>
|
||||||
Theme.of(context).platform == TargetPlatform.iOS ? 'ios' : 'android';
|
Theme.of(context).platform == TargetPlatform.iOS ? 'ios' : 'android';
|
||||||
|
|
||||||
|
|
|
||||||
30
pubspec.lock
30
pubspec.lock
|
|
@ -190,6 +190,20 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.3"
|
version: "1.3.3"
|
||||||
|
extended_image:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: extended_image
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.6.8"
|
||||||
|
extended_image_library:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: extended_image_library
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.9"
|
||||||
extension:
|
extension:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -395,6 +409,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.0+2"
|
version: "0.12.0+2"
|
||||||
|
http_client_helper:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: http_client_helper
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.1"
|
||||||
http_multi_server:
|
http_multi_server:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -522,12 +543,19 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.2"
|
version: "1.0.2"
|
||||||
native_pdf_renderer:
|
native_pdf_renderer:
|
||||||
dependency: "direct main"
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: native_pdf_renderer
|
name: native_pdf_renderer
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.6.1"
|
version: "1.6.1"
|
||||||
|
native_pdf_view:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: native_pdf_view
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
node_interop:
|
node_interop:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@ dependencies:
|
||||||
flutter_json_widget: ^1.0.2
|
flutter_json_widget: ^1.0.2
|
||||||
webview_flutter: ^0.3.15+1
|
webview_flutter: ^0.3.15+1
|
||||||
timeago: ^2.0.22
|
timeago: ^2.0.22
|
||||||
native_pdf_renderer: any
|
#native_pdf_renderer: any
|
||||||
|
native_pdf_view: any
|
||||||
flutter_typeahead: ^1.7.0
|
flutter_typeahead: ^1.7.0
|
||||||
#quick_actions: ^0.2.1
|
#quick_actions: ^0.2.1
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue