toshiaki-h / split_view

SplitView for Flutter
MIT License
38 stars 20 forks source link

Divider Hides Edges of view1 and view2 #3

Closed cedarbob closed 3 years ago

cedarbob commented 3 years ago

The Positioned widgets which wrap view1 and view2 each need to have one of their left, right, bottom or top fields adjusted to account for the widget.gripSize. For example, in a horizontal SplitView, the Positioned widget which wraps view1 should probably have its right field set to widget.gripSize / 2.0.

toshiaki-h commented 3 years ago

@cedarbob Thank you for your advice. I'll fix it.

cedarbob commented 3 years ago

The fix just made didn't solve the issue. Below is the fix I had in mind for _buildHorizontalView (in my original post I meant to say 'increase the right field by widget.gripSize / 2.0', instead of 'set to widget.gripSize / 2.0):

  Widget _buildHorizontalView(BuildContext context, BoxConstraints constraints, double w) {
    final double left = constraints.maxWidth * w;
    final double right = constraints.maxWidth * (1.0 - w);

    return Stack(
      children: <Widget>[
        Positioned(
          top: 0,
          left: 0,
          right: right + widget.gripSize / 2.0,
          bottom: 0,
          child: widget.view1,
        ),
        Positioned(
          top: 0,
          left: left + widget.gripSize / 2.0,
          right: 0,
          bottom: 0,
          child: widget.view2,
        ),
        Positioned(
          top: 0,
          left: left - widget.gripSize / 2.0,
          right: right - widget.gripSize / 2.0,
          bottom: 0,
          child: MouseRegion(
            cursor: SystemMouseCursors.resizeColumn,
            child: GestureDetector(
              behavior: HitTestBehavior.translucent,
              onVerticalDragUpdate: (detail) {
                final RenderBox container = context.findRenderObject() as RenderBox;
                final pos = container.globalToLocal(detail.globalPosition);
                if (pos.dx > widget.positionLimit &&
                    pos.dx < (container.size.width - widget.positionLimit)) {
                  weight.value = pos.dx / container.size.width;
                }
              },
              child: Container(color: widget.gripColor),
            ),
          ),
        ),
      ],
    );
  }
toshiaki-h commented 3 years ago

@cedarbob Thank you for your report. I couldn't find the bug because the sample project wasn't built correctly. I fixed it. Is it in line with your idea?

cedarbob commented 3 years ago

Reran my tests and the latest update works great.