fullscreen: print
This commit is contained in:
parent
f73c72973a
commit
cc869df575
4 changed files with 68 additions and 2 deletions
|
@ -12,8 +12,10 @@ import 'package:flushbar/flushbar.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:pdf/widgets.dart' as pdf;
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
import 'package:photo_view/photo_view_gallery.dart';
|
||||
import 'package:printing/printing.dart';
|
||||
import 'package:screen/screen.dart';
|
||||
|
||||
class FullscreenPage extends AnimatedWidget {
|
||||
|
@ -236,6 +238,9 @@ class FullscreenBodyState extends State<FullscreenBody> with SingleTickerProvide
|
|||
case FullscreenAction.openMap:
|
||||
AndroidAppService.openMap(entry.geoUri);
|
||||
break;
|
||||
case FullscreenAction.print:
|
||||
print(entry);
|
||||
break;
|
||||
case FullscreenAction.rotateCCW:
|
||||
rotate(entry, clockwise: false);
|
||||
break;
|
||||
|
@ -264,6 +269,19 @@ class FullscreenBodyState extends State<FullscreenBody> with SingleTickerProvide
|
|||
)..show(context);
|
||||
}
|
||||
|
||||
print(ImageEntry entry) async {
|
||||
final doc = pdf.Document(title: entry.title);
|
||||
final image = await pdfImageFromImageProvider(
|
||||
pdf: doc.document,
|
||||
image: FileImage(File(entry.path)),
|
||||
);
|
||||
doc.addPage(pdf.Page(build: (context) => pdf.Center(child: pdf.Image(image)))); // Page
|
||||
Printing.layoutPdf(
|
||||
onLayout: (format) => doc.save(),
|
||||
name: entry.title,
|
||||
);
|
||||
}
|
||||
|
||||
rotate(ImageEntry entry, {@required bool clockwise}) async {
|
||||
final success = await entry.rotate(clockwise: clockwise);
|
||||
showFeedback(success ? 'Done!' : 'Failed');
|
||||
|
@ -320,7 +338,7 @@ class FullscreenBodyState extends State<FullscreenBody> with SingleTickerProvide
|
|||
}
|
||||
}
|
||||
|
||||
enum FullscreenAction { delete, edit, info, open, openMap, rename, rotateCCW, rotateCW, setAs, share }
|
||||
enum FullscreenAction { delete, edit, info, open, openMap, print, rename, rotateCCW, rotateCW, setAs, share }
|
||||
|
||||
class ImagePage extends StatefulWidget {
|
||||
final ImageCollection collection;
|
||||
|
|
|
@ -71,6 +71,10 @@ class FullscreenTopOverlay extends StatelessWidget {
|
|||
value: FullscreenAction.rotateCW,
|
||||
child: MenuRow(text: 'Rotate right', icon: Icons.rotate_right),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: FullscreenAction.print,
|
||||
child: MenuRow(text: 'Print', icon: Icons.print),
|
||||
),
|
||||
PopupMenuDivider(),
|
||||
PopupMenuItem(
|
||||
value: FullscreenAction.edit,
|
||||
|
|
44
pubspec.lock
44
pubspec.lock
|
@ -8,6 +8,20 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.7+2"
|
||||
archive:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: archive
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.10"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: args
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.5.2"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -50,6 +64,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
flushbar:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -144,6 +165,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.4"
|
||||
pdf:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: pdf
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.18"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -172,6 +200,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.2"
|
||||
printing:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: printing
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.3"
|
||||
quiver:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -275,6 +310,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.6"
|
||||
utf:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: utf
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.9.0+5"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -298,4 +340,4 @@ packages:
|
|||
version: "3.5.0"
|
||||
sdks:
|
||||
dart: ">=2.4.0 <3.0.0"
|
||||
flutter: ">=1.5.9-pre.94 <2.0.0"
|
||||
flutter: ">=1.7.0 <2.0.0"
|
||||
|
|
|
@ -28,8 +28,10 @@ dependencies:
|
|||
google_maps_flutter:
|
||||
intl:
|
||||
path:
|
||||
pdf:
|
||||
permission_handler:
|
||||
photo_view:
|
||||
printing:
|
||||
screen:
|
||||
shared_preferences:
|
||||
sqflite:
|
||||
|
|
Loading…
Reference in a new issue