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

Support Scrolling within Floating Overlay #5

Open
ac-arconomy opened this issue Feb 24, 2023 · 4 comments · May be fixed by #6
Open

Support Scrolling within Floating Overlay #5

ac-arconomy opened this issue Feb 24, 2023 · 4 comments · May be fixed by #6
Assignees

Comments

@ac-arconomy
Copy link

ac-arconomy commented Feb 24, 2023

Hi - thanks for building a great widget. Are you still supporting this?

I am building for flutter web app - and the floating overlay uses the Positioned widget which means that a scrollable widget as a child does not scroll unless all the constructors for the positioned widget are set.

https://stackoverflow.com/questions/59936098/listview-not-scrolling-in-positioned-widget

I have forked the repo and updated the _Reposition class to set the right and bottom properties of the Positioned constructor to 0 (see below) - although this means that the overlay cannot be scaled from the right or bottom anymore.

  @override
  Widget build(BuildContext context) {
    return StreamBuilder<Offset>(
      initialData: offsetController.state,
      stream: offsetController.stream,
      builder: (context, snapshot) {
        final position = snapshot.data!;
        return Positioned(
          top: position.dy,
          left: position.dx,
          bottom: 0,
          right: 0,
          child: child,
        );
      },
    );
  }

Any suggestions for how to set the right and bottom properties correctly in the _Reposition class so that the overlay will still scale from all 4 sides? I think the solution maybe to pass in the _Side.bottom and _Side.right from the get _entryProcesWidgets call in the floating_overlay_controller?

Many Thanks
Alistair

@FMorschel
Copy link
Owner

FMorschel commented Feb 24, 2023

Hi! Thank you for the compliment! I'm still supporting this even with less time available.

I see why the gesture detectors would conflict if you tried to scroll inside the floating overlay. We could think of a flag inside the controller that would disable some or all gesture detection from the floating widget.

This way you could create a pin or some other button to indicate that the floating widget is fixed to that position/scale.

About what you did to solve that, I get the size from the widget after the first frame, maybe filling the width and height do the same as filling the bottom and right parameters? Since it could then internally create a Rect, I would have to test it anyways.

If you are willing to try and implement this, I would gladly accept a PR from your fork.

Edit:

If the width and height parameters don't fix your problem you could create a Rect from these parameters (with top and left) and find the bottom and right parameters to fill the Positioned.

@FMorschel FMorschel self-assigned this Feb 24, 2023
@ac-arconomy
Copy link
Author

ac-arconomy commented Feb 27, 2023

Hi - I have been trying to get the _FloatingOverlayOffset to use a Rect instead of Offset but unfortunately I have not been able to get a version working successfully - there seems to be some magic creating the limits and enabling the scaling that I don't fully understand - I have run out of time on this.

The more important requirement is to improve how the GestureDetector works with the floating child so that I can use TextFields or drop-down fields in the floating widget. I thought maybe I could try and add a header widget in a Column (with the existing child widget) and modify the gestureDetector of the FloatingOverlayController to only move or scale if the header was moused over - this would mean that only the header (top, topRight, topLeft) of the floating widget could be interacted with for moving/scaling, but I could live with that if I could then interact with other widgets in the body of the floating widget.

Thoughts? I'd be happy to pay you for implementing the features if you gave me a quote.

Many Thanks
Alistair

Edit: I have also tried to use a flag to only return the GestureDetector widget in the _CursorResizing and the FloatingOverlayController when this flag is set to false. The FloatingWidget still gets rebuilt every time I interact with the floating child widget. This seems to be because the OverlayEntry builder function is called anytime I interact with the floating widget. Do you know why this is?

@ac-arconomy
Copy link
Author

I found a solution! The issue was with the Overlay builder and the _Reposition object. I will submitt a PR tomorrow. Still need to fix getting the bottom right offset passed to the FloatingOverlayOffset.. but getting closer

@FMorschel
Copy link
Owner

Great work! Waiting for your PR!

About the rebuilding, that's something I'm trying to solve, I think it has something to do with getting the size of the child widget, but if you have any insight let me know!

@FMorschel FMorschel linked a pull request Oct 9, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants