-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Flyout and TitleView Offset Measurements (#12480)
* - Simplify and fix flyout offset measurements * - fix merge * Update PublicAPI.Unshipped.txt * Update PublicAPI.Unshipped.txt * Update ShellTests.cs * - fix up null checks and formatting * - fix merge * Auto-format source code * -sample * Auto-format source code * - fix safe area mistake * - fix titleview lifecycles on shell * Auto-format source code * - fix titlebar android * - remove samples * Update UIContainerView.cs * - PR comments * - formatting --------- Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com> Co-authored-by: Rui Marinho <me@ruimarinho.net>
- Loading branch information
1 parent
40dfb10
commit ebc990b
Showing
12 changed files
with
298 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 47 additions & 9 deletions
56
src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellFlyoutHeaderContainer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,70 @@ | ||
#nullable disable | ||
using System; | ||
using CoreGraphics; | ||
using Microsoft.Maui.Platform; | ||
using UIKit; | ||
|
||
namespace Microsoft.Maui.Controls.Platform.Compatibility | ||
{ | ||
internal class ShellFlyoutHeaderContainer : UIContainerView | ||
{ | ||
Thickness _safearea = Thickness.Zero; | ||
public ShellFlyoutHeaderContainer(View view) : base(view) | ||
{ | ||
UpdateSafeAreaMargin(); | ||
} | ||
|
||
public override Thickness Margin | ||
{ | ||
get | ||
{ | ||
if (!View.IsSet(View.MarginProperty)) | ||
{ | ||
var newMargin = new Thickness(0, (float)UIApplication.SharedApplication.GetSafeAreaInsetsForWindow().Top, 0, 0); | ||
if (View.IsSet(View.MarginProperty)) | ||
return View.Margin; | ||
|
||
if (newMargin != View.Margin) | ||
{ | ||
View.Margin = newMargin; | ||
} | ||
} | ||
var safeArea = UIApplication.SharedApplication.GetSafeAreaInsetsForWindow(); | ||
|
||
return View.Margin; | ||
return new Thickness( | ||
safeArea.Left, | ||
safeArea.Top, | ||
safeArea.Right, | ||
safeArea.Left); | ||
} | ||
} | ||
|
||
public override void LayoutSubviews() | ||
{ | ||
if (!UpdateSafeAreaMargin()) | ||
base.LayoutSubviews(); | ||
} | ||
|
||
public override void SafeAreaInsetsDidChange() | ||
{ | ||
UpdateSafeAreaMargin(); | ||
base.SafeAreaInsetsDidChange(); | ||
} | ||
|
||
bool UpdateSafeAreaMargin() | ||
{ | ||
var safeArea = UIApplication.SharedApplication.GetSafeAreaInsetsForWindow(); | ||
|
||
if (safeArea.Top != _safearea.Top || | ||
safeArea.Bottom != _safearea.Bottom || | ||
safeArea.Right != _safearea.Right || | ||
safeArea.Left != _safearea.Left) | ||
{ | ||
_safearea = | ||
new Thickness( | ||
safeArea.Left, | ||
safeArea.Top, | ||
safeArea.Right, | ||
safeArea.Bottom); | ||
|
||
OnHeaderSizeChanged(); | ||
return true; | ||
} | ||
|
||
return false; | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.