maui icon indicating copy to clipboard operation
maui copied to clipboard

Add Frame observer for UIWindow frame changes

Open drasticactions opened this issue 1 year ago • 0 comments

Description of Change

As far as I can see, there are no SizeChange events fired for iOS and Mac, as beyond its initial creation there's no events wired in to handle it. Normally, I believe, you would override viewWillTransitionToSize on the UIView, but since I don't think MAUI subclasses UIWindow, we can steal what the WindowOverlay does and subscribe to frame changes. Those should fire when the underlying UIWindow Frame updates.

I'm not 100% sure if the numbers are correct for the parameters being passed in, but since SizeChange itself doesn't send that info, it should be safe enough as an underlying SizeChange event.

The two underlying issues I have with this are:

  • I don't know where to dispose the FrameObserver from the handler.
  • I'm not sure how to write a test for this.

Issues Fixed

Fixes https://github.com/dotnet/maui/issues/20198

https://github.com/dotnet/maui/assets/898335/15016bb8-23f3-4828-9736-bc6fb6ea0d67

drasticactions avatar Jan 30 '24 06:01 drasticactions