Skip to content

Commit 38c0051

Browse files
kubafloPureWeen
andauthored
[Net10] [iOS] Enable sizing back/flyout icon with the FontImageSource size property (#30962)
* FontImageSource * - just use height as the bounding box not width * - set to 24 * - change to 44 * - fix screen shots --------- Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
1 parent 42f1f20 commit 38c0051

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -977,16 +977,27 @@ internal static void SetFlyoutLeftBarButton(UIViewController containerController
977977
{
978978
var icon = result?.Value;
979979
var originalImageSize = icon?.Size ?? CGSize.Empty;
980-
// Referred from the default hamburger size
981-
var defaultIconHeight = 23f;
982-
var defaultIconWidth = 23f;
980+
981+
// The largest height you can use for navigation bar icons in iOS.
982+
// Per Apple's Human Interface Guidelines, the navigation bar height is 44 points,
983+
// so using the full height ensures maximum visual clarity and maintains consistency
984+
// with iOS design standards. This allows icons to utilize the entire available
985+
// vertical space within the navigation bar container.
986+
var defaultIconHeight = 44f;
983987
var buffer = 0.1;
988+
// We only check height because the navigation bar constrains vertical space (44pt height),
989+
// but allows horizontal flexibility. Width can vary based on icon design and content,
990+
// while height must fit within the fixed navigation bar bounds to avoid clipping.
991+
984992
// if the image is bigger than the default available size, resize it
985993
if (icon is not null)
986994
{
987-
if (originalImageSize.Height - defaultIconHeight > buffer || originalImageSize.Width - defaultIconWidth > buffer)
995+
if (originalImageSize.Height - defaultIconHeight > buffer)
988996
{
989-
icon = icon.ResizeImageSource(defaultIconWidth, defaultIconHeight, originalImageSize);
997+
if (FlyoutPage.Flyout.IconImageSource is not FontImageSource fontImageSource || !fontImageSource.IsSet(FontImageSource.SizeProperty))
998+
{
999+
icon = icon.ResizeImageSource(originalImageSize.Width, defaultIconHeight, originalImageSize);
1000+
}
9901001
}
9911002
try
9921003
{

src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,15 +465,26 @@ void UpdateLeftToolbarItems()
465465
{
466466
icon = result?.Value;
467467
var originalImageSize = icon?.Size ?? CGSize.Empty;
468-
// Referred from the default hamburger size
469-
var defaultIconHeight = 23f;
470-
var defaultIconWidth = 23f;
468+
469+
// The largest height you can use for navigation bar icons in iOS.
470+
// Per Apple's Human Interface Guidelines, the navigation bar height is 44 points,
471+
// so using the full height ensures maximum visual clarity and maintains consistency
472+
// with iOS design standards. This allows icons to utilize the entire available
473+
// vertical space within the navigation bar container.
474+
var defaultIconHeight = 44f;
471475
var buffer = 0.1;
476+
// We only check height because the navigation bar constrains vertical space (44pt height),
477+
// but allows horizontal flexibility. Width can vary based on icon design and content,
478+
// while height must fit within the fixed navigation bar bounds to avoid clipping.
479+
472480
// if the image is bigger than the default available size, resize it
473481

474-
if (icon is not null && originalImageSize.Height - defaultIconHeight > buffer || originalImageSize.Width - defaultIconWidth > buffer)
482+
if (icon is not null && originalImageSize.Height - defaultIconHeight > buffer)
475483
{
476-
icon = icon.ResizeImageSource(defaultIconWidth, defaultIconHeight, originalImageSize);
484+
if (image is not FontImageSource fontImageSource || !fontImageSource.IsSet(FontImageSource.SizeProperty))
485+
{
486+
icon = icon.ResizeImageSource(originalImageSize.Width, defaultIconHeight, originalImageSize);
487+
}
477488
}
478489
}
479490
else if (String.IsNullOrWhiteSpace(text) && IsRootPage && _flyoutBehavior == FlyoutBehavior.Flyout)
1.47 KB
Loading
2.77 KB
Loading

0 commit comments

Comments
 (0)