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
22.27k stars 1.76k forks source link

iOS Button Flickering Animations when Layout Updates #25487

Open tj-devel709 opened 1 month ago

tj-devel709 commented 1 month ago

Description

When the button is resized and the title and image need to be translated, there is a little flicker animation going on. For example, if you apply the following code where the button text changes, you will see there will be a little flicker animation before the image and text are both recentered.

Steps to Reproduce

In a MAUI Project, add the following xaml and code behind:

    <VerticalStackLayout>
        <Button Text="Short" ImageSource="dotnet_bot.png" 
            ContentLayout="Top" x:Name="Button1" 
            Clicked="OnButtonClicked" Background="Purple" />
        <Button Text="A very long text that will take up more space" 
            ImageSource="dotnet_bot.png" ContentLayout="Top" 
            x:Name="Button2" Background="Purple" />
    </VerticalStackLayout>
    bool _isToggled;

    void OnButtonClicked(object sender, EventArgs e)
    {
        if (!_isToggled)
        {
            Button1.Text = "A very long text that will take up more space";
            Button2.Text = "Short";
        }

        else
        {
            Button1.Text = "Short";
            Button2.Text = "A very long text that will take up more space";
        }

        _isToggled = !_isToggled;
    }

When you click the top button, you will see there a very noticeable animation flickering where the text is changed and then the layout is recalculated and centered.

https://github.com/user-attachments/assets/c18c2d4e-ebb2-4a24-b2bf-6f3b3f952e21

Link to public reproduction project repository

No response

Version with bug

8.0.92 SR9.2

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

Zhanglirong-Winnie commented 1 month ago

This issue has been verified using Visual Studio 17.12.0 Preview 3( 8.0.92 &8.0.82 & 8.0.3). Can repro this issue on iOS platform. Windows and Android platforms work fine.