mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Added workshop home, changed VM routing structure
This commit is contained in:
1 parent
99a365be0b
commit
65f81ab768
34 files changed
+667
-75
No files matched your search
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Platform;
|
||||
|
||||
namespace Artemis.UI.Shared.Routing;
|
||||
|
||||
@@ -72,7 +73,15 @@ public abstract class RoutableScreen<TScreen, TParam> : ActivatableViewModelBase
|
||||
|
||||
void IRoutableScreen.InternalChangeScreen(object? screen)
|
||||
{
|
||||
Screen = screen as TScreen;
|
||||
if (screen == null)
|
||||
{
|
||||
Screen = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (screen is not TScreen typedScreen)
|
||||
throw new ArtemisRoutingException($"Provided screen is not assignable to {typeof(TScreen).FullName}");
|
||||
Screen = typedScreen;
|
||||
}
|
||||
|
||||
async Task IRoutableScreen.InternalOnNavigating(NavigationArguments args, CancellationToken cancellationToken)
|
||||
|
||||
@@ -70,7 +70,17 @@ internal class Navigation
|
||||
|
||||
// Only change the screen if it wasn't reused
|
||||
if (!ReferenceEquals(host.InternalScreen, screen))
|
||||
host.InternalChangeScreen(screen);
|
||||
{
|
||||
try
|
||||
{
|
||||
host.InternalChangeScreen(screen);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Cancel();
|
||||
_logger.Error(e, "Failed to navigate to {Path}", resolution.Path);
|
||||
}
|
||||
}
|
||||
|
||||
if (CancelIfRequested(args, "ChangeScreen", screen))
|
||||
return;
|
||||
@@ -93,8 +103,16 @@ internal class Navigation
|
||||
return;
|
||||
}
|
||||
|
||||
if (resolution.Child != null && screen is IRoutableScreen childScreen)
|
||||
await NavigateResolution(resolution.Child, args, childScreen);
|
||||
if (screen is IRoutableScreen childScreen)
|
||||
{
|
||||
// Navigate the child too
|
||||
if (resolution.Child != null)
|
||||
await NavigateResolution(resolution.Child, args, childScreen);
|
||||
// Make sure there is no child
|
||||
else if (childScreen.InternalScreen != null)
|
||||
childScreen.InternalChangeScreen(null);
|
||||
}
|
||||
|
||||
|
||||
Completed = true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user