Skip to content

Comments

[.Net10] [Proposal] [iOS] TabbedPage.AutoResizeIconsProperty#28046

Closed
kubaflo wants to merge 4 commits intodotnet:net10.0from
kubaflo:autoresize-tabbed-page-icons
Closed

[.Net10] [Proposal] [iOS] TabbedPage.AutoResizeIconsProperty#28046
kubaflo wants to merge 4 commits intodotnet:net10.0from
kubaflo:autoresize-tabbed-page-icons

Conversation

@kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Feb 26, 2025

Description of Change

Maybe we can add TabbedPage.AutoResizeIconsProperty so that when it is set to true, the tab bar icons will be resized to Apple's recommended values grabbed from here https://developer.apple.com/design/human-interface-guidelines/tab-bars#Target-dimensions. Currently, devs have to manually rescale their images to make them look appealing to users, which is not a disaster, but I think they would appreciate us making it for them

TabbedPage.AutoResizeIconsProperty

False True
Screen.Recording.2025-02-26.at.01.21.12.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Feb 26, 2025
@kubaflo kubaflo added t/enhancement ☀️ New feature or request proposal/open platform/ios area-controls-tabbedpage TabbedPage and removed community ✨ Community Contribution labels Feb 26, 2025
@kubaflo
Copy link
Contributor Author

kubaflo commented Feb 26, 2025

If this makes sense, then I think It would be a good idea to do something similar for shell

@jfversluis
Copy link
Member

Yes! Love it! Do we have any indication how much of a performance hit this would be?

I guess another approach to circumvent that is to generate an image with the right size at compile time and add _tab or something to the name and make it use that automatically. But I guess this is fine and shouldn’t even be noticed, especially on iOS.

25 is hard coded now, can we get that size programmatically from somewhere? And isn’t there a different size for the compact mode? What will this do when you turn the iPhone to landscape?

@jsuarezruiz
Copy link
Contributor

Also, could retarget to the net10.0 branch?

@kubaflo
Copy link
Contributor Author

kubaflo commented Feb 26, 2025

Also, could retarget to the net10.0 branch?

Yeah, I will do it, but later, because it is easier for me to develop on net9.0

@kubaflo
Copy link
Contributor Author

kubaflo commented Feb 26, 2025

Yes! Love it! Do we have any indication how much of a performance hit this would be?

I guess another approach to circumvent that is to generate an image with the right size at compile time and add _tab or something to the name and make it use that automatically. But I guess this is fine and shouldn’t even be noticed, especially on iOS.

25 is hard coded now, can we get that size programmatically from somewhere? And isn’t there a different size for the compact mode? What will this do when you turn the iPhone to landscape?

Hmmm that's kind of tricky because according to Apple there are a few configurations:

Screenshot 2025-02-26 at 12 48 07

The 25pt is almost always used, but you're right for the compact/horizontal mode it should be 18pt. I tried to find some method to get the recommended size for the current screen from Apple's API, but they don't provide devs with this :/

@kubaflo
Copy link
Contributor Author

kubaflo commented Feb 26, 2025

Apple docs for tab bar and icons: https://developer.apple.com/design/human-interface-guidelines/tab-bars

@kubaflo
Copy link
Contributor Author

kubaflo commented Feb 26, 2025

@jfversluis I think I've figured it out! Now it should adjust when switching orientation and in compact mode. Check the latest commit :)

Simulator.Screen.Recording.-.iPhone.16.Pro.Max.-.2025-02-26.at.20.17.27.mp4

@kubaflo
Copy link
Contributor Author

kubaflo commented Feb 26, 2025

@jfversluis I've noticed one bug with my approach. I didn't respect proportions, so all images were scaled to a square. I've added a commit that fixes it. Now everything adheres to Apple's native scaling https://developer.apple.com/design/human-interface-guidelines/tab-bars#Target-dimensions

Before After

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jfversluis
Copy link
Member

Dude you're on fire, this makes me so happy

@jfversluis jfversluis added this to the .NET 10.0-preview2 milestone Feb 28, 2025
@jfversluis jfversluis self-assigned this Feb 28, 2025
@kubaflo
Copy link
Contributor Author

kubaflo commented Feb 28, 2025

Dude you're on fire, this makes me so happy

Yeah, I like it too. What puzzles me is whether we should do something similar for the tabbed page generated by shell?
Currently, this iOS-specific flag works only with TabbedPage

@jfversluis
Copy link
Member

Why would we (not) do that?

@kubaflo
Copy link
Contributor Author

kubaflo commented Feb 28, 2025

Why would we (not) do that?

Okay, I will see what I can come up with this weekend

@kubaflo kubaflo force-pushed the autoresize-tabbed-page-icons branch from f0fc6ea to 799e940 Compare March 2, 2025 14:47
@kubaflo kubaflo force-pushed the autoresize-tabbed-page-icons branch from 799e940 to d97c250 Compare March 2, 2025 15:36
@kubaflo
Copy link
Contributor Author

kubaflo commented Mar 2, 2025

Why would we (not) do that?

Here it is :)
#28128

@jsuarezruiz
Copy link
Contributor

jsuarezruiz commented Mar 4, 2025

/azp run

@azure-pipelines

This comment was marked as off-topic.

CGSize newSize = image.Size;

//https://developer.apple.com/design/human-interface-guidelines/tab-bars#Target-dimensions
bool isRegularTabBar = traitCollection.VerticalSizeClass == UIUserInterfaceSizeClass.Regular;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, can create some variables like:

bool isRegularTabBar = traitCollection.VerticalSizeClass == UIUserInterfaceSizeClass.Regular;
float targetWidth = isRegularTabBar ? 31f : 23f;
float targetHeight = isRegularTabBar ? 28f : 20f;

And then, reuse like:

if (image.Size.Width > image.Size.Height) // Wide
{
    newSize.Width = targetWidth;
    newSize.Height = targetWidth * image.Size.Height / image.Size.Width;
}
else if (image.Size.Width < image.Size.Height) // Tall
{
    newSize.Height = targetHeight;
    newSize.Width = targetHeight * image.Size.Width / image.Size.Height;
}

bool isRegularTabBar = traitCollection.VerticalSizeClass == UIUserInterfaceSizeClass.Regular;
if (image.Size.Width > image.Size.Height) //Wide
{
newSize.Width = isRegularTabBar ? 31 : 23;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link to the apple dimensions guidelines is nice, but could we include more comments associated with the numbers?

@kubaflo kubaflo marked this pull request as ready for review March 19, 2025 09:23
@kubaflo kubaflo requested a review from a team as a code owner March 19, 2025 09:23
@kubaflo kubaflo force-pushed the autoresize-tabbed-page-icons branch from 861d5b4 to 7e90052 Compare March 21, 2025 01:15
@jsuarezruiz
Copy link
Contributor

@kubaflo Could you rebase and fix the conflicts?

@kubaflo kubaflo force-pushed the autoresize-tabbed-page-icons branch from 7e90052 to 4046576 Compare March 21, 2025 12:52
@kubaflo
Copy link
Contributor Author

kubaflo commented Mar 21, 2025

@kubaflo Could you rebase and fix the conflicts?

done

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

public void TabBarIconsShouldAutoscale()
{
App.WaitForElement("Tab1");
VerifyScreenshot();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending snapshots. Could you commit the images?

Example, Windows:
image

@rmarinho
Copy link
Member

Can you rebase and retarget net10.0 @kubaflo ? and change the base of the PR .

Thanks

@kubaflo kubaflo force-pushed the autoresize-tabbed-page-icons branch from 3b98b6a to bc7d157 Compare March 27, 2025 00:18
@kubaflo kubaflo requested a review from a team as a code owner March 27, 2025 00:18
@kubaflo kubaflo changed the base branch from main to net10.0 March 27, 2025 00:19
Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to review APIs

@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing Mar 28, 2025
@kubaflo kubaflo self-assigned this Mar 30, 2025
@PureWeen
Copy link
Member

Closing in favor of #29003

@PureWeen PureWeen closed this Apr 15, 2025
@github-project-automation github-project-automation bot moved this from Ready To Review to Done in MAUI SDK Ongoing Apr 15, 2025
@github-actions github-actions bot locked and limited conversation to collaborators May 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants