Skip to content

Commit e1490c8

Browse files
committed
PDF support
1 parent 54098c2 commit e1490c8

File tree

5 files changed

+111
-42
lines changed

5 files changed

+111
-42
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
#.android/
7676
#.ios/
7777

78+
lib/generated_plugin_registrant.dart
7879
.flutter-plugins-dependencies
7980
.env.dart
8081
key.properties

lib/ui/app/menu_drawer.dart

+15-15
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:flutter/gestures.dart';
33
import 'package:flutter/material.dart';
44
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
55
import 'package:invoiceninja_flutter/ui/app/debug/state_inspector.dart';
6+
import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart';
67
import 'package:invoiceninja_flutter/ui/app/loading_indicator.dart';
78
import 'package:invoiceninja_flutter/ui/app/resources/cached_image.dart';
89
import 'package:invoiceninja_flutter/utils/pdf.dart';
@@ -351,23 +352,24 @@ class SidebarFooter extends StatelessWidget {
351352
return StateInspector();
352353
}),
353354
),
354-
if (state.lastError.isNotEmpty)
355+
IconButton(
356+
icon: Icon(Icons.filter),
357+
onPressed: () => viewPdf(InvoiceEntity(), context),
358+
),
359+
if (state.lastError.isNotEmpty && !kReleaseMode)
355360
IconButton(
356361
icon: Icon(
357362
Icons.warning,
358363
color: Colors.red,
359364
),
360-
onPressed: () => viewPdf(InvoiceEntity(), context),
361-
/*
362-
onPressed: () => showDialog<ErrorDialog>(
363-
context: context,
364-
builder: (BuildContext context) {
365-
return ErrorDialog(
366-
state.lastError,
367-
clearErrorOnDismiss: true,
368-
);
369-
}),
370-
*/
365+
onPressed: () => showDialog<ErrorDialog>(
366+
context: context,
367+
builder: (BuildContext context) {
368+
return ErrorDialog(
369+
state.lastError,
370+
clearErrorOnDismiss: true,
371+
);
372+
}),
371373
),
372374
/*
373375
if (!Platform.isIOS &&
@@ -439,13 +441,11 @@ class SidebarFooterCollapsed extends StatelessWidget {
439441
}
440442

441443
void _showAbout(BuildContext context) {
442-
443444
final localization = AppLocalization.of(context);
444445
final ThemeData themeData = Theme.of(context);
445446
final TextStyle aboutTextStyle = themeData.textTheme.body2;
446447
final TextStyle linkStyle =
447-
themeData.textTheme.body2.copyWith(color: themeData.accentColor);
448-
448+
themeData.textTheme.body2.copyWith(color: themeData.accentColor);
449449

450450
showAboutDialog(
451451
context: context,

lib/utils/pdf.dart

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import 'dart:async';
2+
import 'dart:io';
23
import 'package:flutter/material.dart';
34
import 'package:invoiceninja_flutter/data/models/invoice_model.dart';
4-
/*
5-
import 'dart:io';
65
import 'package:flutter/foundation.dart';
76
import 'package:invoiceninja_flutter/ui/app/loading_indicator.dart';
87
import 'package:invoiceninja_flutter/utils/localization.dart';
98
import 'package:url_launcher/url_launcher.dart';
109
import 'package:native_pdf_renderer/native_pdf_renderer.dart';
11-
*/
1210

1311

1412
Future<Null> viewPdf(InvoiceEntity invoice, BuildContext context) async {
15-
/*
1613
final localization = AppLocalization.of(context);
1714
if (Platform.isIOS) {
1815
if (await canLaunch(invoice.invitationBorderlessLink)) {
@@ -98,11 +95,8 @@ Future<Null> viewPdf(InvoiceEntity invoice, BuildContext context) async {
9895
),
9996
);
10097
});
101-
102-
*/
10398
}
10499

105-
/*
106100
Future<List<PDFPageImage>> renderPDF(String url) async {
107101
url =
108102
//'https://staging.invoiceninja.com/download/gj5d2udwzowatfsjibarq4eyo4k0cvpd'; // one page
@@ -123,4 +117,3 @@ Future<List<PDFPageImage>> renderPDF(String url) async {
123117

124118
return pages;
125119
}
126-
*/

pubspec.lock

+93-18
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ packages:
8484
name: build_runner_core
8585
url: "https://pub.dartlang.org"
8686
source: hosted
87-
version: "4.2.0"
87+
version: "4.3.0"
8888
built_collection:
8989
dependency: "direct main"
9090
description:
@@ -190,6 +190,13 @@ packages:
190190
url: "https://pub.dartlang.org"
191191
source: hosted
192192
version: "1.3.3"
193+
extension:
194+
dependency: transitive
195+
description:
196+
name: extension
197+
url: "https://pub.dartlang.org"
198+
source: hosted
199+
version: "0.0.5"
193200
faker:
194201
dependency: "direct dev"
195202
description:
@@ -204,6 +211,13 @@ packages:
204211
url: "https://pub.dartlang.org"
205212
source: hosted
206213
version: "5.1.0"
214+
firebase:
215+
dependency: transitive
216+
description:
217+
name: firebase
218+
url: "https://pub.dartlang.org"
219+
source: hosted
220+
version: "7.1.0"
207221
firebase_auth:
208222
dependency: "direct main"
209223
description:
@@ -217,14 +231,21 @@ packages:
217231
name: firebase_core
218232
url: "https://pub.dartlang.org"
219233
source: hosted
220-
version: "0.4.2+1"
234+
version: "0.4.3+1"
221235
firebase_core_platform_interface:
222236
dependency: transitive
223237
description:
224238
name: firebase_core_platform_interface
225239
url: "https://pub.dartlang.org"
226240
source: hosted
227-
version: "1.0.0"
241+
version: "1.0.2"
242+
firebase_core_web:
243+
dependency: transitive
244+
description:
245+
name: firebase_core_web
246+
url: "https://pub.dartlang.org"
247+
source: hosted
248+
version: "0.1.1+1"
228249
fixnum:
229250
dependency: transitive
230251
description:
@@ -301,6 +322,11 @@ packages:
301322
url: "https://pub.dartlang.org"
302323
source: hosted
303324
version: "1.7.0"
325+
flutter_web_plugins:
326+
dependency: transitive
327+
description: flutter
328+
source: sdk
329+
version: "0.0.0"
304330
font_awesome_flutter:
305331
dependency: "direct main"
306332
description:
@@ -333,14 +359,21 @@ packages:
333359
name: google_sign_in
334360
url: "https://pub.dartlang.org"
335361
source: hosted
336-
version: "4.0.14"
362+
version: "4.1.1"
337363
google_sign_in_platform_interface:
338364
dependency: transitive
339365
description:
340366
name: google_sign_in_platform_interface
341367
url: "https://pub.dartlang.org"
342368
source: hosted
343-
version: "1.0.0"
369+
version: "1.0.3"
370+
google_sign_in_web:
371+
dependency: transitive
372+
description:
373+
name: google_sign_in_web
374+
url: "https://pub.dartlang.org"
375+
source: hosted
376+
version: "0.8.2+1"
344377
graphs:
345378
dependency: transitive
346379
description:
@@ -389,14 +422,14 @@ packages:
389422
name: image_picker
390423
url: "https://pub.dartlang.org"
391424
source: hosted
392-
version: "0.6.2+1"
425+
version: "0.6.2+3"
393426
in_app_purchase:
394427
dependency: "direct main"
395428
description:
396429
name: in_app_purchase
397430
url: "https://pub.dartlang.org"
398431
source: hosted
399-
version: "0.2.2+3"
432+
version: "0.2.2+4"
400433
intl:
401434
dependency: "direct main"
402435
description:
@@ -488,6 +521,13 @@ packages:
488521
url: "https://pub.dartlang.org"
489522
source: hosted
490523
version: "1.0.2"
524+
native_pdf_renderer:
525+
dependency: "direct main"
526+
description:
527+
name: native_pdf_renderer
528+
url: "https://pub.dartlang.org"
529+
source: hosted
530+
version: "1.6.1"
491531
node_interop:
492532
dependency: transitive
493533
description:
@@ -543,7 +583,7 @@ packages:
543583
name: path_provider
544584
url: "https://pub.dartlang.org"
545585
source: hosted
546-
version: "1.4.5"
586+
version: "1.5.1"
547587
pedantic:
548588
dependency: transitive
549589
description:
@@ -565,6 +605,13 @@ packages:
565605
url: "https://pub.dartlang.org"
566606
source: hosted
567607
version: "2.2.1"
608+
plugin_platform_interface:
609+
dependency: transitive
610+
description:
611+
name: plugin_platform_interface
612+
url: "https://pub.dartlang.org"
613+
source: hosted
614+
version: "1.0.1"
568615
pool:
569616
dependency: transitive
570617
description:
@@ -641,21 +688,35 @@ packages:
641688
name: share
642689
url: "https://pub.dartlang.org"
643690
source: hosted
644-
version: "0.6.3+4"
691+
version: "0.6.3+5"
645692
shared_preferences:
646693
dependency: "direct main"
647694
description:
648695
name: shared_preferences
649696
url: "https://pub.dartlang.org"
650697
source: hosted
651-
version: "0.5.4+8"
698+
version: "0.5.6"
699+
shared_preferences_macos:
700+
dependency: transitive
701+
description:
702+
name: shared_preferences_macos
703+
url: "https://pub.dartlang.org"
704+
source: hosted
705+
version: "0.0.1+3"
652706
shared_preferences_platform_interface:
653707
dependency: transitive
654708
description:
655709
name: shared_preferences_platform_interface
656710
url: "https://pub.dartlang.org"
657711
source: hosted
658-
version: "1.0.0"
712+
version: "1.0.1"
713+
shared_preferences_web:
714+
dependency: transitive
715+
description:
716+
name: shared_preferences_web
717+
url: "https://pub.dartlang.org"
718+
source: hosted
719+
version: "0.1.2+2"
659720
shelf:
660721
dependency: transitive
661722
description:
@@ -723,7 +784,7 @@ packages:
723784
name: sqflite
724785
url: "https://pub.dartlang.org"
725786
source: hosted
726-
version: "1.1.7+3"
787+
version: "1.2.0"
727788
stack_trace:
728789
dependency: transitive
729790
description:
@@ -758,7 +819,7 @@ packages:
758819
name: synchronized
759820
url: "https://pub.dartlang.org"
760821
source: hosted
761-
version: "2.1.0+2"
822+
version: "2.1.1"
762823
term_glyph:
763824
dependency: transitive
764825
description:
@@ -814,14 +875,28 @@ packages:
814875
name: url_launcher
815876
url: "https://pub.dartlang.org"
816877
source: hosted
817-
version: "5.2.7"
878+
version: "5.4.1"
879+
url_launcher_macos:
880+
dependency: transitive
881+
description:
882+
name: url_launcher_macos
883+
url: "https://pub.dartlang.org"
884+
source: hosted
885+
version: "0.0.1+2"
818886
url_launcher_platform_interface:
819887
dependency: transitive
820888
description:
821889
name: url_launcher_platform_interface
822890
url: "https://pub.dartlang.org"
823891
source: hosted
824-
version: "1.0.1"
892+
version: "1.0.5"
893+
url_launcher_web:
894+
dependency: transitive
895+
description:
896+
name: url_launcher_web
897+
url: "https://pub.dartlang.org"
898+
source: hosted
899+
version: "0.1.0+2"
825900
usage:
826901
dependency: transitive
827902
description:
@@ -849,7 +924,7 @@ packages:
849924
name: vm_service
850925
url: "https://pub.dartlang.org"
851926
source: hosted
852-
version: "2.1.3"
927+
version: "2.1.4"
853928
vm_service_client:
854929
dependency: transitive
855930
description:
@@ -877,7 +952,7 @@ packages:
877952
name: webview_flutter
878953
url: "https://pub.dartlang.org"
879954
source: hosted
880-
version: "0.3.17"
955+
version: "0.3.18+1"
881956
xml:
882957
dependency: transitive
883958
description:
@@ -901,4 +976,4 @@ packages:
901976
version: "0.8.0"
902977
sdks:
903978
dart: ">=2.6.0 <3.0.0"
904-
flutter: ">=1.10.15-pre.148 <2.0.0"
979+
flutter: ">=1.12.13+hotfix.4 <2.0.0"

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ dependencies:
4040
flutter_json_widget: ^1.0.2
4141
webview_flutter: ^0.3.15+1
4242
timeago: ^2.0.22
43-
#native_pdf_renderer: any
43+
native_pdf_renderer: any
4444
flutter_typeahead: ^1.7.0
4545
#quick_actions: ^0.2.1
4646

0 commit comments

Comments
 (0)