Skip to content

Commit

Permalink
Merge pull request #392 from nventive/dev/jpl/mouse-back-button
Browse files Browse the repository at this point in the history
feat: Add support for mouse back button navigation.
  • Loading branch information
jeanplevesque authored Feb 9, 2024
2 parents 91025af + a38d075 commit 1d4e8a1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)

Prefix your items with `(Template)` if the change is about the template and not the resulting application.

## 3.2.X
- Added support for mouse back button navigation.

## 3.1.X
- Updated to .NET 8.
- Added MAUI essentials on Windows.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<TrimMode>partial</TrimMode>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Chinook.BackButtonManager.Uno.WinUI" Version="2.0.0" />
<PackageReference Include="Chinook.BackButtonManager.Uno.WinUI" Version="2.1.0" />
<PackageReference Include="Chinook.DataLoader.Uno.WinUI" Version="2.0.0" />
<PackageReference Include="Chinook.DynamicMvvm.Uno.WinUI" Version="2.0.0" />
<PackageReference Include="Chinook.SectionsNavigation.Uno.WinUI" Version="3.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<PackageReference Include="Chinook.DynamicMvvm.CollectionTracking" Version="2.0.0" />
<PackageReference Include="Chinook.DataLoader" Version="2.0.0" />
<PackageReference Include="Chinook.DataLoader.DynamicMvvm" Version="2.0.0" />
<PackageReference Include="Chinook.BackButtonManager" Version="2.0.0" />
<PackageReference Include="Chinook.BackButtonManager" Version="2.1.0" />
<PackageReference Include="Chinook.SectionsNavigation" Version="3.0.0" />
<PackageReference Include="Chinook.SectionsNavigation.Reactive" Version="3.0.0" />
<PackageReference Include="MessageDialogService" Version="2.0.0" />
Expand Down
22 changes: 22 additions & 0 deletions src/app/ApplicationTemplate.Shared.Views/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ protected override async Task StartViewServices(IServiceProvider services, bool
await SetShellViewModel();

await AddSystemBackButtonSource(services);
await AddMouseBackButtonSource(services);

HandleSystemBackVisibility(services);

Expand Down Expand Up @@ -194,6 +195,27 @@ void AddSystemBackButtonSourceInner()
//+:cnd:noEmit
}

/// <summary>
/// Adds mouse back button to the IBackButtonManager.
/// </summary>
private async Task AddMouseBackButtonSource(IServiceProvider services)
{
//-:cnd:noEmit
#if __WINDOWS__
var dispatcherQueue = services.GetRequiredService<DispatcherQueue>();
var backButtonManager = services.GetRequiredService<IBackButtonManager>();
await dispatcherQueue.EnqueueAsync(AddSystemBackButtonSourceInner, DispatcherQueuePriority.High);

// Runs on main thread.
void AddSystemBackButtonSourceInner()
{
var source = new PointerXButton1BackButtonSource(App.Instance.Shell);
backButtonManager.AddSource(source);
}
#endif
//+:cnd:noEmit
}

private void SetStatusBarColor(IServiceProvider services)
{
//-:cnd:noEmit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Chinook.BackButtonManager.Uno.WinUI" Version="2.0.0" />
<PackageReference Include="Chinook.BackButtonManager.Uno.WinUI" Version="2.1.0" />
<PackageReference Include="Chinook.DataLoader.Uno.WinUI" Version="2.0.0" />
<PackageReference Include="Chinook.DynamicMvvm.Uno.WinUI" Version="2.0.0" />
<PackageReference Include="Chinook.SectionsNavigation.Uno.WinUI" Version="3.0.0" />
Expand Down

0 comments on commit 1d4e8a1

Please sign in to comment.