Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add safearea to shell and add margin to control #616

Merged
merged 2 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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">
kazo0 marked this conversation as resolved.
Show resolved Hide resolved
<!-- 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
Loading