Browse Source

Make mobile TryGetPlatformHandle consistent (#18483)

* Use AndroidViewControlHandle for android toplevel handle

* Use UIViewControlHandle for iOS toplevel handle

* Use JSObjectControlHandle for browser toplevel handle

* Revert NativeControlHostImpl changes
Maxwell Katz 8 months ago
parent
commit
314e58aa4a

+ 3 - 2
src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs

@@ -78,7 +78,8 @@ namespace Avalonia.Android.Platform.SkiaPlatform
 
             _systemNavigationManager = new AndroidSystemNavigationManagerImpl(avaloniaView.Context as IActivityNavigationService);
 
-            Surfaces = new object[] { _gl, _framebuffer, Handle };
+            Surfaces = new object[] { _gl, _framebuffer, _view };
+            Handle = new AndroidViewControlHandle(_view);
         }
 
         public IInputRoot? InputRoot { get; private set; }
@@ -102,7 +103,7 @@ namespace Avalonia.Android.Platform.SkiaPlatform
         internal InvalidationAwareSurfaceView InternalView => _view;
 
         public double DesktopScaling => RenderScaling;
-        public IPlatformHandle Handle => _view;
+        public IPlatformHandle Handle { get; }
 
         public IEnumerable<object> Surfaces { get; }
 

+ 2 - 0
src/Browser/Avalonia.Browser/BrowserTopLevelImpl.cs

@@ -70,6 +70,8 @@ namespace Avalonia.Browser
             _surface.SizeChanged += OnSizeChanged;
             _surface.ScalingChanged += OnScalingChanged;
             Compositor = _surface.Compositor;
+
+            Handle = new JSObjectControlHandle(container);
         }
 
         private void OnScalingChanged()

+ 2 - 0
src/iOS/Avalonia.iOS/AvaloniaView.cs

@@ -156,6 +156,8 @@ namespace Avalonia.iOS
             public TopLevelImpl(AvaloniaView view)
             {
                 _view = view;
+                Handle = new UIViewControlHandle(_view);
+
                 _nativeControlHost = new NativeControlHostImpl(view);
 #if TVOS
                 _storageProvider = null;