Add page buttons to PDF preview
This commit is contained in:
parent
2acbee7f4f
commit
89a7c9e8a4
|
|
@ -54,6 +54,8 @@ class ClientPdfView extends StatefulWidget {
|
|||
class _ClientPdfViewState extends State<ClientPdfView> {
|
||||
bool _isLoading = false;
|
||||
http.Response _response;
|
||||
//int _pageCount = 1;
|
||||
//int _currentPage = 1;
|
||||
|
||||
static const STATUS_ALL = 'all';
|
||||
static const STATUS_PAID = 'paid';
|
||||
|
|
@ -181,20 +183,32 @@ class _ClientPdfViewState extends State<ClientPdfView> {
|
|||
: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.navigate_before),
|
||||
onPressed: _pageNumber > 1 ? () => null : null,
|
||||
onPressed: _currentPage > 1
|
||||
? () {
|
||||
setState(() {
|
||||
_currentPage++;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text(localization.pdfPageInfo
|
||||
.replaceFirst(':current', '$_pageNumber')
|
||||
.replaceFirst(':current', '$_currentPage')
|
||||
.replaceFirst(':total', '$_pageCount')),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.navigate_next),
|
||||
onPressed: _pageNumber < _pageCount ? () => null : null,
|
||||
onPressed: _currentPage < _pageCount
|
||||
? () {
|
||||
setState(() {
|
||||
_currentPage++;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
),
|
||||
];
|
||||
*/
|
||||
*/
|
||||
|
||||
bool showEmail = false; //isDesktop(context);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
|
|||
// Package imports:
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja_flutter/redux/vendor/vendor_selectors.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/buttons/elevated_button.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/entity_dropdown.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
|
|
@ -47,6 +48,7 @@ import 'package:invoiceninja_flutter/utils/completers.dart';
|
|||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
import 'package:invoiceninja_flutter/utils/icons.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
import 'package:printing/printing.dart';
|
||||
|
||||
class InvoiceEditDesktop extends StatefulWidget {
|
||||
|
|
@ -928,6 +930,8 @@ class _PdfPreview extends StatefulWidget {
|
|||
class __PdfPreviewState extends State<_PdfPreview> {
|
||||
final _pdfDebouncer = Debouncer(milliseconds: kMillisecondsToDebounceSave);
|
||||
|
||||
int _pageCount = 1;
|
||||
int _currentPage = 1;
|
||||
http.Response _response;
|
||||
bool _isLoading = false;
|
||||
|
||||
|
|
@ -984,10 +988,12 @@ class __PdfPreviewState extends State<_PdfPreview> {
|
|||
webClient
|
||||
.post(url, credentials.token,
|
||||
data: json.encode(data), rawResponse: true)
|
||||
.then((dynamic response) {
|
||||
.then((dynamic response) async {
|
||||
final pages = await Printing.raster(response.bodyBytes, dpi: 5).toList();
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
_response = response;
|
||||
_pageCount = pages.length;
|
||||
});
|
||||
}).catchError((dynamic error) {
|
||||
setState(() {
|
||||
|
|
@ -998,17 +1004,16 @@ class __PdfPreviewState extends State<_PdfPreview> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//final localization = AppLocalization.of(context);
|
||||
final localization = AppLocalization.of(context);
|
||||
|
||||
return Container(
|
||||
height: 1200,
|
||||
height: 1450,
|
||||
child: Stack(
|
||||
alignment: Alignment.topCenter,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
/*
|
||||
if (_pageCount > 1)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
|
|
@ -1019,17 +1024,28 @@ class __PdfPreviewState extends State<_PdfPreview> {
|
|||
width: 180,
|
||||
label: localization.previousPage,
|
||||
iconData: MdiIcons.pagePrevious,
|
||||
onPressed: _currentPage == 1 ? null : () {}),
|
||||
onPressed: _currentPage == 1
|
||||
? null
|
||||
: () {
|
||||
setState(() {
|
||||
_currentPage--;
|
||||
});
|
||||
}),
|
||||
SizedBox(width: kTableColumnGap),
|
||||
AppButton(
|
||||
width: 180,
|
||||
label: localization.nextPage,
|
||||
iconData: MdiIcons.pageNext,
|
||||
onPressed: _currentPage == _pageCount ? null : () {}),
|
||||
onPressed: _currentPage == _pageCount
|
||||
? null
|
||||
: () {
|
||||
setState(() {
|
||||
_currentPage++;
|
||||
});
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
*/
|
||||
Expanded(
|
||||
child: _response == null
|
||||
? SizedBox()
|
||||
|
|
@ -1038,6 +1054,7 @@ class __PdfPreviewState extends State<_PdfPreview> {
|
|||
canChangeOrientation: false,
|
||||
canChangePageFormat: false,
|
||||
canDebug: false,
|
||||
pages: [_currentPage - 1],
|
||||
)),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -55,7 +55,8 @@ class _InvoicePdfViewState extends State<InvoicePdfView> {
|
|||
String _activityId;
|
||||
String _pdfString;
|
||||
http.Response _response;
|
||||
int _pageNumber = 1, _pageCount = 1;
|
||||
//int _pageCount = 1;
|
||||
//int _currentPage = 1;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
@ -110,17 +111,17 @@ class _InvoicePdfViewState extends State<InvoicePdfView> {
|
|||
: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.navigate_before),
|
||||
onPressed: _pageNumber > 1 ? () => null : null,
|
||||
onPressed: _currentPage > 1 ? () => null : null,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text(localization.pdfPageInfo
|
||||
.replaceFirst(':current', '$_pageNumber')
|
||||
.replaceFirst(':current', '$_currentPage')
|
||||
.replaceFirst(':total', '$_pageCount')),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.navigate_next),
|
||||
onPressed: _pageNumber < _pageCount ? () => null : null,
|
||||
onPressed: _currentPage < _pageCount ? () => null : null,
|
||||
),
|
||||
];
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue