-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] Auto Resize chrome icons on iOS to make it more consistent with other platforms - Toolbar items #30995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |||||
| using CoreGraphics; | ||||||
| using Foundation; | ||||||
| using Microsoft.Maui.Graphics; | ||||||
| using Microsoft.Maui.Graphics.Platform; | ||||||
| using Microsoft.Maui.Platform; | ||||||
| using ObjCRuntime; | ||||||
| using UIKit; | ||||||
|
|
@@ -57,6 +58,35 @@ internal static SecondarySubToolbarItem ToSecondarySubToolbarItem(this ToolbarIt | |||||
| return new SecondarySubToolbarItem(item, action); | ||||||
| } | ||||||
|
|
||||||
| static UIImage ScaleImageToSystemDefaults(ImageSource imageSource, UIImage uIImage) | ||||||
| { | ||||||
| var icon = uIImage; | ||||||
|
|
||||||
| var originalImageSize = icon?.Size ?? CGSize.Empty; | ||||||
|
|
||||||
| // The largest height you can use for navigation bar icons in iOS. | ||||||
| // Per Apple's Human Interface Guidelines, the navigation bar height is 44 points, | ||||||
| // so using the full height ensures maximum visual clarity and maintains consistency | ||||||
| // with iOS design standards. This allows icons to utilize the entire available | ||||||
| // vertical space within the navigation bar container. | ||||||
| var defaultIconHeight = 44f; | ||||||
| var buffer = 0.1; | ||||||
|
||||||
| var buffer = 0.1; | |
| var buffer = IconHeightComparisonTolerance; |
Copilot
AI
Aug 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ResizeImageSource call passes originalImageSize.Width for the new width but also passes originalImageSize as the third parameter. This appears redundant and could be confusing - consider clarifying the intent or simplifying the parameters.
| icon = icon.ResizeImageSource(originalImageSize.Width, defaultIconHeight, originalImageSize); | |
| icon = icon.ResizeImageSource(originalImageSize.Width, defaultIconHeight); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 44f should be extracted to a named constant to improve maintainability and make the iOS navigation bar height constraint explicit.