Skip to content

Conversation

@NazarenoCavazzon
Copy link
Contributor

It adds a new Axis? parameter to the Interactive Viewer called panningDirection that let's you lock the panning to a certain axis.

Fixes #108935

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Aug 5, 2022
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@NazarenoCavazzon NazarenoCavazzon changed the title panning direction working Panning Aug 5, 2022
@NazarenoCavazzon NazarenoCavazzon changed the title Panning panningDirection parameter added to InteractiveViewer Aug 5, 2022
@HansMuller HansMuller requested a review from justinmc August 5, 2022 23:17
@justinmc
Copy link
Contributor

justinmc commented Aug 8, 2022

@NazarenoCavazzon Thanks for the PR! Overall I think this parameter makes sense, I agree that alignPanAxis doesn't quite do what you want.

It looks like you ran a formatter on these files, though. Would you be able to undo the formatter changes so that this is easier to review?

@NazarenoCavazzon
Copy link
Contributor Author

Yep, didn't saw it hahahaha, I'll undo it

@NazarenoCavazzon
Copy link
Contributor Author

I have also a question, do I need to update the flutter version or make a document like this one explaining the changes and the tests I added?

@NazarenoCavazzon
Copy link
Contributor Author

@justinmc I reverted the formatting, let me know if you need something

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

Thanks for undoing the formatting, much easier to read now! A few small comments below.

If someone specified panningDirection, then there is no reason to specify alignPanAxis too, right? Maybe add an assert to make sure that both aren't set at the same time?

Or, maybe the two parameters should be combined? What if there was just one parameter, an enum (maybe called panAxis?) with values horizontal, vertical, both, and aligned.

To answer your question about writing a design doc, I think it's probably not necessary since this feature is relatively small and not super controversial. It's always welcome if you want to write one though :)

@NazarenoCavazzon
Copy link
Contributor Author

NazarenoCavazzon commented Aug 10, 2022

I like more the enum approach, it makes more sense, thanks for the review, I'll make the changes ASAP

@NazarenoCavazzon
Copy link
Contributor Author

@justinmc I made the alignPanAxis and Enum.

@NazarenoCavazzon
Copy link
Contributor Author

Everything ready 2 review

@goderbauer goderbauer requested a review from justinmc August 16, 2022 22:11
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

I really like the enum approach, thanks for doing that!

The main thing is just my comment about using a new name and deprecating alignPanAxis.

- Modified the new parameter to be called panAxis
- Restored alignPanAxis and added the deprecated annotation
- Default value of panAxis changed from both to free
- Modified some comments
- Added 3 more test for panAxis.vertical and 1 for panAxis.free
@NazarenoCavazzon
Copy link
Contributor Author

Ready 2 review

@goderbauer goderbauer requested a review from justinmc August 30, 2022 22:09
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

LGTM with nits 👍

Can you search through the code and make sure alignPanAxis isn't referenced anywhere in comments or anything? I think I found one case below.

this.scaleFactor = 200.0,
this.transformationController,
required Widget this.child,
}) : assert(alignPanAxis != null),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you keep this assert here for now? Once alignPanAxis is removed then this assert should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added it again

)
final bool alignPanAxis;

/// When set to [PanAxis.aligned] panning is only allowed in the horizontal
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comma: "When set to [PanAxis.aligned],"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

alignedTranslation = _alignAxis(translation, Axis.vertical);
break;
case PanAxis.aligned:
alignedTranslation = _alignAxis(translation, _panAxis!);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you update the comment at the definition of _panAxis? It still references alignPanAxis.

Also it's kind of confusing that there is both panAxis and _panAxis, but they mean different things and have different types... Maybe if we just change _panAxis to _panningAxis or _currentAxis or something? Up to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All done!

Copy link
Contributor

@pdblasi-google pdblasi-google left a comment

Choose a reason for hiding this comment

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

LGTM

@justinmc justinmc added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 16, 2022
@justinmc
Copy link
Contributor

Thanks for your persistence on this PR and for fixing those last few comments! This will be merged when the build is green.

@NazarenoCavazzon
Copy link
Contributor Author

NazarenoCavazzon commented Sep 16, 2022

Thanks for reviewing it!.

After this change I think it would be a great idea to update this widget of the week https://youtu.be/zrn7V3bMJvg hahahah.

@auto-submit auto-submit bot merged commit 0ad0a56 into flutter:master Sep 16, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 16, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 16, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 16, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the option to block panning in a certain axis in Flutter interactive viewer

3 participants