Skip to content

Make mobile TryGetPlatformHandle consistent #18483

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

Merged
merged 4 commits into from
Mar 20, 2025
Merged

Make mobile TryGetPlatformHandle consistent #18483

merged 4 commits into from
Mar 20, 2025

Conversation

maxkatz6
Copy link
Member

What does the pull request do?

TopLevel.TryGetPlatformHandle is expected to return handle of the view/window where top level is hosted. That's how it works on desktop platforms, and is useful for interop integrations.
On mobile, the same API couldn't be utilized to its potential, which this PR solves.

What is the current behavior?

iOS:

  • TryGetPlatformHandle returns null

Browser:

  • TryGetPlatformHandle returns null

Android:

  • TryGetPlatformHandle returns Surface handle, which is only usable in the internal rendering and is already exposed by PlatformImpl.Surfaces (private api).

What is the updated/expected behavior with this PR?

iOS:

  • TryGetPlatformHandle returns UIViewControlHandle with UIKit view reference.

Browser:

  • TryGetPlatformHandle returns JSObjectControlHandle with container <div/> reference.

Android:

  • TryGetPlatformHandle returns AndroidViewControlHandle with Android view reference.

Breaking changes

Android.TryGetPlatformHandle returns different type of handle now. But arguably, previous value wasn't useful.

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0055643-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added the backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch label Mar 20, 2025
@maxkatz6 maxkatz6 added this pull request to the merge queue Mar 20, 2025
Merged via the queue into master with commit 314e58a Mar 20, 2025
12 checks passed
@maxkatz6 maxkatz6 deleted the mobile-handles branch March 20, 2025 08:23
MrJul pushed a commit that referenced this pull request Mar 29, 2025
* Use AndroidViewControlHandle for android toplevel handle

* Use UIViewControlHandle for iOS toplevel handle

* Use JSObjectControlHandle for browser toplevel handle

* Revert NativeControlHostImpl changes
@MrJul MrJul added backported-11.2.x and removed backport-candidate-11.2.x Consider this PR for backporting to 11.2 branch labels Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants