-
Notifications
You must be signed in to change notification settings - Fork 598
Owen/control docs p5 #5845
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?
Owen/control docs p5 #5845
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: |
65a4a3c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7e8c401b.flet-docs.pages.dev |
| Branch Preview URL: | https://owen-control-docs-p5.flet-docs.pages.dev |
| "tap", {"finder_id": finder.id, "finder_index": finder.index} | ||
| ) | ||
|
|
||
| async def tap_at(self, x_offset: int, y_offset: int): |
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 have ft.Offset type which can be passed to method args "as is".
| ```python | ||
| ft.Row( | ||
| scroll=ft.ScrollMode.AUTO, |
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.
I think scroll prop can be removed from this example, for brevity :)
| var offsetObj = args["offset"]; | ||
| var offsetX = offsetObj["x"].toDouble(); | ||
| var offsetY = offsetObj["y"].toDouble(); | ||
| var offset = Offset(offsetX, offsetY); |
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.
Use parseOffset() function to parse received Offset object.
| var offsetX = offsetObj["x"].toDouble(); | ||
| var offsetY = offsetObj["y"].toDouble(); | ||
| var offset = Offset(offsetX, offsetY); | ||
| debugPrint(offset.toString()); |
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.
Remove this debug statement.
| var offsetX = offsetObj["x"].toDouble(); | ||
| var offsetY = offsetObj["y"].toDouble(); | ||
| var offset = Offset(offsetX, offsetY); | ||
| debugPrint(offset.toString()); | ||
| var offset = parseOffset(offsetObj); | ||
| if (offset == null) { | ||
| throw Exception("Offset not found: $offsetObj, $offset"); | ||
| } |
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.
I'd do just:
var offset = parseOffset(args["offset"]);
if (offset == null) {
throw Exception("Offset is required.");
}| Args: | ||
| x_offset: x value of offset from top right. | ||
| y_offset: y value of offset from top right. | ||
| """ |
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.
Update docstring, since we now have only one prop.
| ft.Row( | ||
| controls=[ | ||
| ft.Card( | ||
| shape=ft.ContinuousRectangleBorder(radius=10), | ||
| content=ft.Container( | ||
| padding=5, | ||
| border_radius=ft.BorderRadius.all(5), | ||
| bgcolor=ft.Colors.AMBER_100, | ||
| content=ft.Text(f"Control {i}"), | ||
| ), | ||
| ) | ||
| for i in range(1, 6) | ||
| ], | ||
| ), |
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.
| ft.Row( | |
| controls=[ | |
| ft.Card( | |
| shape=ft.ContinuousRectangleBorder(radius=10), | |
| content=ft.Container( | |
| padding=5, | |
| border_radius=ft.BorderRadius.all(5), | |
| bgcolor=ft.Colors.AMBER_100, | |
| content=ft.Text(f"Control {i}"), | |
| ), | |
| ) | |
| for i in range(1, 6) | |
| ], | |
| ), | |
| ft.Row( | |
| controls=[ | |
| ft.Card( | |
| shape=ft.ContinuousRectangleBorder(radius=10), | |
| content=ft.Container( | |
| padding=5, | |
| border_radius=ft.BorderRadius.all(5), | |
| bgcolor=ft.Colors.AMBER_100, | |
| content=ft.Text(f"Control {i}"), | |
| ), | |
| ) | |
| for i in range(1, 6) | |
| ], | |
| ) |
| var offsetObj = args["offset"]; | ||
| var offset = parseOffset(offsetObj); | ||
| if (offset == null) { | ||
| throw Exception("Offset not found: $offsetObj, $offset"); | ||
| } | ||
| await control.backend.tester!.tapAt(offset); |
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.
| var offsetObj = args["offset"]; | |
| var offset = parseOffset(offsetObj); | |
| if (offset == null) { | |
| throw Exception("Offset not found: $offsetObj, $offset"); | |
| } | |
| await control.backend.tester!.tapAt(offset); | |
| var offset = parseOffset(args["offset"]); | |
| if (offset != null) { | |
| await control.backend.tester!.tapAt(offset); | |
| } |
| ```python | ||
| ft.SearchBar(bar_hint_text="Search...") | ||
| ``` | ||
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.
| ```python | |
| ft.SearchBar(bar_hint_text="Search...") | |
| ``` | |
| Example: | |
| ```python | |
| ft.SearchBar(bar_hint_text="Search...") | |
| ``` |
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.
Are you suggesting this for every small code snippet at the top of a control's doc?
I think with small non-runnable example snippets it's unnecessary to label them as "examples"
Description
SearchBar, Slider and Row example tests and images.
Add tap_at method to flet Tester class.
Summary by Sourcery
Add new test infrastructure and documentation imagery for Row, Slider, and SearchBar controls while extending tester capabilities for coordinate-based taps.
New Features:
Enhancements:
Documentation:
Tests: