dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.83k stars 1.67k forks source link

On Platform="Default" not working #22105

Open twojnarowski opened 2 months ago

twojnarowski commented 2 months ago

Description

I want to have font sizes specific for each idiom and each platform. I have created a Resources file with this code:

    <OnIdiom x:Key="TestSizeDefault" x:TypeArguments="x:Double">
        <OnIdiom.Tablet>
            <OnPlatform x:TypeArguments="x:Double">
                <On Platform="iOS" Value="100" />
                <On Platform="Default" Value="100" />
            </OnPlatform>
        </OnIdiom.Tablet>
        <OnIdiom.Phone>
            <OnPlatform x:TypeArguments="x:Double">
                <On Platform="Default" Value="100" />
            </OnPlatform>
        </OnIdiom.Phone>
        <OnIdiom.Desktop>
            <OnPlatform x:TypeArguments="x:Double">
                <On Platform="Default" Value="100" />
            </OnPlatform>
        </OnIdiom.Desktop>
        <OnIdiom.Default>
            <OnPlatform x:TypeArguments="x:Double">
                <On Platform="Default" Value="100" />
            </OnPlatform>
        </OnIdiom.Default>
    </OnIdiom>

And while running the application on both Windows and Android phone, the font sizes are not being set to 100 from the "Default" platform. This is what it looks like in a reproduction repo (first text is from On Platform="Android" second one from On Platform="Default"):

image

Steps to Reproduce

Create an OnIdiom that has OnPlatform inside of it and make a Label use FontSize from the static resource with this OnIdiom. Running the repository with reproduction, one Label gets big and other one does not, while both should have font size = 100.

Link to public reproduction project repository

https://github.com/twojnarowski/MauiAppOnPlatformDefaultRepro/tree/master

Version with bug

8.0.7 SR2

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows

Affected platform versions

No response

Did you find any workaround?

I have to set manually On Platforms for each platform, instead of using only Default where I want the same size for each platform.

Relevant log output

No response

kevinxufei commented 2 months ago

Can repro this issue at android platform on the latest 17.10 Preview 5 (8.0.21&8.0.3).