diff --git a/src/Artemis.UI.Shared/Routing/Routable/IRoutableHostScreen.cs b/src/Artemis.UI.Shared/Routing/Routable/IRoutableHostScreen.cs new file mode 100644 index 000000000..b09afb676 --- /dev/null +++ b/src/Artemis.UI.Shared/Routing/Routable/IRoutableHostScreen.cs @@ -0,0 +1,13 @@ +namespace Artemis.UI.Shared.Routing; + +/// +/// For internal use. +/// +/// +/// +internal interface IRoutableHostScreen : IRoutableScreen +{ + bool RecycleScreen { get; } + IRoutableScreen? InternalScreen { get; } + void InternalChangeScreen(IRoutableScreen? screen); +} \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Routing/Routable/IRoutableScreen.cs b/src/Artemis.UI.Shared/Routing/Routable/IRoutableScreen.cs new file mode 100644 index 000000000..3b28384cd --- /dev/null +++ b/src/Artemis.UI.Shared/Routing/Routable/IRoutableScreen.cs @@ -0,0 +1,14 @@ +using System.Threading; +using System.Threading.Tasks; +using ReactiveUI; + +namespace Artemis.UI.Shared.Routing; + +/// +/// For internal use. +/// +internal interface IRoutableScreen : IActivatableViewModel +{ + Task InternalOnNavigating(NavigationArguments args, CancellationToken cancellationToken); + Task InternalOnClosing(NavigationArguments args); +} \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Routing/Routable/RoutableHostScreenOfTScreen.cs b/src/Artemis.UI.Shared/Routing/Routable/RoutableHostScreenOfTScreen.cs new file mode 100644 index 000000000..c61c27820 --- /dev/null +++ b/src/Artemis.UI.Shared/Routing/Routable/RoutableHostScreenOfTScreen.cs @@ -0,0 +1,42 @@ +namespace Artemis.UI.Shared.Routing; + +/// +/// Represents a view model to which routing can take place and which in turn can host another view model. +/// +/// The type of view model the screen can host. +public abstract class RoutableHostScreen : RoutableScreen, IRoutableHostScreen where TScreen : RoutableScreen +{ + private bool _recycleScreen = true; + private TScreen? _screen; + + /// + /// Gets the currently active child screen. + /// + public TScreen? Screen + { + get => _screen; + private set => RaiseAndSetIfChanged(ref _screen, value); + } + + /// + public bool RecycleScreen + { + get => _recycleScreen; + protected set => RaiseAndSetIfChanged(ref _recycleScreen, value); + } + + IRoutableScreen? IRoutableHostScreen.InternalScreen => Screen; + + void IRoutableHostScreen.InternalChangeScreen(IRoutableScreen? screen) + { + 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; + } +} \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Routing/Routable/RoutableHostScreenOfTScreenTParam.cs b/src/Artemis.UI.Shared/Routing/Routable/RoutableHostScreenOfTScreenTParam.cs new file mode 100644 index 000000000..89773e8d4 --- /dev/null +++ b/src/Artemis.UI.Shared/Routing/Routable/RoutableHostScreenOfTScreenTParam.cs @@ -0,0 +1,44 @@ +namespace Artemis.UI.Shared.Routing; + +/// +/// Represents a view model to which routing with parameters can take place and which in turn can host another view +/// model. +/// +/// The type of view model the screen can host. +/// The type of parameters the screen expects. It must have a parameterless constructor. +public abstract class RoutableHostScreen : RoutableScreen, IRoutableHostScreen where TScreen : RoutableScreen where TParam : new() +{ + private bool _recycleScreen = true; + private TScreen? _screen; + + /// + /// Gets the currently active child screen. + /// + public TScreen? Screen + { + get => _screen; + private set => RaiseAndSetIfChanged(ref _screen, value); + } + + /// + public bool RecycleScreen + { + get => _recycleScreen; + protected set => RaiseAndSetIfChanged(ref _recycleScreen, value); + } + + IRoutableScreen? IRoutableHostScreen.InternalScreen => Screen; + + void IRoutableHostScreen.InternalChangeScreen(IRoutableScreen? screen) + { + 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; + } +} \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Routing/Routable/RoutableScreen.cs b/src/Artemis.UI.Shared/Routing/Routable/RoutableScreen.cs index 53973de46..7db5dbe2e 100644 --- a/src/Artemis.UI.Shared/Routing/Routable/RoutableScreen.cs +++ b/src/Artemis.UI.Shared/Routing/Routable/RoutableScreen.cs @@ -1,24 +1,55 @@ using System.Threading; using System.Threading.Tasks; -using ReactiveUI; namespace Artemis.UI.Shared.Routing; /// -/// For internal use. +/// Represents a view model to which routing can take place. /// -/// -/// -internal interface IRoutableScreen : IActivatableViewModel +public abstract class RoutableScreen : ActivatableViewModelBase, IRoutableScreen { /// - /// Gets or sets a value indicating whether or not to reuse the child screen instance if the type has not changed. + /// Called before navigating to this screen. /// - /// Defaults to . - bool RecycleScreen { get; } + /// Navigation arguments containing information about the navigation action. + public virtual Task BeforeNavigating(NavigationArguments args) + { + return Task.CompletedTask; + } - object? InternalScreen { get; } - void InternalChangeScreen(object? screen); - Task InternalOnNavigating(NavigationArguments args, CancellationToken cancellationToken); - Task InternalOnClosing(NavigationArguments args); + /// + /// Called while navigating to this screen. + /// + /// Navigation arguments containing information about the navigation action. + /// + /// A cancellation token that can be used by other objects or threads to receive notice of + /// cancellation. + /// + public virtual Task OnNavigating(NavigationArguments args, CancellationToken cancellationToken) + { + return Task.CompletedTask; + } + + /// + /// Called before navigating away from this screen. + /// + /// Navigation arguments containing information about the navigation action. + public virtual Task OnClosing(NavigationArguments args) + { + return Task.CompletedTask; + } + + #region Overrides of RoutableScreen + + async Task IRoutableScreen.InternalOnNavigating(NavigationArguments args, CancellationToken cancellationToken) + { + await OnNavigating(args, cancellationToken); + } + + async Task IRoutableScreen.InternalOnClosing(NavigationArguments args) + { + await OnClosing(args); + } + + #endregion } \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Routing/Routable/RoutableScreenOfTScreenTParam.cs b/src/Artemis.UI.Shared/Routing/Routable/RoutableScreenOfTParam.cs similarity index 68% rename from src/Artemis.UI.Shared/Routing/Routable/RoutableScreenOfTScreenTParam.cs rename to src/Artemis.UI.Shared/Routing/Routable/RoutableScreenOfTParam.cs index ac62129dc..bbe71fe2a 100644 --- a/src/Artemis.UI.Shared/Routing/Routable/RoutableScreenOfTScreenTParam.cs +++ b/src/Artemis.UI.Shared/Routing/Routable/RoutableScreenOfTParam.cs @@ -4,39 +4,15 @@ using System.Linq; using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; -using Avalonia.Platform; namespace Artemis.UI.Shared.Routing; /// -/// Represents a view model to which routing with parameters can take place and which in turn can host another view -/// model. +/// Represents a view model to which routing with parameters can take place. /// -/// The type of view model the screen can host. /// The type of parameters the screen expects. It must have a parameterless constructor. -public abstract class RoutableScreen : ActivatableViewModelBase, IRoutableScreen where TScreen : class where TParam : new() +public abstract class RoutableScreen : RoutableScreen, IRoutableScreen where TParam : new() { - private bool _recycleScreen = true; - private TScreen? _screen; - - /// - /// Gets the currently active child screen. - /// - public TScreen? Screen - { - get => _screen; - private set => RaiseAndSetIfChanged(ref _screen, value); - } - - /// - /// Called before navigating to this screen. - /// - /// Navigation arguments containing information about the navigation action. - public virtual Task BeforeNavigating(NavigationArguments args) - { - return Task.CompletedTask; - } - /// /// Called while navigating to this screen. /// @@ -50,40 +26,7 @@ public abstract class RoutableScreen : ActivatableViewModelBase { return Task.CompletedTask; } - - /// - /// Called before navigating away from this screen. - /// - /// Navigation arguments containing information about the navigation action. - public virtual Task OnClosing(NavigationArguments args) - { - return Task.CompletedTask; - } - - /// - public bool RecycleScreen - { - get => _recycleScreen; - protected set => RaiseAndSetIfChanged(ref _recycleScreen, value); - } - - #region Overrides of RoutableScreen - - object? IRoutableScreen.InternalScreen => Screen; - - void IRoutableScreen.InternalChangeScreen(object? screen) - { - 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) { Func activator = GetParameterActivator(); @@ -92,6 +35,7 @@ public abstract class RoutableScreen : ActivatableViewModelBase throw new ArtemisRoutingException($"Did not retrieve the required amount of parameters, expects {_parameterPropertyCount}, got {args.SegmentParameters.Length}."); TParam parameters = activator(args.SegmentParameters); + await OnNavigating(args, cancellationToken); await OnNavigating(parameters, args, cancellationToken); } @@ -100,8 +44,6 @@ public abstract class RoutableScreen : ActivatableViewModelBase await OnClosing(args); } - #endregion - #region Parameter generation // ReSharper disable once StaticMemberInGenericType - That's intentional, each kind of TParam should have its own property count diff --git a/src/Artemis.UI.Shared/Routing/Routable/RoutableScreenOfTScreen.cs b/src/Artemis.UI.Shared/Routing/Routable/RoutableScreenOfTScreen.cs deleted file mode 100644 index b4f60ca47..000000000 --- a/src/Artemis.UI.Shared/Routing/Routable/RoutableScreenOfTScreen.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; - -namespace Artemis.UI.Shared.Routing; - -/// -/// Represents a view model to which routing can take place and which in turn can host another view model. -/// -/// The type of view model the screen can host. -public abstract class RoutableScreen : ActivatableViewModelBase, IRoutableScreen where TScreen : class -{ - private TScreen? _screen; - private bool _recycleScreen = true; - - /// - /// Gets the currently active child screen. - /// - public TScreen? Screen - { - get => _screen; - private set => RaiseAndSetIfChanged(ref _screen, value); - } - - /// - public bool RecycleScreen - { - get => _recycleScreen; - protected set => RaiseAndSetIfChanged(ref _recycleScreen, value); - } - - /// - /// Called before navigating to this screen. - /// - /// Navigation arguments containing information about the navigation action. - public virtual Task BeforeNavigating(NavigationArguments args) - { - return Task.CompletedTask; - } - - /// - /// Called while navigating to this screen. - /// - /// Navigation arguments containing information about the navigation action. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - public virtual Task OnNavigating(NavigationArguments args, CancellationToken cancellationToken) - { - return Task.CompletedTask; - } - - /// - /// Called before navigating away from this screen. - /// - /// Navigation arguments containing information about the navigation action. - public virtual Task OnClosing(NavigationArguments args) - { - return Task.CompletedTask; - } - - #region Overrides of RoutableScreen - - object? IRoutableScreen.InternalScreen => Screen; - - void IRoutableScreen.InternalChangeScreen(object? screen) - { - 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) - { - await OnNavigating(args, cancellationToken); - } - - async Task IRoutableScreen.InternalOnClosing(NavigationArguments args) - { - await OnClosing(args); - } - - #endregion -} \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Routing/Route/RouteRegistration.cs b/src/Artemis.UI.Shared/Routing/Route/RouteRegistration.cs index 2d9f8508f..c62437d03 100644 --- a/src/Artemis.UI.Shared/Routing/Route/RouteRegistration.cs +++ b/src/Artemis.UI.Shared/Routing/Route/RouteRegistration.cs @@ -7,7 +7,7 @@ namespace Artemis.UI.Shared.Routing; /// Represents a registration for a route and its associated view model. /// /// The type of the view model associated with the route. -public class RouteRegistration : IRouterRegistration where TViewModel : ViewModelBase +public class RouteRegistration : IRouterRegistration where TViewModel : RoutableScreen { /// /// Initializes a new instance of the class. diff --git a/src/Artemis.UI.Shared/Routing/Route/RouteResolution.cs b/src/Artemis.UI.Shared/Routing/Route/RouteResolution.cs index 32d285ccd..b80bad548 100644 --- a/src/Artemis.UI.Shared/Routing/Route/RouteResolution.cs +++ b/src/Artemis.UI.Shared/Routing/Route/RouteResolution.cs @@ -74,19 +74,12 @@ internal class RouteResolution }; } - public object GetViewModel(IContainer container) + public RoutableScreen GetViewModel(IContainer container) { - if (ViewModel == null) - throw new ArtemisRoutingException("Cannot get a view model of a non-success route resolution"); - - object? viewModel = container.Resolve(ViewModel); - if (viewModel == null) - throw new ArtemisRoutingException($"Could not resolve view model of type {ViewModel}"); - - return viewModel; + return GetViewModel(container); } - public T GetViewModel(IContainer container) + public T GetViewModel(IContainer container) where T : RoutableScreen { if (ViewModel == null) throw new ArtemisRoutingException("Cannot get a view model of a non-success route resolution"); diff --git a/src/Artemis.UI.Shared/Routing/Router/IRouter.cs b/src/Artemis.UI.Shared/Routing/Router/IRouter.cs index 44d77bb5c..cfbd0eb89 100644 --- a/src/Artemis.UI.Shared/Routing/Router/IRouter.cs +++ b/src/Artemis.UI.Shared/Routing/Router/IRouter.cs @@ -50,7 +50,7 @@ public interface IRouter /// /// The root screen to set. /// The type of the root screen. It must be a class. - void SetRoot(RoutableScreen root) where TScreen : class; + void SetRoot(RoutableHostScreen root) where TScreen : RoutableScreen; /// /// Sets the root screen from which navigation takes place. @@ -58,7 +58,7 @@ public interface IRouter /// The root screen to set. /// The type of the root screen. It must be a class. /// The type of the parameters for the root screen. It must have a parameterless constructor. - void SetRoot(RoutableScreen root) where TScreen : class where TParam : new(); + void SetRoot(RoutableHostScreen root) where TScreen : RoutableScreen where TParam : new(); /// /// Clears the route used by the previous window, so that it is not restored when the main window opens. diff --git a/src/Artemis.UI.Shared/Routing/Router/Navigation.cs b/src/Artemis.UI.Shared/Routing/Router/Navigation.cs index d04fded6f..50505a706 100644 --- a/src/Artemis.UI.Shared/Routing/Router/Navigation.cs +++ b/src/Artemis.UI.Shared/Routing/Router/Navigation.cs @@ -14,12 +14,12 @@ internal class Navigation private readonly IContainer _container; private readonly ILogger _logger; - private readonly IRoutableScreen _root; + private readonly IRoutableHostScreen _root; private readonly RouteResolution _resolution; private readonly RouterNavigationOptions _options; private CancellationTokenSource _cts; - public Navigation(IContainer container, ILogger logger, IRoutableScreen root, RouteResolution resolution, RouterNavigationOptions options) + public Navigation(IContainer container, ILogger logger, IRoutableHostScreen root, RouteResolution resolution, RouterNavigationOptions options) { _container = container; _logger = logger; @@ -54,21 +54,21 @@ internal class Navigation _cts.Cancel(); } - private async Task NavigateResolution(RouteResolution resolution, NavigationArguments args, IRoutableScreen host) + private async Task NavigateResolution(RouteResolution resolution, NavigationArguments args, IRoutableHostScreen host) { if (Cancelled) return; // Reuse the screen if its type has not changed, if a new one must be created, don't do so on the UI thread - object screen; + IRoutableScreen screen; if (_options.RecycleScreens && host.RecycleScreen && host.InternalScreen != null && host.InternalScreen.GetType() == resolution.ViewModel) screen = host.InternalScreen; else screen = await Task.Run(() => resolution.GetViewModel(_container)); // If resolution has a child, ensure the screen can host it - if (resolution.Child != null && screen is not IRoutableScreen) - throw new ArtemisRoutingException($"Route resolved with a child but view model of type {resolution.ViewModel} is does mot implement {nameof(IRoutableScreen)}."); + if (resolution.Child != null && screen is not IRoutableHostScreen) + throw new ArtemisRoutingException($"Route resolved with a child but view model of type {resolution.ViewModel} is does mot implement {nameof(IRoutableHostScreen)}."); // Only change the screen if it wasn't reused if (!ReferenceEquals(host.InternalScreen, screen)) @@ -87,27 +87,24 @@ internal class Navigation if (CancelIfRequested(args, "ChangeScreen", screen)) return; - - // If the screen implements some form of Navigable, activate it + + // Navigate on the screen args.SegmentParameters = resolution.Parameters ?? Array.Empty(); - if (screen is IRoutableScreen routableScreen) + try { - try - { - await routableScreen.InternalOnNavigating(args, _cts.Token); - } - catch (Exception e) - { - Cancel(); - if (e is not TaskCanceledException) - _logger.Error(e, "Failed to navigate to {Path}", resolution.Path); - } - - if (CancelIfRequested(args, "OnNavigating", screen)) - return; + await screen.InternalOnNavigating(args, _cts.Token); + } + catch (Exception e) + { + Cancel(); + if (e is not TaskCanceledException) + _logger.Error(e, "Failed to navigate to {Path}", resolution.Path); } - if (screen is IRoutableScreen childScreen) + if (CancelIfRequested(args, "OnNavigating", screen)) + return; + + if (screen is IRoutableHostScreen childScreen) { // Navigate the child too if (resolution.Child != null) diff --git a/src/Artemis.UI.Shared/Routing/Router/Router.cs b/src/Artemis.UI.Shared/Routing/Router/Router.cs index 028d7be02..84e44c4ac 100644 --- a/src/Artemis.UI.Shared/Routing/Router/Router.cs +++ b/src/Artemis.UI.Shared/Routing/Router/Router.cs @@ -14,15 +14,15 @@ internal class Router : CorePropertyChanged, IRouter, IDisposable private readonly Stack _backStack = new(); private readonly BehaviorSubject _currentRouteSubject; private readonly Stack _forwardStack = new(); - private readonly Func _getNavigation; + private readonly Func _getNavigation; private readonly ILogger _logger; private readonly IMainWindowService _mainWindowService; private Navigation? _currentNavigation; - private IRoutableScreen? _root; + private IRoutableHostScreen? _root; private string? _previousWindowRoute; - public Router(ILogger logger, IMainWindowService mainWindowService, Func getNavigation) + public Router(ILogger logger, IMainWindowService mainWindowService, Func getNavigation) { _logger = logger; _mainWindowService = mainWindowService; @@ -45,21 +45,17 @@ internal class Router : CorePropertyChanged, IRouter, IDisposable return RouteResolution.AsFailure(path); } - private async Task RequestClose(object screen, NavigationArguments args) + private async Task RequestClose(IRoutableScreen screen, NavigationArguments args) { - if (screen is not IRoutableScreen routableScreen) - return true; - - await routableScreen.InternalOnClosing(args); - if (args.Cancelled) - { - _logger.Debug("Navigation to {Path} cancelled during RequestClose by {Screen}", args.Path, screen.GetType().Name); + // Drill down to child screens first + if (screen is IRoutableHostScreen hostScreen && hostScreen.InternalScreen != null && !await RequestClose(hostScreen.InternalScreen, args)) return false; - } - if (routableScreen.InternalScreen == null) + await screen.InternalOnClosing(args); + if (!args.Cancelled) return true; - return await RequestClose(routableScreen.InternalScreen, args); + _logger.Debug("Navigation to {Path} cancelled during RequestClose by {Screen}", args.Path, screen.GetType().Name); + return false; } private bool PathEquals(string path, bool allowPartialMatch) @@ -161,13 +157,13 @@ internal class Router : CorePropertyChanged, IRouter, IDisposable } /// - public void SetRoot(RoutableScreen root) where TScreen : class + public void SetRoot(RoutableHostScreen root) where TScreen : RoutableScreen { _root = root; } /// - public void SetRoot(RoutableScreen root) where TScreen : class where TParam : new() + public void SetRoot(RoutableHostScreen root) where TScreen : RoutableScreen where TParam : new() { _root = root; } diff --git a/src/Artemis.UI/Routing/Routes.cs b/src/Artemis.UI/Routing/Routes.cs index da329999b..128209f99 100644 --- a/src/Artemis.UI/Routing/Routes.cs +++ b/src/Artemis.UI/Routing/Routes.cs @@ -35,8 +35,9 @@ public static class Routes { Children = new List() { - new RouteRegistration("installed"), - new RouteRegistration("submissions"), + new RouteRegistration("installed"), + new RouteRegistration("submissions"), + new RouteRegistration("submissions/{entryId:guid}"), } } } diff --git a/src/Artemis.UI/Screens/Home/HomeViewModel.cs b/src/Artemis.UI/Screens/Home/HomeViewModel.cs index bd4266895..3460ea13b 100644 --- a/src/Artemis.UI/Screens/Home/HomeViewModel.cs +++ b/src/Artemis.UI/Screens/Home/HomeViewModel.cs @@ -1,12 +1,13 @@ using Artemis.Core.Services; using Artemis.UI.Screens.StartupWizard; using Artemis.UI.Shared; +using Artemis.UI.Shared.Routing; using Artemis.UI.Shared.Services; using Avalonia.Threading; namespace Artemis.UI.Screens.Home; -public class HomeViewModel : ViewModelBase, IMainScreenViewModel +public class HomeViewModel : RoutableScreen, IMainScreenViewModel { public HomeViewModel(ISettingsService settingsService, IWindowService windowService) { diff --git a/src/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs index 89781e125..b3da24ce2 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs @@ -17,14 +17,13 @@ using Artemis.UI.Shared; using Artemis.UI.Shared.Routing; using Artemis.UI.Shared.Services.MainWindow; using Artemis.UI.Shared.Services.ProfileEditor; -using Avalonia.Threading; using DynamicData; using DynamicData.Binding; using ReactiveUI; namespace Artemis.UI.Screens.ProfileEditor; -public class ProfileEditorViewModel : RoutableScreen, IMainScreenViewModel +public class ProfileEditorViewModel : RoutableScreen, IMainScreenViewModel { private readonly IProfileEditorService _profileEditorService; private readonly IProfileService _profileService; diff --git a/src/Artemis.UI/Screens/Root/BlankViewModel.cs b/src/Artemis.UI/Screens/Root/BlankViewModel.cs index fe445a6ee..3cfbb2c3b 100644 --- a/src/Artemis.UI/Screens/Root/BlankViewModel.cs +++ b/src/Artemis.UI/Screens/Root/BlankViewModel.cs @@ -1,8 +1,9 @@ using Artemis.UI.Shared; +using Artemis.UI.Shared.Routing; namespace Artemis.UI.Screens.Root; -public class BlankViewModel : ViewModelBase, IMainScreenViewModel +public class BlankViewModel : RoutableScreen, IMainScreenViewModel { /// public ViewModelBase? TitleBarViewModel => null; diff --git a/src/Artemis.UI/Screens/Root/RootView.axaml.cs b/src/Artemis.UI/Screens/Root/RootView.axaml.cs index 23d822d48..8267c9c3e 100644 --- a/src/Artemis.UI/Screens/Root/RootView.axaml.cs +++ b/src/Artemis.UI/Screens/Root/RootView.axaml.cs @@ -1,5 +1,6 @@ using System; using System.Reactive.Disposables; +using Artemis.UI.Shared.Routing; using Avalonia.ReactiveUI; using Avalonia.Threading; using ReactiveUI; @@ -14,7 +15,7 @@ public partial class RootView : ReactiveUserControl this.WhenActivated(d => ViewModel.WhenAnyValue(vm => vm.Screen).Subscribe(Navigate).DisposeWith(d)); } - private void Navigate(IMainScreenViewModel viewModel) + private void Navigate(RoutableScreen viewModel) { try { diff --git a/src/Artemis.UI/Screens/Root/RootViewModel.cs b/src/Artemis.UI/Screens/Root/RootViewModel.cs index 9b2a46ddf..d057893e5 100644 --- a/src/Artemis.UI/Screens/Root/RootViewModel.cs +++ b/src/Artemis.UI/Screens/Root/RootViewModel.cs @@ -18,7 +18,7 @@ using ReactiveUI; namespace Artemis.UI.Screens.Root; -public class RootViewModel : RoutableScreen, IMainWindowProvider +public class RootViewModel : RoutableHostScreen, IMainWindowProvider { private readonly ICoreService _coreService; private readonly IDebugService _debugService; @@ -100,12 +100,10 @@ public class RootViewModel : RoutableScreen, IMainWindowPr _router.GoForward(); } - private void UpdateTitleBarViewModel(IMainScreenViewModel? viewModel) + private void UpdateTitleBarViewModel(RoutableScreen? viewModel) { - if (viewModel?.TitleBarViewModel != null) - TitleBarViewModel = viewModel.TitleBarViewModel; - else - TitleBarViewModel = _defaultTitleBarViewModel; + IMainScreenViewModel? mainScreenViewModel = viewModel as IMainScreenViewModel; + TitleBarViewModel = mainScreenViewModel?.TitleBarViewModel ?? _defaultTitleBarViewModel; } private void CurrentMainWindowOnClosing(object? sender, EventArgs e) diff --git a/src/Artemis.UI/Screens/Settings/SettingsViewModel.cs b/src/Artemis.UI/Screens/Settings/SettingsViewModel.cs index 561c4e3d6..63b97b1ab 100644 --- a/src/Artemis.UI/Screens/Settings/SettingsViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/SettingsViewModel.cs @@ -11,7 +11,7 @@ using ReactiveUI; namespace Artemis.UI.Screens.Settings; -public class SettingsViewModel : RoutableScreen, IMainScreenViewModel +public class SettingsViewModel : RoutableHostScreen, IMainScreenViewModel { private readonly IRouter _router; private RouteViewModel? _selectedTab; diff --git a/src/Artemis.UI/Screens/Settings/Tabs/AboutTabViewModel.cs b/src/Artemis.UI/Screens/Settings/Tabs/AboutTabViewModel.cs index 883372aec..984187e6f 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/AboutTabViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Tabs/AboutTabViewModel.cs @@ -1,9 +1,9 @@ using Artemis.Core; -using Artemis.UI.Shared; +using Artemis.UI.Shared.Routing; namespace Artemis.UI.Screens.Settings; -public class AboutTabViewModel : ActivatableViewModelBase +public class AboutTabViewModel : RoutableScreen { public AboutTabViewModel() { diff --git a/src/Artemis.UI/Screens/Settings/Tabs/DevicesTabViewModel.cs b/src/Artemis.UI/Screens/Settings/Tabs/DevicesTabViewModel.cs index 620da173e..e6c1366c1 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/DevicesTabViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Tabs/DevicesTabViewModel.cs @@ -8,7 +8,7 @@ using Artemis.Core; using Artemis.Core.Services; using Artemis.UI.DryIoc.Factories; using Artemis.UI.Screens.Device; -using Artemis.UI.Shared; +using Artemis.UI.Shared.Routing; using Artemis.UI.Shared.Services; using Avalonia.Threading; using DynamicData; @@ -16,7 +16,7 @@ using ReactiveUI; namespace Artemis.UI.Screens.Settings; -public class DevicesTabViewModel : ActivatableViewModelBase +public class DevicesTabViewModel : RoutableScreen { private readonly IDeviceVmFactory _deviceVmFactory; private readonly IRgbService _rgbService; diff --git a/src/Artemis.UI/Screens/Settings/Tabs/GeneralTabViewModel.cs b/src/Artemis.UI/Screens/Settings/Tabs/GeneralTabViewModel.cs index 110c948e8..74adce108 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/GeneralTabViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Tabs/GeneralTabViewModel.cs @@ -13,8 +13,8 @@ using Artemis.Core.Services; using Artemis.UI.Screens.StartupWizard; using Artemis.UI.Services.Interfaces; using Artemis.UI.Services.Updating; -using Artemis.UI.Shared; using Artemis.UI.Shared.Providers; +using Artemis.UI.Shared.Routing; using Artemis.UI.Shared.Services; using Artemis.UI.Shared.Services.Builders; using Avalonia.Threading; @@ -26,7 +26,7 @@ using Serilog.Events; namespace Artemis.UI.Screens.Settings; -public class GeneralTabViewModel : ActivatableViewModelBase +public class GeneralTabViewModel : RoutableScreen { private readonly IAutoRunProvider? _autoRunProvider; private readonly IDebugService _debugService; diff --git a/src/Artemis.UI/Screens/Settings/Tabs/PluginsTabViewModel.cs b/src/Artemis.UI/Screens/Settings/Tabs/PluginsTabViewModel.cs index 217ca1383..6113a20b4 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/PluginsTabViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Tabs/PluginsTabViewModel.cs @@ -9,18 +9,17 @@ using Artemis.Core; using Artemis.Core.Services; using Artemis.UI.DryIoc.Factories; using Artemis.UI.Screens.Plugins; -using Artemis.UI.Shared; +using Artemis.UI.Shared.Routing; using Artemis.UI.Shared.Services; using Artemis.UI.Shared.Services.Builders; using Avalonia.ReactiveUI; -using Avalonia.Threading; using DynamicData; using DynamicData.Binding; using ReactiveUI; namespace Artemis.UI.Screens.Settings; -public class PluginsTabViewModel : ActivatableViewModelBase +public class PluginsTabViewModel : RoutableScreen { private readonly INotificationService _notificationService; private readonly IPluginManagementService _pluginManagementService; diff --git a/src/Artemis.UI/Screens/Settings/Tabs/ReleasesTabViewModel.cs b/src/Artemis.UI/Screens/Settings/Tabs/ReleasesTabViewModel.cs index fe6a1a532..d316b62a8 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/ReleasesTabViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Tabs/ReleasesTabViewModel.cs @@ -22,7 +22,7 @@ using StrawberryShake; namespace Artemis.UI.Screens.Settings; -public class ReleasesTabViewModel : RoutableScreen +public class ReleasesTabViewModel : RoutableHostScreen { private readonly ILogger _logger; private readonly IUpdateService _updateService; diff --git a/src/Artemis.UI/Screens/Settings/Updating/ReleaseDetailsViewModel.cs b/src/Artemis.UI/Screens/Settings/Updating/ReleaseDetailsViewModel.cs index 2ea6be462..2d9a1a413 100644 --- a/src/Artemis.UI/Screens/Settings/Updating/ReleaseDetailsViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Updating/ReleaseDetailsViewModel.cs @@ -18,7 +18,7 @@ using StrawberryShake; namespace Artemis.UI.Screens.Settings.Updating; -public class ReleaseDetailsViewModel : RoutableScreen +public class ReleaseDetailsViewModel : RoutableScreen { private readonly ObservableAsPropertyHelper _fileSize; private readonly ILogger _logger; diff --git a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorViewModel.cs b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorViewModel.cs index a6e28ea39..fadaaaf0e 100644 --- a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorViewModel.cs +++ b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorViewModel.cs @@ -10,6 +10,7 @@ using Artemis.Core.Services; using Artemis.UI.DryIoc.Factories; using Artemis.UI.Extensions; using Artemis.UI.Shared; +using Artemis.UI.Shared.Routing; using Artemis.UI.Shared.Services; using Avalonia; using ReactiveUI; @@ -17,7 +18,7 @@ using SkiaSharp; namespace Artemis.UI.Screens.SurfaceEditor; -public class SurfaceEditorViewModel : ActivatableViewModelBase, IMainScreenViewModel +public class SurfaceEditorViewModel : RoutableScreen, IMainScreenViewModel { private readonly IDeviceService _deviceService; private readonly IDeviceVmFactory _deviceVmFactory; diff --git a/src/Artemis.UI/Screens/Workshop/Entries/EntryListBaseViewModel.cs b/src/Artemis.UI/Screens/Workshop/Entries/EntryListBaseViewModel.cs index 2c51081e3..970b966fb 100644 --- a/src/Artemis.UI/Screens/Workshop/Entries/EntryListBaseViewModel.cs +++ b/src/Artemis.UI/Screens/Workshop/Entries/EntryListBaseViewModel.cs @@ -18,7 +18,7 @@ using StrawberryShake; namespace Artemis.UI.Screens.Workshop.Entries; -public abstract class EntryListBaseViewModel : RoutableScreen, IWorkshopViewModel +public abstract class EntryListBaseViewModel : RoutableScreen { private readonly INotificationService _notificationService; private readonly IWorkshopClient _workshopClient; diff --git a/src/Artemis.UI/Screens/Workshop/Home/WorkshopHomeViewModel.cs b/src/Artemis.UI/Screens/Workshop/Home/WorkshopHomeViewModel.cs index 2dad32aa0..de2e8f54d 100644 --- a/src/Artemis.UI/Screens/Workshop/Home/WorkshopHomeViewModel.cs +++ b/src/Artemis.UI/Screens/Workshop/Home/WorkshopHomeViewModel.cs @@ -14,7 +14,7 @@ using ReactiveUI; namespace Artemis.UI.Screens.Workshop.Home; -public class WorkshopHomeViewModel : ActivatableViewModelBase, IWorkshopViewModel +public class WorkshopHomeViewModel : RoutableScreen { private readonly IWindowService _windowService; private readonly IWorkshopService _workshopService; diff --git a/src/Artemis.UI/Screens/Workshop/Home/WorkshopOfflineViewModel.cs b/src/Artemis.UI/Screens/Workshop/Home/WorkshopOfflineViewModel.cs index ee46c079b..e9370d1d5 100644 --- a/src/Artemis.UI/Screens/Workshop/Home/WorkshopOfflineViewModel.cs +++ b/src/Artemis.UI/Screens/Workshop/Home/WorkshopOfflineViewModel.cs @@ -10,7 +10,7 @@ using ReactiveUI; namespace Artemis.UI.Screens.Workshop.Home; -public class WorkshopOfflineViewModel : RoutableScreen, IWorkshopViewModel +public class WorkshopOfflineViewModel : RoutableScreen { private readonly IRouter _router; private readonly IWorkshopService _workshopService; diff --git a/src/Artemis.UI/Screens/Workshop/Layout/LayoutDetailsViewModel.cs b/src/Artemis.UI/Screens/Workshop/Layout/LayoutDetailsViewModel.cs index dcfb608bf..3bd224a6a 100644 --- a/src/Artemis.UI/Screens/Workshop/Layout/LayoutDetailsViewModel.cs +++ b/src/Artemis.UI/Screens/Workshop/Layout/LayoutDetailsViewModel.cs @@ -9,7 +9,7 @@ using StrawberryShake; namespace Artemis.UI.Screens.Workshop.Layout; -public class LayoutDetailsViewModel : RoutableScreen, IWorkshopViewModel +public class LayoutDetailsViewModel : RoutableScreen { private readonly IWorkshopClient _client; private IGetEntryById_Entry? _entry; diff --git a/src/Artemis.UI/Screens/Workshop/Library/Tabs/LibraryInstalledView.axaml b/src/Artemis.UI/Screens/Workshop/Library/Tabs/InstalledTabView.axaml similarity index 82% rename from src/Artemis.UI/Screens/Workshop/Library/Tabs/LibraryInstalledView.axaml rename to src/Artemis.UI/Screens/Workshop/Library/Tabs/InstalledTabView.axaml index 208718542..df334299a 100644 --- a/src/Artemis.UI/Screens/Workshop/Library/Tabs/LibraryInstalledView.axaml +++ b/src/Artemis.UI/Screens/Workshop/Library/Tabs/InstalledTabView.axaml @@ -3,6 +3,6 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" - x:Class="Artemis.UI.Screens.Workshop.Library.Tabs.LibraryInstalledView"> + x:Class="Artemis.UI.Screens.Workshop.Library.Tabs.InstalledTabView"> Installed entries management here 🫡 diff --git a/src/Artemis.UI/Screens/Workshop/Library/Tabs/LibraryInstalledView.axaml.cs b/src/Artemis.UI/Screens/Workshop/Library/Tabs/InstalledTabView.axaml.cs similarity index 61% rename from src/Artemis.UI/Screens/Workshop/Library/Tabs/LibraryInstalledView.axaml.cs rename to src/Artemis.UI/Screens/Workshop/Library/Tabs/InstalledTabView.axaml.cs index b98518ae5..8a9a8b444 100644 --- a/src/Artemis.UI/Screens/Workshop/Library/Tabs/LibraryInstalledView.axaml.cs +++ b/src/Artemis.UI/Screens/Workshop/Library/Tabs/InstalledTabView.axaml.cs @@ -5,9 +5,9 @@ using Avalonia.ReactiveUI; namespace Artemis.UI.Screens.Workshop.Library.Tabs; -public partial class LibraryInstalledView : ReactiveUserControl +public partial class InstalledTabView : ReactiveUserControl { - public LibraryInstalledView() + public InstalledTabView() { InitializeComponent(); } diff --git a/src/Artemis.UI/Screens/Workshop/Library/Tabs/LibraryInstalledViewModel.cs b/src/Artemis.UI/Screens/Workshop/Library/Tabs/InstalledTabViewModel.cs similarity index 51% rename from src/Artemis.UI/Screens/Workshop/Library/Tabs/LibraryInstalledViewModel.cs rename to src/Artemis.UI/Screens/Workshop/Library/Tabs/InstalledTabViewModel.cs index b615c18b1..3bfdf406f 100644 --- a/src/Artemis.UI/Screens/Workshop/Library/Tabs/LibraryInstalledViewModel.cs +++ b/src/Artemis.UI/Screens/Workshop/Library/Tabs/InstalledTabViewModel.cs @@ -1,8 +1,9 @@ using Artemis.UI.Shared; +using Artemis.UI.Shared.Routing; namespace Artemis.UI.Screens.Workshop.Library.Tabs; -public class LibraryInstalledViewModel : ActivatableViewModelBase +public class InstalledTabViewModel : RoutableScreen { } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsDetailView.axaml b/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsDetailView.axaml new file mode 100644 index 000000000..1a4585317 --- /dev/null +++ b/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsDetailView.axaml @@ -0,0 +1,8 @@ + + Welcome to Avalonia! + diff --git a/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsDetailView.axaml.cs b/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsDetailView.axaml.cs new file mode 100644 index 000000000..1af01b4d4 --- /dev/null +++ b/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsDetailView.axaml.cs @@ -0,0 +1,14 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; +using Avalonia.ReactiveUI; + +namespace Artemis.UI.Screens.Workshop.Library.Tabs; + +public partial class SubmissionsDetailView : ReactiveUserControl +{ + public SubmissionsDetailView() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsDetailViewModel.cs b/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsDetailViewModel.cs new file mode 100644 index 000000000..b81f5a368 --- /dev/null +++ b/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsDetailViewModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Artemis.UI.Screens.Workshop.Parameters; +using Artemis.UI.Shared.Routing; + +namespace Artemis.UI.Screens.Workshop.Library.Tabs; + +public class SubmissionsDetailViewModel : RoutableScreen +{ + public override Task OnNavigating(WorkshopDetailParameters parameters, NavigationArguments args, CancellationToken cancellationToken) + { + Console.WriteLine(parameters.EntryId); + return Task.CompletedTask; + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Workshop/Library/Tabs/LibrarySubmissionsView.axaml b/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsTabView.axaml similarity index 97% rename from src/Artemis.UI/Screens/Workshop/Library/Tabs/LibrarySubmissionsView.axaml rename to src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsTabView.axaml index b57eee7d1..9fb0f3055 100644 --- a/src/Artemis.UI/Screens/Workshop/Library/Tabs/LibrarySubmissionsView.axaml +++ b/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsTabView.axaml @@ -8,8 +8,8 @@ xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia" xmlns:converters="clr-namespace:Artemis.UI.Converters" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="650" - x:Class="Artemis.UI.Screens.Workshop.Library.Tabs.LibrarySubmissionsView" - x:DataType="tabs:LibrarySubmissionsViewModel"> + x:Class="Artemis.UI.Screens.Workshop.Library.Tabs.SubmissionsTabView" + x:DataType="tabs:SubmissionsTabViewModel"> @@ -54,7 +54,7 @@ Margin="0 0 0 5" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" - Command="{Binding $parent[tabs:LibrarySubmissionsView].DataContext.NavigateToEntry}" + Command="{Binding $parent[tabs:SubmissionsTabView].DataContext.NavigateToEntry}" CommandParameter="{CompiledBinding}"> diff --git a/src/Artemis.UI/Screens/Workshop/Library/Tabs/LibrarySubmissionsView.axaml.cs b/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsTabView.axaml.cs similarity index 60% rename from src/Artemis.UI/Screens/Workshop/Library/Tabs/LibrarySubmissionsView.axaml.cs rename to src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsTabView.axaml.cs index baf08341b..cedd6574c 100644 --- a/src/Artemis.UI/Screens/Workshop/Library/Tabs/LibrarySubmissionsView.axaml.cs +++ b/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsTabView.axaml.cs @@ -5,9 +5,9 @@ using Avalonia.ReactiveUI; namespace Artemis.UI.Screens.Workshop.Library.Tabs; -public partial class LibrarySubmissionsView : ReactiveUserControl +public partial class SubmissionsTabView : ReactiveUserControl { - public LibrarySubmissionsView() + public SubmissionsTabView() { InitializeComponent(); } diff --git a/src/Artemis.UI/Screens/Workshop/Library/Tabs/LibrarySubmissionsViewModel.cs b/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsTabViewModel.cs similarity index 92% rename from src/Artemis.UI/Screens/Workshop/Library/Tabs/LibrarySubmissionsViewModel.cs rename to src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsTabViewModel.cs index a43448109..719f56353 100644 --- a/src/Artemis.UI/Screens/Workshop/Library/Tabs/LibrarySubmissionsViewModel.cs +++ b/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsTabViewModel.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using Artemis.UI.Extensions; using Artemis.UI.Screens.Workshop.CurrentUser; using Artemis.UI.Screens.Workshop.SubmissionWizard; -using Artemis.UI.Shared; using Artemis.UI.Shared.Routing; using Artemis.UI.Shared.Services; using Artemis.WebClient.Workshop; @@ -17,7 +16,7 @@ using StrawberryShake; namespace Artemis.UI.Screens.Workshop.Library.Tabs; -public class LibrarySubmissionsViewModel : ActivatableViewModelBase, IWorkshopViewModel +public class SubmissionsTabViewModel : RoutableScreen { private readonly IWorkshopClient _client; private readonly SourceCache _entries; @@ -25,7 +24,7 @@ public class LibrarySubmissionsViewModel : ActivatableViewModelBase, IWorkshopVi private bool _isLoading = true; private bool _workshopReachable; - public LibrarySubmissionsViewModel(IWorkshopClient client, IAuthenticationService authenticationService, IWindowService windowService, IWorkshopService workshopService, IRouter router) + public SubmissionsTabViewModel(IWorkshopClient client, IAuthenticationService authenticationService, IWindowService windowService, IWorkshopService workshopService, IRouter router) { _client = client; _windowService = windowService; diff --git a/src/Artemis.UI/Screens/Workshop/Library/WorkshopLibraryViewModel.cs b/src/Artemis.UI/Screens/Workshop/Library/WorkshopLibraryViewModel.cs index 707d22cde..93588e198 100644 --- a/src/Artemis.UI/Screens/Workshop/Library/WorkshopLibraryViewModel.cs +++ b/src/Artemis.UI/Screens/Workshop/Library/WorkshopLibraryViewModel.cs @@ -12,7 +12,7 @@ using System; namespace Artemis.UI.Screens.Workshop.Library; -public class WorkshopLibraryViewModel : RoutableScreen, IWorkshopViewModel +public class WorkshopLibraryViewModel : RoutableHostScreen { private RouteViewModel? _selectedTab; diff --git a/src/Artemis.UI/Screens/Workshop/Profile/ProfileDetailsViewModel.cs b/src/Artemis.UI/Screens/Workshop/Profile/ProfileDetailsViewModel.cs index 83e5280f3..614ca84e7 100644 --- a/src/Artemis.UI/Screens/Workshop/Profile/ProfileDetailsViewModel.cs +++ b/src/Artemis.UI/Screens/Workshop/Profile/ProfileDetailsViewModel.cs @@ -18,7 +18,7 @@ using StrawberryShake; namespace Artemis.UI.Screens.Workshop.Profile; -public class ProfileDetailsViewModel : RoutableScreen, IWorkshopViewModel +public class ProfileDetailsViewModel : RoutableScreen { private readonly IWorkshopClient _client; private readonly ProfileEntryDownloadHandler _downloadHandler; diff --git a/src/Artemis.UI/Screens/Workshop/Search/SearchViewModel.cs b/src/Artemis.UI/Screens/Workshop/Search/SearchViewModel.cs index 8ae11ad48..f8da8558c 100644 --- a/src/Artemis.UI/Screens/Workshop/Search/SearchViewModel.cs +++ b/src/Artemis.UI/Screens/Workshop/Search/SearchViewModel.cs @@ -19,7 +19,6 @@ public class SearchViewModel : ViewModelBase private readonly ILogger _logger; private readonly IRouter _router; private readonly IWorkshopClient _workshopClient; - private EntryType? _entryType; private bool _isLoading; private SearchResultViewModel? _selectedEntry; @@ -44,12 +43,6 @@ public class SearchViewModel : ViewModelBase set => RaiseAndSetIfChanged(ref _selectedEntry, value); } - public EntryType? EntryType - { - get => _entryType; - set => RaiseAndSetIfChanged(ref _entryType, value); - } - public bool IsLoading { get => _isLoading; @@ -76,7 +69,7 @@ public class SearchViewModel : ViewModelBase return new List(); IsLoading = true; - IOperationResult results = await _workshopClient.SearchEntries.ExecuteAsync(input, EntryType, cancellationToken); + IOperationResult results = await _workshopClient.SearchEntries.ExecuteAsync(input, null, cancellationToken); return results.Data?.SearchEntries.Select(e => new SearchResultViewModel(e) as object) ?? new List(); } catch (Exception e) diff --git a/src/Artemis.UI/Screens/Workshop/WorkshopViewModel.cs b/src/Artemis.UI/Screens/Workshop/WorkshopViewModel.cs index f6b53a013..aa6fc9eb2 100644 --- a/src/Artemis.UI/Screens/Workshop/WorkshopViewModel.cs +++ b/src/Artemis.UI/Screens/Workshop/WorkshopViewModel.cs @@ -1,38 +1,18 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using Artemis.UI.Screens.Workshop.Home; +using Artemis.UI.Screens.Workshop.Home; using Artemis.UI.Screens.Workshop.Search; using Artemis.UI.Shared; using Artemis.UI.Shared.Routing; -using Artemis.WebClient.Workshop; namespace Artemis.UI.Screens.Workshop; -public class WorkshopViewModel : RoutableScreen, IMainScreenViewModel +public class WorkshopViewModel : RoutableHostScreen, IMainScreenViewModel { - private readonly SearchViewModel _searchViewModel; - public WorkshopViewModel(SearchViewModel searchViewModel, WorkshopHomeViewModel homeViewModel) { - _searchViewModel = searchViewModel; - TitleBarViewModel = searchViewModel; HomeViewModel = homeViewModel; } public ViewModelBase TitleBarViewModel { get; } public WorkshopHomeViewModel HomeViewModel { get; } - - /// - public override Task OnNavigating(NavigationArguments args, CancellationToken cancellationToken) - { - _searchViewModel.EntryType = Screen?.EntryType; - return Task.CompletedTask; - } -} - -public interface IWorkshopViewModel -{ - public EntryType? EntryType { get; } } \ No newline at end of file