-
Notifications
You must be signed in to change notification settings - Fork 589
fix: improve InteractiveViewer programmatic transformations
#5775
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
base: main
Are you sure you want to change the base?
Conversation
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.
We've reviewed this pull request using the Sourcery rules engine
Deploying flet-docs with
|
| Latest commit: |
94380a8
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5fcdd191.flet-docs.pages.dev |
| Branch Preview URL: | https://fix-interactive-viewer.flet-docs.pages.dev |
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.
Pull Request Overview
This PR enhances documentation across several Flet controls, particularly focusing on the InteractiveViewer control. The changes include improved docstrings with more detailed explanations, formatting improvements, and a new example demonstrating programmatic transformations.
- Enhanced documentation for
InteractiveViewerproperties with expanded explanations and usage notes - Added documentation for enum values in
ImageRepeatand improved formatting inVisualDensityand other types - Created a new example showcasing programmatic transformations in
InteractiveViewer - Implemented boundary-aware transformation logic in the Dart implementation
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/python/packages/flet/src/flet/controls/types.py | Updated docstrings for UrlTarget, ClipBehavior, ImageRepeat, and VisualDensity enums with improved formatting and descriptions |
| sdk/python/packages/flet/src/flet/controls/core/interactive_viewer.py | Enhanced documentation for InteractiveViewer properties with detailed explanations, changed default value of boundary_margin to use factory function |
| sdk/python/packages/flet/docs/controls/interactiveviewer.md | Added new section for programmatic transformations example |
| sdk/python/examples/controls/interactive_viewer/transformations.py | New example file demonstrating zoom, pan, reset, and state save/restore operations |
| packages/flet/lib/src/controls/interactive_viewer.dart | Implemented boundary-aware transformation logic with helper methods for scaling and panning operations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| """Repeat the image in both the x and y directions until the box is filled.""" | ||
|
|
||
| REPEAT = "repeat" | ||
| """Repeat the image in the x direction until the box is filled horizontally.""" | ||
|
|
||
| REPEAT_X = "repeatX" | ||
| """Repeat the image in the y direction until the box is filled vertically.""" | ||
|
|
||
| REPEAT_Y = "repeatY" | ||
| """Leave uncovered portions of the box transparent.""" |
Copilot
AI
Nov 5, 2025
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.
The documentation for ImageRepeat enum values is incorrect. The descriptions are mismatched with the enum values. NO_REPEAT should leave portions transparent (not repeat), REPEAT should repeat in both directions, REPEAT_X should repeat in x direction, and REPEAT_Y should repeat in y direction. The current mapping has these backwards.
| """Repeat the image in both the x and y directions until the box is filled.""" | |
| REPEAT = "repeat" | |
| """Repeat the image in the x direction until the box is filled horizontally.""" | |
| REPEAT_X = "repeatX" | |
| """Repeat the image in the y direction until the box is filled vertically.""" | |
| REPEAT_Y = "repeatY" | |
| """Leave uncovered portions of the box transparent.""" | |
| """Do not repeat the image. Leave uncovered portions of the box transparent.""" | |
| REPEAT = "repeat" | |
| """Repeat the image in both the x and y directions until the box is filled.""" | |
| REPEAT_X = "repeatX" | |
| """Repeat the image in the x direction until the box is filled horizontally.""" | |
| REPEAT_Y = "repeatY" | |
| """Repeat the image in the y direction until the box is filled vertically.""" |
| A margin for the visible boundaries of the [`content`][(c).]. | ||
| Any transformation that results in the viewport being able to view outside | ||
| of the boundaries will be stopped at the boundary. The boundaries do not |
Copilot
AI
Nov 5, 2025
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.
[nitpick] Using a lambda in default_factory is unnecessarily verbose. Consider using default_factory=lambda: Margin.all(0) can be simplified to a partial function or a named function if this pattern is repeated, or use field(default_factory=Margin) if Margin.all(0) is the default constructor behavior.
Fix #4642
Fix #5728
Example
Summary by Sourcery
Enable robust programmatic zooming, panning, resetting, and state management on InteractiveViewer while enforcing boundary and scale constraints and enrich the Python API with more descriptive properties and examples.
Bug Fixes:
Enhancements:
Documentation: