From 643f9a9464139f6ae929627a7b0886805ca214a3 Mon Sep 17 00:00:00 2001 From: David Gray Date: Thu, 25 Jul 2024 10:16:21 -0500 Subject: [PATCH] add invisibleGripPadding --- lib/split_view.dart | 56 ++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/lib/split_view.dart b/lib/split_view.dart index 75b1973..931ade4 100644 --- a/lib/split_view.dart +++ b/lib/split_view.dart @@ -11,6 +11,7 @@ class SplitView extends StatefulWidget { static const Color defaultGripColorActive = Color.fromARGB(0xff, 0x66, 0x66, 0x66); static const double defaultGripSize = 12.0; + static const double defaultInvisibleGripPadding = 0; static const double _weightLimit = 0.01; final List children; @@ -39,8 +40,10 @@ class SplitView extends StatefulWidget { /// Grip indicator for active state. final Widget? activeIndicator; + final double invisibleGripPadding; + /// Creates a [SplitView]. - SplitView({ + const SplitView({ Key? key, required this.children, required this.viewMode, @@ -51,6 +54,7 @@ class SplitView extends StatefulWidget { this.onWeightChanged, this.indicator, this.activeIndicator, + this.invisibleGripPadding = defaultInvisibleGripPadding, }) : super(key: key); @override @@ -151,8 +155,10 @@ class _SplitViewState extends State { top += (viewsHeight * weight); if (i != widget.children.length - 1) { children.add(Positioned( - top: top, - height: widget.gripSize, + top: top - widget.invisibleGripPadding, + height: widget.invisibleGripPadding + + widget.gripSize + + widget.invisibleGripPadding, left: 0, right: 0, child: MouseRegion( @@ -191,14 +197,17 @@ class _SplitViewState extends State { var diff = pos.dy - _startDragPos.dy; _changeWeights(diff, viewsHeight, i); }, - child: Container( - color: _activeIndex == i ? _gripColor : widget.gripColor, - alignment: Alignment.center, - child: _activeIndex == i - ? widget.activeIndicator != null - ? widget.activeIndicator - : widget.indicator - : widget.indicator, + child: Center( + child: Container( + height: widget.gripSize, + color: _activeIndex == i ? _gripColor : widget.gripColor, + alignment: Alignment.center, + child: _activeIndex == i + ? widget.activeIndicator != null + ? widget.activeIndicator + : widget.indicator + : widget.indicator, + ), ), ), ), @@ -232,8 +241,10 @@ class _SplitViewState extends State { left += (viewsWidth * weight); if (i != widget.children.length - 1) { children.add(Positioned( - left: left, - width: widget.gripSize, + left: left - widget.invisibleGripPadding, + width: widget.invisibleGripPadding + + widget.gripSize + + widget.invisibleGripPadding, top: 0, bottom: 0, child: MouseRegion( @@ -272,14 +283,17 @@ class _SplitViewState extends State { var diff = pos.dx - _startDragPos.dx; _changeWeights(diff, viewsWidth, i); }, - child: Container( - color: _activeIndex == i ? _gripColor : widget.gripColor, - alignment: Alignment.center, - child: _activeIndex == i - ? widget.activeIndicator != null - ? widget.activeIndicator - : widget.indicator - : widget.indicator, + child: Center( + child: Container( + width: widget.gripSize, + color: _activeIndex == i ? _gripColor : widget.gripColor, + alignment: Alignment.center, + child: _activeIndex == i + ? widget.activeIndicator != null + ? widget.activeIndicator + : widget.indicator + : widget.indicator, + ), ), ), ),