Add Navigations
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Toolkit.Foundation
|
||||
{
|
||||
public interface IEventParameter
|
||||
{
|
||||
List<object> GetValues(EventArgs args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Kromek.Framework.Core.Extensions
|
||||
{
|
||||
public interface INavigationConfirmation
|
||||
{
|
||||
bool CanConfirm();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
namespace Kromek.Framework.Core.Extensions
|
||||
{
|
||||
public interface INavigationConfirmationAsync
|
||||
{
|
||||
Task<bool> CanConfirmAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Toolkit.Foundation
|
||||
{
|
||||
public interface INavigationRoute
|
||||
{
|
||||
void Add(string name, object route);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Toolkit.Foundation
|
||||
{
|
||||
public interface INavigationRouteDescriptor
|
||||
{
|
||||
object Route { get; }
|
||||
|
||||
string? Name { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Toolkit.Foundation
|
||||
{
|
||||
public interface INavigationRouteDescriptorCollection : IList<INavigationRouteDescriptor>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Toolkit.Foundation
|
||||
{
|
||||
public interface INavigationRouter : IInitializer
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Toolkit.Foundation
|
||||
{
|
||||
public interface IParameter
|
||||
{
|
||||
string? Key { get; }
|
||||
|
||||
KeyValuePair<string, object>? GetValue(object target);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace Toolkit.Foundation
|
||||
{
|
||||
public record Navigate
|
||||
{
|
||||
public Navigate(string name, params object?[] parameters)
|
||||
{
|
||||
Name = name;
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
public Navigate(Type type, params object?[] parameters)
|
||||
{
|
||||
Type = type;
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
public Type? Type { get; }
|
||||
|
||||
public object? Route { get; init; }
|
||||
|
||||
public string? Name { get; }
|
||||
|
||||
public string? FriendlyName { get; init; }
|
||||
|
||||
public object?[] Parameters { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace Toolkit.Foundation
|
||||
{
|
||||
public record NavigateBack(object Route);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
|
||||
namespace Toolkit.Foundation
|
||||
{
|
||||
public class NavigateHandler : IRecipient<Navigate>
|
||||
{
|
||||
private readonly IMessenger messenger;
|
||||
|
||||
public NavigateHandler(IMessenger messenger)
|
||||
{
|
||||
this.messenger = messenger;
|
||||
}
|
||||
|
||||
public void Receive(Navigate request)
|
||||
{
|
||||
messenger.Send(request);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace Toolkit.Foundation
|
||||
{
|
||||
public class Navigated<TContent, TDataContext> where TContent : class where TDataContext : class
|
||||
{
|
||||
public Navigated()
|
||||
{
|
||||
}
|
||||
|
||||
public Navigated(TContent content, TDataContext dataContext, IDictionary<string, object>? parameters = null)
|
||||
{
|
||||
Content = content;
|
||||
DataContext = dataContext;
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
public TContent? Content { get; }
|
||||
|
||||
public TDataContext? DataContext { get; }
|
||||
|
||||
public IDictionary<string, object>? Parameters { get; }
|
||||
}
|
||||
|
||||
public class Navigated
|
||||
{
|
||||
public static Navigated<TTemplate, TDataTemplate> Create<TTemplate, TDataTemplate>(TTemplate content, TDataTemplate dataContext, IDictionary<string, object>? parameters = null) where TTemplate : class where TDataTemplate : class
|
||||
{
|
||||
return new Navigated<TTemplate, TDataTemplate>(content, dataContext, parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Toolkit.Foundation
|
||||
{
|
||||
public record NavigationRouteDescriptor : INavigationRouteDescriptor
|
||||
{
|
||||
public NavigationRouteDescriptor(string name, object route)
|
||||
{
|
||||
Name = name;
|
||||
Route = route;
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public object Route { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Toolkit.Foundation
|
||||
{
|
||||
public class NavigationRouteDescriptorCollection : List<INavigationRouteDescriptor>, INavigationRouteDescriptorCollection
|
||||
{
|
||||
public NavigationRouteDescriptorCollection(IEnumerable<INavigationRouteDescriptor> collection) : base(collection)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user