Improve sub navigations
This commit is contained in:
@@ -3,7 +3,6 @@ using Avalonia.Interactivity;
|
|||||||
using FluentAvalonia.UI.Media.Animation;
|
using FluentAvalonia.UI.Media.Animation;
|
||||||
using FluentAvalonia.UI.Navigation;
|
using FluentAvalonia.UI.Navigation;
|
||||||
using Toolkit.Foundation;
|
using Toolkit.Foundation;
|
||||||
using Toolkit.UI.Avalonia;
|
|
||||||
using Toolkit.UI.Controls.Avalonia;
|
using Toolkit.UI.Controls.Avalonia;
|
||||||
|
|
||||||
namespace Toolkit.Avalonia;
|
namespace Toolkit.Avalonia;
|
||||||
@@ -24,8 +23,6 @@ public class FrameHandler :
|
|||||||
async void HandleNavigatedTo(object? _,
|
async void HandleNavigatedTo(object? _,
|
||||||
NavigationEventArgs __)
|
NavigationEventArgs __)
|
||||||
{
|
{
|
||||||
sender.RemoveHandler(Frame.NavigatedToEvent, HandleNavigatedTo);
|
|
||||||
|
|
||||||
async void HandleNavigatingFrom(object? _,
|
async void HandleNavigatingFrom(object? _,
|
||||||
NavigatingCancelEventArgs args)
|
NavigatingCancelEventArgs args)
|
||||||
{
|
{
|
||||||
@@ -43,12 +40,16 @@ public class FrameHandler :
|
|||||||
await deactivated.OnDeactivated();
|
await deactivated.OnDeactivated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (content is not IBackStack)
|
||||||
|
{
|
||||||
if (content is IDisposable disposable)
|
if (content is IDisposable disposable)
|
||||||
{
|
{
|
||||||
disposable.Dispose();
|
disposable.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sender.AddHandler(Frame.NavigatedFromEvent, HandleNavigatedFrom);
|
sender.AddHandler(Frame.NavigatedFromEvent, HandleNavigatedFrom);
|
||||||
if (sender.DataContext is object content)
|
if (sender.DataContext is object content)
|
||||||
@@ -85,7 +86,9 @@ public class FrameHandler :
|
|||||||
|
|
||||||
async void HandleUnloaded(object? _, RoutedEventArgs __)
|
async void HandleUnloaded(object? _, RoutedEventArgs __)
|
||||||
{
|
{
|
||||||
|
sender.RemoveHandler(Frame.NavigatedToEvent, HandleNavigatedTo);
|
||||||
sender.RemoveHandler(Frame.NavigatingFromEvent, HandleNavigatingFrom);
|
sender.RemoveHandler(Frame.NavigatingFromEvent, HandleNavigatingFrom);
|
||||||
|
|
||||||
control.Unloaded -= HandleUnloaded;
|
control.Unloaded -= HandleUnloaded;
|
||||||
|
|
||||||
if (control.DataContext is object content)
|
if (control.DataContext is object content)
|
||||||
@@ -116,7 +119,7 @@ public class FrameHandler :
|
|||||||
{
|
{
|
||||||
if (args.Parameters.TryGetValue("Transition", out object? transition))
|
if (args.Parameters.TryGetValue("Transition", out object? transition))
|
||||||
{
|
{
|
||||||
switch($"{transition}")
|
switch ($"{transition}")
|
||||||
{
|
{
|
||||||
case "FromLeft":
|
case "FromLeft":
|
||||||
case "FromRight":
|
case "FromRight":
|
||||||
@@ -129,6 +132,14 @@ public class FrameHandler :
|
|||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.Parameters.TryGetValue("NavigationStackEnabled", out object? navigationStackEnabled))
|
||||||
|
{
|
||||||
|
if (navigationStackEnabled is bool value)
|
||||||
|
{
|
||||||
|
navigationOptions.IsNavigationStackEnabled = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,12 +155,6 @@ public class FrameHandler :
|
|||||||
{
|
{
|
||||||
if (args.Context is Frame frame)
|
if (args.Context is Frame frame)
|
||||||
{
|
{
|
||||||
//NavigationTransitionInfo? navigationTransitionInfo = null;
|
|
||||||
//if (frame.Content is IBackwardNavigation navigation)
|
|
||||||
//{
|
|
||||||
// navigationTransitionInfo = navigation.Transition;
|
|
||||||
//}
|
|
||||||
|
|
||||||
frame.GoBack();
|
frame.GoBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
|
public interface IBackStack;
|
||||||
Reference in New Issue
Block a user