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.98k stars 1.71k forks source link

Flow Direction updates are ignored in Android #15182

Open arahmancsd opened 1 year ago

arahmancsd commented 1 year ago

Description

I am trying to change FlowDirectionof the content page based on Localization, however, the FlowDirectionseems to have no effect on Android. The property is wholly ignored in Android.

Windows Left to Right Screenshot 2023-05-19 152827

Windows Right to Left Screenshot 2023-05-19 152850

Android 33 - Left to Right Screenshot 2023-05-19 153007

Android 33 - Right to Left Screenshot 2023-05-19 153021

Steps to Reproduce

Run the project and click on the button "Click me". The button changes direction each time clicked.

Link to public reproduction project repository

https://github.com/arahmancsd/MauiApp2.App

Version with bug

7.0.86

Last version that worked well

7.0.86

Affected platforms

Android

Affected platform versions

Android 33

Did you find any workaround?

No response

Relevant log output

No response

hartez commented 1 year ago

As a workaround until we get this fixed, you can add a call to InvalidateMeasure() after you change the page's FlowDirection - that will force the page to update and lay things out according to the new setting:

private void OnCounterClicked(object sender, EventArgs e)
{
    count++;

    if (count == 1)
        CounterBtn.Text = $"Clicked {count} time";
    else
        CounterBtn.Text = $"Clicked {count} times";

    FlowDirection = FlowDirection == FlowDirection.LeftToRight ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
    InvalidateMeasure();
}
XamlTest commented 1 year ago

Verified this on Visual Studio Enterprise 17.7.0 Preview 3.0. Repro on Android 13.0-API33 .NET 8, not repro on Windows 11 and iOS 16.4 with below Project: 15182.zip

Direction