UI - Added routing (#802)

ColorGradient - Fixed GetColor returning the first stop if position was after the last stop
This commit is contained in:
RobertBeekman authored and GitHub committed 2023-07-02 22:15:38 +02:00
1 parent 79309dcee7
commit 962b13c6ed
77 files changed
+2034 -854

No files matched your search

@@ -18,6 +18,12 @@
<StackPanel Margin="12" Spacing="5">
<Border Classes="card">
<StackPanel Spacing="5">
<TextBlock Classes="h4">Navigation test</TextBlock>
<TextBox Text="{CompiledBinding NavigationPath}" Watermark="Enter a navigation path"></TextBox>
<Button Command="{CompiledBinding TestNavigation}">
Navigate
</Button>
<TextBlock Classes="h4">Notification tests</TextBlock>
<Button Command="{CompiledBinding ShowNotification}" CommandParameter="{x:Static builders:NotificationSeverity.Informational}">
Notification test (default)
@@ -1,6 +1,8 @@
using System.Reactive;
using System.Reactive.Linq;
using Artemis.Core;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Routing;
using Artemis.UI.Shared.Services;
using Artemis.UI.Shared.Services.Builders;
using Avalonia.Input;
@@ -9,7 +11,7 @@ using SkiaSharp;
namespace Artemis.UI.Screens.Workshop;
public class WorkshopViewModel : MainScreenViewModel
public class WorkshopViewModel : ActivatableViewModelBase, IMainScreenViewModel
{
private readonly ObservableAsPropertyHelper<Cursor> _cursor;
private readonly INotificationService _notificationService;
@@ -26,17 +28,21 @@ public class WorkshopViewModel : MainScreenViewModel
private StandardCursorType _selectedCursor;
private double _testValue;
private string? _navigationPath;
public WorkshopViewModel(IScreen hostScreen, INotificationService notificationService) : base(hostScreen, "workshop")
public WorkshopViewModel(INotificationService notificationService, IRouter router)
{
_notificationService = notificationService;
_cursor = this.WhenAnyValue(vm => vm.SelectedCursor).Select(c => new Cursor(c)).ToProperty(this, vm => vm.Cursor);
DisplayName = "Workshop";
ShowNotification = ReactiveCommand.Create<NotificationSeverity>(ExecuteShowNotification);
TestNavigation = ReactiveCommand.CreateFromTask(async () => await router.Navigate(NavigationPath!), this.WhenAnyValue(vm => vm.NavigationPath).Select(p => !string.IsNullOrWhiteSpace(p)));
}
public ViewModelBase? TitleBarViewModel => null;
public ReactiveCommand<NotificationSeverity, Unit> ShowNotification { get; set; }
public ReactiveCommand<Unit, Unit> TestNavigation { get; set; }
public StandardCursorType SelectedCursor
{
@@ -46,6 +52,12 @@ public class WorkshopViewModel : MainScreenViewModel
public Cursor Cursor => _cursor.Value;
public string? NavigationPath
{
get => _navigationPath;
set => RaiseAndSetIfChanged(ref _navigationPath, value);
}
public ColorGradient ColorGradient
{
get => _colorGradient;