Created Gallery settings page (#3247)
This commit is contained in:
Родитель
480ad45e2c
Коммит
769ccb380a
|
@ -24,17 +24,15 @@ namespace Maui.Controls.Sample.Pages.Base
|
|||
|
||||
ToolbarItems.Add(new ToolbarItem()
|
||||
{
|
||||
Text = "RTL",
|
||||
Text = "Settings",
|
||||
IconImageSource = ImageSource.FromFile("settings.png"),
|
||||
Command = new Command(OnToolbarItemClicked)
|
||||
});
|
||||
}
|
||||
|
||||
private void OnToolbarItemClicked()
|
||||
void OnToolbarItemClicked()
|
||||
{
|
||||
if (FlowDirection != Microsoft.Maui.FlowDirection.RightToLeft)
|
||||
FlowDirection = Microsoft.Maui.FlowDirection.RightToLeft;
|
||||
else
|
||||
FlowDirection = Microsoft.Maui.FlowDirection.LeftToRight;
|
||||
Navigation.PushModalAsync(new SettingsPage());
|
||||
}
|
||||
|
||||
protected override void OnAppearing()
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<views:BasePage
|
||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Maui.Controls.Sample.Pages.MultiWindowPage"
|
||||
xmlns:views="clr-namespace:Maui.Controls.Sample.Pages.Base">
|
||||
<views:BasePage.Content>
|
||||
<StackLayout
|
||||
Margin="12">
|
||||
<Button
|
||||
Clicked="OnNewWindowClicked"
|
||||
Text="Open new Window" />
|
||||
</StackLayout>
|
||||
</views:BasePage.Content>
|
||||
</views:BasePage>
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using Maui.Controls.Sample.Pages.Base;
|
||||
using Microsoft.Maui.Controls;
|
||||
|
||||
namespace Maui.Controls.Sample.Pages
|
||||
{
|
||||
public partial class MultiWindowPage : BasePage
|
||||
{
|
||||
public MultiWindowPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
void OnNewWindowClicked(object sender, EventArgs e)
|
||||
{
|
||||
Application.Current.OpenWindow(new Window(new MultiWindowPage()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -40,7 +40,7 @@
|
|||
<Setter Property="FlexLayout.Basis" Value="50%"/>
|
||||
<Setter Property="FlexLayout.Grow" Value="0"/>
|
||||
</Style>
|
||||
|
||||
|
||||
<Style x:Key="FooterStyle" TargetType="Label">
|
||||
<Setter Property="FontSize" Value="Small" />
|
||||
<Setter Property="FontFamily" Value="Segoe UI" />
|
||||
|
@ -51,11 +51,6 @@
|
|||
|
||||
</ResourceDictionary>
|
||||
</views:BasePage.Resources>
|
||||
<views:BasePage.ToolbarItems>
|
||||
<ToolbarItem
|
||||
IconImageSource="settings.png"
|
||||
Text="Settings" />
|
||||
</views:BasePage.ToolbarItems>
|
||||
<ScrollView>
|
||||
<Grid
|
||||
RowDefinitions="150, *, Auto"
|
||||
|
@ -68,7 +63,7 @@
|
|||
<Grid
|
||||
RowSpacing="0"
|
||||
Grid.Row="0"
|
||||
RowDefinitions="Auto,*,Auto">
|
||||
RowDefinitions="Auto,*">
|
||||
<Label
|
||||
Text=".NET MAUI"
|
||||
Style="{StaticResource TitleStyle}"/>
|
||||
|
@ -76,10 +71,6 @@
|
|||
Grid.Row="1"
|
||||
Text="An open-source framework for building iOS, Android, macOS and Windows apps"
|
||||
Style="{StaticResource SubTitleStyle}"/>
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Text="One more window"
|
||||
Clicked="ShowNewWindow" />
|
||||
</Grid>
|
||||
<!-- SECTIONS -->
|
||||
<Grid
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using Maui.Controls.Sample.ViewModels;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
@ -8,8 +9,8 @@ namespace Maui.Controls.Sample.Pages
|
|||
{
|
||||
public partial class MainPage
|
||||
{
|
||||
IServiceProvider _services;
|
||||
MainViewModel _viewModel;
|
||||
readonly IServiceProvider _services;
|
||||
readonly MainViewModel _viewModel;
|
||||
|
||||
public MainPage(IServiceProvider services, MainViewModel viewModel)
|
||||
{
|
||||
|
@ -19,12 +20,8 @@ namespace Maui.Controls.Sample.Pages
|
|||
|
||||
_services = services;
|
||||
_viewModel = viewModel;
|
||||
}
|
||||
|
||||
void ShowNewWindow(object sender, EventArgs e)
|
||||
{
|
||||
var mvm = _services.GetService<MainViewModel>();
|
||||
Application.Current.OpenWindow(new Window(new CustomNavigationPage(_services, mvm)));
|
||||
Debug.WriteLine($"Received as parameters, ServiceProvider: {_services != null} and MainViewModel: {_viewModel != null}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<views:BasePage
|
||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Maui.Controls.Sample.Pages.SettingsPage"
|
||||
xmlns:views="clr-namespace:Maui.Controls.Sample.Pages.Base"
|
||||
xmlns:viewmodels="clr-namespace:Maui.Controls.Sample.ViewModels"
|
||||
BackgroundColor="{DynamicResource BackgroundColor}"
|
||||
Title="Settings">
|
||||
<views:BasePage.Resources>
|
||||
<ResourceDictionary>
|
||||
|
||||
<Color x:Key="SectionBorderColor">#C8C8C8</Color>
|
||||
|
||||
<Style x:Key="SectionBorderStyle" TargetType="Frame">
|
||||
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource LightBackgroundSecondaryColor}, Dark={StaticResource DarkBackgroundSecondaryColor}}" />
|
||||
<Setter Property="BorderColor" Value="{StaticResource SectionBorderColor}" />
|
||||
<Setter Property="CornerRadius" Value="0" />
|
||||
<Setter Property="HasShadow" Value="False" />
|
||||
<Setter Property="Padding" Value="12" />
|
||||
<Setter Property="Margin" Value="12" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="TitleStyle" TargetType="Label">
|
||||
<Setter Property="FontSize" Value="24" />
|
||||
<Setter Property="Margin" Value="16, 24, 16, 12" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SectionTitleStyle" TargetType="Label">
|
||||
<Setter Property="FontSize" Value="16" />
|
||||
<Setter Property="Margin" Value="16, 0" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SectionDescriptionStyle" TargetType="Label">
|
||||
<Setter Property="FontSize" Value="12" />
|
||||
<Setter Property="Margin" Value="16, 6, 16, 0" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SectionSwitchStyle" TargetType="Switch">
|
||||
<Setter Property="OnColor" Value="White" />
|
||||
<Setter Property="ThumbColor" Value="White" />
|
||||
<Setter Property="HorizontalOptions" Value="Start" />
|
||||
<Setter Property="Margin" Value="0, 0, 0, 36" />
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
</views:BasePage.Resources>
|
||||
<views:BasePage.BindingContext>
|
||||
<viewmodels:SettingsViewModel />
|
||||
</views:BasePage.BindingContext>
|
||||
<views:BasePage.Content>
|
||||
<ScrollView>
|
||||
<StackLayout>
|
||||
<Grid>
|
||||
<Grid.GestureRecognizers>
|
||||
<TapGestureRecognizer Tapped="OnTapGestureRecognizerTapped" />
|
||||
</Grid.GestureRecognizers>
|
||||
<Label
|
||||
Text="Settings"
|
||||
Style="{StaticResource TitleStyle}"/>
|
||||
</Grid>
|
||||
<!-- RTL SETTINGS -->
|
||||
<Frame
|
||||
Style="{StaticResource SectionBorderStyle}">
|
||||
<StackLayout>
|
||||
<Label
|
||||
Text="Right to Left"
|
||||
Style="{StaticResource SectionTitleStyle}"/>
|
||||
<Label
|
||||
Text="Do you want to use Right to Left mode instead of Left to Right?"
|
||||
Style="{StaticResource SectionDescriptionStyle}" />
|
||||
<Switch
|
||||
Toggled="OnRTLToggled"
|
||||
Style="{StaticResource SectionSwitchStyle}"/>
|
||||
</StackLayout>
|
||||
</Frame>
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
</views:BasePage.Content>
|
||||
</views:BasePage>
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using Maui.Controls.Sample.Pages.Base;
|
||||
using Microsoft.Maui.Controls;
|
||||
|
||||
namespace Maui.Controls.Sample.Pages
|
||||
{
|
||||
public partial class SettingsPage : BasePage
|
||||
{
|
||||
public SettingsPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
void OnTapGestureRecognizerTapped(object sender, EventArgs args)
|
||||
{
|
||||
Navigation.PopModalAsync();
|
||||
}
|
||||
|
||||
void OnRTLToggled(object sender, ToggledEventArgs e)
|
||||
{
|
||||
var mainPage = Application.Current.MainPage;
|
||||
|
||||
if (mainPage == null)
|
||||
return;
|
||||
|
||||
if (mainPage.FlowDirection != Microsoft.Maui.FlowDirection.RightToLeft)
|
||||
mainPage.FlowDirection = FlowDirection = Microsoft.Maui.FlowDirection.RightToLeft;
|
||||
else
|
||||
mainPage.FlowDirection = FlowDirection = Microsoft.Maui.FlowDirection.LeftToRight;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,6 +36,9 @@ namespace Maui.Controls.Sample.ViewModels
|
|||
new SectionModel(typeof(ModalPage), "Modal",
|
||||
"Allows you to push and pop Modal Pages."),
|
||||
|
||||
new SectionModel(typeof(MultiWindowPage), "Multi-Window",
|
||||
"Allows you to open a new Window in the App."),
|
||||
|
||||
new SectionModel(typeof(NavigationGallery), "Navigation Page",
|
||||
"Play with the different Navigation APIs."),
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
using Maui.Controls.Sample.ViewModels.Base;
|
||||
|
||||
namespace Maui.Controls.Sample.ViewModels
|
||||
{
|
||||
public class SettingsViewModel : BaseViewModel
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче