From 086a628024a0b0ae1803c1709d1f717f875ad747 Mon Sep 17 00:00:00 2001 From: Omid Mafakher Date: Wed, 3 Sep 2025 21:08:12 +0200 Subject: [PATCH] merge: release 1.3.2.2 (#113) * Update dependency Projektanker.Icons.Avalonia.FontAwesome to 8.4.0 (#86) Co-authored-by: Renovate Bot * Update dependency Projektanker.Icons.Avalonia to 8.4.0 (#85) Co-authored-by: Renovate Bot * Update dependency Projektanker.Icons.Avalonia to v9 (#95) Co-authored-by: Renovate Bot * Update dependency Projektanker.Icons.Avalonia.FontAwesome to v9 (#96) Co-authored-by: Renovate Bot * fix issue of crash when host navigate back (#100) * #98 fix issue of crash when host navigate back * Update src/AvaloniaInside.Shell/StackContentView.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update dependency ReactiveUI to 20.3.1 (#99) Co-authored-by: Renovate Bot * Update avalonia monorepo to 11.3.1 (#101) * Update avalonia monorepo to 11.3.1 * Update src/Directory.Packages.props Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/Directory.Packages.props Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Renovate Bot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update dependency Xamarin.AndroidX.Core.SplashScreen to 1.0.1.16 (#102) Co-authored-by: Renovate Bot * Update avalonia monorepo to 11.3.2 (#103) Co-authored-by: Renovate Bot * Update dependency ReactiveUI to 20.4.1 (#104) Co-authored-by: Renovate Bot * Synchronize window title with navigation bar header (#105) * Initial plan * Implement window title synchronization with navigation bar header Co-authored-by: OmidID <956077+OmidID@users.noreply.github.com> * Clean up implementation and restore original target frameworks Co-authored-by: OmidID <956077+OmidID@users.noreply.github.com> * Implement OnNavigate event and revert primary constructor changes Co-authored-by: OmidID <956077+OmidID@users.noreply.github.com> * Restore original target frameworks Co-authored-by: OmidID <956077+OmidID@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: OmidID <956077+OmidID@users.noreply.github.com> * Update avalonia monorepo to 11.3.4 (#108) Co-authored-by: Renovate Bot * Update dependency Xamarin.AndroidX.Core.SplashScreen to 1.0.1.17 (#109) Co-authored-by: Renovate Bot * Update dependency ReactiveUI to v21 (#110) Co-authored-by: Renovate Bot * Update avalonia monorepo to 11.3.5 (#111) Co-authored-by: Renovate Bot * Release version 1.3.2.2 - Update package version in csproj and README (#112) * Initial plan * Update version to 1.3.2.2 in csproj and README Co-authored-by: OmidID <956077+OmidID@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: OmidID <956077+OmidID@users.noreply.github.com> --------- Co-authored-by: Renovate Bot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: OmidID <956077+OmidID@users.noreply.github.com> --- README.md | 2 +- .../AvaloniaInside.Shell.csproj | 2 +- src/AvaloniaInside.Shell/INavigator.cs | 2 ++ src/AvaloniaInside.Shell/Navigator.cs | 16 ++++++++++ src/AvaloniaInside.Shell/StackContentView.cs | 13 ++++++-- src/Directory.Packages.props | 27 ++++++++-------- .../ShellExample/Views/MainWindow.axaml | 2 +- .../ShellExample/Views/MainWindow.axaml.cs | 32 +++++++++++++++++++ 8 files changed, 77 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index c94b959..ce2cf7e 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ We welcome feedback, suggestions, and contributions from anyone who is intereste To use AvaloniaInside.Shell in your Avalonia project, you can install the package via NuGet using the following command in the Package Manager Console: ```bash -dotnet add package AvaloniaInside.Shell --version 1.3.2 +dotnet add package AvaloniaInside.Shell --version 1.3.2.2 ``` Alternatively, you can also install the package through Visual Studio's NuGet Package Manager. diff --git a/src/AvaloniaInside.Shell/AvaloniaInside.Shell.csproj b/src/AvaloniaInside.Shell/AvaloniaInside.Shell.csproj index ada87c5..35dcff5 100644 --- a/src/AvaloniaInside.Shell/AvaloniaInside.Shell.csproj +++ b/src/AvaloniaInside.Shell/AvaloniaInside.Shell.csproj @@ -3,7 +3,7 @@ net8.0;net9.0 enable latest - 1.3.2 + 1.3.2.2 Shell view for Avalonia Shell reduces the complexity of mobile/desktop application development by providing the fundamental features that most applications require AvaloniaInside diff --git a/src/AvaloniaInside.Shell/INavigator.cs b/src/AvaloniaInside.Shell/INavigator.cs index 18d03a5..d8f4e90 100644 --- a/src/AvaloniaInside.Shell/INavigator.cs +++ b/src/AvaloniaInside.Shell/INavigator.cs @@ -9,6 +9,8 @@ public interface INavigator { Uri CurrentUri { get; } + event EventHandler? OnNavigate; + INavigationRegistrar Registrar { get; } NavigationChain? CurrentChain { get; } diff --git a/src/AvaloniaInside.Shell/Navigator.cs b/src/AvaloniaInside.Shell/Navigator.cs index d189083..f993d24 100644 --- a/src/AvaloniaInside.Shell/Navigator.cs +++ b/src/AvaloniaInside.Shell/Navigator.cs @@ -18,6 +18,8 @@ public partial class Navigator : INavigator private bool _navigating; private ShellView? _shellView; + public event EventHandler? OnNavigate; + public ShellView ShellView => _shellView ?? throw new ArgumentNullException(nameof(ShellView)); public Uri CurrentUri => _stack.Current?.Uri ?? Registrar.RootUri; @@ -154,6 +156,20 @@ await _updateStrategy.UpdateChangesAsync( await fromPage.OnNavigateAsync(args, cancellationToken); } + // Fire the OnNavigate event for external subscribers + OnNavigate?.Invoke(this, new NaviagateEventArgs + { + Sender = sender, + From = fromPage, + To = _stack.Current?.Instance, + FromUri = origin, + ToUri = newUri, + Argument = argument, + Navigate = finalNavigateType, + WithAnimation = withAnimation, + OverrideTransition = overrideTransition + }); + _navigating = false; } diff --git a/src/AvaloniaInside.Shell/StackContentView.cs b/src/AvaloniaInside.Shell/StackContentView.cs index 98ffb74..91dd1a6 100644 --- a/src/AvaloniaInside.Shell/StackContentView.cs +++ b/src/AvaloniaInside.Shell/StackContentView.cs @@ -60,8 +60,17 @@ public async Task PushViewAsync(object view, // Bring to front if exists in collection if (Children.Contains(control)) - Children.Remove(control); - Children.Add(control); + { + var currentIndex = Children.IndexOf(control); + if (currentIndex != Children.Count - 1) + { + Children.Move(currentIndex, Children.Count - 1); + } + } + else + { + Children.Add(control); + } await OnContentUpdateAsync(control, cancellationToken); await UpdateCurrentViewAsync(current, control, navigateType, false, cancellationToken); diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 739b949..3881585 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -4,20 +4,19 @@ true - - - - - - - - - - + + + + + + + + + - - - - + + + + diff --git a/src/Example/ShellExample/ShellExample/Views/MainWindow.axaml b/src/Example/ShellExample/ShellExample/Views/MainWindow.axaml index 70ee737..34e2a51 100644 --- a/src/Example/ShellExample/ShellExample/Views/MainWindow.axaml +++ b/src/Example/ShellExample/ShellExample/Views/MainWindow.axaml @@ -8,5 +8,5 @@ Icon="/Assets/avalonia-logo.ico" Title="ShellExample" Width="450"> - + diff --git a/src/Example/ShellExample/ShellExample/Views/MainWindow.axaml.cs b/src/Example/ShellExample/ShellExample/Views/MainWindow.axaml.cs index f9a4814..06958c6 100644 --- a/src/Example/ShellExample/ShellExample/Views/MainWindow.axaml.cs +++ b/src/Example/ShellExample/ShellExample/Views/MainWindow.axaml.cs @@ -1,5 +1,7 @@ using Avalonia; using Avalonia.Controls; +using Avalonia.Interactivity; +using AvaloniaInside.Shell; namespace ShellExample.Views; @@ -11,4 +13,34 @@ public MainWindow() InitializeComponent(); } + protected override void OnLoaded(RoutedEventArgs e) + { + base.OnLoaded(e); + + // Subscribe to navigation events to update window title + if (MainView.Navigator != null) + { + MainView.Navigator.OnNavigate += OnNavigate; + } + } + + protected override void OnUnloaded(RoutedEventArgs e) + { + // Unsubscribe from navigation events + if (MainView.Navigator != null) + { + MainView.Navigator.OnNavigate -= OnNavigate; + } + + base.OnUnloaded(e); + } + + private void OnNavigate(object? sender, NaviagateEventArgs e) + { + if (e.To is AvaloniaObject targetView) + { + var header = NavigationBar.GetHeader(targetView) as string; + Title = header ?? "Shell Example"; + } + } }