Repository: dotnet/maui
File: src/Controls/src/Core/Compatibility/Handlers/FlyoutPage/iOS/PhoneFlyoutPageRenderer.cs (C#)

Code before:
		}

		void HandlePropertyChanged(object sender, PropertyChangedEventArgs e)
		{
			if (e.PropertyName == "Flyout" || e.PropertyName == "Detail")
				UpdateFlyoutPageContainers();
			else if (e.PropertyName == Microsoft.Maui.Controls.FlyoutPage.IsPresentedProperty.PropertyName)
				UpdatePresented(((FlyoutPage)Element).IsPresented, true);
			else if (e.PropertyName == Microsoft.Maui.Controls.FlyoutPage.IsGestureEnabledProperty.PropertyName)
				UpdatePanGesture();
			else if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName || e.PropertyName == VisualElement.BackgroundProperty.PropertyName)
				UpdateBackground();
			else if (e.PropertyName == Page.BackgroundImageSourceProperty.PropertyName)
				UpdateBackground();
			else if (e.PropertyName == PlatformConfiguration.iOSSpecific.FlyoutPage.ApplyShadowProperty.PropertyName)
				UpdateApplyShadow(((FlyoutPage)Element).OnThisPlatform().GetApplyShadow());
			else if (e.PropertyName == PlatformConfiguration.iOSSpecific.Page.PrefersHomeIndicatorAutoHiddenProperty.PropertyName ||
					 e.PropertyName == PlatformConfiguration.iOSSpecific.Page.PrefersStatusBarHiddenProperty.PropertyName)
				UpdatePageSpecifics();
		}

		void LayoutChildren(bool animated)
		{
			var frame = Element.Bounds.ToCGRect();

			if (Element is FlyoutPage flyoutPage && flyoutPage is ISafeAreaView sav &&
			 !sav.IgnoreSafeArea && OperatingSystem.IsIOSVersionAtLeast(11))
			{
				var safeAreaInsets = View.SafeAreaInsets;

				if (safeAreaInsets.Top > 0)
				{
					frame.Y = safeAreaInsets.Top;
					frame.Height -= safeAreaInsets.Top;
				}
			}

			var flyoutFrame = frame;
			nfloat opacity = 1;

			if (FlyoutOverlapsDetailsInPopoverMode)
				flyoutFrame.Width = 320;
			else
				flyoutFrame.Width = (int)(Math.Min(flyoutFrame.Width, flyoutFrame.Height) * 0.8);

			var detailRenderer = FlyoutPage.Detail.Handler as IPlatformViewHandler;
			if (detailRenderer == null)
				return;

			var detailView = detailRenderer.ViewController.View;


Review comment (refactor):
`var safeAreaTop = safeAreaInsets.Top;`

`safeAreaInsets.Top` is checked twice, can extract it into a local variable.

Code after:
				UpdateBackground();
			else if (e.PropertyName == Page.BackgroundImageSourceProperty.PropertyName)
				UpdateBackground();
			else if (e.PropertyName == PlatformConfiguration.iOSSpecific.FlyoutPage.ApplyShadowProperty.PropertyName)
				UpdateApplyShadow(((FlyoutPage)Element).OnThisPlatform().GetApplyShadow());
			else if (e.PropertyName == Microsoft.Maui.Controls.FlyoutPage.FlyoutLayoutBehaviorProperty.PropertyName)
				UpdateFlyoutLayoutBehaviorChanges();
			else if (e.PropertyName == PlatformConfiguration.iOSSpecific.Page.PrefersHomeIndicatorAutoHiddenProperty.PropertyName ||
					 e.PropertyName == PlatformConfiguration.iOSSpecific.Page.PrefersStatusBarHiddenProperty.PropertyName)
				UpdatePageSpecifics();
		}

		void LayoutChildren(bool animated)
		{
			var frame = Element.Bounds.ToCGRect();

			// Apply safe area insets to the FlyoutPage container if UseSafeArea is enabled.
			// This ensures the Flyout content (e.g., CollectionView) renders below the status bar/notch
			// on iOS devices with notches (iPhone X and newer). Without this adjustment, the container
			// would start at Y=0, causing content to overlap with the status bar.
			// https://github.com/dotnet/maui/issues/29170
			if (Element is FlyoutPage flyoutPage && flyoutPage is ISafeAreaView sav &&
			 !sav.IgnoreSafeArea && OperatingSystem.IsIOSVersionAtLeast(11))
			{
				var safeAreaTopInset = View.SafeAreaInsets.Top;

				if (safeAreaTopInset > 0)
				{
					frame.Y = safeAreaTopInset;
					frame.Height -= safeAreaTopInset;
				}
			}

			var flyoutFrame = frame;
			nfloat opacity = 1;

			if (FlyoutOverlapsDetailsInPopoverMode)
				flyoutFrame.Width = 320;
			else
				flyoutFrame.Width = (int)(Math.Min(flyoutFrame.Width, flyoutFrame.Height) * 0.8);

			var detailRenderer = FlyoutPage.Detail.Handler as IPlatformViewHandler;
			if (detailRenderer == null)
				return;

			var detailView = detailRenderer.ViewController.View;

			if (IsRTL && !FlyoutOverlapsDetailsInPopoverMode)
			{
				flyoutFrame.X = (int)(flyoutFrame.Width * .25);
			}