Skip to content

Commit

Permalink
Merge pull request #64 from RadekVyM/dev
Browse files Browse the repository at this point in the history
Core 6.0.0 and SimpleShell 5.0.0
  • Loading branch information
RadekVyM authored Dec 23, 2024
2 parents a243304 + e0a10ae commit 941eb55
Show file tree
Hide file tree
Showing 235 changed files with 1,177 additions and 4,426 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Here are some of my samples that were built using this library:
<a href="https://github.com/RadekVyM/MarvelousMAUI"><em>Marvelous .NET MAUI</em></a>
</p>
<p align="center">
<img src="https://raw.githubusercontent.com/RadekVyM/Gadgets-Store-App/main/samples/ios_gadgets_store_app.gif" width="239" />
<img src="https://raw.githubusercontent.com/RadekVyM/Gadgets-Store-App/main/samples/android_gadgets_store_app.webp" width="234" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<img src="https://raw.githubusercontent.com/RadekVyM/Bet-App/main/Images/ios_betapp.webp" width="236" />
</p>
Expand Down Expand Up @@ -121,4 +121,4 @@ builder.UseSimpleShell();
- A `SimpleShell`-based application may not have as good accessibility in some scenarios due to the lack of platform-specific navigation controls. .NET MAUI `Shell` should be accessible out of the box since it uses platform-specific controls.
- Maybe I have implemented something wrong that has a negative impact on the performance, stability, accessibility, or something like that.

See [documentation](./docs/SimpleToolkit.SimpleShell) for more information.
See [documentation](./docs/SimpleToolkit.SimpleShell) for more information.
18 changes: 9 additions & 9 deletions docs/Samples.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# List of Samples Built Using SimpleToolkit
# List of samples built using SimpleToolkit

## [Marvelous .NET MAUI](https://github.com/RadekVyM/MarvelousMAUI)
**.NET MAUI clone** of the [Wonderous app](https://flutter.gskinner.com/wonderous/) - a visual showcase of **eight wonders of the world** made with [Flutter](https://github.com/flutter/flutter) by the team at [gskinner](https://gskinner.com/).
Expand All @@ -7,9 +7,9 @@ https://github.com/RadekVyM/MarvelousMAUI/assets/65116078/3a6b59a0-e48f-4af4-b16

## [Gadget Store App](https://github.com/RadekVyM/Gadgets-Store-App)

**.NET MAUI** implementation of [Gadgets Store App](https://dribbble.com/shots/6983164-Gadgets-Store-App) design by [Sajon](https://dribbble.com/sajon007):
**.NET MAUI** prototype of an e-shop app inspired by the [Gadgets Store App](https://dribbble.com/shots/6983164-Gadgets-Store-App) design by [Sajon](https://dribbble.com/sajon):

https://github.com/RadekVyM/Gadgets-Store-App/assets/65116078/332aa779-861b-44b2-be1f-6a53dc730fae
https://github.com/user-attachments/assets/025ca22d-3ca0-4d67-95aa-8e3b6bc14ddf

# [Bet App](https://github.com/RadekVyM/Bet-App)

Expand All @@ -31,18 +31,18 @@ https://github.com/RadekVyM/HamburgerMenuApp/assets/65116078/e4db39c0-8c6f-4ff7-

## [Navbar Animation #1](https://github.com/RadekVyM/Navbar-Animation-1)

**.NET MAUI** implementation of [Navbar Animation #1](https://dribbble.com/shots/9852644-Navbar-Animation-1) design by [Marie Bernard](https://dribbble.com/marie_brn):
**.NET MAUI** tab bar inspired by the [Navbar Animation #1](https://dribbble.com/shots/9852644-Navbar-Animation-1) design by [Marie Bernard](https://dribbble.com/marie_brn):

https://github.com/RadekVyM/Navbar-Animation-1/assets/65116078/ea396db0-98b7-4412-9eaf-56203ffeb3ee
https://github.com/user-attachments/assets/70a8f41f-7645-4841-b119-cace4dfee0aa

## [Navbar Animation #2](https://github.com/RadekVyM/Navbar-Animation-2)

**.NET MAUI** implementation of [Navbar Animation #2](https://dribbble.com/shots/14122275-Navbar-Animation-2) design by [Marie Bernard](https://dribbble.com/marie_brn):
**.NET MAUI** tab bar inspired by the [Navbar Animation #2](https://dribbble.com/shots/14122275-Navbar-Animation-2) design by [Marie Bernard](https://dribbble.com/marie_brn):

https://github.com/RadekVyM/Navbar-Animation-2/assets/65116078/28e3f2b3-4e61-4471-b7c4-2d6d6d89794d
https://github.com/user-attachments/assets/0e52fe5a-61c1-4815-a311-1b8fec02d6e0

## [Tab Bar Switches Interaction](https://github.com/RadekVyM/Tab-Bar-Switches-Interaction)

**.NET MAUI** implementation of [Tab Bar Switches Interaction](https://dribbble.com/shots/14028381-Tab-Bar-Switches-Interaction) design by [Ronas IT | UI/UX Team](https://dribbble.com/ronasit):
**.NET MAUI** tab bar inspired by the [Tab Bar Switches Interaction](https://dribbble.com/shots/14028381-Tab-Bar-Switches-Interaction) design by [Ronas IT | UI/UX Team](https://dribbble.com/ronasit):

https://github.com/RadekVyM/Tab-Bar-Switches-Interaction/assets/65116078/047f33ff-80e2-4432-b142-05cffe6b59bc
https://github.com/user-attachments/assets/3381a7d4-312a-4a92-a449-b5bfd0866fd7
6 changes: 0 additions & 6 deletions docs/SimpleToolkit.SimpleShell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,12 +565,6 @@ The yellow and green pages are grouped under one tab:
</tr>
</table>

## Disconnecting page handlers

`SimpleShell` automatically calls the `DisconnectHandler()` method on all [handlers](https://learn.microsoft.com/dotnet/maui/user-interface/handlers) of pages that are being removed from a navigation stack. For example, when you pop a page from a navigation stack, the `DisconnectHandler()` method is called on its handler.

This behavior can be disabled on a per-page basis with the `SimpleShell.ShouldAutoDisconnectPageHandler` attached property. Just set this property on the page to `false` if you do not want its handler to be automatically disconnected.

## Transitions

`SimpleShell` allows you to define custom transitions between pages during navigation:
Expand Down
9 changes: 5 additions & 4 deletions src/Playground/Playground.Original/App.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Playground.Original"
x:Class="Playground.Original.App">
<Application
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Playground.Original"
x:Class="Playground.Original.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand Down
24 changes: 16 additions & 8 deletions src/Playground/Playground.Original/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,32 @@

public enum AppShellType
{
Normal, Playground
Normal, Playground, Containers, NoTabs, ShellItems
}

public partial class App : Application
{
public App()
{
InitializeComponent();

RefreshShell(MauiProgram.UsedAppShell);
}

public void RefreshShell(AppShellType type)
{
MainPage = type switch
{
AppShellType.Normal => new NormalAppShell(),
_ => new PlaygroundAppShell()
};
Shell.Current.Window.Page = GetShellPage(type);
}

protected override Window CreateWindow(IActivationState? activationState)
{
return new Window(GetShellPage(MauiProgram.UsedAppShell));
}

private static Page GetShellPage(AppShellType type) => type switch
{
AppShellType.Normal => new NormalAppShell(),
AppShellType.Containers => new ContainersShell(),
AppShellType.NoTabs => new NoTabsShell(),
AppShellType.ShellItems => new ShellItemsShell(),
_ => new PlaygroundAppShell()
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class TestBehavior : Behavior<View>
{
View attachedBindable;
private View? attachedBindable;

public void Test()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<shell:SimpleShell
x:Class="Playground.Containers.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Playground.Containers"
xmlns:pages="clr-namespace:Playground.Core.Views.Pages;assembly=Playground.Core"
x:Class="Playground.Original.ContainersShell"
xmlns:local="clr-namespace:Playground.Original"
xmlns:pages="clr-namespace:Playground.Original.Views.Pages"
xmlns:shell="clr-namespace:SimpleToolkit.SimpleShell;assembly=SimpleToolkit.SimpleShell"
x:Name="thisShell"
Title="Playground.Containers"
Expand Down Expand Up @@ -51,7 +51,7 @@
<HorizontalStackLayout
x:Name="tabBar"
Margin="20,5"
BindableLayout.ItemsSource="{Binding ShellContents, Source={x:Reference thisShell}}"
BindableLayout.ItemsSource="{Binding ShellContents, Source={x:Reference thisShell}, x:DataType={x:Type local:ContainersShell}}"
HorizontalOptions="Center"
MinimumHeightRequest="40"
Spacing="10">
Expand Down Expand Up @@ -105,7 +105,7 @@
FontAttributes="Bold"
FontSize="18"
HorizontalOptions="Center"
Text="{Binding CurrentShellContent.Title, Source={x:Reference thisShell}}"
Text="{Binding CurrentShellContent.Title, Source={x:Reference thisShell}, x:DataType={x:Type local:ContainersShell}}"
VerticalOptions="Center" />

<shell:SimpleNavigationHost Grid.Row="5" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Playground.Containers.Extensions;
using Playground.Core.Views.Pages;
using Playground.Original.Extensions;
using Playground.Original.Views.Pages;
using SimpleToolkit.Core;
using SimpleToolkit.SimpleShell;

#if ANDROID
Expand All @@ -10,26 +11,45 @@
using PlatformContainer = Microsoft.UI.Xaml.Controls.Panel;
#endif

namespace Playground.Containers;
namespace Playground.Original;

public partial class AppShell : SimpleShell
public partial class ContainersShell : SimpleShell
{
private int itemContainerIndex = 0;
private int firstTabContainerIndex = 0;
private int secondTabContainerIndex = 0;


public AppShell()
{
Routing.RegisterRoute(nameof(FirstYellowDetailPage), typeof(FirstYellowDetailPage));
public ContainersShell()
{
Routing.RegisterRoute(nameof(FirstYellowDetailPage), typeof(FirstYellowDetailPage));
Routing.RegisterRoute(nameof(SecondYellowDetailPage), typeof(SecondYellowDetailPage));
Routing.RegisterRoute(nameof(ThirdYellowDetailPage), typeof(ThirdYellowDetailPage));
Routing.RegisterRoute(nameof(FourthYellowDetailPage), typeof(FourthYellowDetailPage));
Routing.RegisterRoute(nameof(FirstGreenDetailPage), typeof(FirstGreenDetailPage));

InitializeComponent();

Loaded += AppShellLoaded;
Unloaded += AppShellUnloaded;

Navigated += AppShellNavigated;
}


private void AppShellLoaded(object? sender, EventArgs e)
{
Window.SubscribeToSafeAreaChanges(OnSafeAreaChanged);
}

private void AppShellUnloaded(object? sender, EventArgs e)
{
Window.UnsubscribeFromSafeAreaChanges(OnSafeAreaChanged);
}

private void OnSafeAreaChanged(Thickness safeAreaPadding)
{
contentContainer.Padding = safeAreaPadding;
}

private async void AppShellNavigated(object? sender, ShellNavigatedEventArgs e)
Expand Down Expand Up @@ -115,9 +135,8 @@ private string GetContainerStats(IView? container)
private async void ShellItemButtonClicked(object sender, EventArgs e)
{
var button = sender as Button;
var shellItem = button?.BindingContext as BaseShellItem;

if (shellItem is null)
if (button?.BindingContext is not BaseShellItem shellItem)
return;

// Navigate to a new tab if it is not the current tab
Expand Down Expand Up @@ -170,4 +189,4 @@ private void RefreshClicked(object sender, EventArgs e)
{
UpdateStats();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Globalization;
using System.Globalization;

namespace Playground.ShellItems.Converters;
namespace Playground.Original.Converters;

public class EqualsConverter : IMultiValueConverter
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SimpleToolkit.SimpleShell;
using SimpleToolkit.SimpleShell;

namespace Playground.Containers.Extensions;
namespace Playground.Original.Extensions;

public static class ViewExtensions
{
Expand Down
9 changes: 6 additions & 3 deletions src/Playground/Playground.Original/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ public static MauiApp CreateMauiApp()
if (UsedAppShell == AppShellType.Playground)
builder.DisplayContentBehindBars();

#if ANDROID
builder.SetDefaultStatusBarAppearance(color: Colors.Transparent, lightElements: false);
builder.SetDefaultNavigationBarAppearance(color: Colors.Transparent, lightElements: false);
#if ANDROID && !ANDROID35_0_OR_GREATER
builder.SetDefaultStatusBarAppearance(color: Colors.Black, lightElements: true);
builder.SetDefaultNavigationBarAppearance(color: Colors.Black, lightElements: true);
#endif

#pragma warning disable CS8793 // The given expression always matches the provided pattern.
if (UsedAppShell is not AppShellType.Normal)
{
builder.UseSimpleShell(true);
}
#pragma warning restore CS8793 // The given expression always matches the provided pattern.

return builder.Build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<shell:SimpleShell
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Playground.Original"
xmlns:shell="clr-namespace:SimpleToolkit.SimpleShell;assembly=SimpleToolkit.SimpleShell"
xmlns:pages="clr-namespace:Playground.Core.Views.Pages;assembly=Playground.Core"
x:Class="Playground.NoTabs.AppShell"
Title="NoTabsAppShell"
xmlns:pages="clr-namespace:Playground.Original.Views.Pages"
x:Class="Playground.Original.NoTabsShell"
Title="NoTabsShell"

x:Name="thisShell"

Expand Down Expand Up @@ -41,7 +41,7 @@
Grid.Row="1"
Margin="20,5"
HorizontalOptions="Center" Spacing="10"
BindableLayout.ItemsSource="{Binding ShellContents, Source={x:Reference thisShell}}">
BindableLayout.ItemsSource="{Binding ShellContents, Source={x:Reference thisShell}, x:DataType={x:Type local:NoTabsShell}}">
<BindableLayout.ItemTemplate>
<DataTemplate
x:DataType="BaseShellItem">
Expand All @@ -57,6 +57,7 @@

<shell:SimpleShell.Content>
<Grid
x:Name="rootContainer"
RowDefinitions="50, *">
<Button
x:Name="backButton"
Expand All @@ -68,7 +69,7 @@
<Label
Margin="20,5"
HorizontalOptions="Center" VerticalOptions="Center"
Text="{Binding CurrentShellContent.Title, Source={x:Reference thisShell}}"
Text="{Binding CurrentShellContent.Title, Source={x:Reference thisShell}, x:DataType={x:Type local:NoTabsShell}}"
FontAttributes="Bold" FontSize="18"/>
<shell:SimpleNavigationHost
Grid.Row="1"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Playground.Core.Views.Pages;
using Playground.Original.Views.Pages;
using SimpleToolkit.Core;
using SimpleToolkit.SimpleShell;
using SimpleToolkit.SimpleShell.Extensions;
using Playground.Core;

namespace Playground.NoTabs;
namespace Playground.Original;

public partial class AppShell : SimpleShell
public partial class NoTabsShell : SimpleShell
{
public AppShell()
public NoTabsShell()
{
Routing.RegisterRoute(nameof(FirstYellowDetailPage), typeof(FirstYellowDetailPage));
Routing.RegisterRoute(nameof(SecondYellowDetailPage), typeof(SecondYellowDetailPage));
Expand All @@ -17,21 +17,39 @@ public AppShell()

InitializeComponent();

Loaded += AppShellLoaded;
Unloaded += AppShellUnloaded;

this.SetTransition(Transitions.DefaultUniversalTransition);
}

private async void ShellItemButtonClicked(object sender, EventArgs e)

private void AppShellLoaded(object? sender, EventArgs e)
{
Window.SubscribeToSafeAreaChanges(OnSafeAreaChanged);
}

private void AppShellUnloaded(object? sender, EventArgs e)
{
Window.UnsubscribeFromSafeAreaChanges(OnSafeAreaChanged);
}

private void OnSafeAreaChanged(Thickness safeAreaPadding)
{
rootContainer.Padding = safeAreaPadding;
}

private async void ShellItemButtonClicked(object? sender, EventArgs e)
{
var button = sender as Button;
var shellItem = button.BindingContext as BaseShellItem;
if (sender is not Button button || button.BindingContext is not BaseShellItem shellItem)
return;

// Navigate to a new tab if it is not the current tab
if (!CurrentState.Location.OriginalString.Contains(shellItem.Route))
await GoToAsync($"///{shellItem.Route}", true);
}

private async void BackButtonClicked(object sender, EventArgs e)
private async void BackButtonClicked(object? sender, EventArgs e)
{
await GoToAsync("..");
}
Expand Down
Loading

0 comments on commit 941eb55

Please sign in to comment.