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 ios page background #1279

Merged
merged 7 commits into from
Jun 11, 2021
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
47 changes: 40 additions & 7 deletions src/Controls/samples/Controls.Sample/Pages/XamlPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,49 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:Maui.Controls.Sample.Controls"
xmlns:layout="clr-namespace:Microsoft.Maui.Controls.Layout2;assembly=Microsoft.Maui.Controls"
x:Class="Maui.Controls.Sample.Pages.XamlPage">
x:Class="Maui.Controls.Sample.Pages.XamlPage"
BackgroundColor="#512bdf"
>

<layout:GridLayout x:Name="MyLayout" Margin="40" BackgroundColor="LightGreen">
<ScrollView Padding="{OnPlatform iOS='30,60,30,30', Default='30'}">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checked in our sample as the xamlapp so we can test it more easily

<StackLayout>
<Grid RowSpacing="25" RowDefinitions="Auto,Auto,Auto,Auto,*">

<Label
Text="Welcome to Microsoft MAUI!"
BackgroundColor="LightBlue" Margin="10,20,10,20"/>
<Label Text="Hello, World!"
Grid.Row="0"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="CenterAndExpand" />


</layout:GridLayout>
<Label Text="Welcome to .NET Multi-platform App UI"
Grid.Row="1"
SemanticProperties.Hint="Counts the number of times you click"
FontSize="16"
HorizontalOptions="CenterAndExpand" />

<Label Text="Current count: 0"
Grid.Row="2"
SemanticProperties.Hint="Counts the number of times you click"
FontSize="18"
FontAttributes="Bold"
x:Name="CounterLabel"
HorizontalOptions="Center" />

<Button Text="Click me"
Grid.Row="3"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Center" />

<Image Grid.Row="4"
Source="dotnet_bot.png"
SemanticProperties.Description="Cute dotnet bot waving hi to you!"
WidthRequest="300"
HorizontalOptions="Center" />

</Grid>
</StackLayout>
</ScrollView>


</controls:BasePage>
13 changes: 8 additions & 5 deletions src/Controls/samples/Controls.Sample/Pages/XamlPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using System;
using System.Diagnostics;
using Maui.Controls.Sample.Controls;
using Microsoft.Maui.Controls.Xaml;

Expand All @@ -10,11 +11,13 @@ public partial class XamlPage : BasePage
public XamlPage()
{
InitializeComponent();
}

foreach (var x in MyLayout)
{
Debug.WriteLine($"{x}");
}
int count = 0;
private void OnCounterClicked(object sender, EventArgs e)
{
count++;
CounterLabel.Text = $"Current count: {count}";
}
}
}
6 changes: 6 additions & 0 deletions src/Core/src/Handlers/Page/PageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ public partial class PageHandler : IViewHandler
{
[nameof(IPage.Title)] = MapTitle,
[nameof(IPage.Content)] = MapContent,
#if __IOS__
Actions =
{
[nameof(IFrameworkElement.Frame)] = MapFrame,
}
#endif
};

public PageHandler() : base(PageMapper)
Expand Down
9 changes: 9 additions & 0 deletions src/Core/src/Handlers/Page/PageHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,14 @@ public static void MapContent(PageHandler handler, IPage page)
{
handler.UpdateContent();
}

public static void MapFrame(PageHandler handler, IView view)
{
ViewHandler.MapFrame(handler, view);

// TODO MAUI: Currently the background layer frame is tied to the layout system
// which needs to be investigated more
handler.NativeView?.UpdateBackgroundLayerFrame();
}
}
}