Skip to content

Commit

Permalink
fix: add safearea to shell and add margin to control
Browse files Browse the repository at this point in the history
  • Loading branch information
carlh98 committed Jun 16, 2023
1 parent 7e9da83 commit d0f26b4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<rtt:UnitTestsControl />
<rtt:UnitTestsControl Margin="0,20,0,0" />
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
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 Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
utu:SafeArea.Insets="Top, Bottom">
<Grid.RowDefinitions>
<RowDefinition x:Name="TopPaddingRow"
Height="0" />
Expand All @@ -33,7 +35,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 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 d0f26b4

Please sign in to comment.