Skip to content
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@
HorizontalOptions="Center"
AutomationId="ShellTabbedButton"
WidthRequest="400"/>
<Button Text="Shell Page"
Clicked="OnShellPageButtonClicked"
HorizontalOptions="Center"
AutomationId="ShellPageButton"
WidthRequest="400"/>
</VerticalStackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ namespace Maui.Controls.Sample;

public class ShellFeaturePage : NavigationPage
{
public ShellFeaturePage()
public ShellFeaturePage() : base(new ShellFeatureMainPage())
{
PushAsync(new ShellFeatureMainPage());
}
}

Expand All @@ -27,4 +26,9 @@ private void OnShellTabbedButtonClicked(object sender, EventArgs e)
{
Application.Current.MainPage = new ShellTabbedControlPage();
}

private void OnShellPageButtonClicked(object sender, EventArgs e)
{
this.Window.Page = new ShellControlPage();
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
using Microsoft.Maui.Controls;

using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Maui.Controls.Sample;

public partial class ShellControlPage : Shell
{
private ShellViewModel _viewModel;
public ShellContent HomePage => homePage;
private const string NotAnimatedRoute = "shell-feature/notanimated";
private const string AnimatedRoute = "shell-feature/animated";
private const string ModalRoute = "shell-feature/modal";
private const string ModalAnimatedRoute = "shell-feature/modalanimated";
private const string ModalNotAnimatedRoute = "shell-feature/modalnotanimated";


public ShellControlPage()
{
InitializeComponent();
_viewModel = new ShellViewModel();
BindingContext = _viewModel;
Routing.RegisterRoute(NotAnimatedRoute, typeof(NotAnimatedPresentationPage));
Routing.RegisterRoute(AnimatedRoute, typeof(AnimatedPresentationPage));
Routing.RegisterRoute(ModalRoute, typeof(ModalPresentationPage));
Routing.RegisterRoute(ModalAnimatedRoute, typeof(ModalAnimatedPresentationPage));
Routing.RegisterRoute(ModalNotAnimatedRoute, typeof(ModalNotAnimatedPresentationPage));
}
async void NavigateToOptionsPage_Clicked(object sender, EventArgs e)
{
BindingContext = _viewModel = new ShellViewModel();
await Navigation.PushAsync(new ShellOptionsPage(_viewModel));
}
void OnNavBarAnimTrueClicked(object sender, EventArgs e)
{
Shell.SetNavBarVisibilityAnimationEnabled(this, true);
}
void OnNavBarAnimFalseClicked(object sender, EventArgs e)
{
Shell.SetNavBarVisibilityAnimationEnabled(this, false);
}
void OnNavBarVisibleClicked(object sender, EventArgs e)
{
Shell.SetNavBarIsVisible(this, true);
}
void OnNavBarHiddenClicked(object sender, EventArgs e)
{
Shell.SetNavBarIsVisible(this, false);
}
void OnNavBarHasShadowTrueClicked(object sender, EventArgs e)
{
Shell.SetNavBarHasShadow(this, true);
}
void OnNavBarHasShadowFalseClicked(object sender, EventArgs e)
{
Shell.SetNavBarHasShadow(this, false);
}
private async void OnGoToNotAnimated(object sender, EventArgs e)
=> await Shell.Current.GoToAsync(NotAnimatedRoute);

private async void OnGoToAnimated(object sender, EventArgs e)
=> await Shell.Current.GoToAsync(AnimatedRoute);

private async void OnGoToModal(object sender, EventArgs e)
=> await Shell.Current.GoToAsync(ModalRoute);

private async void OnGoToModalAnimated(object sender, EventArgs e)
=> await Shell.Current.GoToAsync(ModalAnimatedRoute);

private async void OnGoToModalNotAnimated(object sender, EventArgs e)
=> await Shell.Current.GoToAsync(ModalNotAnimatedRoute);
private async void OnGoToHomeClicked(object sender, EventArgs e)
{
await Shell.Current.GoToAsync("//home");
}
private async void OnGoBackClicked(object sender, EventArgs e)
{
await Shell.Current.GoToAsync("..");
}
private void SetTitleView()
{
var grid = new Grid
{
ColumnDefinitions =
{
new ColumnDefinition { Width = GridLength.Auto },
new ColumnDefinition { Width = GridLength.Auto }
},
VerticalOptions = LayoutOptions.Center
};
var image = new Image
{
Source = "dotnet_bot.png",
WidthRequest = 28,
HeightRequest = 28,
HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.Center
};

var label = new Label
{
Text = "Shell TitleView",
Margin = new Thickness(30, 0, 0, 0),
VerticalOptions = LayoutOptions.Center,
FontAttributes = FontAttributes.Bold,
TextColor = Colors.Black
};

Grid.SetColumn(label, 1);

grid.Add(image);
grid.Add(label);

Shell.SetTitleView(this, grid);
}
private void RemoveTitleView()
{
Shell.SetTitleView(this, null);
}
private void OnShowTitleViewClicked(object sender, EventArgs e)
{
SetTitleView();
}
private void OnHideTitleViewClicked(object sender, EventArgs e)
{
RemoveTitleView();
}

private abstract class PresentationModePage : ContentPage
{
protected PresentationModePage(string title, PresentationMode mode)
{
Title = title;
BackgroundColor = Colors.White;
Shell.SetPresentationMode(this, mode);

var backButton = new Button
{
Text = "Go Back",
AutomationId = "GoBackButton",
BackgroundColor = Color.FromArgb("F5F5F5"),
TextColor = Colors.Black
};
backButton.Clicked += async (_, __) => await Shell.Current.GoToAsync("..");

Content = new VerticalStackLayout
{
Padding = 20,
Spacing = 20,
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
Children =
{
new Label { Text = title, HorizontalOptions = LayoutOptions.Center },
backButton
}
};
}
}

private sealed class NotAnimatedPresentationPage : PresentationModePage
{
public NotAnimatedPresentationPage()
: base("NotAnimated Page", PresentationMode.NotAnimated)
{
}
}

private sealed class AnimatedPresentationPage : PresentationModePage
{
public AnimatedPresentationPage()
: base("Animated Page", PresentationMode.Animated)
{
}
}

private sealed class ModalPresentationPage : PresentationModePage
{
public ModalPresentationPage()
: base("Modal Page", PresentationMode.Modal)
{
}
}

private sealed class ModalAnimatedPresentationPage : PresentationModePage
{
public ModalAnimatedPresentationPage()
: base("ModalAnimated Page", PresentationMode.ModalAnimated)
{
}
}

private sealed class ModalNotAnimatedPresentationPage : PresentationModePage
{
public ModalNotAnimatedPresentationPage()
: base("ModalNotAnimated Page", PresentationMode.ModalNotAnimated)
{
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Maui.Controls.Sample"
x:Class="Maui.Controls.Sample.ShellOptionsPage"
x:DataType="local:ShellViewModel"
Title="ShellOptionsPage">
<ScrollView>
<VerticalStackLayout Padding="20" Spacing="5" >

<!-- Apply Button -->
<Button Text="Apply" Clicked="OnApplyClicked"
AutomationId="Apply"
BackgroundColor="DodgerBlue" TextColor="White"
Margin="0,0,0,10"/>

<!-- BackgroundColor -->
<Label Text="BackgroundColor" FontAttributes="Bold"/>
<Grid ColumnDefinitions="*,*,*" ColumnSpacing="10">
<Button Grid.Column="0" Text="SkyBlue" AutomationId="SkyBlueBackgroundColor" Clicked="OnBackgroundColorClicked"/>
<Button Grid.Column="1" Text="LightGreen" AutomationId="LightGreenBackgroundColor" Clicked="OnBackgroundColorClicked"/>
<Button Grid.Column="2" Text="White" AutomationId="WhiteBackgroundColor" Clicked="OnBackgroundColorClicked"/>
</Grid>

<!-- ForegroundColor -->
<Label Text="ForegroundColor" FontAttributes="Bold" />
<Grid ColumnDefinitions="*,*,*" ColumnSpacing="10">
<Button Grid.Column="0" Text="Brown" AutomationId="BrownForegroundColor" Clicked="OnForegroundColorClicked"/>
<Button Grid.Column="1" Text="Magenta" AutomationId="MagentaForegroundColor" Clicked="OnForegroundColorClicked"/>
<Button Grid.Column="2" Text="Purple" AutomationId="PurpleForegroundColor" Clicked="OnForegroundColorClicked"/>
</Grid>

<!-- TitleColor -->
<Label Text="TitleColor" FontAttributes="Bold" />
<Grid ColumnDefinitions="*,*,*" ColumnSpacing="10">
<Button Grid.Column="0" Text="Red" AutomationId="RedTitleColor" Clicked="OnTitleColorClicked"/>
<Button Grid.Column="1" Text="Green" AutomationId="GreenTitleColor" Clicked="OnTitleColorClicked"/>
<Button Grid.Column="2" Text="Navy" AutomationId="NavyTitleColor" Clicked="OnTitleColorClicked"/>
</Grid>

<!-- DisabledColor -->
<Label Text="DisabledColor" FontAttributes="Bold" />
<Grid ColumnDefinitions="*,*,*" ColumnSpacing="10">
<Button Grid.Column="0" Text="Gold" AutomationId="GoldDisabledColor" Clicked="OnDisabledColorClicked"/>
<Button Grid.Column="1" Text="Violet" AutomationId="VioletDisabledColor" Clicked="OnDisabledColorClicked"/>
<Button Grid.Column="2" Text="Silver" AutomationId="SilverDisabledColor" Clicked="OnDisabledColorClicked"/>
</Grid>

<!-- UnselectedColor -->
<Label Text="UnselectedColor" FontAttributes="Bold" />
<Grid ColumnDefinitions="*,*,*" ColumnSpacing="10">
<Button Grid.Column="0" Text="Maroon" AutomationId="MaroonUnselectedColor" Clicked="OnUnselectedColorClicked"/>
<Button Grid.Column="1" Text="Blue" AutomationId="BlueUnselectedColor" Clicked="OnUnselectedColorClicked"/>
<Button Grid.Column="2" Text="Indigo" AutomationId="IndigoUnselectedColor" Clicked="OnUnselectedColorClicked"/>
</Grid>

<!-- Shell Properties Section -->
<Grid ColumnDefinitions="*,*" ColumnSpacing="20" >
<VerticalStackLayout Grid.Column="0" >
<Label Text="IsEnabled" FontAttributes="Bold" AutomationId="IsEnabledLabel"/>
<HorizontalStackLayout Spacing="10">
<RadioButton Content="True" IsChecked="True" GroupName="IsEnabled" CheckedChanged="OnIsEnabledChanged" AutomationId="IsEnabledTrue"/>
<RadioButton Content="False" GroupName="IsEnabled" CheckedChanged="OnIsEnabledChanged" AutomationId="IsEnabledFalse"/>
</HorizontalStackLayout>
</VerticalStackLayout>
<VerticalStackLayout Grid.Column="1" >
<Label Text="IsVisible" FontAttributes="Bold" AutomationId="IsVisibleLabel"/>
<HorizontalStackLayout Spacing="10">
<RadioButton Content="True" IsChecked="True" GroupName="IsVisible" CheckedChanged="OnIsVisibleChanged" AutomationId="IsVisibleTrue"/>
<RadioButton Content="False" GroupName="IsVisible" CheckedChanged="OnIsVisibleChanged" AutomationId="IsVisibleFalse"/>
</HorizontalStackLayout>
</VerticalStackLayout>
</Grid>

<!-- FlowDirection -->
<Grid ColumnDefinitions="*,*" ColumnSpacing="20" >
<VerticalStackLayout Grid.Column="0" >
<Label Text="FlowDirection" FontAttributes="Bold" />
<HorizontalStackLayout Spacing="10" >
<RadioButton Content="LTR" IsChecked="True" GroupName="FlowDirection" CheckedChanged="OnFlowDirectionChanged" AutomationId="FlowDirectionLTR"/>
<RadioButton Content="RTL" GroupName="FlowDirection" CheckedChanged="OnFlowDirectionChanged" AutomationId="FlowDirectionRTL"/>
</HorizontalStackLayout>
</VerticalStackLayout>
</Grid>
</VerticalStackLayout>
</ScrollView>
</ContentPage>
Loading
Loading