diff --git a/CHANGELOG.md b/CHANGELOG.md index 2187ef4841..6e0d073006 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,14 @@ ### Improvements +* `flet run` and `ft.run()` now print a warning with the desktop client's path when they use one from a previous `flet build` in `build/`, so an outdated client that lacks an extension is easy to spot ([#6821](https://github.com/flet-dev/flet/issues/6821)) by @ndonkoHenri. * `flet build` and `flet debug` pass the arguments that follow a `--` separator to Flutter, e.g. `flet build apk -- --obfuscate --split-debug-info=build/symbols`, as an alternative to repeating `--flutter-build-args` ([#6879](https://github.com/flet-dev/flet/pull/6879)) by @ndonkoHenri. * `flet pack` passes the arguments that follow a `--` separator to PyInstaller, e.g. `flet pack main.py -- --clean`, as an alternative to repeating `--pyinstaller-build-args` ([#6879](https://github.com/flet-dev/flet/pull/6879)) by @ndonkoHenri. * `flet test` passes the arguments that follow a `--` separator to pytest, e.g. `flet test -k screenshot -- -x --maxfail=1` ([#6879](https://github.com/flet-dev/flet/pull/6879)) by @ndonkoHenri. ### Bug fixes +* Fix `InteractiveViewer` failing to render when `alignment` is set ([#6744](https://github.com/flet-dev/flet/issues/6744), [#6887](https://github.com/flet-dev/flet/pull/6887)) by @ndonkoHenri. * flet-charts: Fix `ScatterChart` failing to render when a `ScatterChartSpot` has `x_error` or `y_error` set. Error ranges are now set with the new `ChartErrorRange` type and drawn as error bars in the color of their spot ([#6885](https://github.com/flet-dev/flet/pull/6885)) by @ndonkoHenri. * Fix iOS apps that use `sqlite3` stopping with `Assertion failed: (0), function isBulkReadStatement` when run from Xcode on iOS 18 and later, by turning off Xcode's Thread Performance Checker in the scheme generated by `flet build` ([#5480](https://github.com/flet-dev/flet/issues/5480), [#6882](https://github.com/flet-dev/flet/pull/6882)) by @ndonkoHenri. * Fix `Button(icon=...)` and other material buttons rendering an error box when `content` is not set. Icon-only buttons now render the icon centered ([#6886](https://github.com/flet-dev/flet/issues/6886), [#6889](https://github.com/flet-dev/flet/pull/6889)) by @FeodorFitsner. diff --git a/packages/flet/lib/src/controls/interactive_viewer.dart b/packages/flet/lib/src/controls/interactive_viewer.dart index 732796177f..206705041c 100644 --- a/packages/flet/lib/src/controls/interactive_viewer.dart +++ b/packages/flet/lib/src/controls/interactive_viewer.dart @@ -7,6 +7,7 @@ import 'package:vector_math/vector_math_64.dart' show Matrix4, Quad, Vector3; import '../extensions/control.dart'; import '../models/control.dart'; +import '../utils/alignment.dart'; import '../utils/edge_insets.dart'; import '../utils/events.dart'; import '../utils/misc.dart'; @@ -158,7 +159,7 @@ class _InteractiveViewerControlState extends State scaleFactor: widget.control.getDouble("scale_factor", 200)!, clipBehavior: widget.control.getClipBehavior("clip_behavior", Clip.hardEdge)!, - alignment: widget.control.get("alignment"), + alignment: widget.control.getAlignment("alignment"), boundaryMargin: widget.control.getMargin("boundary_margin", EdgeInsets.zero)!, onInteractionStart: !widget.control.disabled diff --git a/sdk/python/examples/extensions/audio/audio_playback_controls/pyproject.toml b/sdk/python/examples/extensions/audio/audio_playback_controls/pyproject.toml index fefb87a1b9..1042b26c78 100644 --- a/sdk/python/examples/extensions/audio/audio_playback_controls/pyproject.toml +++ b/sdk/python/examples/extensions/audio/audio_playback_controls/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "audio-playback-controls" version = "1.0.0" -description = "Controls audio playback, seek position, volume, and balance for a remote track." +description = "Controls audio playback, seek position, volume, and balance for a local track." requires-python = ">=3.10" keywords = ["services", "audio", "playback", "seek", "volume", "balance", "async"] authors = [{ name = "Flet team", email = "hello@flet.dev" }] @@ -15,6 +15,7 @@ categories = ["Media/Audio"] [tool.flet.metadata] title = "Audio playback controls" +docs_intro = "Plays `viper.mp3` from the example's [`assets`](https://github.com/flet-dev/flet/tree/main/sdk/python/examples/extensions/audio/audio_playback_controls/assets) folder. To run the code on its own, put that file in an `assets` folder next to your script, or set [`src`][flet_audio.Audio.src] to the URL of an audio file." controls = ["SafeArea", "Column", "Row", "Button", "Audio"] layout_pattern = "inline-actions" complexity = "basic" diff --git a/sdk/python/packages/flet-desktop/src/flet_desktop/__init__.py b/sdk/python/packages/flet-desktop/src/flet_desktop/__init__.py index 84d31fe68f..3dc13d1b24 100644 --- a/sdk/python/packages/flet-desktop/src/flet_desktop/__init__.py +++ b/sdk/python/packages/flet-desktop/src/flet_desktop/__init__.py @@ -421,6 +421,25 @@ def find_macos_app_bundle(directory) -> Path | None: return None +def __log_build_client(build_dir: str, client_path: str | Path) -> None: + """ + Reports that a client from a previous `flet build` is used instead of the + standard one. + + Logged as a warning, so it is shown even without `flet run -v`: a client + built before an extension was added lacks that extension, and the app's + calls to it then time out without pointing at the client. + + Args: + build_dir: The `build/` directory the client was found in. + client_path: The client executable or `.app` bundle that is launched. + """ + logger.warning( + f"Using the Flet client from a previous `flet build`: {client_path}. " + f"Move, rename or delete {build_dir} to use the standard client." + ) + + def __linux_identity_args(args: list) -> tuple: """ Give the client window a per-app identity on Linux, without touching it. @@ -604,6 +623,8 @@ def __locate_and_unpack_flet_view(page_url, assets_dir, hidden): for f in os.listdir(build_windows): if f.endswith(".exe"): flet_path = os.path.join(build_windows, f) + if flet_path: + __log_build_client(build_windows, flet_path) # 2. Check FLET_VIEW_PATH (developer mode) if not flet_path: @@ -631,7 +652,7 @@ def __locate_and_unpack_flet_view(page_url, assets_dir, hidden): build_macos = os.path.join(os.getcwd(), "build", "macos") app_path = find_macos_app_bundle(build_macos) if app_path: - logger.info(f"Flet.app found in {build_macos}") + __log_build_client(build_macos, app_path) # 2. Check FLET_VIEW_PATH (developer mode) if not app_path: @@ -668,6 +689,8 @@ def __locate_and_unpack_flet_view(page_url, assets_dir, hidden): ef = os.path.join(build_linux, f) if os.path.isfile(ef) and stat.S_IXUSR & os.stat(ef)[stat.ST_MODE]: app_path = ef + if app_path: + __log_build_client(build_linux, app_path) # 2. Check FLET_VIEW_PATH (developer mode) if not app_path: diff --git a/sdk/python/packages/flet/src/flet/controls/core/interactive_viewer.py b/sdk/python/packages/flet/src/flet/controls/core/interactive_viewer.py index 1610cf601c..7864ba7535 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/interactive_viewer.py +++ b/sdk/python/packages/flet/src/flet/controls/core/interactive_viewer.py @@ -135,7 +135,19 @@ class InteractiveViewer(LayoutControl): alignment: Optional[Alignment] = None """ - The alignment of the :attr:`content` within this viewer. + The origin of the transformation applied to the :attr:`content` when it is + zoomed or panned, relative to the content's size. + + :meth:`zoom` scales the content around this point. It does not change where the + content is placed in this viewer; to position the content, wrap it in a control + that aligns its child, such as a :class:`~flet.Container` with + :attr:`~flet.Container.alignment` set. + + Note: + Gestures and the limits of :meth:`pan` treat the top-left corner as the + origin. With any other value, the content drifts away from the pointer while + zooming with a gesture, and once zoomed in, panning stops short of one edge + of the content and goes past the opposite one, leaving empty space. """ boundary_margin: MarginValue = field(default_factory=lambda: Margin.all(0)) diff --git a/website/docs/getting-started/running-app.md b/website/docs/getting-started/running-app.md index e3880d2463..875e127d6b 100644 --- a/website/docs/getting-started/running-app.md +++ b/website/docs/getting-started/running-app.md @@ -86,9 +86,11 @@ require rebuilding the client. See [Creating an Extension](../extend/user-extensions.md#change-python-files) for an example of this workflow. -To use the standard client again, move or rename the corresponding -`build/` directory and unset `FLET_VIEW_PATH` if it is set. Setting -`FLET_VIEW_PATH` alone does not override a client found in `build/`. +When Flet uses a client from `build/`, it prints a warning with the +client's path. To use the standard client again, move, rename or delete the +corresponding `build/` directory and unset `FLET_VIEW_PATH` if it is +set. Setting `FLET_VIEW_PATH` alone does not override a client found in +`build/`. :::note Opening the built executable directly runs the packaged app, including the Python