Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MartyIX committed Aug 7, 2024
1 parent 6ee1d85 commit 3862e00
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
16 changes: 7 additions & 9 deletions src/Core/src/Handlers/Window/WindowHandler.iOS.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
using System;
using Foundation;
using ObjCRuntime;
using UIKit;

namespace Microsoft.Maui.Handlers
{
public partial class WindowHandler : ElementHandler<IWindow, UIWindow>
{
private IDisposable? effectiveGeometryObserver;
private IDisposable? _effectiveGeometryObserver;

protected override void ConnectHandler(UIWindow platformView)
{
base.ConnectHandler(platformView);

UpdateVirtualViewFrame(platformView);

effectiveGeometryObserver = platformView.WindowScene?.AddObserver("effectiveGeometry", NSKeyValueObservingOptions.OldNew, HandleEffectiveGeometryObserved);
_effectiveGeometryObserver = platformView.WindowScene?.AddObserver("effectiveGeometry", NSKeyValueObservingOptions.OldNew, HandleEffectiveGeometryObserved);
}

#pragma warning disable RS0016 // Add public types and members to the declared API
protected override void DisconnectHandler(UIWindow platformView)
#pragma warning restore RS0016 // Add public types and members to the declared API
{
base.DisconnectHandler(platformView);
_effectiveGeometryObserver?.Dispose();

effectiveGeometryObserver?.Dispose();
base.DisconnectHandler(platformView);
}

void HandleEffectiveGeometryObserved(NSObservedChange obj)
{
if (obj is not null && obj.OldValue is UIWindowSceneGeometry oldGeometry && obj.NewValue is UIWindowSceneGeometry newGeometry)
if (obj is not null && obj.NewValue is UIWindowSceneGeometry newGeometry)
{
Console.WriteLine($" oldValue={oldGeometry.SystemFrame}, newValue={newGeometry.SystemFrame}");
VirtualView.FrameChanged(newGeometry.SystemFrame.ToRectangle());
}
}
Expand Down Expand Up @@ -105,7 +101,9 @@ public static void MapMenuBar(IWindowHandler handler, IWindow view)
public static void MapRequestDisplayDensity(IWindowHandler handler, IWindow window, object? args)
{
if (args is DisplayDensityRequest request)
{
request.SetResult(handler.PlatformView.GetDisplayDensity());
}
}

void UpdateVirtualViewFrame(UIWindow window)
Expand Down
9 changes: 3 additions & 6 deletions src/Core/src/Platform/iOS/WindowExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,20 @@ internal static void UpdateCoordinates(this UIWindow platformWindow, IWindow win
{
var callFrameChanged = true;
var rectangle = platformWindow.Bounds.ToRectangle();
Console.WriteLine($"UpdateCoordinates: platformWindow={rectangle}, window=[X={window.X}, Y={window.Y}, Width={window.Width}, Height Height={window.Height}]");

if (OperatingSystem.IsIOSVersionAtLeast(16))
{
var windowScene = platformWindow.WindowScene;

if (windowScene is not null)
{
var preferences = new UIWindowSceneGeometryPreferencesMac
UIWindowSceneGeometryPreferencesMac preferences = new()
{
SystemFrame = new CGRect(window.X, window.Y, window.Width, window.Height)
};

windowScene.RequestGeometryUpdate(preferences, (error) => {
System.Diagnostics.Debug.WriteLine("" + error);
});

// TODO: Log errors.
windowScene.RequestGeometryUpdate(preferences, (error) => { });
callFrameChanged = false;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ override Microsoft.Maui.Handlers.SwipeItemButton.Frame.set -> void
override Microsoft.Maui.Handlers.SwipeItemMenuItemHandler.ConnectHandler(UIKit.UIButton! platformView) -> void
override Microsoft.Maui.Handlers.SwipeItemMenuItemHandler.DisconnectHandler(UIKit.UIButton! platformView) -> void
override Microsoft.Maui.Handlers.SwitchHandler.NeedsContainer.get -> bool
override Microsoft.Maui.Handlers.WindowHandler.DisconnectHandler(UIKit.UIWindow! platformView) -> void
override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool
override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int
override Microsoft.Maui.Platform.ContentView.WillRemoveSubview(UIKit.UIView! uiview) -> void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,4 @@ virtual Microsoft.Maui.MauiUIApplicationDelegate.PerformFetch(UIKit.UIApplicatio
Microsoft.Maui.Platform.UIEdgeInsetsExtensions
static Microsoft.Maui.Platform.UIEdgeInsetsExtensions.ToThickness(this UIKit.UIEdgeInsets insets) -> Microsoft.Maui.Thickness
*REMOVED*override Microsoft.Maui.Platform.MauiLabel.InvalidateIntrinsicContentSize() -> void
override Microsoft.Maui.Handlers.WindowHandler.DisconnectHandler(UIKit.UIWindow! platformView) -> void

0 comments on commit 3862e00

Please sign in to comment.