@@ -745,19 +745,36 @@ class _MainBody extends StatelessWidget {
745745 pos == ToolbarPosition .top) &&
746746 ! isMobile) &&
747747 currentIndex.hideUi == HideState .visible;
748+ final shareToolbarAndZoomEdge =
749+ ! isMobile &&
750+ currentIndex.hideUi == HideState .visible &&
751+ _toolbarAndZoomShareVerticalEdge (settings);
752+ final combineTopToolbarAndZoom = showToolbar && shareToolbarAndZoomEdge;
753+ final combineBottomToolbarAndZoom =
754+ pos == ToolbarPosition .bottom && shareToolbarAndZoomEdge;
748755
749756 return Expanded (
750757 child: Column (
751758 crossAxisAlignment: CrossAxisAlignment .center,
752759 children: [
753- if (showToolbar) toolbar,
760+ if (showToolbar)
761+ combineTopToolbarAndZoom
762+ ? _buildCombinedToolbarAndZoom (settings, toolbar)
763+ : toolbar,
754764 if (optPos == OptionsPanelPosition .top &&
755765 currentIndex.hideUi == HideState .visible)
756766 const ToolbarView (),
757767 Expanded (
758768 child: Stack (
759769 children: [
760- _buildZoomAndTools (context, settings, isMobile, currentIndex),
770+ _buildZoomAndTools (
771+ context,
772+ settings,
773+ isMobile,
774+ currentIndex,
775+ hideZoomTools:
776+ combineTopToolbarAndZoom || combineBottomToolbarAndZoom,
777+ ),
761778 Align (
762779 alignment: switch (settings.propertyPosition) {
763780 ZoomPosition .topRight => Alignment .topRight,
@@ -775,18 +792,56 @@ class _MainBody extends StatelessWidget {
775792 const ToolbarView (),
776793 if ((isMobile || pos == ToolbarPosition .bottom) &&
777794 currentIndex.hideUi == HideState .visible)
778- toolbar,
795+ combineBottomToolbarAndZoom
796+ ? _buildCombinedToolbarAndZoom (settings, toolbar)
797+ : toolbar,
779798 ],
780799 ),
781800 );
782801 }
783802
803+ bool _toolbarAndZoomShareVerticalEdge (ButterflySettings settings) =>
804+ switch (settings.toolbarPosition) {
805+ ToolbarPosition .top =>
806+ settings.zoomPosition == ZoomPosition .topLeft ||
807+ settings.zoomPosition == ZoomPosition .topRight,
808+ ToolbarPosition .bottom =>
809+ settings.zoomPosition == ZoomPosition .bottomLeft ||
810+ settings.zoomPosition == ZoomPosition .bottomRight,
811+ _ => false ,
812+ };
813+
814+ Widget _buildCombinedToolbarAndZoom (
815+ ButterflySettings settings,
816+ Widget toolbar,
817+ ) {
818+ final isLeft =
819+ settings.zoomPosition == ZoomPosition .topLeft ||
820+ settings.zoomPosition == ZoomPosition .bottomLeft;
821+ final zoomTools = SizedBox (
822+ width: 400 ,
823+ child: _buildZoomToolsRow (settings, false ),
824+ );
825+ final children = < Widget > [
826+ zoomTools,
827+ Expanded (child: Align (child: toolbar)),
828+ ];
829+ return Padding (
830+ padding: const EdgeInsets .symmetric (horizontal: 8 ),
831+ child: Row (
832+ spacing: 8 ,
833+ children: isLeft ? children : children.reversed.toList (),
834+ ),
835+ );
836+ }
837+
784838 Widget _buildZoomAndTools (
785839 BuildContext context,
786840 ButterflySettings settings,
787841 bool isMobile,
788- CurrentIndex currentIndex,
789- ) {
842+ CurrentIndex currentIndex, {
843+ bool hideZoomTools = false ,
844+ }) {
790845 return Padding (
791846 padding: const EdgeInsets .all (8.0 ),
792847 child: Align (
@@ -807,25 +862,7 @@ class _MainBody extends StatelessWidget {
807862 ZoomPosition .bottomLeft => CrossAxisAlignment .start,
808863 },
809864 children: [
810- Builder (
811- builder: (context) {
812- final isLeft =
813- settings.zoomPosition == ZoomPosition .topLeft ||
814- settings.zoomPosition == ZoomPosition .bottomLeft;
815- final children = < Widget > [
816- if (settings.zoomEnabled)
817- Flexible (child: ZoomView (isMobile: isMobile)),
818- const PenOnlyToggle (),
819- ];
820- return Row (
821- mainAxisAlignment: isLeft
822- ? MainAxisAlignment .start
823- : MainAxisAlignment .end,
824- spacing: 8 ,
825- children: isLeft ? children : children.reversed.toList (),
826- );
827- },
828- ),
865+ if (! hideZoomTools) _buildZoomToolsRow (settings, isMobile),
829866 if (currentIndex.hideUi == HideState .touch)
830867 FloatingActionButton .small (
831868 tooltip: AppLocalizations .of (context).exit,
@@ -840,4 +877,21 @@ class _MainBody extends StatelessWidget {
840877 ),
841878 );
842879 }
880+
881+ Widget _buildZoomToolsRow (ButterflySettings settings, bool isMobile) {
882+ final isLeft =
883+ settings.zoomPosition == ZoomPosition .topLeft ||
884+ settings.zoomPosition == ZoomPosition .bottomLeft;
885+ final children = [
886+ const PenOnlyToggle (),
887+ if (settings.zoomEnabled) Flexible (child: ZoomView (isMobile: isMobile)),
888+ ];
889+ return Row (
890+ mainAxisAlignment: isLeft
891+ ? MainAxisAlignment .start
892+ : MainAxisAlignment .end,
893+ spacing: 8 ,
894+ children: isLeft ? children.reversed.toList () : children,
895+ );
896+ }
843897}
0 commit comments