-
-
Notifications
You must be signed in to change notification settings - Fork 862
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
Reworked layers mechanism #1615
Conversation
Improved internal file structure
Improved documentation
Improved error message for incorrect `AnchoredLayer` usage
…onstructor on `AnchoredLayer`
Improved internal documentation
i am not a huge fan of these specific changes on first reading. i feel uneasy about the layers stack changes specifically. i really like the concept of removing non-rotated children. the end user should not be able to place a map layer somewhere where it can go, but will function incorrectly and might not be obvious (as in they should not be concerned about whether a layer rotates; the layer should decide if it wants to rotate and how). i think the implementation of the layer stack is sub-optimal though. it is quite convoluted and the concept of an Anchored Layer is introduced. as a developer i would expect these behaviors from fm
I think this philosophy also applies to the layers_stack implementation. I don't think it is necessary to extend Widget to create an AnchoredLayer widget to isolate layers that need rotating and then picking those out of the stack, its convoluted in my opinion and gets further away from the everything is a widget philosophy (and might even cause flutter optimization issues). My immediate thoughts are this. Treat all layers as non-rotated children, then have a FM provided widget that is literally just rotates the map layer just like how all other layers are already (basically returning the old behavior); we can wrap all of our internal layers that want that rotation in it, and any external developers who are creating layers can easily just wrap their widgets in our "old behavior" widget to return the old behavior. this makes migration trivial. I think the benefits are obvious with this implementation:
these are my immediate thoughts, i haven't looked deeply at the translucent_pointer, but i have a feeling both of these things can get mitigated by a slightly easier design. we shouldn't need to be injecting touch behavior, if someone wants to modify a layers touch properties they should do it by wrapping the widget themselves (in my opinion; we should avoid modifying "default" touch/input capturing behavior when possible). i can hopefully take a closer look at this project soon, ive been incredibly busy. but i think this is worth looking at because we should solve the gesture and layer rotation problem. it is quite strange that we are just rotating all of the widgets in my opinion when they can easily handle it internally with a single widget. i think the "flutter way" is that it is okay to have a widget handle behavior change. not everything needs to be a parameter, especially not things related to gesture handling, we can provide the widgets to handle these changes, just like flutter already has IgnorePointer and others. |
Ok, I think what you're saying is the inverse of what it currently is. However, I think there are still problems with this approach:
Essentially, with those 3 points, you come to this PRs implementation. However, because the detection will need to be applied more frequently, and for longer each execution (unless you use mixins), I would say it would be less performant.
One thing I would agree with is that the current It would be great if @TesteurManiak & @ibrierley could also join in, and maybe @Robbendebiene as well, as you seemed to be interested in this. |
I'm not sure I have anything useful to add, I think I'm 50/50 on everything (without looking at the code in depth) but a couple of thoughts.. If one of the main incentives for any decision is a performance reason, I'd probably want to verify that is the case. Flutter often does a few optimisations anyway. I'm not convinced either way on the non-rotated argument. My gut instinct is that a non-rotated widget is clear what happens to anyone new looking at code (but I don't really like the name), and makes them think about it (rather than having to think about every individual layer differently and know about it). I was wondering about the notion of only having a StaticLayer or a MovingLayer, so there's clarity, but really I'm not sure I like that either :). I feel a bit like an "anchored" layer is a bit confusing (as we use anchors elsewhere a bit differently?) The gesture stuff, I'm even less sure of. Sorry, not being much help here, but will give any thoughts if they pop up. |
Just quickly read through this so apologies for any potential misconceptions. I don't really understand why detection would still be needed in this case. |
Ah, I think I've got you now. Of course, I forgot that layers can access the map's state :d. I was going along that the state would need to be injected into the layers. Apologies for my stupidity. I do wonder whether transforming more, shorter depth, widgets is less performant than transforming fewer, stacked/longer depth, widgets. But as @ibrierley said, we should probably test the performance somehow. In regards to the translucent gesture stuff, that's almost definitely necessary IMO. There's no other way to allow all layers to handle their gestures independently. I'll see if I can put something together... |
Deprecate `nonRotatedChildren`
@mootw @Robbendebiene @ibrierley @TesteurManiak Ok, I have implemented that in 48c0ec6. Let me know what you think. However, one thing to note is that a widget which uses neither the new On a different note, I also have not tested performance yet. |
Removed flaky(?) test
The zoom buttons are implemented as a column of FloatingActionButtons. I removed the alignment and used the Column's mainAxisAlignment + a row to push 'em back to the bottom right. The Row and Column should fully expand into the parent's constraints. I also added a marker layer (with the MobileTransformer) to make sure to have both in the stack and added a semi-transparent colored container with a margin: Rotating seems fine. Did you have the issues with this revision of your code? I'm a bit baffled because just by reading the Stack's documentation I would expect issues but I'm not having any. Should I be excited? 🤔 Did you maybe have the Stack within the OverflowBox at some point? |
I can't seem to reproduce the issue now either. Maybe I managed to reproduce it then made some changes afterward that fixed it without me realising. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renaming anchorPose to alignment is breaking but a better name. just need to make sure documentation exists for that change
Yep, it was changed because anchor was a poor name that could be considered to mean the opposite of what it actually did. Migration info is already written (check the v6 docs). |
Removed joint `AttributionWidget` class Improved marker layer efficiency
There are four issues with the current way of defining layers:
MarkerLayer
, meaning it cannot receive gesture eventsI've decided to make the following changes:
FlutterMap.nonRotatedChildren
MobileLayerTransformer
widget which can be included in a layer'sbuild
methodTranslucentPointer
widgets around all layers (optionally, on by default)FlutterMap.simple
constructor that just supports one very basicTileLayer
and an attribution layerThe changes I've made are extremely intrusive, so open to suggestion! Doubtless someone'll spot a better way to do something.
Also includes some refactoring and cleanup that I couldn't resist doing. More to come in another PR!