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.
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@
HorizontalOptions="Center"
AutomationId="ShellFlyoutButton"
WidthRequest="400"/>
<Button Text="Shell Tabbed"
Clicked="OnShellTabbedButtonClicked"
HorizontalOptions="Center"
AutomationId="ShellTabbedButton"
WidthRequest="400"/>
</VerticalStackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ private void OnShellFlyoutButtonClicked(object sender, EventArgs e)
Application.Current.MainPage = new ShellFlyoutControlPage();
}

private void OnShellTabbedButtonClicked(object sender, EventArgs e)
{
Application.Current.MainPage = new ShellTabbedControlPage();
}
}

Large diffs are not rendered by default.

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

namespace Maui.Controls.Sample;

public partial class ShellTabbedControlPage : Shell
{
private ShellViewModel _viewModel;
public ShellContent VegetablesItem => vegetablesItem;
public ShellContent FruitsItem => fruitsItem;
public ShellContent Tab1Item => tab1Item;
public ShellContent Tab3Item => tab3Item;
public ShellContent Tab4Item => tab4Item;
public ShellContent Tab5Item => tab5Item;
public ShellContent Tab6Item => tab6Item;

public ShellTabbedControlPage()
{
InitializeComponent();
_viewModel = new ShellViewModel();
BindingContext = _viewModel;
Navigated += OnNavigated;
}

private async void NavigateToOptionsPage_Clicked(object sender, EventArgs e)
{
BindingContext = _viewModel = new ShellViewModel();
await Navigation.PushAsync(new ShellTabbedOptionsPage(_viewModel));
}

private void OnGoToTab1Clicked(object sender, EventArgs e)
{
this.CurrentItem = this.tab1Item;
}

private void OnNavigated(object sender, ShellNavigatedEventArgs e)
{
_viewModel.CurrentItemTitle = CurrentItem?.CurrentItem?.Title ?? "Unknown";
}

protected override void OnDisappearing()
{
base.OnDisappearing();
Navigated -= OnNavigated; // Clean up
}
}

Large diffs are not rendered by default.

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

namespace Maui.Controls.Sample;

public partial class ShellTabbedOptionsPage : ContentPage
{
private ShellViewModel _viewModel;

public ShellTabbedOptionsPage(ShellViewModel viewModel)
{
InitializeComponent();
_viewModel = viewModel;
BindingContext = _viewModel;
}
private void ApplyButton_Clicked(object sender, EventArgs e)
{
Navigation.PopAsync();
}

private void OnTabBarBackgroundColorClicked(object sender, EventArgs e)
{
if (sender is Button button)
{
switch (button.Text)
{
case "LightYellow":
_viewModel.TabBarBackgroundColor = Colors.LightYellow;
break;
case "LightGreen":
_viewModel.TabBarBackgroundColor = Colors.LightGreen;
break;
case "LightBlue":
_viewModel.TabBarBackgroundColor = Colors.LightBlue;
break;
}
}
}

private void OnTabBarDisabledColorClicked(object sender, EventArgs e)
{
if (sender is Button button)
{
switch (button.Text)
{
case "Maroon":
_viewModel.TabBarDisabledColor = Colors.Maroon;
break;
case "Magenta":
_viewModel.TabBarDisabledColor = Colors.Magenta;
break;
case "Gold":
_viewModel.TabBarDisabledColor = Colors.Gold;
break;
}
}
}

private void OnTabBarForegroundColorClicked(object sender, EventArgs e)
{
if (sender is Button button)
{
switch (button.Text)
{
case "Blue":
_viewModel.TabBarForegroundColor = Colors.Blue;
break;
case "Red":
_viewModel.TabBarForegroundColor = Colors.Red;
break;
case "Green":
_viewModel.TabBarForegroundColor = Colors.Green;
break;
}
}
}

private void OnTabBarTitleColorClicked(object sender, EventArgs e)
{
if (sender is Button button)
{
switch (button.Text)
{
case "Lavender":
_viewModel.TabBarTitleColor = Colors.Lavender;
break;
case "Orange":
_viewModel.TabBarTitleColor = Colors.Orange;
break;
case "Purple":
_viewModel.TabBarTitleColor = Colors.Purple;
break;
}
}
}

private void OnTabBarUnselectedColorClicked(object sender, EventArgs e)
{
if (sender is Button button)
{
switch (button.Text)
{
case "Blue":
_viewModel.TabBarUnselectedColor = Colors.Blue;
break;
case "Brown":
_viewModel.TabBarUnselectedColor = Colors.Brown;
break;
case "PeachPuff":
_viewModel.TabBarUnselectedColor = Colors.PeachPuff;
break;
}
}
}

private void OnTabBarIsVisibleChanged(object sender, CheckedChangedEventArgs e)
{
if (sender is RadioButton radioButton && e.Value)
{
_viewModel.TabBarIsVisible = radioButton.Content.ToString() == "True";
}
}

private void OnIsEnabledChanged(object sender, CheckedChangedEventArgs e)
{
if (sender is RadioButton radioButton && e.Value)
{
_viewModel.IsEnabled = radioButton.Content.ToString() == "True";
}
}

private void OnIsVisibleChanged(object sender, CheckedChangedEventArgs e)
{
if (sender is RadioButton radioButton && e.Value)
{
_viewModel.IsVisible = radioButton.Content.ToString() == "True";
}
}

private void OnFlowDirectionChanged(object sender, EventArgs e)
{
if (sender is RadioButton rb)
{
_viewModel.FlowDirection = rb.Content?.ToString() == "LTR" ? FlowDirection.LeftToRight : FlowDirection.RightToLeft;
}
}

private void OnCurrentItemClicked(object sender, EventArgs e)
{
if (sender is Button button)
{
if (Application.Current?.MainPage is ShellTabbedControlPage shell)
{
switch (button.Text)
{
case "Vegetables":
Shell.Current.CurrentItem = shell.VegetablesItem;
break;
case "Fruits":
Shell.Current.CurrentItem = shell.FruitsItem;
break;
case "Tab1":
Shell.Current.CurrentItem = shell.Tab1Item;
break;
case "Tab3":
Shell.Current.CurrentItem = shell.Tab3Item;
break;
case "Tab4":
Shell.Current.CurrentItem = shell.Tab4Item;
break;
case "Tab5":
Shell.Current.CurrentItem = shell.Tab5Item;
break;
case "Tab6":
Shell.Current.CurrentItem = shell.Tab6Item;
break;
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Graphics;

namespace Maui.Controls.Sample;

public class ShellViewModel : INotifyPropertyChanged
Expand Down Expand Up @@ -29,6 +31,14 @@ public class ShellViewModel : INotifyPropertyChanged
private Brush _flyoutBackdrop = Brush.Default;
private FlowDirection _flowDirection = FlowDirection.LeftToRight;
private DataTemplate _itemTemplate;
private Color _tabBarBackgroundColor;
private Color _tabBarDisabledColor;
private Color _tabBarForegroundColor;
private Color _tabBarTitleColor;
private Color _tabBarUnselectedColor;
private bool _tabBarIsVisible = true;
private bool _isEnabled = true;
private bool _isVisible = true;

public FlyoutDisplayOptions FlyoutDisplayOptions
{
Expand Down Expand Up @@ -161,6 +171,102 @@ public string CurrentItemTitle
get => _currentItemTitle;
set { _currentItemTitle = value; OnPropertyChanged(); }
}
public Color TabBarBackgroundColor
{
get => _tabBarBackgroundColor;
set
{
if (_tabBarBackgroundColor != value)
{
_tabBarBackgroundColor = value;
OnPropertyChanged();
}
}
}
public Color TabBarDisabledColor
{
get => _tabBarDisabledColor;
set
{
if (_tabBarDisabledColor != value)
{
_tabBarDisabledColor = value;
OnPropertyChanged();
}
}
}
public Color TabBarForegroundColor
{
get => _tabBarForegroundColor;
set
{
if (_tabBarForegroundColor != value)
{
_tabBarForegroundColor = value;
OnPropertyChanged();
}
}
}
public Color TabBarTitleColor
{
get => _tabBarTitleColor;
set
{
if (_tabBarTitleColor != value)
{
_tabBarTitleColor = value;
OnPropertyChanged();
}
}
}
public Color TabBarUnselectedColor
{
get => _tabBarUnselectedColor;
set
{
if (_tabBarUnselectedColor != value)
{
_tabBarUnselectedColor = value;
OnPropertyChanged();
}
}
}
public bool TabBarIsVisible
{
get => _tabBarIsVisible;
set
{
if (_tabBarIsVisible != value)
{
_tabBarIsVisible = value;
OnPropertyChanged();
}
}
}
public bool IsEnabled
{
get => _isEnabled;
set
{
if (_isEnabled != value)
{
_isEnabled = value;
OnPropertyChanged();
}
}
}
public bool IsVisible
{
get => _isVisible;
set
{
if (_isVisible != value)
{
_isVisible = value;
OnPropertyChanged();
}
}
}
public ShellViewModel()
{
ItemTemplate = new DataTemplate(() =>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading