mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Sidebar - Added subitems support
This commit is contained in:
1 parent
229d93901b
commit
99a365be0b
33 files changed
+572
-162
No files matched your search
@@ -62,7 +62,15 @@ public abstract class RoutableScreen<TScreen> : ActivatableViewModelBase, IRouta
|
||||
|
||||
void IRoutableScreen.InternalChangeScreen(object? screen)
|
||||
{
|
||||
Screen = screen as TScreen;
|
||||
if (screen == null)
|
||||
{
|
||||
Screen = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (screen is not TScreen typedScreen)
|
||||
throw new ArtemisRoutingException($"Screen cannot be hosted, {screen.GetType().Name} is not assignable to {typeof(TScreen).Name}.");
|
||||
Screen = typedScreen;
|
||||
}
|
||||
|
||||
async Task IRoutableScreen.InternalOnNavigating(NavigationArguments args, CancellationToken cancellationToken)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
namespace Artemis.UI.Shared.Routing.ParameterParsers;
|
||||
|
||||
internal class IntParameterParser : IRouteParameterParser
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public bool IsMatch(RouteSegment segment, string source)
|
||||
{
|
||||
return int.TryParse(source, out _);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public object GetValue(RouteSegment segment, string source)
|
||||
{
|
||||
return int.Parse(source);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using DryIoc;
|
||||
|
||||
namespace Artemis.UI.Shared.Routing;
|
||||
|
||||
@@ -48,11 +48,14 @@ public partial class RouteSegment
|
||||
|
||||
private IRouteParameterParser GetParameterParser(string parameterType)
|
||||
{
|
||||
if (parameterType == "guid")
|
||||
return new GuidParameterParser();
|
||||
return parameterType switch
|
||||
{
|
||||
"guid" => new GuidParameterParser(),
|
||||
"int" => new IntParameterParser(),
|
||||
_ => new StringParameterParser()
|
||||
};
|
||||
|
||||
// Default to a string parser which just returns the segment as is
|
||||
return new StringParameterParser();
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"\{(\w+):(\w+)\}")]
|
||||
|
||||
Reference in new issue
Block a user