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

Simplified the building of RichAttributionWidget #1661

Merged
merged 3 commits into from
Sep 25, 2023
Merged

Simplified the building of RichAttributionWidget #1661

merged 3 commits into from
Sep 25, 2023

Conversation

bramp
Copy link
Contributor

@bramp bramp commented Sep 25, 2023

Previously the widget waited two frames to find the dimensions it was allowed, then set the minWidth to be the width it naturally wanted. I think this was to ensure the widget took the full width of the screen. It was simple to set a Container's width to infinity to achieve the same thing, with less complexity.

I may have misunderstood the purpose, but either way it seems I get the same behaviour when tested.

…m the render tree.

While there was an assertion to check for this, it being removed ~1-2 frames after its added is perfectly valid, and thus we should easily check if the widget is still mounted.
While we are at it, it seemed a GlobalKey was being used to track the context. In later versions of flutter Stateful widgets have a context property for this purpose.
Previous the widget waited two frames to find the dimensions it was allowed, then set the minWidth to be the width it naturally wanted. I think this was to ensure the widget took
the full width of the screen. It was simple to set a Container's width to infinity to achive the same thing, with less complexity.
@JaffaKetchup JaffaKetchup changed the title Simplified building the RichAttributionWidget. Simplified building the RichAttributionWidget Sep 25, 2023
@JaffaKetchup
Copy link
Member

Yeah, I remember adding this and thinking it was less than ideal. It's quite possible that this approach was needed before, but with some of the changes since then, it's become redundant.

Copy link
Member

@JaffaKetchup JaffaKetchup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has broken the sizing rules of the attribution box. On wider screens, it should shrink wrap around its contents, and on narrower screens, it should consume all of the available width. This appears to have made the box always behave as if it were on a narrow screen.

@bramp
Copy link
Contributor Author

bramp commented Sep 25, 2023

Can you provide me an example. Here are two screenshots (narrow and wide) from before my change:

Screenshot 2023-09-25 at 11 44 13 AM Screenshot 2023-09-25 at 11 43 42 AM

Both show the box expanding across the screen. Do you see something different? I'm happy to adjust to meet whatever you think is correct.

@JaffaKetchup
Copy link
Member

JaffaKetchup commented Sep 25, 2023

Yep, so the wider screen should shrink wrap around the attribution text (be as small as possible), instead of expanding. You can check the latest master (latest exe build on master if you're on windows), to see what it should be.

@bramp
Copy link
Contributor Author

bramp commented Sep 25, 2023

Those screenshots were taken from the latest master (without my change). Running the example app, in a Chrome browser. That's why I'm confused as I don't see what you see.

@JaffaKetchup
Copy link
Member

JaffaKetchup commented Sep 25, 2023

Ah, that's strange, I checked latest main and it was different. Can you just run from a prebuild if that's possible, just to rule out any caching or something? I'll have a double check as well ASAP, but away from my PC atm.

Edit: it may also not be wide enough.

@bramp
Copy link
Contributor Author

bramp commented Sep 25, 2023

Ok using release from https://github.com/fleaflet/flutter_map/releases/tag/v6.0.0-dev.3 I get the behaviour you expect.
Screenshot 2023-09-25 at 12 18 52 PM

After a lot of hitting vscode, the master branch now also looks like that. So I think I had some build caching issue somewhere :(

Anyways, I'll make it act like how you want, which should take less time than debugging why my setup looked different to yours :)

@bramp
Copy link
Contributor Author

bramp commented Sep 25, 2023

Minor tweak. It now seems to do what you would like. Please take a look.

Copy link
Member

@JaffaKetchup JaffaKetchup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still not quite as it was :D On narrow screens, it should expand fully. On wide screens, it should not.

However, I think for the sake of simplifying the codebase, it looks fine like this.

LGTM, thanks for the contribution. I'll update the CHANGELOG.

@JaffaKetchup JaffaKetchup changed the title Simplified building the RichAttributionWidget Simplified the building of RichAttributionWidget Sep 25, 2023
@JaffaKetchup JaffaKetchup merged commit eb3b790 into fleaflet:master Sep 25, 2023
6 checks passed
@bramp
Copy link
Contributor Author

bramp commented Sep 25, 2023

I'm happy to tweak it more if needed, to fill width if less than 420 pixel, otherwise its natural size.

As for changelog/attribution I don't mind. I only stumbled on this because it caused a crash in my app, and happy to help improve the project.

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 this pull request may close these issues.

2 participants