Printing [WIP]
This commit is contained in:
parent
f0cda7bf4d
commit
c1cef9dda2
|
|
@ -850,6 +850,7 @@ abstract class InvoiceEntity extends Object
|
|||
actions.add(EntityAction.viewPdf);
|
||||
if (!isRecurring) {
|
||||
actions.add(EntityAction.download);
|
||||
//actions.add(EntityAction.printPdf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ class EntityAction extends EnumClass {
|
|||
static const EntityAction viewPdf = _$viewPdf;
|
||||
static const EntityAction viewStatement = _$viewStatement;
|
||||
static const EntityAction more = _$more;
|
||||
static const EntityAction printPdf = _$printPdf;
|
||||
static const EntityAction start = _$start;
|
||||
static const EntityAction resume = _$resume;
|
||||
static const EntityAction stop = _$stop;
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ const EntityAction _$refundPayment = const EntityAction._('refundPayment');
|
|||
const EntityAction _$viewPdf = const EntityAction._('viewPdf');
|
||||
const EntityAction _$viewStatement = const EntityAction._('viewStatement');
|
||||
const EntityAction _$more = const EntityAction._('more');
|
||||
const EntityAction _$printPdf = const EntityAction._('printPdf');
|
||||
const EntityAction _$start = const EntityAction._('start');
|
||||
const EntityAction _$resume = const EntityAction._('resume');
|
||||
const EntityAction _$stop = const EntityAction._('stop');
|
||||
|
|
@ -163,6 +164,8 @@ EntityAction _$valueOf(String name) {
|
|||
return _$viewStatement;
|
||||
case 'more':
|
||||
return _$more;
|
||||
case 'printPdf':
|
||||
return _$printPdf;
|
||||
case 'start':
|
||||
return _$start;
|
||||
case 'resume':
|
||||
|
|
@ -239,6 +242,7 @@ final BuiltSet<EntityAction> _$values =
|
|||
_$viewPdf,
|
||||
_$viewStatement,
|
||||
_$more,
|
||||
_$printPdf,
|
||||
_$start,
|
||||
_$resume,
|
||||
_$stop,
|
||||
|
|
|
|||
|
|
@ -6,9 +6,12 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/widgets.dart';
|
||||
|
||||
// Package imports:
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:invoiceninja_flutter/data/web_client.dart';
|
||||
import 'package:printing/printing.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
// Project imports:
|
||||
|
|
@ -704,6 +707,13 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
|
|||
}
|
||||
}
|
||||
break;
|
||||
case EntityAction.printPdf:
|
||||
final invitation = invoice.invitations.first;
|
||||
final url = invitation.downloadLink;
|
||||
final http.Response response =
|
||||
await WebClient().get(url, '', rawResponse: true);
|
||||
await Printing.layoutPdf(onLayout: (_) => response.bodyBytes);
|
||||
break;
|
||||
case EntityAction.more:
|
||||
showEntityActionsDialog(
|
||||
entities: [invoice],
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
static final Map<String, Map<String, String>> _localizedValues = {
|
||||
'en': {
|
||||
// STARTER: lang key - do not remove comment
|
||||
'print_pdf': 'Print PDF',
|
||||
'remind_me': 'Remind Me',
|
||||
'instant_bank_pay': 'Instant Bank Pay',
|
||||
'click_selected': 'Click Selected',
|
||||
|
|
@ -62839,6 +62840,10 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
_localizedValues[localeCode]['remind_me'] ??
|
||||
_localizedValues['en']['remind_me'];
|
||||
|
||||
String get printPdf =>
|
||||
_localizedValues[localeCode]['print_pdf'] ??
|
||||
_localizedValues['en']['print_pdf'];
|
||||
|
||||
// STARTER: lang field - do not remove comment
|
||||
|
||||
String lookup(String key) {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ IconData getEntityActionIcon(EntityAction entityAction) {
|
|||
case EntityAction.viewPdf:
|
||||
case EntityAction.bulkDownload:
|
||||
return Icons.picture_as_pdf;
|
||||
case EntityAction.printPdf:
|
||||
return Icons.print;
|
||||
case EntityAction.download:
|
||||
return Icons.download;
|
||||
case EntityAction.clientPortal:
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ dependencies:
|
|||
contacts_service: ^0.6.1
|
||||
super_editor: ^0.1.0
|
||||
diacritic: ^0.1.3
|
||||
# printing: ^5.6.3
|
||||
# quick_actions: ^0.2.1
|
||||
# idb_shim: ^1.11.1+1
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue