Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add invisibleGripPadding #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 35 additions & 21 deletions lib/split_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Widget> children;
Expand Down Expand Up @@ -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,
Expand All @@ -51,6 +54,7 @@ class SplitView extends StatefulWidget {
this.onWeightChanged,
this.indicator,
this.activeIndicator,
this.invisibleGripPadding = defaultInvisibleGripPadding,
}) : super(key: key);

@override
Expand Down Expand Up @@ -151,8 +155,10 @@ class _SplitViewState extends State<SplitView> {
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(
Expand Down Expand Up @@ -191,14 +197,17 @@ class _SplitViewState extends State<SplitView> {
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,
),
),
),
),
Expand Down Expand Up @@ -232,8 +241,10 @@ class _SplitViewState extends State<SplitView> {
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(
Expand Down Expand Up @@ -272,14 +283,17 @@ class _SplitViewState extends State<SplitView> {
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,
),
),
),
),
Expand Down