-
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
Conversation
|
Hey there @@kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
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.
Pull Request Overview
This PR implements automatic resizing of toolbar item icons on iOS to maintain consistency with other platforms. The change ensures that oversized icons are scaled down to fit within the iOS navigation bar's 44-point height limit while preserving aspect ratio.
- Adds a new
ScaleImageToSystemDefaultsmethod that intelligently resizes icons based on iOS navigation bar constraints - Updates both primary and secondary toolbar items to use the new scaling logic
- Maintains special handling for FontImageSource icons that already have explicit size settings
| // 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; |
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 magic number 44f should be extracted to a named constant to improve maintainability and make the iOS navigation bar height constraint explicit.
| var defaultIconHeight = 44f; | |
| var defaultIconHeight = NavigationBarHeight; |
| // 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; |
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 magic number 0.1 should be extracted to a named constant with a descriptive name explaining its purpose as a tolerance buffer for size comparison.
| var buffer = 0.1; | |
| var buffer = IconHeightComparisonTolerance; |
| { | ||
| if (imageSource is not FontImageSource fontImageSource || !fontImageSource.IsSet(FontImageSource.SizeProperty)) | ||
| { | ||
| icon = icon.ResizeImageSource(originalImageSize.Width, defaultIconHeight, originalImageSize); |
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); |
|
/azp run |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
| static UIImage ScaleImageToSystemDefaults(ImageSource imageSource, UIImage uIImage) | ||
| { | ||
| var icon = imageSource is not FontImageSource | ||
| ? uIImage?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) |
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.
@kubaflo based on what we reverted for NET9 do we need to change this back for now so that we get the blue tint still by default for iOS?
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Issues Fixed
Fixes #30994