uno icon indicating copy to clipboard operation
uno copied to clipboard

[Android][iOS] ApplicationView.GetForCurrentView().VisibleBounds returns a Rectangle with all values set to 0

Open takla21 opened this issue 1 year ago • 1 comments

Current behavior

image

For instance, when having this logic to set the bottom bar

#if __ANDROID__ || __IOS__
        var full = App.Instance.MainWindow!.Bounds;
        var bounds = ApplicationView.GetForCurrentView().VisibleBounds;

        var bottomPadding = full.Bottom - bounds.Bottom;
#else
        var bottomPadding = 0;
#endif

        TestTextBlock.Text = bottomPadding.ToString();
        if (bottomPadding > 0)
        {
            SafeAreaRow.Height = new GridLength(bottomPadding);
        }
<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="*" />
    <!-- SafeAreaRow.Height is set in code behind -->
    <RowDefinition x:Name="SafeAreaRow"
                   Height="0" />
  </Grid.RowDefinitions>

  <TextBlock x:Name="TestTextBlock"
             FontSize="20"
             VerticalAlignment="Center" />

  <Border Background="Red"
          Grid.Row="1" />
</Grid>

it looks like this Screenshot_20240216-134700

Expected behavior

image (1) ApplicationView.GetForCurrentView().VisibleBounds should return a Rect with the dimension of the screen excluding phone edges.

How to reproduce it (as minimally and precisely as possible)

Workaround

N/A

Works on UWP/WinUI

None

Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

5.2.0-dev.683

Affected platforms

Android, iOS

IDE

Visual Studio 2022

IDE version

17.10.0 Preview 1.0

Relevant plugins

No response

Anything else we need to know?

I've found this bug while trying to create a sample for this issue #15520

takla21 avatar Feb 16 '24 23:02 takla21

This feels similar to https://github.com/unoplatform/nventive-private/issues/510, what do you think @kazo0?

jeromelaban avatar Feb 19 '24 12:02 jeromelaban