Skip to content

Commit

Permalink
fix: add safearea to shell and add margin to control (#616)
Browse files Browse the repository at this point in the history
* fix: add safearea to shell and add margin to control

* fix: adjust safearea

---------

Co-authored-by: Steve Bilogan <steve.bilogan@gmail.com>
  • Loading branch information
carlh98 and kazo0 committed Jun 27, 2023
1 parent d4cb6e5 commit 9dd918f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,17 @@
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<rtt:UnitTestsControl />
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Text="Runtime Tests"
MaxLines="1"
FontSize="34"
TextTrimming="CharacterEllipsis"
Foreground="{ThemeResource OnBackgroundBrush}"
Margin="48,0,0,0" />
<rtt:UnitTestsControl Grid.Row="1" />
</Grid>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:wasm="http://uno.ui/wasm"
xmlns:xamarin="http://uno.ui/xamarin"
xmlns:utu="using:Uno.Toolkit.UI"
mc:Ignorable="wasm xamarin">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition x:Name="TopPaddingRow"
Height="0" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<!-- We set CompactModeThresholdWidth to a very high value so that it never happens. We don't want to use the compact mode. -->
<muxc:NavigationView Grid.Row="2"
<muxc:NavigationView Grid.Row="1"
utu:SafeArea.Insets="VisibleBounds"
x:Name="NavigationViewControl"
OpenPaneLength="260"
IsSettingsVisible="False"
Expand All @@ -33,7 +33,7 @@
IsTabStop="False">
<muxc:NavigationView.PaneHeader>
<!-- Left padding for overlay toggle button -->
<Grid Padding="24,0,0,0">
<Grid Padding="24,8,0,0">
<!-- Image -->
<Image Source="ms-appx:///Assets/UnoLogo.png"
Height="101"
Expand All @@ -55,11 +55,12 @@
<!-- Nested frame for samples that needs to be fullscreen -->
<Frame x:Name="NestedSampleFrame"
AutomationProperties.AutomationId="NestedSampleFrame"
Grid.RowSpan="3"
Grid.RowSpan="2"
Visibility="Collapsed" />

<!-- Custom pane toggle button -->
<Button Grid.Row="2"
<Button Grid.Row="1"
utu:SafeArea.Insets="Top, Left"
x:Name="NavViewToggleButton"
Click="NavViewToggleButton_Click"
HorizontalAlignment="Left"
Expand All @@ -69,7 +70,7 @@

<StackPanel x:Name="DebugPanel"
x:Load="False"
Grid.RowSpan="3"
Grid.RowSpan="2"
Background="Pink"
Padding="5"
HorizontalAlignment="Center"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ public Shell()
{
this.InitializeComponent();

InitializeSafeArea();
this.Loaded += OnLoaded;
this.SizeChanged += (s, e) => InitializeSafeArea();

NestedSampleFrame.RegisterPropertyChangedCallback(ContentControl.ContentProperty, OnNestedSampleFrameChanged);

Expand Down Expand Up @@ -82,24 +80,6 @@ private void SetDarkLightToggleInitialState()
#endif
}

/// <summary>
/// This method handles the top padding for phones like iPhone X.
/// </summary>
private void InitializeSafeArea()
{
#if !IS_WINUI
var full = XamlWindow.Current.Bounds;
var bounds = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds;

var topPadding = Math.Abs(full.Top - bounds.Top);

if (topPadding > 0)
{
TopPaddingRow.Height = new GridLength(topPadding);
}
#endif
}

private void ToggleButton_Click(object sender, RoutedEventArgs e)
{
if (this.XamlRoot.Content is FrameworkElement root)
Expand Down

0 comments on commit 9dd918f

Please sign in to comment.