Skip to content

Commit

Permalink
Add the template to the sample (#1867)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow committed Jul 29, 2021
1 parent aa817b5 commit fe4c3d0
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Pages.TemplatePage"
BackgroundColor="{DynamicResource PageBackgroundColor}">

<ContentPage.Resources>
<ResourceDictionary>

<Color x:Key="PageBackgroundColor">#512bdf</Color>
<Color x:Key="PrimaryTextColor">White</Color>

<Style TargetType="Label">
<Setter Property="TextColor" Value="{DynamicResource PrimaryTextColor}" />
<Setter Property="FontFamily" Value="OpenSansRegular" />
</Style>

<Style TargetType="Button">
<Setter Property="TextColor" Value="{DynamicResource PrimaryTextColor}" />
<Setter Property="FontFamily" Value="OpenSansRegular" />
<Setter Property="BackgroundColor" Value="#2b0b98" />
<Setter Property="Padding" Value="14,10" />
</Style>

</ResourceDictionary>
</ContentPage.Resources>

<ScrollView Padding="{OnPlatform iOS='30,60,30,30', Default='30'}">
<Grid RowSpacing="25" RowDefinitions="Auto,Auto,Auto,Auto,*">

<Label Text="Hello, World!"
Grid.Row="0"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="CenterAndExpand" />

<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"
HeightRequest="372"
HorizontalOptions="Center" />

</Grid>
</ScrollView>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;

namespace Maui.Controls.Sample.Pages
{
public partial class TemplatePage
{
public TemplatePage()
{
InitializeComponent();
}

int count = 0;
private void OnCounterClicked(object sender, EventArgs e)
{
count++;
CounterLabel.Text = $"Current count: {count}";
}
}
}
3 changes: 2 additions & 1 deletion src/Controls/samples/Controls.Sample/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class CustomButton : Button { }

public class Startup : IStartup
{
enum PageType { Main, Blazor, Shell }
enum PageType { Main, Blazor, Shell, Template }
readonly PageType _pageType = PageType.Main;

public void Configure(IAppHostBuilder appBuilder)
Expand Down Expand Up @@ -100,6 +100,7 @@ public void Configure(IAppHostBuilder appBuilder)
serviceType: typeof(Page),
implementationType: _pageType switch
{
PageType.Template => typeof(TemplatePage),
PageType.Shell => typeof(AppShell),
#if WINDOWS
PageType.Main => typeof(TempPage),
Expand Down
64 changes: 31 additions & 33 deletions src/Templates/src/templates/maui-mobile/MauiApp1/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,41 @@
BackgroundColor="{DynamicResource PageBackgroundColor}">

<ScrollView Padding="{OnPlatform iOS='30,60,30,30', Default='30'}">
<StackLayout>
<Grid RowSpacing="25" RowDefinitions="Auto,Auto,Auto,Auto,*">

<Label Text="Hello, World!"
Grid.Row="0"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="CenterAndExpand" />
<Grid RowSpacing="25" RowDefinitions="Auto,Auto,Auto,Auto,*">

<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="Hello, World!"
Grid.Row="0"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
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" />
<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" />

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

<Image Grid.Row="4"
Source="dotnet_bot.png"
SemanticProperties.Description="Cute dotnet bot waving hi to you!"
WidthRequest="300"
HeightRequest="372"
HorizontalOptions="Center" />
<Button Text="Click me"
Grid.Row="3"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Center" />

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

</Grid>
</ScrollView>
</ContentPage>

0 comments on commit fe4c3d0

Please sign in to comment.