createUnfoldDragTarget method

void createUnfoldDragTarget({
  1. required Offset offset,
})

Implementation

void createUnfoldDragTarget({required Offset offset}) {
  _removeHolderIfExit();
  _holder = OverlayEntry(builder: (context) {
    double maxY = 200;
    if (logUIWidgetKey.currentState != null) {
      maxY = MediaQuery.of(context).size.height -
          logUIWidgetKey.currentState!.windowHeight -
          titleBarHeight;
    }
    return Positioned(
        top: offset.dy < 50
            ? 50
            : offset.dy > maxY
                ? maxY
                : offset.dy,
        child: DragTarget(
            builder: (BuildContext context, List incoming, List rejected) {
          return GestureDetector(
            onVerticalDragDown: (DragDownDetails details) {
              RenderBox renderBox = logUIWidgetKey.currentContext!
                  .findRenderObject() as RenderBox;
              _dragTouchOffset =
                  renderBox.globalToLocal(details.globalPosition);
            },
            child: Draggable(
              axis: Axis.vertical,
              child: unFoldView,
              feedback: unFoldView,
              onDragEnd: (detail) {
                _widgetLastY = detail.offset.dy;
                createUnfoldDragTarget(offset: detail.offset);
                _dragTouchOffset = Offset(0, 0);
              },
              onDragUpdate: (DragUpdateDetails detail) {
                bool yFit = _dragTouchOffset.dy >= 0 &&
                    _dragTouchOffset.dy <= titleBarHeight;
                bool xFit =
                    _dragTouchOffset.dx >= 30 && _dragTouchOffset.dx <= 60;
                if (xFit && yFit) {
                  logUIWidgetKey.currentState!.updateWindowHeight(detail);
                }
              },
              childWhenDragging: Container(),
              ignoringFeedbackSemantics: false,
            ),
          );
          // );
        }));
  });
  topOverlay.insert(_holder!);
}