UI - Use PropertyChanged.SourceGenerator in workshop

This commit is contained in:
Robert committed 2023-10-20 20:00:07 +02:00
1 parent 8f1509fc28
commit d656c6960d
28 files changed
+119 -411

No files matched your search

@@ -3,14 +3,15 @@ using Artemis.UI.Shared;
using Artemis.UI.Shared.Services;
using Artemis.WebClient.Workshop;
using DryIoc;
using PropertyChanged.SourceGenerator;
namespace Artemis.UI.Screens.Workshop.SubmissionWizard;
public class ReleaseWizardViewModel : ActivatableViewModelBase, IWorkshopWizardViewModel
public partial class ReleaseWizardViewModel : ActivatableViewModelBase, IWorkshopWizardViewModel
{
private readonly SubmissionWizardState _state;
private SubmissionViewModel? _screen;
private bool _shouldClose;
[Notify] private bool _shouldClose;
public ReleaseWizardViewModel(IContainer container, IWindowService windowService, CurrentUserViewModel currentUserViewModel, IGetSubmittedEntryById_Entry entry)
{
@@ -42,10 +43,4 @@ public class ReleaseWizardViewModel : ActivatableViewModelBase, IWorkshopWizardV
RaiseAndSetIfChanged(ref _screen, value);
}
}
public bool ShouldClose
{
get => _shouldClose;
set => RaiseAndSetIfChanged(ref _shouldClose, value);
}
}
@@ -1,12 +1,13 @@
using System.Reactive.Linq;
using Artemis.WebClient.Workshop;
using PropertyChanged.SourceGenerator;
using ReactiveUI;
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
public class EntryTypeStepViewModel : SubmissionViewModel
public partial class EntryTypeStepViewModel : SubmissionViewModel
{
private EntryType? _selectedEntryType;
[Notify] private EntryType? _selectedEntryType;
/// <inheritdoc />
public EntryTypeStepViewModel()
@@ -21,12 +22,6 @@ public class EntryTypeStepViewModel : SubmissionViewModel
public bool ShowLayouts => false;
#endif
public EntryType? SelectedEntryType
{
get => _selectedEntryType;
set => RaiseAndSetIfChanged(ref _selectedEntryType, value);
}
private void ExecuteContinue()
{
if (SelectedEntryType == null)
@@ -6,16 +6,17 @@ using Artemis.Core.Services;
using Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Services;
using PropertyChanged.SourceGenerator;
using ReactiveUI;
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Profile;
public class ProfileAdaptionHintsLayerViewModel : ViewModelBase
public partial class ProfileAdaptionHintsLayerViewModel : ViewModelBase
{
private readonly ObservableAsPropertyHelper<string> _adaptionHintText;
private readonly IProfileService _profileService;
private readonly IWindowService _windowService;
private int _adaptionHintCount;
[Notify(Setter.Private)] private int _adaptionHintCount;
public ProfileAdaptionHintsLayerViewModel(Layer layer, IWindowService windowService, IProfileService profileService)
{
@@ -29,15 +30,7 @@ public class ProfileAdaptionHintsLayerViewModel : ViewModelBase
}
public Layer Layer { get; }
public ReactiveCommand<Unit, Unit> EditAdaptionHints { get; }
public int AdaptionHintCount
{
get => _adaptionHintCount;
private set => RaiseAndSetIfChanged(ref _adaptionHintCount, value);
}
public string AdaptionHintText => _adaptionHintText.Value;
private async Task ExecuteEditAdaptionHints()
@@ -8,15 +8,16 @@ using Artemis.Core.Services;
using Artemis.UI.Extensions;
using Artemis.UI.Screens.Workshop.Profile;
using Material.Icons;
using PropertyChanged.SourceGenerator;
using ReactiveUI;
using SkiaSharp;
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Profile;
public class ProfileSelectionStepViewModel : SubmissionViewModel
public partial class ProfileSelectionStepViewModel : SubmissionViewModel
{
private readonly IProfileService _profileService;
private ProfileConfiguration? _selectedProfile;
[Notify] private ProfileConfiguration? _selectedProfile;
/// <inheritdoc />
public ProfileSelectionStepViewModel(IProfileService profileService, ProfilePreviewViewModel profilePreviewViewModel)
@@ -45,12 +46,6 @@ public class ProfileSelectionStepViewModel : SubmissionViewModel
public ObservableCollection<ProfileConfiguration> Profiles { get; }
public ProfilePreviewViewModel ProfilePreview { get; }
public ProfileConfiguration? SelectedProfile
{
get => _selectedProfile;
set => RaiseAndSetIfChanged(ref _selectedProfile, value);
}
private void Update(ProfileConfiguration? profileConfiguration)
{
ProfilePreview.ProfileConfiguration = null;
@@ -8,14 +8,15 @@ using Artemis.UI.Screens.Workshop.Entries;
using Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Profile;
using Artemis.WebClient.Workshop;
using DynamicData;
using PropertyChanged.SourceGenerator;
using ReactiveUI;
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
public class SpecificationsStepViewModel : SubmissionViewModel
public partial class SpecificationsStepViewModel : SubmissionViewModel
{
private readonly Func<EntrySpecificationsViewModel> _getEntrySpecificationsViewModel;
private EntrySpecificationsViewModel? _entrySpecificationsViewModel;
[Notify] private EntrySpecificationsViewModel? _entrySpecificationsViewModel;
public SpecificationsStepViewModel(Func<EntrySpecificationsViewModel> getEntrySpecificationsViewModel)
{
@@ -29,12 +30,6 @@ public class SpecificationsStepViewModel : SubmissionViewModel
});
}
public EntrySpecificationsViewModel? EntrySpecificationsViewModel
{
get => _entrySpecificationsViewModel;
set => RaiseAndSetIfChanged(ref _entrySpecificationsViewModel, value);
}
private void ExecuteGoBack()
{
// Apply what's there so far
@@ -9,15 +9,16 @@ using Artemis.WebClient.Workshop;
using Artemis.WebClient.Workshop.Services;
using Avalonia.Media.Imaging;
using IdentityModel;
using PropertyChanged.SourceGenerator;
using ReactiveUI;
using StrawberryShake;
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
public class SubmitStepViewModel : SubmissionViewModel
public partial class SubmitStepViewModel : SubmissionViewModel
{
private ReadOnlyObservableCollection<CategoryViewModel>? _categories;
private Bitmap? _iconBitmap;
[Notify] private ReadOnlyObservableCollection<CategoryViewModel>? _categories;
[Notify] private Bitmap? _iconBitmap;
/// <inheritdoc />
public SubmitStepViewModel(IAuthenticationService authenticationService, IWorkshopClient workshopClient)
@@ -40,21 +41,9 @@ public class SubmitStepViewModel : SubmissionViewModel
Observable.FromAsync(workshopClient.GetCategories.ExecuteAsync).Subscribe(PopulateCategories).DisposeWith(d);
});
}
public Bitmap? IconBitmap
{
get => _iconBitmap;
set => RaiseAndSetIfChanged(ref _iconBitmap, value);
}
public string? CurrentUser { get; }
public ReadOnlyObservableCollection<CategoryViewModel>? Categories
{
get => _categories;
set => RaiseAndSetIfChanged(ref _categories, value);
}
private void PopulateCategories(IOperationResult<IGetCategoriesResult> result)
{
if (result.Data == null)
@@ -11,13 +11,14 @@ using Artemis.WebClient.Workshop;
using Artemis.WebClient.Workshop.Exceptions;
using Artemis.WebClient.Workshop.Handlers.UploadHandlers;
using Artemis.WebClient.Workshop.Services;
using PropertyChanged.SourceGenerator;
using ReactiveUI;
using Serilog;
using StrawberryShake;
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
public class UploadStepViewModel : SubmissionViewModel
public partial class UploadStepViewModel : SubmissionViewModel
{
private readonly ILogger _logger;
private readonly EntryUploadHandlerFactory _entryUploadHandlerFactory;
@@ -28,11 +29,10 @@ public class UploadStepViewModel : SubmissionViewModel
private readonly IWindowService _windowService;
private readonly IWorkshopClient _workshopClient;
private readonly IWorkshopService _workshopService;
private long? _entryId;
private bool _failed;
private bool _finished;
private bool _succeeded;
[Notify] private bool _failed;
[Notify] private bool _finished;
[Notify] private bool _succeeded;
/// <inheritdoc />
public UploadStepViewModel(ILogger logger,
@@ -66,24 +66,6 @@ public class UploadStepViewModel : SubmissionViewModel
public int ProgressPercentage => _progressPercentage.Value;
public bool ProgressIndeterminate => _progressIndeterminate.Value;
public bool Finished
{
get => _finished;
set => RaiseAndSetIfChanged(ref _finished, value);
}
public bool Succeeded
{
get => _succeeded;
set => RaiseAndSetIfChanged(ref _succeeded, value);
}
public bool Failed
{
get => _failed;
set => RaiseAndSetIfChanged(ref _failed, value);
}
private async Task ExecuteUpload(CancellationToken cancellationToken)
{
// Use the existing entry or create a new one
@@ -1,53 +1,18 @@
using System.Reactive;
using Artemis.UI.Shared;
using PropertyChanged.SourceGenerator;
using ReactiveUI;
namespace Artemis.UI.Screens.Workshop.SubmissionWizard;
public abstract class SubmissionViewModel : ValidatableViewModelBase
public abstract partial class SubmissionViewModel : ValidatableViewModelBase
{
private ReactiveCommand<Unit, Unit>? _continue;
private ReactiveCommand<Unit, Unit>? _goBack;
private string _continueText = "Continue";
private bool _showFinish;
private bool _showGoBack = true;
private bool _showHeader = true;
[Notify] private ReactiveCommand<Unit, Unit>? _continue;
[Notify] private ReactiveCommand<Unit, Unit>? _goBack;
[Notify] private string _continueText = "Continue";
[Notify] private bool _showFinish;
[Notify] private bool _showGoBack = true;
[Notify] private bool _showHeader = true;
public SubmissionWizardState State { get; set; } = null!;
public ReactiveCommand<Unit, Unit>? Continue
{
get => _continue;
set => RaiseAndSetIfChanged(ref _continue, value);
}
public ReactiveCommand<Unit, Unit>? GoBack
{
get => _goBack;
set => RaiseAndSetIfChanged(ref _goBack, value);
}
public bool ShowHeader
{
get => _showHeader;
set => RaiseAndSetIfChanged(ref _showHeader, value);
}
public bool ShowGoBack
{
get => _showGoBack;
set => RaiseAndSetIfChanged(ref _showGoBack, value);
}
public bool ShowFinish
{
get => _showFinish;
set => RaiseAndSetIfChanged(ref _showFinish, value);
}
public string ContinueText
{
get => _continueText;
set => RaiseAndSetIfChanged(ref _continueText, value);
}
}
@@ -3,14 +3,15 @@ using Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Services;
using DryIoc;
using PropertyChanged.SourceGenerator;
namespace Artemis.UI.Screens.Workshop.SubmissionWizard;
public class SubmissionWizardViewModel : ActivatableViewModelBase, IWorkshopWizardViewModel
public partial class SubmissionWizardViewModel : ActivatableViewModelBase, IWorkshopWizardViewModel
{
private readonly SubmissionWizardState _state;
private SubmissionViewModel _screen;
private bool _shouldClose;
[Notify] private bool _shouldClose;
public SubmissionWizardViewModel(IContainer container,
IWindowService windowService,
@@ -38,10 +39,4 @@ public class SubmissionWizardViewModel : ActivatableViewModelBase, IWorkshopWiza
RaiseAndSetIfChanged(ref _screen, value);
}
}
public bool ShouldClose
{
get => _shouldClose;
set => RaiseAndSetIfChanged(ref _shouldClose, value);
}
}