@@ -741,19 +741,36 @@ class _MainBody extends StatelessWidget {
741741 pos == ToolbarPosition .top) &&
742742 ! isMobile) &&
743743 currentIndex.hideUi == HideState .visible;
744+ final shareToolbarAndZoomEdge =
745+ ! isMobile &&
746+ currentIndex.hideUi == HideState .visible &&
747+ _toolbarAndZoomShareVerticalEdge (settings);
748+ final combineTopToolbarAndZoom = showToolbar && shareToolbarAndZoomEdge;
749+ final combineBottomToolbarAndZoom =
750+ pos == ToolbarPosition .bottom && shareToolbarAndZoomEdge;
744751
745752 return Expanded (
746753 child: Column (
747754 crossAxisAlignment: CrossAxisAlignment .center,
748755 children: [
749- if (showToolbar) toolbar,
756+ if (showToolbar)
757+ combineTopToolbarAndZoom
758+ ? _buildCombinedToolbarAndZoom (settings, toolbar)
759+ : toolbar,
750760 if (optPos == OptionsPanelPosition .top &&
751761 currentIndex.hideUi == HideState .visible)
752762 const ToolbarView (),
753763 Expanded (
754764 child: Stack (
755765 children: [
756- _buildZoomAndTools (context, settings, isMobile, currentIndex),
766+ _buildZoomAndTools (
767+ context,
768+ settings,
769+ isMobile,
770+ currentIndex,
771+ hideZoomTools:
772+ combineTopToolbarAndZoom || combineBottomToolbarAndZoom,
773+ ),
757774 const Align (
758775 alignment: Alignment .topRight,
759776 child: PropertyView (),
@@ -766,18 +783,56 @@ class _MainBody extends StatelessWidget {
766783 const ToolbarView (),
767784 if ((isMobile || pos == ToolbarPosition .bottom) &&
768785 currentIndex.hideUi == HideState .visible)
769- toolbar,
786+ combineBottomToolbarAndZoom
787+ ? _buildCombinedToolbarAndZoom (settings, toolbar)
788+ : toolbar,
770789 ],
771790 ),
772791 );
773792 }
774793
794+ bool _toolbarAndZoomShareVerticalEdge (ButterflySettings settings) =>
795+ switch (settings.toolbarPosition) {
796+ ToolbarPosition .top =>
797+ settings.zoomPosition == ZoomPosition .topLeft ||
798+ settings.zoomPosition == ZoomPosition .topRight,
799+ ToolbarPosition .bottom =>
800+ settings.zoomPosition == ZoomPosition .bottomLeft ||
801+ settings.zoomPosition == ZoomPosition .bottomRight,
802+ _ => false ,
803+ };
804+
805+ Widget _buildCombinedToolbarAndZoom (
806+ ButterflySettings settings,
807+ Widget toolbar,
808+ ) {
809+ final isLeft =
810+ settings.zoomPosition == ZoomPosition .topLeft ||
811+ settings.zoomPosition == ZoomPosition .bottomLeft;
812+ final zoomTools = SizedBox (
813+ width: 400 ,
814+ child: _buildZoomToolsRow (settings, false ),
815+ );
816+ final children = < Widget > [
817+ zoomTools,
818+ Expanded (child: Align (child: toolbar)),
819+ ];
820+ return Padding (
821+ padding: const EdgeInsets .symmetric (horizontal: 8 ),
822+ child: Row (
823+ spacing: 8 ,
824+ children: isLeft ? children : children.reversed.toList (),
825+ ),
826+ );
827+ }
828+
775829 Widget _buildZoomAndTools (
776830 BuildContext context,
777831 ButterflySettings settings,
778832 bool isMobile,
779- CurrentIndex currentIndex,
780- ) {
833+ CurrentIndex currentIndex, {
834+ bool hideZoomTools = false ,
835+ }) {
781836 return Padding (
782837 padding: const EdgeInsets .all (8.0 ),
783838 child: Align (
@@ -798,25 +853,7 @@ class _MainBody extends StatelessWidget {
798853 ZoomPosition .bottomLeft => CrossAxisAlignment .start,
799854 },
800855 children: [
801- Builder (
802- builder: (context) {
803- final isLeft =
804- settings.zoomPosition == ZoomPosition .topLeft ||
805- settings.zoomPosition == ZoomPosition .bottomLeft;
806- final children = < Widget > [
807- if (settings.zoomEnabled)
808- Flexible (child: ZoomView (isMobile: isMobile)),
809- const PenOnlyToggle (),
810- ];
811- return Row (
812- mainAxisAlignment: isLeft
813- ? MainAxisAlignment .start
814- : MainAxisAlignment .end,
815- spacing: 8 ,
816- children: isLeft ? children : children.reversed.toList (),
817- );
818- },
819- ),
856+ if (! hideZoomTools) _buildZoomToolsRow (settings, isMobile),
820857 if (currentIndex.hideUi == HideState .touch)
821858 FloatingActionButton .small (
822859 tooltip: AppLocalizations .of (context).exit,
@@ -831,4 +868,21 @@ class _MainBody extends StatelessWidget {
831868 ),
832869 );
833870 }
871+
872+ Widget _buildZoomToolsRow (ButterflySettings settings, bool isMobile) {
873+ final isLeft =
874+ settings.zoomPosition == ZoomPosition .topLeft ||
875+ settings.zoomPosition == ZoomPosition .bottomLeft;
876+ final children = [
877+ const PenOnlyToggle (),
878+ if (settings.zoomEnabled) Flexible (child: ZoomView (isMobile: isMobile)),
879+ ];
880+ return Row (
881+ mainAxisAlignment: isLeft
882+ ? MainAxisAlignment .start
883+ : MainAxisAlignment .end,
884+ spacing: 8 ,
885+ children: isLeft ? children.reversed.toList () : children,
886+ );
887+ }
834888}
0 commit comments