From 2049a18786e8a18d33a2146f8c69617f05000b38 Mon Sep 17 00:00:00 2001 From: Thiago Bomfim Date: Thu, 6 Aug 2020 14:12:53 -0300 Subject: [PATCH] Hide BottomNavigationBar when document have just one page. --- lib/src/viewer.dart | 109 ++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/lib/src/viewer.dart b/lib/src/viewer.dart index 9326a223..18f12845 100644 --- a/lib/src/viewer.dart +++ b/lib/src/viewer.dart @@ -140,64 +140,65 @@ class _PDFViewerState extends State { ) : null, floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, - bottomNavigationBar: (widget.showNavigation || widget.document.count > 1) - ? BottomAppBar( - child: new Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: IconButton( - icon: Icon(Icons.first_page), - tooltip: widget.tooltip.first, - onPressed: () { - _pageNumber = 1; - _loadPage(); - }, - ), - ), - Expanded( - child: IconButton( - icon: Icon(Icons.chevron_left), - tooltip: widget.tooltip.previous, - onPressed: () { - _pageNumber--; - if (1 > _pageNumber) { - _pageNumber = 1; - } - _loadPage(); - }, - ), + bottomNavigationBar: Visibility( + visible: (widget.showNavigation && widget.document.count > 1), + child: BottomAppBar( + child: new Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: IconButton( + icon: Icon(Icons.first_page), + tooltip: widget.tooltip.first, + onPressed: () { + _pageNumber = 1; + _loadPage(); + }, ), - widget.showPicker - ? Expanded(child: Text('')) - : SizedBox(width: 1), - Expanded( - child: IconButton( - icon: Icon(Icons.chevron_right), - tooltip: widget.tooltip.next, - onPressed: () { - _pageNumber++; - if (widget.document.count < _pageNumber) { - _pageNumber = widget.document.count; - } - _loadPage(); - }, - ), + ), + Expanded( + child: IconButton( + icon: Icon(Icons.chevron_left), + tooltip: widget.tooltip.previous, + onPressed: () { + _pageNumber--; + if (1 > _pageNumber) { + _pageNumber = 1; + } + _loadPage(); + }, ), - Expanded( - child: IconButton( - icon: Icon(Icons.last_page), - tooltip: widget.tooltip.last, - onPressed: () { + ), + widget.showPicker + ? Expanded(child: Text('')) + : SizedBox(width: 1), + Expanded( + child: IconButton( + icon: Icon(Icons.chevron_right), + tooltip: widget.tooltip.next, + onPressed: () { + _pageNumber++; + if (widget.document.count < _pageNumber) { _pageNumber = widget.document.count; - _loadPage(); - }, - ), + } + _loadPage(); + }, ), - ], - ), - ) - : Container(), + ), + Expanded( + child: IconButton( + icon: Icon(Icons.last_page), + tooltip: widget.tooltip.last, + onPressed: () { + _pageNumber = widget.document.count; + _loadPage(); + }, + ), + ), + ], + ), + ) + ), ); } }