mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Workshop - Did all the things (Markdown stuff)
This commit is contained in:
parent
c132edeb51
commit
a0536b4302
@ -16,7 +16,7 @@ public interface IWindowService : IArtemisSharedUIService
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TViewModel">The type of view model to create</typeparam>
|
/// <typeparam name="TViewModel">The type of view model to create</typeparam>
|
||||||
/// <returns>The created view model</returns>
|
/// <returns>The created view model</returns>
|
||||||
TViewModel ShowWindow<TViewModel>(params object[] parameters);
|
Window ShowWindow<TViewModel>(out TViewModel viewModel, params object[] parameters);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Given a ViewModel, show its corresponding View as a window
|
/// Given a ViewModel, show its corresponding View as a window
|
||||||
|
|||||||
@ -21,14 +21,13 @@ internal class WindowService : IWindowService
|
|||||||
_container = container;
|
_container = container;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T ShowWindow<T>(params object[] parameters)
|
public Window ShowWindow<T>(out T viewModel, params object[] parameters)
|
||||||
{
|
{
|
||||||
T viewModel = _container.Resolve<T>(parameters);
|
viewModel = _container.Resolve<T>(parameters);
|
||||||
if (viewModel == null)
|
if (viewModel == null)
|
||||||
throw new ArtemisSharedUIException($"Failed to show window for VM of type {typeof(T).Name}, could not create instance.");
|
throw new ArtemisSharedUIException($"Failed to show window for VM of type {typeof(T).Name}, could not create instance.");
|
||||||
|
|
||||||
ShowWindow(viewModel);
|
return ShowWindow(viewModel);
|
||||||
return viewModel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Window ShowWindow(object viewModel)
|
public Window ShowWindow(object viewModel)
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AsyncImageLoader.Avalonia" Version="3.2.0" />
|
<PackageReference Include="AsyncImageLoader.Avalonia" Version="3.2.0" />
|
||||||
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
|
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
|
||||||
|
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.0.1" />
|
||||||
<PackageReference Include="Avalonia.Controls.PanAndZoom" Version="11.0.0" />
|
<PackageReference Include="Avalonia.Controls.PanAndZoom" Version="11.0.0" />
|
||||||
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
|
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
|
||||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
@ -28,6 +29,7 @@
|
|||||||
<PackageReference Include="Avalonia.ReactiveUI" Version="$(AvaloniaVersion)" />
|
<PackageReference Include="Avalonia.ReactiveUI" Version="$(AvaloniaVersion)" />
|
||||||
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="$(AvaloniaBehavioursVersion)" />
|
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="$(AvaloniaBehavioursVersion)" />
|
||||||
<PackageReference Include="Avalonia.Skia.Lottie" Version="11.0.0" />
|
<PackageReference Include="Avalonia.Skia.Lottie" Version="11.0.0" />
|
||||||
|
<PackageReference Include="AvaloniaEdit.TextMate" Version="11.0.1" />
|
||||||
<PackageReference Include="DryIoc.dll" Version="5.4.0" />
|
<PackageReference Include="DryIoc.dll" Version="5.4.0" />
|
||||||
<PackageReference Include="DynamicData" Version="7.13.1" />
|
<PackageReference Include="DynamicData" Version="7.13.1" />
|
||||||
<PackageReference Include="FluentAvaloniaUI" Version="$(FluentAvaloniaVersion)" />
|
<PackageReference Include="FluentAvaloniaUI" Version="$(FluentAvaloniaVersion)" />
|
||||||
@ -43,9 +45,25 @@
|
|||||||
<PackageReference Include="SkiaSharp" Version="$(SkiaSharpVersion)" />
|
<PackageReference Include="SkiaSharp" Version="$(SkiaSharpVersion)" />
|
||||||
<PackageReference Include="Splat.DryIoc" Version="14.6.8" />
|
<PackageReference Include="Splat.DryIoc" Version="14.6.8" />
|
||||||
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
||||||
|
<PackageReference Include="TextMateSharp.Grammars" Version="1.0.55" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AvaloniaResource Include="Assets\**" />
|
<AvaloniaResource Include="Assets\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="Screens\Workshop\Entries\Tabs\ProfileListView.axaml.cs">
|
||||||
|
<DependentUpon>ProfileListView.axaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="Screens\Workshop\Entries\Tabs\LayoutListView.axaml.cs">
|
||||||
|
<DependentUpon>LayoutListView.axaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="Screens\Workshop\Library\SubmissionsDetailView.axaml.cs">
|
||||||
|
<DependentUpon>SubmissionsDetailView.axaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@ -4,18 +4,20 @@ namespace Artemis.UI.Routing;
|
|||||||
|
|
||||||
public class RouteViewModel
|
public class RouteViewModel
|
||||||
{
|
{
|
||||||
public RouteViewModel(string path, string name)
|
public RouteViewModel(string name, string path, string? mathPath = null)
|
||||||
{
|
{
|
||||||
Path = path;
|
Path = path;
|
||||||
Name = name;
|
Name = name;
|
||||||
|
MathPath = mathPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Path { get; }
|
public string Path { get; }
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
|
public string? MathPath { get; }
|
||||||
|
|
||||||
public bool Matches(string path)
|
public bool Matches(string path)
|
||||||
{
|
{
|
||||||
return path.StartsWith(Path, StringComparison.InvariantCultureIgnoreCase);
|
return path.StartsWith(MathPath ?? Path, StringComparison.InvariantCultureIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@ -6,6 +6,8 @@ using Artemis.UI.Screens.Settings;
|
|||||||
using Artemis.UI.Screens.Settings.Updating;
|
using Artemis.UI.Screens.Settings.Updating;
|
||||||
using Artemis.UI.Screens.SurfaceEditor;
|
using Artemis.UI.Screens.SurfaceEditor;
|
||||||
using Artemis.UI.Screens.Workshop;
|
using Artemis.UI.Screens.Workshop;
|
||||||
|
using Artemis.UI.Screens.Workshop.Entries;
|
||||||
|
using Artemis.UI.Screens.Workshop.Entries.Tabs;
|
||||||
using Artemis.UI.Screens.Workshop.Home;
|
using Artemis.UI.Screens.Workshop.Home;
|
||||||
using Artemis.UI.Screens.Workshop.Layout;
|
using Artemis.UI.Screens.Workshop.Layout;
|
||||||
using Artemis.UI.Screens.Workshop.Library;
|
using Artemis.UI.Screens.Workshop.Library;
|
||||||
@ -24,16 +26,22 @@ public static class Routes
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
new RouteRegistration<WorkshopViewModel>("workshop")
|
new RouteRegistration<WorkshopViewModel>("workshop")
|
||||||
{
|
{
|
||||||
Children = new List<IRouterRegistration>()
|
Children = new List<IRouterRegistration>
|
||||||
{
|
{
|
||||||
new RouteRegistration<WorkshopOfflineViewModel>("offline/{message:string}"),
|
new RouteRegistration<WorkshopOfflineViewModel>("offline/{message:string}"),
|
||||||
new RouteRegistration<ProfileListViewModel>("profiles/{page:int}"),
|
new RouteRegistration<EntriesViewModel>("entries")
|
||||||
new RouteRegistration<ProfileDetailsViewModel>("profiles/{entryId:guid}"),
|
{
|
||||||
new RouteRegistration<LayoutListViewModel>("layouts/{page:int}"),
|
Children = new List<IRouterRegistration>
|
||||||
new RouteRegistration<LayoutDetailsViewModel>("layouts/{entryId:guid}"),
|
{
|
||||||
|
new RouteRegistration<ProfileListViewModel>("profiles/{page:int}"),
|
||||||
|
new RouteRegistration<ProfileDetailsViewModel>("profiles/details/{entryId:guid}"),
|
||||||
|
new RouteRegistration<LayoutListViewModel>("layouts/{page:int}"),
|
||||||
|
new RouteRegistration<LayoutDetailsViewModel>("layouts/details/{entryId:guid}"),
|
||||||
|
}
|
||||||
|
},
|
||||||
new RouteRegistration<WorkshopLibraryViewModel>("library")
|
new RouteRegistration<WorkshopLibraryViewModel>("library")
|
||||||
{
|
{
|
||||||
Children = new List<IRouterRegistration>()
|
Children = new List<IRouterRegistration>
|
||||||
{
|
{
|
||||||
new RouteRegistration<InstalledTabViewModel>("installed"),
|
new RouteRegistration<InstalledTabViewModel>("installed"),
|
||||||
new RouteRegistration<SubmissionsTabViewModel>("submissions"),
|
new RouteRegistration<SubmissionsTabViewModel>("submissions"),
|
||||||
|
|||||||
@ -128,7 +128,7 @@ public class RootViewModel : RoutableHostScreen<RoutableScreen>, IMainWindowProv
|
|||||||
|
|
||||||
private void ShowSplashScreen()
|
private void ShowSplashScreen()
|
||||||
{
|
{
|
||||||
_windowService.ShowWindow<SplashViewModel>();
|
_windowService.ShowWindow(out SplashViewModel _);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Tray commands
|
#region Tray commands
|
||||||
|
|||||||
@ -21,11 +21,11 @@ public class SettingsViewModel : RoutableHostScreen<RoutableScreen>, IMainScreen
|
|||||||
_router = router;
|
_router = router;
|
||||||
SettingTabs = new ObservableCollection<RouteViewModel>
|
SettingTabs = new ObservableCollection<RouteViewModel>
|
||||||
{
|
{
|
||||||
new("settings/general", "General"),
|
new("General", "settings/general"),
|
||||||
new("settings/plugins", "Plugins"),
|
new("Plugins", "settings/plugins"),
|
||||||
new("settings/devices", "Devices"),
|
new("Devices", "settings/devices"),
|
||||||
new("settings/releases", "Releases"),
|
new("Releases", "settings/releases"),
|
||||||
new("settings/about", "About"),
|
new("About", "settings/about"),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Navigate on tab change
|
// Navigate on tab change
|
||||||
|
|||||||
@ -41,8 +41,8 @@ public class SidebarViewModel : ActivatableViewModelBase
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
new(MaterialIconKind.TestTube, "Workshop", "workshop", null, new ObservableCollection<SidebarScreenViewModel>
|
new(MaterialIconKind.TestTube, "Workshop", "workshop", null, new ObservableCollection<SidebarScreenViewModel>
|
||||||
{
|
{
|
||||||
new(MaterialIconKind.FolderVideo, "Profiles", "workshop/profiles/1", "workshop/profiles"),
|
new(MaterialIconKind.FolderVideo, "Profiles", "workshop/entries/profiles/1", "workshop/entries/profiles"),
|
||||||
new(MaterialIconKind.KeyboardVariant, "Layouts", "workshop/layouts/1", "workshop/layouts"),
|
new(MaterialIconKind.KeyboardVariant, "Layouts", "workshop/entries/layouts/1", "workshop/entries/layouts"),
|
||||||
new(MaterialIconKind.Bookshelf, "Library", "workshop/library"),
|
new(MaterialIconKind.Bookshelf, "Library", "workshop/library"),
|
||||||
}),
|
}),
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
32
src/Artemis.UI/Screens/Workshop/Entries/EntriesView.axaml
Normal file
32
src/Artemis.UI/Screens/Workshop/Entries/EntriesView.axaml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:entries="clr-namespace:Artemis.UI.Screens.Workshop.Entries"
|
||||||
|
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
|
xmlns:ui="clr-namespace:Artemis.UI"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="Artemis.UI.Screens.Workshop.Entries.EntriesView"
|
||||||
|
x:DataType="entries:EntriesViewModel">
|
||||||
|
<controls:NavigationView PaneDisplayMode="Top"
|
||||||
|
MenuItemsSource="{CompiledBinding Tabs}"
|
||||||
|
SelectedItem="{CompiledBinding SelectedTab}"
|
||||||
|
IsBackEnabled="True"
|
||||||
|
IsBackButtonVisible="True"
|
||||||
|
IsSettingsVisible="False"
|
||||||
|
BackRequested="NavigationView_OnBackRequested">
|
||||||
|
<controls:NavigationView.Styles>
|
||||||
|
<Styles>
|
||||||
|
<Style Selector="controls|NavigationView:topnavminimal /template/ SplitView Border#ContentGridBorder">
|
||||||
|
<Setter Property="CornerRadius" Value="8 0 0 0" />
|
||||||
|
</Style>
|
||||||
|
</Styles>
|
||||||
|
</controls:NavigationView.Styles>
|
||||||
|
|
||||||
|
<controls:Frame Name="TabFrame" IsNavigationStackEnabled="False" CacheSize="0" Padding="20">
|
||||||
|
<controls:Frame.NavigationPageFactory>
|
||||||
|
<ui:PageFactory/>
|
||||||
|
</controls:Frame.NavigationPageFactory>
|
||||||
|
</controls:Frame>
|
||||||
|
</controls:NavigationView>
|
||||||
|
</UserControl>
|
||||||
28
src/Artemis.UI/Screens/Workshop/Entries/EntriesView.axaml.cs
Normal file
28
src/Artemis.UI/Screens/Workshop/Entries/EntriesView.axaml.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using System.Reactive.Disposables;
|
||||||
|
using Artemis.UI.Shared;
|
||||||
|
using Avalonia.ReactiveUI;
|
||||||
|
using Avalonia.Threading;
|
||||||
|
using FluentAvalonia.UI.Controls;
|
||||||
|
using ReactiveUI;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Screens.Workshop.Entries;
|
||||||
|
|
||||||
|
public partial class EntriesView : ReactiveUserControl<EntriesViewModel>
|
||||||
|
{
|
||||||
|
public EntriesView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.WhenActivated(d => { ViewModel.WhenAnyValue(vm => vm.Screen).WhereNotNull().Subscribe(Navigate).DisposeWith(d); });
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Navigate(ViewModelBase viewModel)
|
||||||
|
{
|
||||||
|
Dispatcher.UIThread.Invoke(() => TabFrame.NavigateFromObject(viewModel));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NavigationView_OnBackRequested(object? sender, NavigationViewBackRequestedEventArgs e)
|
||||||
|
{
|
||||||
|
ViewModel?.GoBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
65
src/Artemis.UI/Screens/Workshop/Entries/EntriesViewModel.cs
Normal file
65
src/Artemis.UI/Screens/Workshop/Entries/EntriesViewModel.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reactive.Disposables;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Artemis.UI.Routing;
|
||||||
|
using Artemis.UI.Shared.Routing;
|
||||||
|
using ReactiveUI;
|
||||||
|
using System;
|
||||||
|
using System.Reactive.Linq;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Screens.Workshop.Entries;
|
||||||
|
|
||||||
|
public class EntriesViewModel : RoutableHostScreen<RoutableScreen>
|
||||||
|
{
|
||||||
|
private readonly IRouter _router;
|
||||||
|
private RouteViewModel? _selectedTab;
|
||||||
|
private ObservableAsPropertyHelper<bool>? _viewingDetails;
|
||||||
|
|
||||||
|
public EntriesViewModel(IRouter router)
|
||||||
|
{
|
||||||
|
_router = router;
|
||||||
|
|
||||||
|
Tabs = new ObservableCollection<RouteViewModel>
|
||||||
|
{
|
||||||
|
new("Profiles", "workshop/entries/profiles/1", "workshop/entries/profiles"),
|
||||||
|
new("Layouts", "workshop/entries/layouts/1", "workshop/entries/layouts")
|
||||||
|
};
|
||||||
|
|
||||||
|
this.WhenActivated(d =>
|
||||||
|
{
|
||||||
|
// Show back button on details page
|
||||||
|
_viewingDetails = _router.CurrentPath.Select(p => p != null && p.Contains("details")).ToProperty(this, vm => vm.ViewingDetails).DisposeWith(d);
|
||||||
|
// Navigate on tab change
|
||||||
|
this.WhenAnyValue(vm => vm.SelectedTab)
|
||||||
|
.WhereNotNull()
|
||||||
|
.Subscribe(s => router.Navigate(s.Path, new RouterNavigationOptions {IgnoreOnPartialMatch = true}))
|
||||||
|
.DisposeWith(d);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ViewingDetails => _viewingDetails?.Value ?? false;
|
||||||
|
public ObservableCollection<RouteViewModel> Tabs { get; }
|
||||||
|
|
||||||
|
public RouteViewModel? SelectedTab
|
||||||
|
{
|
||||||
|
get => _selectedTab;
|
||||||
|
set => RaiseAndSetIfChanged(ref _selectedTab, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task OnNavigating(NavigationArguments args, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
SelectedTab = Tabs.FirstOrDefault(t => t.Matches(args.Path));
|
||||||
|
if (SelectedTab == null)
|
||||||
|
await args.Router.Navigate(Tabs.First().Path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GoBack()
|
||||||
|
{
|
||||||
|
if (ViewingDetails)
|
||||||
|
_router.GoBack();
|
||||||
|
else
|
||||||
|
_router.Navigate("workshop");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -33,10 +33,10 @@ public class EntryListItemViewModel : ActivatableViewModelBase
|
|||||||
switch (Entry.EntryType)
|
switch (Entry.EntryType)
|
||||||
{
|
{
|
||||||
case EntryType.Layout:
|
case EntryType.Layout:
|
||||||
await _router.Navigate($"workshop/layouts/{Entry.Id}");
|
await _router.Navigate($"workshop/entries/layouts/details/{Entry.Id}");
|
||||||
break;
|
break;
|
||||||
case EntryType.Profile:
|
case EntryType.Profile:
|
||||||
await _router.Navigate($"workshop/profiles/{Entry.Id}");
|
await _router.Navigate($"workshop/entries/profiles/details/{Entry.Id}");
|
||||||
break;
|
break;
|
||||||
case EntryType.Plugin:
|
case EntryType.Plugin:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -18,7 +18,7 @@ using StrawberryShake;
|
|||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Entries;
|
namespace Artemis.UI.Screens.Workshop.Entries;
|
||||||
|
|
||||||
public abstract class EntryListBaseViewModel : RoutableScreen<WorkshopListParameters>
|
public abstract class EntryListViewModel : RoutableScreen<WorkshopListParameters>
|
||||||
{
|
{
|
||||||
private readonly INotificationService _notificationService;
|
private readonly INotificationService _notificationService;
|
||||||
private readonly IWorkshopClient _workshopClient;
|
private readonly IWorkshopClient _workshopClient;
|
||||||
@ -31,7 +31,7 @@ public abstract class EntryListBaseViewModel : RoutableScreen<WorkshopListParame
|
|||||||
private int _totalPages = 1;
|
private int _totalPages = 1;
|
||||||
private int _entriesPerPage = 10;
|
private int _entriesPerPage = 10;
|
||||||
|
|
||||||
protected EntryListBaseViewModel(IWorkshopClient workshopClient, IRouter router, CategoriesViewModel categoriesViewModel, INotificationService notificationService,
|
protected EntryListViewModel(IWorkshopClient workshopClient, IRouter router, CategoriesViewModel categoriesViewModel, INotificationService notificationService,
|
||||||
Func<IGetEntries_Entries_Items, EntryListItemViewModel> getEntryListViewModel)
|
Func<IGetEntries_Entries_Items, EntryListItemViewModel> getEntryListViewModel)
|
||||||
{
|
{
|
||||||
_workshopClient = workshopClient;
|
_workshopClient = workshopClient;
|
||||||
@ -143,6 +143,4 @@ public abstract class EntryListBaseViewModel : RoutableScreen<WorkshopListParame
|
|||||||
{
|
{
|
||||||
return new EntryFilterInput {And = CategoriesViewModel.CategoryFilters};
|
return new EntryFilterInput {And = CategoriesViewModel.CategoryFilters};
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntryType? EntryType => null;
|
|
||||||
}
|
}
|
||||||
@ -0,0 +1,105 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:entries="clr-namespace:Artemis.UI.Screens.Workshop.Entries"
|
||||||
|
xmlns:tagsInput="clr-namespace:Artemis.UI.Shared.TagsInput;assembly=Artemis.UI.Shared"
|
||||||
|
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||||
|
xmlns:categories="clr-namespace:Artemis.UI.Screens.Workshop.Categories"
|
||||||
|
xmlns:avaloniaEdit="https://github.com/avaloniaui/avaloniaedit"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="800"
|
||||||
|
x:Class="Artemis.UI.Screens.Workshop.Entries.EntrySpecificationsView"
|
||||||
|
x:DataType="entries:EntrySpecificationsViewModel">
|
||||||
|
<StackPanel>
|
||||||
|
<StackPanel.Styles>
|
||||||
|
<Styles>
|
||||||
|
<Style Selector="TextBlock">
|
||||||
|
<Setter Property="TextWrapping" Value="Wrap"></Setter>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Label">
|
||||||
|
<Setter Property="Margin" Value="0 8 0 0"></Setter>
|
||||||
|
</Style>
|
||||||
|
</Styles>
|
||||||
|
</StackPanel.Styles>
|
||||||
|
|
||||||
|
<Grid ColumnDefinitions="103,*">
|
||||||
|
<StackPanel Grid.Column="0" Width="95">
|
||||||
|
<Label Target="Name">Icon</Label>
|
||||||
|
<Button Width="95"
|
||||||
|
Height="95"
|
||||||
|
Command="{CompiledBinding SelectIcon}"
|
||||||
|
IsVisible="{CompiledBinding IconBitmap, Converter={x:Static ObjectConverters.IsNull}}">
|
||||||
|
<avalonia:MaterialIcon Kind="FolderOpen"
|
||||||
|
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
|
||||||
|
Width="30"
|
||||||
|
Height="30" />
|
||||||
|
</Button>
|
||||||
|
<Border IsVisible="{CompiledBinding IconBitmap, Converter={x:Static ObjectConverters.IsNotNull}}"
|
||||||
|
ClipToBounds="True"
|
||||||
|
CornerRadius="6"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Width="95"
|
||||||
|
Height="95">
|
||||||
|
<Panel>
|
||||||
|
<Image Source="{CompiledBinding IconBitmap}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"></Image>
|
||||||
|
<Button Classes="icon-button image-picker"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Cursor="Hand"
|
||||||
|
Command="{CompiledBinding SelectIcon}"
|
||||||
|
ToolTip.Tip="Click to browse">
|
||||||
|
</Button>
|
||||||
|
</Panel>
|
||||||
|
|
||||||
|
</Border>
|
||||||
|
<TextBlock Foreground="{DynamicResource SystemFillColorCriticalBrush}" Margin="2 0" IsVisible="{CompiledBinding !IconValid}" TextWrapping="Wrap">
|
||||||
|
Icon required
|
||||||
|
</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Column="1">
|
||||||
|
<Label Target="Name">Name</Label>
|
||||||
|
<TextBox Name="Name" Text="{CompiledBinding Name}"></TextBox>
|
||||||
|
|
||||||
|
<Label Target="Summary" Margin="0 5 0 0">Summary</Label>
|
||||||
|
<TextBox Name="Summary" Text="{CompiledBinding Summary}"></TextBox>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Label Margin="0 28 0 0">Categories</Label>
|
||||||
|
<ItemsControl ItemsSource="{CompiledBinding Categories}">
|
||||||
|
<ItemsControl.ItemsPanel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<WrapPanel />
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</ItemsControl.ItemsPanel>
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate DataType="categories:CategoryViewModel">
|
||||||
|
<ToggleButton IsChecked="{CompiledBinding IsSelected}" Margin="0 0 5 5">
|
||||||
|
<StackPanel Orientation="Horizontal" Spacing="5">
|
||||||
|
<avalonia:MaterialIcon Kind="{CompiledBinding Icon}" />
|
||||||
|
<TextBlock Text="{CompiledBinding Name}" VerticalAlignment="Center" />
|
||||||
|
</StackPanel>
|
||||||
|
</ToggleButton>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
|
<TextBlock Foreground="{DynamicResource SystemFillColorCriticalBrush}" Margin="2 0" IsVisible="{CompiledBinding !CategoriesValid}">
|
||||||
|
At least one category is required
|
||||||
|
</TextBlock>
|
||||||
|
|
||||||
|
<Label>Tags</Label>
|
||||||
|
<tagsInput:TagsInput Tags="{CompiledBinding Tags}" />
|
||||||
|
|
||||||
|
<Label Target="DescriptionEditor" Margin="0 28 0 0">Description</Label>
|
||||||
|
<Border Classes="card">
|
||||||
|
<avaloniaEdit:TextEditor Height="250" Name="DescriptionEditor" Document="{CompiledBinding MarkdownDocument}"/>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
|
||||||
|
<DockPanel HorizontalAlignment="Stretch">
|
||||||
|
<TextBlock Theme="{StaticResource CaptionTextBlockStyle}">Markdown supported, a better editor planned</TextBlock>
|
||||||
|
<Button Margin="0 5" HorizontalAlignment="Right" Command="{CompiledBinding OpenMarkdownPreview}">Open preview</Button>
|
||||||
|
</DockPanel>
|
||||||
|
|
||||||
|
</StackPanel>
|
||||||
|
</UserControl>
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Media;
|
||||||
|
using Avalonia.Media.Immutable;
|
||||||
|
using Avalonia.ReactiveUI;
|
||||||
|
using AvaloniaEdit.TextMate;
|
||||||
|
using TextMateSharp.Grammars;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Screens.Workshop.Entries;
|
||||||
|
|
||||||
|
public partial class EntrySpecificationsView : ReactiveUserControl<EntrySpecificationsViewModel>
|
||||||
|
{
|
||||||
|
public EntrySpecificationsView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
RegistryOptions options = new(ThemeName.Dark);
|
||||||
|
TextMate.Installation? install = DescriptionEditor.InstallTextMate(options);
|
||||||
|
|
||||||
|
install.SetGrammar(options.GetScopeByExtension(".md"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Overrides of Visual
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||||
|
{
|
||||||
|
if (this.TryFindResource("SystemAccentColorLight3", out object? resource) && resource is Color color)
|
||||||
|
DescriptionEditor.TextArea.TextView.LinkTextForegroundBrush = new ImmutableSolidColorBrush(color);
|
||||||
|
base.OnAttachedToVisualTree(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@ -0,0 +1,173 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reactive;
|
||||||
|
using System.Reactive.Disposables;
|
||||||
|
using System.Reactive.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Artemis.UI.Extensions;
|
||||||
|
using Artemis.UI.Screens.Workshop.Categories;
|
||||||
|
using Artemis.UI.Screens.Workshop.Entries.Windows;
|
||||||
|
using Artemis.UI.Shared;
|
||||||
|
using Artemis.UI.Shared.Services;
|
||||||
|
using Artemis.WebClient.Workshop;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using AvaloniaEdit.Document;
|
||||||
|
using DynamicData;
|
||||||
|
using DynamicData.Aggregation;
|
||||||
|
using DynamicData.Binding;
|
||||||
|
using ReactiveUI;
|
||||||
|
using ReactiveUI.Validation.Extensions;
|
||||||
|
using ReactiveUI.Validation.Helpers;
|
||||||
|
using StrawberryShake;
|
||||||
|
using Bitmap = Avalonia.Media.Imaging.Bitmap;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Screens.Workshop.Entries;
|
||||||
|
|
||||||
|
public class EntrySpecificationsViewModel : ValidatableViewModelBase
|
||||||
|
{
|
||||||
|
private readonly IWindowService _windowService;
|
||||||
|
private ObservableAsPropertyHelper<bool>? _categoriesValid;
|
||||||
|
private ObservableAsPropertyHelper<bool>? _iconValid;
|
||||||
|
private string _description = string.Empty;
|
||||||
|
private string _name = string.Empty;
|
||||||
|
private string _summary = string.Empty;
|
||||||
|
private Bitmap? _iconBitmap;
|
||||||
|
private Window? _previewWindow;
|
||||||
|
private TextDocument? _markdownDocument;
|
||||||
|
|
||||||
|
public EntrySpecificationsViewModel(IWorkshopClient workshopClient, IWindowService windowService)
|
||||||
|
{
|
||||||
|
_windowService = windowService;
|
||||||
|
SelectIcon = ReactiveCommand.CreateFromTask(ExecuteSelectIcon);
|
||||||
|
OpenMarkdownPreview = ReactiveCommand.Create(ExecuteOpenMarkdownPreview);
|
||||||
|
|
||||||
|
// this.WhenAnyValue(vm => vm.Description).Subscribe(d => MarkdownDocument.Text = d);
|
||||||
|
this.WhenActivated(d =>
|
||||||
|
{
|
||||||
|
// Load categories
|
||||||
|
Observable.FromAsync(workshopClient.GetCategories.ExecuteAsync).Subscribe(PopulateCategories).DisposeWith(d);
|
||||||
|
|
||||||
|
this.ClearValidationRules();
|
||||||
|
|
||||||
|
MarkdownDocument = new TextDocument(new StringTextSource(Description));
|
||||||
|
MarkdownDocument.TextChanged += MarkdownDocumentOnTextChanged;
|
||||||
|
Disposable.Create(() =>
|
||||||
|
{
|
||||||
|
_previewWindow?.Close();
|
||||||
|
MarkdownDocument.TextChanged -= MarkdownDocumentOnTextChanged;
|
||||||
|
MarkdownDocument = null;
|
||||||
|
ClearIcon();
|
||||||
|
}).DisposeWith(d);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MarkdownDocumentOnTextChanged(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Description = MarkdownDocument.Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReactiveCommand<Unit, Unit> SelectIcon { get; }
|
||||||
|
public ReactiveCommand<Unit, Unit> OpenMarkdownPreview { get; }
|
||||||
|
|
||||||
|
public ObservableCollection<CategoryViewModel> Categories { get; } = new();
|
||||||
|
public ObservableCollection<string> Tags { get; } = new();
|
||||||
|
public bool CategoriesValid => _categoriesValid?.Value ?? true;
|
||||||
|
public bool IconValid => _iconValid?.Value ?? true;
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get => _name;
|
||||||
|
set => RaiseAndSetIfChanged(ref _name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Summary
|
||||||
|
{
|
||||||
|
get => _summary;
|
||||||
|
set => RaiseAndSetIfChanged(ref _summary, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get => _description;
|
||||||
|
set => RaiseAndSetIfChanged(ref _description, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bitmap? IconBitmap
|
||||||
|
{
|
||||||
|
get => _iconBitmap;
|
||||||
|
set => RaiseAndSetIfChanged(ref _iconBitmap, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextDocument? MarkdownDocument
|
||||||
|
{
|
||||||
|
get => _markdownDocument;
|
||||||
|
set => RaiseAndSetIfChanged(ref _markdownDocument, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<int> PreselectedCategories { get; set; } = new List<int>();
|
||||||
|
|
||||||
|
public void SetupDataValidation()
|
||||||
|
{
|
||||||
|
// Hopefully this can be avoided in the future
|
||||||
|
// https://github.com/reactiveui/ReactiveUI.Validation/discussions/558
|
||||||
|
this.ValidationRule(vm => vm.Name, s => !string.IsNullOrWhiteSpace(s), "Name is required");
|
||||||
|
this.ValidationRule(vm => vm.Summary, s => !string.IsNullOrWhiteSpace(s), "Summary is required");
|
||||||
|
this.ValidationRule(vm => vm.Description, s => !string.IsNullOrWhiteSpace(s), "Description is required");
|
||||||
|
|
||||||
|
// These don't use inputs that support validation messages, do so manually
|
||||||
|
ValidationHelper iconRule = this.ValidationRule(vm => vm.IconBitmap, s => s != null, "Icon required");
|
||||||
|
ValidationHelper categoriesRule = this.ValidationRule(vm => vm.Categories, Categories.ToObservableChangeSet().AutoRefresh(c => c.IsSelected).Filter(c => c.IsSelected).IsNotEmpty(),
|
||||||
|
"At least one category must be selected"
|
||||||
|
);
|
||||||
|
_iconValid = iconRule.ValidationChanged.Select(c => c.IsValid).ToProperty(this, vm => vm.IconValid);
|
||||||
|
_categoriesValid = categoriesRule.ValidationChanged.Select(c => c.IsValid).ToProperty(this, vm => vm.CategoriesValid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ExecuteSelectIcon()
|
||||||
|
{
|
||||||
|
string[]? result = await _windowService.CreateOpenFileDialog()
|
||||||
|
.HavingFilter(f => f.WithExtension("png").WithExtension("jpg").WithExtension("bmp").WithName("Bitmap image"))
|
||||||
|
.ShowAsync();
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
IconBitmap?.Dispose();
|
||||||
|
IconBitmap = BitmapExtensions.LoadAndResize(result[0], 128);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteOpenMarkdownPreview()
|
||||||
|
{
|
||||||
|
if (_previewWindow != null)
|
||||||
|
{
|
||||||
|
_previewWindow.Activate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_previewWindow = _windowService.ShowWindow(out MarkdownPreviewViewModel _, this.WhenAnyValue(vm => vm.Description));
|
||||||
|
_previewWindow.Closed += PreviewWindowOnClosed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PreviewWindowOnClosed(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_previewWindow != null)
|
||||||
|
_previewWindow.Closed -= PreviewWindowOnClosed;
|
||||||
|
_previewWindow = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClearIcon()
|
||||||
|
{
|
||||||
|
IconBitmap?.Dispose();
|
||||||
|
IconBitmap = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PopulateCategories(IOperationResult<IGetCategoriesResult> result)
|
||||||
|
{
|
||||||
|
Categories.Clear();
|
||||||
|
if (result.Data != null)
|
||||||
|
Categories.AddRange(result.Data.Categories.Select(c => new CategoryViewModel(c) {IsSelected = PreselectedCategories.Contains(c.Id)}));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:layout="clr-namespace:Artemis.UI.Screens.Workshop.Layout"
|
||||||
|
xmlns:pagination="clr-namespace:Artemis.UI.Shared.Pagination;assembly=Artemis.UI.Shared"
|
||||||
|
xmlns:tabs="clr-namespace:Artemis.UI.Screens.Workshop.Entries.Tabs"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="Artemis.UI.Screens.Workshop.Entries.Tabs.LayoutListView"
|
||||||
|
x:DataType="tabs:LayoutListViewModel">
|
||||||
|
<Grid ColumnDefinitions="300,*" RowDefinitions="*,Auto">
|
||||||
|
<StackPanel Grid.Column="0" Grid.RowSpan="2" Margin="0 0 10 0" VerticalAlignment="Top">
|
||||||
|
<Border Classes="card" VerticalAlignment="Stretch">
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock Theme="{StaticResource SubtitleTextBlockStyle}">Categories</TextBlock>
|
||||||
|
<Border Classes="card-separator" />
|
||||||
|
<ContentControl Content="{CompiledBinding CategoriesViewModel}"></ContentControl>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<ProgressBar Grid.Column="1" Grid.Row="0" VerticalAlignment="Top" Margin="0 0 20 0" IsVisible="{CompiledBinding IsLoading}" IsIndeterminate="True" />
|
||||||
|
<ScrollViewer Grid.Column="1" Grid.Row="0">
|
||||||
|
<ItemsRepeater ItemsSource="{CompiledBinding Entries}" Margin="0 0 20 0">
|
||||||
|
<ItemsRepeater.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<ContentControl Content="{CompiledBinding}" Margin="0 0 0 5"></ContentControl>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsRepeater.ItemTemplate>
|
||||||
|
</ItemsRepeater>
|
||||||
|
</ScrollViewer>
|
||||||
|
|
||||||
|
<pagination:Pagination Grid.Column="1"
|
||||||
|
Grid.Row="1"
|
||||||
|
Margin="0 20 0 10"
|
||||||
|
IsVisible="{CompiledBinding ShowPagination}"
|
||||||
|
Value="{CompiledBinding Page}"
|
||||||
|
Maximum="{CompiledBinding TotalPages}"
|
||||||
|
HorizontalAlignment="Center" />
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@ -1,6 +1,6 @@
|
|||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Layout;
|
namespace Artemis.UI.Screens.Workshop.Entries.Tabs;
|
||||||
|
|
||||||
public partial class LayoutListView : ReactiveUserControl<LayoutListViewModel>
|
public partial class LayoutListView : ReactiveUserControl<LayoutListViewModel>
|
||||||
{
|
{
|
||||||
@ -1,13 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using Artemis.UI.Screens.Workshop.Categories;
|
using Artemis.UI.Screens.Workshop.Categories;
|
||||||
using Artemis.UI.Screens.Workshop.Entries;
|
|
||||||
using Artemis.UI.Shared.Routing;
|
using Artemis.UI.Shared.Routing;
|
||||||
using Artemis.UI.Shared.Services;
|
using Artemis.UI.Shared.Services;
|
||||||
using Artemis.WebClient.Workshop;
|
using Artemis.WebClient.Workshop;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Layout;
|
namespace Artemis.UI.Screens.Workshop.Entries.Tabs;
|
||||||
|
|
||||||
public class LayoutListViewModel : EntryListBaseViewModel
|
public class LayoutListViewModel : EntryListViewModel
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public LayoutListViewModel(IWorkshopClient workshopClient,
|
public LayoutListViewModel(IWorkshopClient workshopClient,
|
||||||
@ -24,7 +23,7 @@ public class LayoutListViewModel : EntryListBaseViewModel
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override string GetPagePath(int page)
|
protected override string GetPagePath(int page)
|
||||||
{
|
{
|
||||||
return $"workshop/layouts/{page}";
|
return $"workshop/entries/layouts/{page}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:profile="clr-namespace:Artemis.UI.Screens.Workshop.Profile"
|
||||||
|
xmlns:pagination="clr-namespace:Artemis.UI.Shared.Pagination;assembly=Artemis.UI.Shared"
|
||||||
|
xmlns:tabs="clr-namespace:Artemis.UI.Screens.Workshop.Entries.Tabs"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="Artemis.UI.Screens.Workshop.Entries.Tabs.ProfileListView"
|
||||||
|
x:DataType="tabs:ProfileListViewModel">
|
||||||
|
<Grid ColumnDefinitions="300,*" RowDefinitions="*,Auto">
|
||||||
|
<StackPanel Grid.Column="0" Grid.RowSpan="2" Margin="0 0 10 0" VerticalAlignment="Top">
|
||||||
|
<Border Classes="card" VerticalAlignment="Stretch">
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock Theme="{StaticResource SubtitleTextBlockStyle}">Categories</TextBlock>
|
||||||
|
<Border Classes="card-separator" />
|
||||||
|
<ContentControl Content="{CompiledBinding CategoriesViewModel}"></ContentControl>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<ProgressBar Grid.Column="1" Grid.Row="0" VerticalAlignment="Top" Margin="0 0 20 0" IsVisible="{CompiledBinding IsLoading}" IsIndeterminate="True" />
|
||||||
|
|
||||||
|
<ScrollViewer Grid.Column="1" Grid.Row="0">
|
||||||
|
<ItemsRepeater ItemsSource="{CompiledBinding Entries}" Margin="0 0 20 0">
|
||||||
|
<ItemsRepeater.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<ContentControl Content="{CompiledBinding}" Margin="0 0 0 5"></ContentControl>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsRepeater.ItemTemplate>
|
||||||
|
</ItemsRepeater>
|
||||||
|
</ScrollViewer>
|
||||||
|
|
||||||
|
<pagination:Pagination Grid.Column="1"
|
||||||
|
Grid.Row="1"
|
||||||
|
Margin="0 20 0 10"
|
||||||
|
IsVisible="{CompiledBinding ShowPagination}"
|
||||||
|
Value="{CompiledBinding Page}"
|
||||||
|
Maximum="{CompiledBinding TotalPages}"
|
||||||
|
HorizontalAlignment="Center" />
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@ -1,6 +1,6 @@
|
|||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Profile;
|
namespace Artemis.UI.Screens.Workshop.Entries.Tabs;
|
||||||
|
|
||||||
public partial class ProfileListView : ReactiveUserControl<ProfileListViewModel>
|
public partial class ProfileListView : ReactiveUserControl<ProfileListViewModel>
|
||||||
{
|
{
|
||||||
@ -1,13 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using Artemis.UI.Screens.Workshop.Categories;
|
using Artemis.UI.Screens.Workshop.Categories;
|
||||||
using Artemis.UI.Screens.Workshop.Entries;
|
|
||||||
using Artemis.UI.Shared.Routing;
|
using Artemis.UI.Shared.Routing;
|
||||||
using Artemis.UI.Shared.Services;
|
using Artemis.UI.Shared.Services;
|
||||||
using Artemis.WebClient.Workshop;
|
using Artemis.WebClient.Workshop;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Profile;
|
namespace Artemis.UI.Screens.Workshop.Entries.Tabs;
|
||||||
|
|
||||||
public class ProfileListViewModel : EntryListBaseViewModel
|
public class ProfileListViewModel : EntryListViewModel
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public ProfileListViewModel(IWorkshopClient workshopClient,
|
public ProfileListViewModel(IWorkshopClient workshopClient,
|
||||||
@ -24,7 +23,7 @@ public class ProfileListViewModel : EntryListBaseViewModel
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override string GetPagePath(int page)
|
protected override string GetPagePath(int page)
|
||||||
{
|
{
|
||||||
return $"workshop/profiles/{page}";
|
return $"workshop/entries/profiles/{page}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
<windowing:AppWindow xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:windows="clr-namespace:Artemis.UI.Screens.Workshop.Entries.Windows"
|
||||||
|
xmlns:windowing="clr-namespace:FluentAvalonia.UI.Windowing;assembly=FluentAvalonia"
|
||||||
|
xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight"
|
||||||
|
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="Artemis.UI.Screens.Workshop.Entries.Windows.MarkdownPreviewView"
|
||||||
|
x:DataType="windows:MarkdownPreviewViewModel"
|
||||||
|
Icon="/Assets/Images/Logo/application.ico"
|
||||||
|
Title="Artemis | Markdown Preview"
|
||||||
|
Width="1200"
|
||||||
|
Height="800">
|
||||||
|
<Grid RowDefinitions="Auto,*" Margin="15">
|
||||||
|
<StackPanel Grid.Row="0">
|
||||||
|
<TextBlock Theme="{StaticResource TitleTextBlockStyle}">Markdown Previewer</TextBlock>
|
||||||
|
<TextBlock TextWrapping="Wrap" Margin="0 10">
|
||||||
|
<Run>In this window you can preview the Markdown you're writing in the main window of the application.</Run>
|
||||||
|
<LineBreak/>
|
||||||
|
<Run>The preview updates realtime, so it might be a good idea to keep this window visible while you're typing.</Run>
|
||||||
|
</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<controls:HyperlinkButton
|
||||||
|
Grid.Row="0"
|
||||||
|
Content="Learn more about Markdown on the wiki"
|
||||||
|
NavigateUri="https://wiki.artemis-rgb.com/guides/user/markdown?mtm_campaign=artemis&mtm_kwd=markdown-editor"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Top" />
|
||||||
|
|
||||||
|
<Border Grid.Row="1" Classes="card">
|
||||||
|
<mdxaml:MarkdownScrollViewer Markdown="{CompiledBinding Markdown^}" MarkdownStyleName="FluentAvalonia" SaveScrollValueWhenContentUpdated="True">
|
||||||
|
<mdxaml:MarkdownScrollViewer.Styles>
|
||||||
|
<StyleInclude Source="/Styles/Markdown.axaml" />
|
||||||
|
</mdxaml:MarkdownScrollViewer.Styles>
|
||||||
|
</mdxaml:MarkdownScrollViewer>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
</windowing:AppWindow>
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
using Artemis.UI.Shared;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Screens.Workshop.Entries.Windows;
|
||||||
|
|
||||||
|
public partial class MarkdownPreviewView : ReactiveAppWindow<MarkdownPreviewViewModel>
|
||||||
|
{
|
||||||
|
public MarkdownPreviewView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using Artemis.UI.Shared;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Screens.Workshop.Entries.Windows;
|
||||||
|
|
||||||
|
public class MarkdownPreviewViewModel : ActivatableViewModelBase
|
||||||
|
{
|
||||||
|
public event EventHandler? Closed;
|
||||||
|
|
||||||
|
public IObservable<string> Markdown { get; }
|
||||||
|
|
||||||
|
public MarkdownPreviewViewModel(IObservable<string> markdown)
|
||||||
|
{
|
||||||
|
Markdown = markdown;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnClosed()
|
||||||
|
{
|
||||||
|
Closed?.Invoke(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
<StackPanel Margin="30 -75 30 0" Grid.Row="1">
|
<StackPanel Margin="30 -75 30 0" Grid.Row="1">
|
||||||
<StackPanel Spacing="10" Orientation="Horizontal" VerticalAlignment="Top">
|
<StackPanel Spacing="10" Orientation="Horizontal" VerticalAlignment="Top">
|
||||||
<Button Width="150" Height="180" Command="{CompiledBinding Navigate}" CommandParameter="workshop/profiles/1" VerticalContentAlignment="Top">
|
<Button Width="150" Height="180" Command="{CompiledBinding Navigate}" CommandParameter="workshop/entries/profiles/1" VerticalContentAlignment="Top">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<avalonia:MaterialIcon Kind="FolderVideo" HorizontalAlignment="Left" Width="60" Height="60" Margin="0 5" />
|
<avalonia:MaterialIcon Kind="FolderVideo" HorizontalAlignment="Left" Width="60" Height="60" Margin="0 5" />
|
||||||
<TextBlock TextWrapping="Wrap" FontSize="16" Margin="0 5">Profiles</TextBlock>
|
<TextBlock TextWrapping="Wrap" FontSize="16" Margin="0 5">Profiles</TextBlock>
|
||||||
@ -49,7 +49,7 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button Width="150" Height="180" Command="{CompiledBinding Navigate}" CommandParameter="workshop/layouts/1" VerticalContentAlignment="Top">
|
<Button Width="150" Height="180" Command="{CompiledBinding Navigate}" CommandParameter="workshop/entries/layouts/1" VerticalContentAlignment="Top">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<avalonia:MaterialIcon Kind="KeyboardVariant" HorizontalAlignment="Left" Width="60" Height="60" Margin="0 5" />
|
<avalonia:MaterialIcon Kind="KeyboardVariant" HorizontalAlignment="Left" Width="60" Height="60" Margin="0 5" />
|
||||||
<TextBlock TextWrapping="Wrap" FontSize="16" Margin="0 5">Layouts</TextBlock>
|
<TextBlock TextWrapping="Wrap" FontSize="16" Margin="0 5">Layouts</TextBlock>
|
||||||
|
|||||||
@ -44,6 +44,4 @@ public class WorkshopHomeViewModel : RoutableScreen
|
|||||||
{
|
{
|
||||||
await _windowService.ShowDialogAsync<SubmissionWizardViewModel, bool>();
|
await _windowService.ShowDialogAsync<SubmissionWizardViewModel, bool>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntryType? EntryType => null;
|
|
||||||
}
|
}
|
||||||
@ -47,8 +47,6 @@ public class WorkshopOfflineViewModel : RoutableScreen<WorkshopOfflineParameters
|
|||||||
|
|
||||||
Message = status.Message;
|
Message = status.Message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntryType? EntryType => null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WorkshopOfflineParameters
|
public class WorkshopOfflineParameters
|
||||||
|
|||||||
@ -2,24 +2,132 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:layout="clr-namespace:Artemis.UI.Screens.Workshop.Layout"
|
xmlns:Layout="clr-namespace:Artemis.UI.Screens.Workshop.Layout"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||||
|
xmlns:il="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
|
||||||
|
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||||
|
xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight"
|
||||||
|
xmlns:mdsvg="https://github.com/whistyun/Markdown.Avalonia.Svg"
|
||||||
|
xmlns:ui="clr-namespace:Artemis.UI"
|
||||||
|
xmlns:converters1="clr-namespace:Artemis.UI.Shared.Converters;assembly=Artemis.UI.Shared"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="800"
|
||||||
x:Class="Artemis.UI.Screens.Workshop.Layout.LayoutDetailsView"
|
x:Class="Artemis.UI.Screens.Workshop.Layout.LayoutDetailsView"
|
||||||
x:DataType="layout:LayoutDetailsViewModel">
|
x:DataType="Layout:LayoutDetailsViewModel">
|
||||||
<Border Classes="router-container">
|
<UserControl.Resources>
|
||||||
<Grid ColumnDefinitions="300,*" RowDefinitions="Auto,*" Margin="10">
|
<converters:EntryIconUriConverter x:Key="EntryIconUriConverter" />
|
||||||
<StackPanel Grid.Row="0" Grid.ColumnSpan="2" >
|
<converters:DateTimeConverter x:Key="DateTimeConverter" />
|
||||||
<TextBlock Text="{CompiledBinding Entry.Name, FallbackValue=Layout}" Classes="h3 no-margin"/>
|
<converters1:BytesToStringConverter x:Key="BytesToStringConverter" />
|
||||||
<TextBlock Text="{CompiledBinding Entry.Author, FallbackValue=Author}" Classes="subtitle" Margin="0 0 0 5"/>
|
</UserControl.Resources>
|
||||||
</StackPanel>
|
<Grid ColumnDefinitions="300,*" RowDefinitions="Auto,*">
|
||||||
|
<StackPanel Grid.Row="1" Grid.Column="0" Margin="0 0 10 0" Spacing="10">
|
||||||
<Border Classes="card-condensed" Grid.Row="1" Grid.Column="0" Margin="0 0 10 0">
|
<Border Classes="card" VerticalAlignment="Top">
|
||||||
<TextBlock>Side panel</TextBlock>
|
<StackPanel>
|
||||||
|
<Border CornerRadius="6"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Margin="0 0 10 0"
|
||||||
|
Width="80"
|
||||||
|
Height="80"
|
||||||
|
ClipToBounds="True">
|
||||||
|
<Image Stretch="UniformToFill" il:ImageLoader.Source="{CompiledBinding Entry.Id, Converter={StaticResource EntryIconUriConverter}, Mode=OneWay}" />
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<TextBlock Theme="{StaticResource TitleTextBlockStyle}"
|
||||||
|
MaxLines="3"
|
||||||
|
TextTrimming="CharacterEllipsis"
|
||||||
|
Text="{CompiledBinding Entry.Name, FallbackValue=Title }" />
|
||||||
|
|
||||||
|
<TextBlock Classes="subtitle" TextTrimming="CharacterEllipsis" Text="{CompiledBinding Entry.Author, FallbackValue=Author}" />
|
||||||
|
|
||||||
|
<TextBlock Margin="0 8" TextWrapping="Wrap" Text="{CompiledBinding Entry.Summary, FallbackValue=Summary}" />
|
||||||
|
|
||||||
|
<!-- Categories -->
|
||||||
|
<ItemsControl ItemsSource="{CompiledBinding Entry.Categories}" Margin="0 0 -8 0">
|
||||||
|
<ItemsControl.ItemsPanel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<WrapPanel Orientation="Horizontal"></WrapPanel>
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</ItemsControl.ItemsPanel>
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0 0 8 0">
|
||||||
|
<avalonia:MaterialIcon Kind="{CompiledBinding Icon}" Margin="0 0 3 0"></avalonia:MaterialIcon>
|
||||||
|
<TextBlock Text="{CompiledBinding Name}" TextTrimming="CharacterEllipsis" />
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
|
|
||||||
|
<Border Classes="card-separator"></Border>
|
||||||
|
|
||||||
|
<TextBlock Margin="0 0 0 8">
|
||||||
|
<avalonia:MaterialIcon Kind="Downloads" />
|
||||||
|
<Run Classes="h5" Text="{CompiledBinding Entry.Downloads, FallbackValue=0}" />
|
||||||
|
<Run>downloads</Run>
|
||||||
|
</TextBlock>
|
||||||
|
|
||||||
|
<TextBlock Classes="subtitle"
|
||||||
|
ToolTip.Tip="{CompiledBinding Entry.CreatedAt, Converter={StaticResource DateTimeConverter}}">
|
||||||
|
<avalonia:MaterialIcon Kind="Calendar" />
|
||||||
|
<Run>Created</Run>
|
||||||
|
<Run Text="{CompiledBinding Entry.CreatedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter='humanize'}"></Run>
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock Classes="subtitle"
|
||||||
|
ToolTip.Tip="{CompiledBinding UpdatedAt, Converter={StaticResource DateTimeConverter}}">
|
||||||
|
<avalonia:MaterialIcon Kind="Update" />
|
||||||
|
<Run>Updated</Run>
|
||||||
|
<Run Text="{CompiledBinding UpdatedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter='humanize'}"></Run>
|
||||||
|
</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<Border Classes="card-condensed" Grid.Row="1" Grid.Column="1">
|
<Border Classes="card" VerticalAlignment="Top" IsVisible="{CompiledBinding Entry.LatestRelease, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||||
<TextBlock>Layout details panel</TextBlock>
|
<StackPanel>
|
||||||
|
<TextBlock Theme="{StaticResource SubtitleTextBlockStyle}">Latest release</TextBlock>
|
||||||
|
<Border Classes="card-separator" />
|
||||||
|
<Button HorizontalAlignment="Stretch"
|
||||||
|
HorizontalContentAlignment="Stretch"
|
||||||
|
Command="{CompiledBinding DownloadLatestRelease}">
|
||||||
|
<Grid ColumnDefinitions="Auto,*">
|
||||||
|
<!-- Icon -->
|
||||||
|
<Border Grid.Column="0"
|
||||||
|
CornerRadius="4"
|
||||||
|
Background="{StaticResource SystemAccentColor}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Margin="0 6"
|
||||||
|
Width="50"
|
||||||
|
Height="50"
|
||||||
|
ClipToBounds="True">
|
||||||
|
<avalonia:MaterialIcon Kind="Download"></avalonia:MaterialIcon>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<!-- Body -->
|
||||||
|
<StackPanel Grid.Column="1" Margin="10 0" VerticalAlignment="Center">
|
||||||
|
<TextBlock Text="{CompiledBinding Entry.LatestRelease.Version, FallbackValue=Version}"></TextBlock>
|
||||||
|
<TextBlock Classes="subtitle">
|
||||||
|
<avalonia:MaterialIcon Kind="BoxOutline" />
|
||||||
|
<Run Text="{CompiledBinding Entry.LatestRelease.DownloadSize, Converter={StaticResource BytesToStringConverter}, Mode=OneWay}"></Run>
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock Classes="subtitle"
|
||||||
|
ToolTip.Tip="{CompiledBinding Entry.LatestRelease.CreatedAt, Converter={StaticResource DateTimeConverter}}">
|
||||||
|
<avalonia:MaterialIcon Kind="Calendar" />
|
||||||
|
<Run>Created</Run>
|
||||||
|
<Run Text="{CompiledBinding Entry.LatestRelease.CreatedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter='humanize'}"></Run>
|
||||||
|
</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</StackPanel>
|
||||||
</Border>
|
|
||||||
|
|
||||||
|
<Border Classes="card" Grid.Row="1" Grid.Column="1">
|
||||||
|
<mdxaml:MarkdownScrollViewer Markdown="{CompiledBinding Entry.Description}" MarkdownStyleName="FluentAvalonia">
|
||||||
|
<mdxaml:MarkdownScrollViewer.Styles>
|
||||||
|
<StyleInclude Source="/Styles/Markdown.axaml" />
|
||||||
|
</mdxaml:MarkdownScrollViewer.Styles>
|
||||||
|
</mdxaml:MarkdownScrollViewer>
|
||||||
|
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -1,10 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Reactive;
|
||||||
|
using System.Reactive.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Artemis.Core;
|
||||||
using Artemis.UI.Screens.Workshop.Parameters;
|
using Artemis.UI.Screens.Workshop.Parameters;
|
||||||
using Artemis.UI.Shared;
|
|
||||||
using Artemis.UI.Shared.Routing;
|
using Artemis.UI.Shared.Routing;
|
||||||
|
using Artemis.UI.Shared.Services;
|
||||||
|
using Artemis.UI.Shared.Services.Builders;
|
||||||
|
using Artemis.UI.Shared.Utilities;
|
||||||
using Artemis.WebClient.Workshop;
|
using Artemis.WebClient.Workshop;
|
||||||
|
using Artemis.WebClient.Workshop.DownloadHandlers;
|
||||||
|
using ReactiveUI;
|
||||||
using StrawberryShake;
|
using StrawberryShake;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Layout;
|
namespace Artemis.UI.Screens.Workshop.Layout;
|
||||||
@ -12,19 +19,29 @@ namespace Artemis.UI.Screens.Workshop.Layout;
|
|||||||
public class LayoutDetailsViewModel : RoutableScreen<WorkshopDetailParameters>
|
public class LayoutDetailsViewModel : RoutableScreen<WorkshopDetailParameters>
|
||||||
{
|
{
|
||||||
private readonly IWorkshopClient _client;
|
private readonly IWorkshopClient _client;
|
||||||
|
private readonly INotificationService _notificationService;
|
||||||
|
private readonly IWindowService _windowService;
|
||||||
|
private readonly ObservableAsPropertyHelper<DateTimeOffset?> _updatedAt;
|
||||||
private IGetEntryById_Entry? _entry;
|
private IGetEntryById_Entry? _entry;
|
||||||
|
|
||||||
public LayoutDetailsViewModel(IWorkshopClient client)
|
public LayoutDetailsViewModel(IWorkshopClient client, INotificationService notificationService, IWindowService windowService)
|
||||||
{
|
{
|
||||||
_client = client;
|
_client = client;
|
||||||
|
_notificationService = notificationService;
|
||||||
|
_windowService = windowService;
|
||||||
|
_updatedAt = this.WhenAnyValue(vm => vm.Entry).Select(e => e?.LatestRelease?.CreatedAt ?? e?.CreatedAt).ToProperty(this, vm => vm.UpdatedAt);
|
||||||
|
|
||||||
|
DownloadLatestRelease = ReactiveCommand.CreateFromTask(ExecuteDownloadLatestRelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntryType? EntryType => null;
|
public ReactiveCommand<Unit, Unit> DownloadLatestRelease { get; }
|
||||||
|
|
||||||
|
public DateTimeOffset? UpdatedAt => _updatedAt.Value;
|
||||||
|
|
||||||
public IGetEntryById_Entry? Entry
|
public IGetEntryById_Entry? Entry
|
||||||
{
|
{
|
||||||
get => _entry;
|
get => _entry;
|
||||||
set => RaiseAndSetIfChanged(ref _entry, value);
|
private set => RaiseAndSetIfChanged(ref _entry, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task OnNavigating(WorkshopDetailParameters parameters, NavigationArguments args, CancellationToken cancellationToken)
|
public override async Task OnNavigating(WorkshopDetailParameters parameters, NavigationArguments args, CancellationToken cancellationToken)
|
||||||
@ -40,4 +57,9 @@ public class LayoutDetailsViewModel : RoutableScreen<WorkshopDetailParameters>
|
|||||||
|
|
||||||
Entry = result.Data?.Entry;
|
Entry = result.Data?.Entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Task ExecuteDownloadLatestRelease(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,42 +0,0 @@
|
|||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:layout="clr-namespace:Artemis.UI.Screens.Workshop.Layout"
|
|
||||||
xmlns:pagination="clr-namespace:Artemis.UI.Shared.Pagination;assembly=Artemis.UI.Shared"
|
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
|
||||||
x:Class="Artemis.UI.Screens.Workshop.Layout.LayoutListView"
|
|
||||||
x:DataType="layout:LayoutListViewModel">
|
|
||||||
<Border Classes="router-container">
|
|
||||||
<Grid ColumnDefinitions="300,*" Margin="10" RowDefinitions="*,Auto">
|
|
||||||
<StackPanel Grid.Column="0" Grid.RowSpan="2" Margin="0 0 10 0" VerticalAlignment="Top">
|
|
||||||
<Border Classes="card" VerticalAlignment="Stretch">
|
|
||||||
<StackPanel>
|
|
||||||
<TextBlock Theme="{StaticResource SubtitleTextBlockStyle}">Categories</TextBlock>
|
|
||||||
<Border Classes="card-separator" />
|
|
||||||
<ContentControl Content="{CompiledBinding CategoriesViewModel}"></ContentControl>
|
|
||||||
</StackPanel>
|
|
||||||
</Border>
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
<ProgressBar Grid.Column="1" Grid.Row="0" VerticalAlignment="Top" Margin="0 0 20 0" IsVisible="{CompiledBinding IsLoading}" IsIndeterminate="True"/>
|
|
||||||
<ScrollViewer Grid.Column="1" Grid.Row="0">
|
|
||||||
<ItemsRepeater ItemsSource="{CompiledBinding Entries}" Margin="0 0 20 0">
|
|
||||||
<ItemsRepeater.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<ContentControl Content="{CompiledBinding}" Margin="0 0 0 5"></ContentControl>
|
|
||||||
</DataTemplate>
|
|
||||||
</ItemsRepeater.ItemTemplate>
|
|
||||||
</ItemsRepeater>
|
|
||||||
</ScrollViewer>
|
|
||||||
|
|
||||||
<pagination:Pagination Grid.Column="1"
|
|
||||||
Grid.Row="1"
|
|
||||||
Margin="0 20 0 10"
|
|
||||||
IsVisible="{CompiledBinding ShowPagination}"
|
|
||||||
Value="{CompiledBinding Page}"
|
|
||||||
Maximum="{CompiledBinding TotalPages}"
|
|
||||||
HorizontalAlignment="Center" />
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
</UserControl>
|
|
||||||
@ -2,7 +2,9 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:library="clr-namespace:Artemis.UI.Screens.Workshop.Library"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Artemis.UI.Screens.Workshop.Library.Tabs.SubmissionsDetailView">
|
x:Class="Artemis.UI.Screens.Workshop.Library.SubmissionsDetailView"
|
||||||
Welcome to Avalonia!
|
x:DataType="library:SubmissionsDetailViewModel">
|
||||||
|
<ContentControl Content="{CompiledBinding EntrySpecificationsViewModel}"></ContentControl>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -1,9 +1,6 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Library.Tabs;
|
namespace Artemis.UI.Screens.Workshop.Library;
|
||||||
|
|
||||||
public partial class SubmissionsDetailView : ReactiveUserControl<SubmissionsDetailViewModel>
|
public partial class SubmissionsDetailView : ReactiveUserControl<SubmissionsDetailViewModel>
|
||||||
{
|
{
|
||||||
@ -1,13 +1,21 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Artemis.UI.Screens.Workshop.Entries;
|
||||||
using Artemis.UI.Screens.Workshop.Parameters;
|
using Artemis.UI.Screens.Workshop.Parameters;
|
||||||
using Artemis.UI.Shared.Routing;
|
using Artemis.UI.Shared.Routing;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Library.Tabs;
|
namespace Artemis.UI.Screens.Workshop.Library;
|
||||||
|
|
||||||
public class SubmissionsDetailViewModel : RoutableScreen<WorkshopDetailParameters>
|
public class SubmissionsDetailViewModel : RoutableScreen<WorkshopDetailParameters>
|
||||||
{
|
{
|
||||||
|
public EntrySpecificationsViewModel EntrySpecificationsViewModel { get; }
|
||||||
|
|
||||||
|
public SubmissionsDetailViewModel(EntrySpecificationsViewModel entrySpecificationsViewModel)
|
||||||
|
{
|
||||||
|
EntrySpecificationsViewModel = entrySpecificationsViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
public override Task OnNavigating(WorkshopDetailParameters parameters, NavigationArguments args, CancellationToken cancellationToken)
|
public override Task OnNavigating(WorkshopDetailParameters parameters, NavigationArguments args, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
Console.WriteLine(parameters.EntryId);
|
Console.WriteLine(parameters.EntryId);
|
||||||
@ -21,6 +21,7 @@ public class SubmissionsTabViewModel : RoutableScreen
|
|||||||
private readonly IWorkshopClient _client;
|
private readonly IWorkshopClient _client;
|
||||||
private readonly SourceCache<IGetSubmittedEntries_SubmittedEntries, Guid> _entries;
|
private readonly SourceCache<IGetSubmittedEntries_SubmittedEntries, Guid> _entries;
|
||||||
private readonly IWindowService _windowService;
|
private readonly IWindowService _windowService;
|
||||||
|
private readonly IRouter _router;
|
||||||
private bool _isLoading = true;
|
private bool _isLoading = true;
|
||||||
private bool _workshopReachable;
|
private bool _workshopReachable;
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ public class SubmissionsTabViewModel : RoutableScreen
|
|||||||
{
|
{
|
||||||
_client = client;
|
_client = client;
|
||||||
_windowService = windowService;
|
_windowService = windowService;
|
||||||
|
_router = router;
|
||||||
_entries = new SourceCache<IGetSubmittedEntries_SubmittedEntries, Guid>(e => e.Id);
|
_entries = new SourceCache<IGetSubmittedEntries_SubmittedEntries, Guid>(e => e.Id);
|
||||||
_entries.Connect().Bind(out ReadOnlyObservableCollection<IGetSubmittedEntries_SubmittedEntries> entries).Subscribe();
|
_entries.Connect().Bind(out ReadOnlyObservableCollection<IGetSubmittedEntries_SubmittedEntries> entries).Subscribe();
|
||||||
|
|
||||||
@ -76,9 +78,9 @@ public class SubmissionsTabViewModel : RoutableScreen
|
|||||||
await _windowService.ShowDialogAsync<SubmissionWizardViewModel, bool>();
|
await _windowService.ShowDialogAsync<SubmissionWizardViewModel, bool>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task ExecuteNavigateToEntry(IGetSubmittedEntries_SubmittedEntries entry, CancellationToken cancellationToken)
|
private async Task ExecuteNavigateToEntry(IGetSubmittedEntries_SubmittedEntries entry, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
await _router.Navigate($"workshop/library/submissions/{entry.Id}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task GetEntries(CancellationToken ct)
|
private async Task GetEntries(CancellationToken ct)
|
||||||
@ -103,6 +105,4 @@ public class SubmissionsTabViewModel : RoutableScreen
|
|||||||
IsLoading = false;
|
IsLoading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntryType? EntryType => null;
|
|
||||||
}
|
}
|
||||||
@ -8,7 +8,13 @@
|
|||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Artemis.UI.Screens.Workshop.Library.WorkshopLibraryView"
|
x:Class="Artemis.UI.Screens.Workshop.Library.WorkshopLibraryView"
|
||||||
x:DataType="library:WorkshopLibraryViewModel">
|
x:DataType="library:WorkshopLibraryViewModel">
|
||||||
<controls:NavigationView PaneDisplayMode="Top" MenuItemsSource="{CompiledBinding Tabs}" SelectedItem="{CompiledBinding SelectedTab}">
|
<controls:NavigationView PaneDisplayMode="Top"
|
||||||
|
MenuItemsSource="{CompiledBinding Tabs}"
|
||||||
|
SelectedItem="{CompiledBinding SelectedTab}"
|
||||||
|
IsBackEnabled="{CompiledBinding CanGoBack}"
|
||||||
|
IsSettingsVisible="False"
|
||||||
|
IsBackButtonVisible="True"
|
||||||
|
BackRequested="NavigationView_OnBackRequested">
|
||||||
<controls:NavigationView.Styles>
|
<controls:NavigationView.Styles>
|
||||||
<Styles>
|
<Styles>
|
||||||
<Style Selector="controls|NavigationView:topnavminimal /template/ SplitView Border#ContentGridBorder">
|
<Style Selector="controls|NavigationView:topnavminimal /template/ SplitView Border#ContentGridBorder">
|
||||||
|
|||||||
@ -3,16 +3,13 @@ using System.Reactive.Disposables;
|
|||||||
using Artemis.UI.Shared;
|
using Artemis.UI.Shared;
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using FluentAvalonia.UI.Media.Animation;
|
using FluentAvalonia.UI.Controls;
|
||||||
using FluentAvalonia.UI.Navigation;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Library;
|
namespace Artemis.UI.Screens.Workshop.Library;
|
||||||
|
|
||||||
public partial class WorkshopLibraryView : ReactiveUserControl<WorkshopLibraryViewModel>
|
public partial class WorkshopLibraryView : ReactiveUserControl<WorkshopLibraryViewModel>
|
||||||
{
|
{
|
||||||
private int _lastIndex;
|
|
||||||
|
|
||||||
public WorkshopLibraryView()
|
public WorkshopLibraryView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -21,18 +18,11 @@ public partial class WorkshopLibraryView : ReactiveUserControl<WorkshopLibraryVi
|
|||||||
|
|
||||||
private void Navigate(ViewModelBase viewModel)
|
private void Navigate(ViewModelBase viewModel)
|
||||||
{
|
{
|
||||||
Dispatcher.UIThread.Invoke(() => TabFrame.NavigateFromObject(viewModel, new FrameNavigationOptions {TransitionInfoOverride = GetTransitionInfo()}));
|
Dispatcher.UIThread.Invoke(() => TabFrame.NavigateFromObject(viewModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
private SlideNavigationTransitionInfo GetTransitionInfo()
|
private void NavigationView_OnBackRequested(object? sender, NavigationViewBackRequestedEventArgs e)
|
||||||
{
|
{
|
||||||
if (ViewModel?.SelectedTab == null)
|
ViewModel?.GoBack();
|
||||||
return new SlideNavigationTransitionInfo();
|
|
||||||
|
|
||||||
SlideNavigationTransitionEffect effect = ViewModel.Tabs.IndexOf(ViewModel.SelectedTab) > _lastIndex ? SlideNavigationTransitionEffect.FromRight : SlideNavigationTransitionEffect.FromLeft;
|
|
||||||
SlideNavigationTransitionInfo info = new() {Effect = effect};
|
|
||||||
_lastIndex = ViewModel.Tabs.IndexOf(ViewModel.SelectedTab);
|
|
||||||
|
|
||||||
return info;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4,35 +4,43 @@ using System.Reactive.Disposables;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Artemis.UI.Routing;
|
using Artemis.UI.Routing;
|
||||||
using Artemis.UI.Shared;
|
|
||||||
using Artemis.UI.Shared.Routing;
|
using Artemis.UI.Shared.Routing;
|
||||||
using Artemis.WebClient.Workshop;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Reactive.Linq;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Library;
|
namespace Artemis.UI.Screens.Workshop.Library;
|
||||||
|
|
||||||
public class WorkshopLibraryViewModel : RoutableHostScreen<RoutableScreen>
|
public class WorkshopLibraryViewModel : RoutableHostScreen<RoutableScreen>
|
||||||
{
|
{
|
||||||
|
private readonly IRouter _router;
|
||||||
private RouteViewModel? _selectedTab;
|
private RouteViewModel? _selectedTab;
|
||||||
|
private ObservableAsPropertyHelper<bool>? _canGoBack;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public WorkshopLibraryViewModel(IRouter router)
|
public WorkshopLibraryViewModel(IRouter router)
|
||||||
{
|
{
|
||||||
|
_router = router;
|
||||||
|
|
||||||
Tabs = new ObservableCollection<RouteViewModel>
|
Tabs = new ObservableCollection<RouteViewModel>
|
||||||
{
|
{
|
||||||
new("workshop/library/installed", "Installed"),
|
new("Installed", "workshop/library/installed"),
|
||||||
new("workshop/library/submissions", "Submissions")
|
new("Submissions", "workshop/library/submissions")
|
||||||
};
|
};
|
||||||
|
|
||||||
// Navigate on tab change
|
this.WhenActivated(d =>
|
||||||
this.WhenActivated(d => this.WhenAnyValue(vm => vm.SelectedTab)
|
{
|
||||||
.WhereNotNull()
|
// Show back button on details page
|
||||||
.Subscribe(s => router.Navigate(s.Path, new RouterNavigationOptions {IgnoreOnPartialMatch = true}))
|
_canGoBack = _router.CurrentPath.Select(p => p != null && p.StartsWith("workshop/library/submissions/")).ToProperty(this, vm => vm.CanGoBack).DisposeWith(d);
|
||||||
.DisposeWith(d));
|
// Navigate on tab change
|
||||||
|
this.WhenAnyValue(vm => vm.SelectedTab)
|
||||||
|
.WhereNotNull()
|
||||||
|
.Subscribe(s => router.Navigate(s.Path, new RouterNavigationOptions {IgnoreOnPartialMatch = true}))
|
||||||
|
.DisposeWith(d);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntryType? EntryType => null;
|
public bool CanGoBack => _canGoBack?.Value ?? false;
|
||||||
public ObservableCollection<RouteViewModel> Tabs { get; }
|
public ObservableCollection<RouteViewModel> Tabs { get; }
|
||||||
|
|
||||||
public RouteViewModel? SelectedTab
|
public RouteViewModel? SelectedTab
|
||||||
@ -47,4 +55,9 @@ public class WorkshopLibraryViewModel : RoutableHostScreen<RoutableScreen>
|
|||||||
if (SelectedTab == null)
|
if (SelectedTab == null)
|
||||||
await args.Router.Navigate(Tabs.First().Path);
|
await args.Router.Navigate(Tabs.First().Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void GoBack()
|
||||||
|
{
|
||||||
|
_router.GoBack();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -18,118 +18,116 @@
|
|||||||
<converters:DateTimeConverter x:Key="DateTimeConverter" />
|
<converters:DateTimeConverter x:Key="DateTimeConverter" />
|
||||||
<converters1:BytesToStringConverter x:Key="BytesToStringConverter" />
|
<converters1:BytesToStringConverter x:Key="BytesToStringConverter" />
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Border Classes="router-container">
|
<Grid ColumnDefinitions="300,*" RowDefinitions="Auto,*">
|
||||||
<Grid ColumnDefinitions="300,*" RowDefinitions="Auto,*" Margin="10">
|
<StackPanel Grid.Row="1" Grid.Column="0" Margin="0 0 10 0" Spacing="10">
|
||||||
<StackPanel Grid.Row="1" Grid.Column="0" Margin="0 0 10 0" Spacing="10">
|
<Border Classes="card" VerticalAlignment="Top">
|
||||||
<Border Classes="card" VerticalAlignment="Top">
|
<StackPanel>
|
||||||
<StackPanel>
|
<Border CornerRadius="6"
|
||||||
<Border CornerRadius="6"
|
HorizontalAlignment="Left"
|
||||||
HorizontalAlignment="Left"
|
Margin="0 0 10 0"
|
||||||
Margin="0 0 10 0"
|
Width="80"
|
||||||
Width="80"
|
Height="80"
|
||||||
Height="80"
|
ClipToBounds="True">
|
||||||
ClipToBounds="True">
|
<Image Stretch="UniformToFill" il:ImageLoader.Source="{CompiledBinding Entry.Id, Converter={StaticResource EntryIconUriConverter}, Mode=OneWay}" />
|
||||||
<Image Stretch="UniformToFill" il:ImageLoader.Source="{CompiledBinding Entry.Id, Converter={StaticResource EntryIconUriConverter}, Mode=OneWay}" />
|
</Border>
|
||||||
</Border>
|
|
||||||
|
|
||||||
<TextBlock Theme="{StaticResource TitleTextBlockStyle}"
|
<TextBlock Theme="{StaticResource TitleTextBlockStyle}"
|
||||||
MaxLines="3"
|
MaxLines="3"
|
||||||
TextTrimming="CharacterEllipsis"
|
TextTrimming="CharacterEllipsis"
|
||||||
Text="{CompiledBinding Entry.Name, FallbackValue=Title }" />
|
Text="{CompiledBinding Entry.Name, FallbackValue=Title }" />
|
||||||
|
|
||||||
<TextBlock Classes="subtitle" TextTrimming="CharacterEllipsis" Text="{CompiledBinding Entry.Author, FallbackValue=Author}" />
|
<TextBlock Classes="subtitle" TextTrimming="CharacterEllipsis" Text="{CompiledBinding Entry.Author, FallbackValue=Author}" />
|
||||||
|
|
||||||
<TextBlock Margin="0 8" TextWrapping="Wrap" Text="{CompiledBinding Entry.Summary, FallbackValue=Summary}" />
|
<TextBlock Margin="0 8" TextWrapping="Wrap" Text="{CompiledBinding Entry.Summary, FallbackValue=Summary}" />
|
||||||
|
|
||||||
<!-- Categories -->
|
<!-- Categories -->
|
||||||
<ItemsControl ItemsSource="{CompiledBinding Entry.Categories}" Margin="0 0 -8 0">
|
<ItemsControl ItemsSource="{CompiledBinding Entry.Categories}" Margin="0 0 -8 0">
|
||||||
<ItemsControl.ItemsPanel>
|
<ItemsControl.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<WrapPanel Orientation="Horizontal"></WrapPanel>
|
<WrapPanel Orientation="Horizontal"></WrapPanel>
|
||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</ItemsControl.ItemsPanel>
|
</ItemsControl.ItemsPanel>
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel Orientation="Horizontal" Margin="0 0 8 0">
|
<StackPanel Orientation="Horizontal" Margin="0 0 8 0">
|
||||||
<avalonia:MaterialIcon Kind="{CompiledBinding Icon}" Margin="0 0 3 0"></avalonia:MaterialIcon>
|
<avalonia:MaterialIcon Kind="{CompiledBinding Icon}" Margin="0 0 3 0"></avalonia:MaterialIcon>
|
||||||
<TextBlock Text="{CompiledBinding Name}" TextTrimming="CharacterEllipsis" />
|
<TextBlock Text="{CompiledBinding Name}" TextTrimming="CharacterEllipsis" />
|
||||||
</StackPanel>
|
|
||||||
</DataTemplate>
|
|
||||||
</ItemsControl.ItemTemplate>
|
|
||||||
</ItemsControl>
|
|
||||||
|
|
||||||
<Border Classes="card-separator"></Border>
|
|
||||||
|
|
||||||
<TextBlock Margin="0 0 0 8">
|
|
||||||
<avalonia:MaterialIcon Kind="Downloads" />
|
|
||||||
<Run Classes="h5" Text="{CompiledBinding Entry.Downloads, FallbackValue=0}" />
|
|
||||||
<Run>downloads</Run>
|
|
||||||
</TextBlock>
|
|
||||||
|
|
||||||
<TextBlock Classes="subtitle"
|
|
||||||
ToolTip.Tip="{CompiledBinding Entry.CreatedAt, Converter={StaticResource DateTimeConverter}}">
|
|
||||||
<avalonia:MaterialIcon Kind="Calendar" />
|
|
||||||
<Run>Created</Run>
|
|
||||||
<Run Text="{CompiledBinding Entry.CreatedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter='humanize'}"></Run>
|
|
||||||
</TextBlock>
|
|
||||||
<TextBlock Classes="subtitle"
|
|
||||||
ToolTip.Tip="{CompiledBinding UpdatedAt, Converter={StaticResource DateTimeConverter}}">
|
|
||||||
<avalonia:MaterialIcon Kind="Update" />
|
|
||||||
<Run>Updated</Run>
|
|
||||||
<Run Text="{CompiledBinding UpdatedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter='humanize'}"></Run>
|
|
||||||
</TextBlock>
|
|
||||||
</StackPanel>
|
|
||||||
</Border>
|
|
||||||
|
|
||||||
<Border Classes="card" VerticalAlignment="Top" IsVisible="{CompiledBinding Entry.LatestRelease, Converter={x:Static ObjectConverters.IsNotNull}}">
|
|
||||||
<StackPanel>
|
|
||||||
<TextBlock Theme="{StaticResource SubtitleTextBlockStyle}">Latest release</TextBlock>
|
|
||||||
<Border Classes="card-separator" />
|
|
||||||
<Button HorizontalAlignment="Stretch"
|
|
||||||
HorizontalContentAlignment="Stretch"
|
|
||||||
Command="{CompiledBinding DownloadLatestRelease}">
|
|
||||||
<Grid ColumnDefinitions="Auto,*">
|
|
||||||
<!-- Icon -->
|
|
||||||
<Border Grid.Column="0"
|
|
||||||
CornerRadius="4"
|
|
||||||
Background="{StaticResource SystemAccentColor}"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Margin="0 6"
|
|
||||||
Width="50"
|
|
||||||
Height="50"
|
|
||||||
ClipToBounds="True">
|
|
||||||
<avalonia:MaterialIcon Kind="Download"></avalonia:MaterialIcon>
|
|
||||||
</Border>
|
|
||||||
|
|
||||||
<!-- Body -->
|
|
||||||
<StackPanel Grid.Column="1" Margin="10 0" VerticalAlignment="Center">
|
|
||||||
<TextBlock Text="{CompiledBinding Entry.LatestRelease.Version, FallbackValue=Version}"></TextBlock>
|
|
||||||
<TextBlock Classes="subtitle">
|
|
||||||
<avalonia:MaterialIcon Kind="BoxOutline" />
|
|
||||||
<Run Text="{CompiledBinding Entry.LatestRelease.DownloadSize, Converter={StaticResource BytesToStringConverter}, Mode=OneWay}"></Run>
|
|
||||||
</TextBlock>
|
|
||||||
<TextBlock Classes="subtitle"
|
|
||||||
ToolTip.Tip="{CompiledBinding Entry.LatestRelease.CreatedAt, Converter={StaticResource DateTimeConverter}}">
|
|
||||||
<avalonia:MaterialIcon Kind="Calendar" />
|
|
||||||
<Run>Created</Run>
|
|
||||||
<Run Text="{CompiledBinding Entry.LatestRelease.CreatedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter='humanize'}"></Run>
|
|
||||||
</TextBlock>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</DataTemplate>
|
||||||
</Button>
|
</ItemsControl.ItemTemplate>
|
||||||
</StackPanel>
|
</ItemsControl>
|
||||||
</Border>
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
|
<Border Classes="card-separator"></Border>
|
||||||
|
|
||||||
<Border Classes="card" Grid.Row="1" Grid.Column="1">
|
<TextBlock Margin="0 0 0 8">
|
||||||
<mdxaml:MarkdownScrollViewer Markdown="{CompiledBinding Entry.Description}" MarkdownStyleName="FluentAvalonia">
|
<avalonia:MaterialIcon Kind="Downloads" />
|
||||||
<mdxaml:MarkdownScrollViewer.Styles>
|
<Run Classes="h5" Text="{CompiledBinding Entry.Downloads, FallbackValue=0}" />
|
||||||
<StyleInclude Source="/Styles/Markdown.axaml" />
|
<Run>downloads</Run>
|
||||||
</mdxaml:MarkdownScrollViewer.Styles>
|
</TextBlock>
|
||||||
</mdxaml:MarkdownScrollViewer>
|
|
||||||
|
|
||||||
|
<TextBlock Classes="subtitle"
|
||||||
|
ToolTip.Tip="{CompiledBinding Entry.CreatedAt, Converter={StaticResource DateTimeConverter}}">
|
||||||
|
<avalonia:MaterialIcon Kind="Calendar" />
|
||||||
|
<Run>Created</Run>
|
||||||
|
<Run Text="{CompiledBinding Entry.CreatedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter='humanize'}"></Run>
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock Classes="subtitle"
|
||||||
|
ToolTip.Tip="{CompiledBinding UpdatedAt, Converter={StaticResource DateTimeConverter}}">
|
||||||
|
<avalonia:MaterialIcon Kind="Update" />
|
||||||
|
<Run>Updated</Run>
|
||||||
|
<Run Text="{CompiledBinding UpdatedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter='humanize'}"></Run>
|
||||||
|
</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
|
||||||
</Border>
|
<Border Classes="card" VerticalAlignment="Top" IsVisible="{CompiledBinding Entry.LatestRelease, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock Theme="{StaticResource SubtitleTextBlockStyle}">Latest release</TextBlock>
|
||||||
|
<Border Classes="card-separator" />
|
||||||
|
<Button HorizontalAlignment="Stretch"
|
||||||
|
HorizontalContentAlignment="Stretch"
|
||||||
|
Command="{CompiledBinding DownloadLatestRelease}">
|
||||||
|
<Grid ColumnDefinitions="Auto,*">
|
||||||
|
<!-- Icon -->
|
||||||
|
<Border Grid.Column="0"
|
||||||
|
CornerRadius="4"
|
||||||
|
Background="{StaticResource SystemAccentColor}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Margin="0 6"
|
||||||
|
Width="50"
|
||||||
|
Height="50"
|
||||||
|
ClipToBounds="True">
|
||||||
|
<avalonia:MaterialIcon Kind="Download"></avalonia:MaterialIcon>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<!-- Body -->
|
||||||
|
<StackPanel Grid.Column="1" Margin="10 0" VerticalAlignment="Center">
|
||||||
|
<TextBlock Text="{CompiledBinding Entry.LatestRelease.Version, FallbackValue=Version}"></TextBlock>
|
||||||
|
<TextBlock Classes="subtitle">
|
||||||
|
<avalonia:MaterialIcon Kind="BoxOutline" />
|
||||||
|
<Run Text="{CompiledBinding Entry.LatestRelease.DownloadSize, Converter={StaticResource BytesToStringConverter}, Mode=OneWay}"></Run>
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock Classes="subtitle"
|
||||||
|
ToolTip.Tip="{CompiledBinding Entry.LatestRelease.CreatedAt, Converter={StaticResource DateTimeConverter}}">
|
||||||
|
<avalonia:MaterialIcon Kind="Calendar" />
|
||||||
|
<Run>Created</Run>
|
||||||
|
<Run Text="{CompiledBinding Entry.LatestRelease.CreatedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter='humanize'}"></Run>
|
||||||
|
</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
|
<Border Classes="card" Grid.Row="1" Grid.Column="1">
|
||||||
|
<mdxaml:MarkdownScrollViewer Markdown="{CompiledBinding Entry.Description}" MarkdownStyleName="FluentAvalonia">
|
||||||
|
<mdxaml:MarkdownScrollViewer.Styles>
|
||||||
|
<StyleInclude Source="/Styles/Markdown.axaml" />
|
||||||
|
</mdxaml:MarkdownScrollViewer.Styles>
|
||||||
|
</mdxaml:MarkdownScrollViewer>
|
||||||
|
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -5,7 +5,6 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Artemis.Core;
|
using Artemis.Core;
|
||||||
using Artemis.UI.Screens.Workshop.Parameters;
|
using Artemis.UI.Screens.Workshop.Parameters;
|
||||||
using Artemis.UI.Shared;
|
|
||||||
using Artemis.UI.Shared.Routing;
|
using Artemis.UI.Shared.Routing;
|
||||||
using Artemis.UI.Shared.Services;
|
using Artemis.UI.Shared.Services;
|
||||||
using Artemis.UI.Shared.Services.Builders;
|
using Artemis.UI.Shared.Services.Builders;
|
||||||
@ -77,6 +76,4 @@ public class ProfileDetailsViewModel : RoutableScreen<WorkshopDetailParameters>
|
|||||||
else
|
else
|
||||||
_notificationService.CreateNotification().WithTitle("Failed to install profile").WithMessage(result.Message).WithSeverity(NotificationSeverity.Error).Show();
|
_notificationService.CreateNotification().WithTitle("Failed to install profile").WithMessage(result.Message).WithSeverity(NotificationSeverity.Error).Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntryType? EntryType => null;
|
|
||||||
}
|
}
|
||||||
@ -1,43 +0,0 @@
|
|||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:profile="clr-namespace:Artemis.UI.Screens.Workshop.Profile"
|
|
||||||
xmlns:pagination="clr-namespace:Artemis.UI.Shared.Pagination;assembly=Artemis.UI.Shared"
|
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
|
||||||
x:Class="Artemis.UI.Screens.Workshop.Profile.ProfileListView"
|
|
||||||
x:DataType="profile:ProfileListViewModel">
|
|
||||||
<Border Classes="router-container">
|
|
||||||
<Grid ColumnDefinitions="300,*" Margin="10" RowDefinitions="*,Auto">
|
|
||||||
<StackPanel Grid.Column="0" Grid.RowSpan="2" Margin="0 0 10 0" VerticalAlignment="Top">
|
|
||||||
<Border Classes="card" VerticalAlignment="Stretch">
|
|
||||||
<StackPanel>
|
|
||||||
<TextBlock Theme="{StaticResource SubtitleTextBlockStyle}">Categories</TextBlock>
|
|
||||||
<Border Classes="card-separator" />
|
|
||||||
<ContentControl Content="{CompiledBinding CategoriesViewModel}"></ContentControl>
|
|
||||||
</StackPanel>
|
|
||||||
</Border>
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
<ProgressBar Grid.Column="1" Grid.Row="0" VerticalAlignment="Top" Margin="0 0 20 0" IsVisible="{CompiledBinding IsLoading}" IsIndeterminate="True"/>
|
|
||||||
|
|
||||||
<ScrollViewer Grid.Column="1" Grid.Row="0">
|
|
||||||
<ItemsRepeater ItemsSource="{CompiledBinding Entries}" Margin="0 0 20 0">
|
|
||||||
<ItemsRepeater.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<ContentControl Content="{CompiledBinding}" Margin="0 0 0 5"></ContentControl>
|
|
||||||
</DataTemplate>
|
|
||||||
</ItemsRepeater.ItemTemplate>
|
|
||||||
</ItemsRepeater>
|
|
||||||
</ScrollViewer>
|
|
||||||
|
|
||||||
<pagination:Pagination Grid.Column="1"
|
|
||||||
Grid.Row="1"
|
|
||||||
Margin="0 20 0 10"
|
|
||||||
IsVisible="{CompiledBinding ShowPagination}"
|
|
||||||
Value="{CompiledBinding Page}"
|
|
||||||
Maximum="{CompiledBinding TotalPages}"
|
|
||||||
HorizontalAlignment="Center" />
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
</UserControl>
|
|
||||||
@ -53,9 +53,9 @@ public class SearchViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
string? url = null;
|
string? url = null;
|
||||||
if (searchResult.Entry.EntryType == WebClient.Workshop.EntryType.Profile)
|
if (searchResult.Entry.EntryType == WebClient.Workshop.EntryType.Profile)
|
||||||
url = $"workshop/profiles/{searchResult.Entry.Id}";
|
url = $"workshop/entries/profiles/{searchResult.Entry.Id}";
|
||||||
if (searchResult.Entry.EntryType == WebClient.Workshop.EntryType.Layout)
|
if (searchResult.Entry.EntryType == WebClient.Workshop.EntryType.Layout)
|
||||||
url = $"workshop/layouts/{searchResult.Entry.Id}";
|
url = $"workshop/entries/layouts/{searchResult.Entry.Id}";
|
||||||
|
|
||||||
if (url != null)
|
if (url != null)
|
||||||
Task.Run(() => _router.Navigate(url));
|
Task.Run(() => _router.Navigate(url));
|
||||||
|
|||||||
@ -3,9 +3,6 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:steps="clr-namespace:Artemis.UI.Screens.Workshop.SubmissionWizard.Steps"
|
xmlns:steps="clr-namespace:Artemis.UI.Screens.Workshop.SubmissionWizard.Steps"
|
||||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
|
||||||
xmlns:categories="clr-namespace:Artemis.UI.Screens.Workshop.Categories"
|
|
||||||
xmlns:tagsInput="clr-namespace:Artemis.UI.Shared.TagsInput;assembly=Artemis.UI.Shared"
|
|
||||||
mc:Ignorable="d" d:DesignWidth="970" d:DesignHeight="625"
|
mc:Ignorable="d" d:DesignWidth="970" d:DesignHeight="625"
|
||||||
x:Class="Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.SpecificationsStepView"
|
x:Class="Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.SpecificationsStepView"
|
||||||
x:DataType="steps:SpecificationsStepViewModel">
|
x:DataType="steps:SpecificationsStepViewModel">
|
||||||
@ -24,104 +21,8 @@
|
|||||||
</TextBlock>
|
</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<ScrollViewer Grid.Row="1" Padding="0 0 20 0">
|
<ScrollViewer Grid.Row="1" Padding="0 0 20 0" Margin="0 20 0 0">
|
||||||
<StackPanel>
|
<ContentControl Content="{CompiledBinding EntrySpecificationsViewModel}"></ContentControl>
|
||||||
<StackPanel.Styles>
|
|
||||||
<Styles>
|
|
||||||
<Style Selector="TextBlock">
|
|
||||||
<Setter Property="TextWrapping" Value="Wrap"></Setter>
|
|
||||||
</Style>
|
|
||||||
<Style Selector="Label">
|
|
||||||
<Setter Property="Margin" Value="0 8 0 0"></Setter>
|
|
||||||
</Style>
|
|
||||||
</Styles>
|
|
||||||
</StackPanel.Styles>
|
|
||||||
|
|
||||||
<Grid ColumnDefinitions="103,*">
|
|
||||||
<StackPanel Grid.Column="0" Width="95">
|
|
||||||
|
|
||||||
|
|
||||||
<Label Target="Name" Margin="0 15 0 0">Icon</Label>
|
|
||||||
|
|
||||||
<Button Width="95"
|
|
||||||
Height="95"
|
|
||||||
Command="{CompiledBinding SelectIcon}"
|
|
||||||
IsVisible="{CompiledBinding IconBitmap, Converter={x:Static ObjectConverters.IsNull}}">
|
|
||||||
<avalonia:MaterialIcon Kind="FolderOpen"
|
|
||||||
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
|
|
||||||
Width="30"
|
|
||||||
Height="30" />
|
|
||||||
</Button>
|
|
||||||
<Border IsVisible="{CompiledBinding IconBitmap, Converter={x:Static ObjectConverters.IsNotNull}}"
|
|
||||||
ClipToBounds="True"
|
|
||||||
CornerRadius="6"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Width="95"
|
|
||||||
Height="95">
|
|
||||||
<Panel>
|
|
||||||
<Image Source="{CompiledBinding IconBitmap}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"></Image>
|
|
||||||
<Button Classes="icon-button image-picker"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
Cursor="Hand"
|
|
||||||
Command="{CompiledBinding SelectIcon}"
|
|
||||||
ToolTip.Tip="Click to browse">
|
|
||||||
</Button>
|
|
||||||
</Panel>
|
|
||||||
|
|
||||||
</Border>
|
|
||||||
<TextBlock Foreground="{DynamicResource SystemFillColorCriticalBrush}" Margin="2 0"
|
|
||||||
IsVisible="{CompiledBinding !IconValid}"
|
|
||||||
TextWrapping="Wrap">
|
|
||||||
Icon required
|
|
||||||
</TextBlock>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel Grid.Column="1">
|
|
||||||
<Label Target="Name" Margin="0 15 0 0">Name</Label>
|
|
||||||
<TextBox Name="Name" Text="{CompiledBinding Name}"></TextBox>
|
|
||||||
|
|
||||||
<Label Target="Summary" Margin="0 5 0 0">Summary</Label>
|
|
||||||
<TextBox Name="Summary" Text="{CompiledBinding Summary}"></TextBox>
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <TextBlock Theme="{StaticResource CaptionTextBlockStyle}">A short summary of your submission's description</TextBlock> -->
|
|
||||||
|
|
||||||
<Label Margin="0 28 0 0">Categories</Label>
|
|
||||||
<ItemsControl ItemsSource="{CompiledBinding Categories}">
|
|
||||||
<ItemsControl.ItemsPanel>
|
|
||||||
<ItemsPanelTemplate>
|
|
||||||
<WrapPanel />
|
|
||||||
</ItemsPanelTemplate>
|
|
||||||
</ItemsControl.ItemsPanel>
|
|
||||||
<ItemsControl.ItemTemplate>
|
|
||||||
<DataTemplate DataType="categories:CategoryViewModel">
|
|
||||||
<ToggleButton IsChecked="{CompiledBinding IsSelected}" Margin="0 0 5 5">
|
|
||||||
<StackPanel Orientation="Horizontal" Spacing="5">
|
|
||||||
<avalonia:MaterialIcon Kind="{CompiledBinding Icon}" />
|
|
||||||
<TextBlock Text="{CompiledBinding Name}" VerticalAlignment="Center" />
|
|
||||||
</StackPanel>
|
|
||||||
</ToggleButton>
|
|
||||||
</DataTemplate>
|
|
||||||
</ItemsControl.ItemTemplate>
|
|
||||||
</ItemsControl>
|
|
||||||
<TextBlock Foreground="{DynamicResource SystemFillColorCriticalBrush}" Margin="2 0" IsVisible="{CompiledBinding !CategoriesValid}">
|
|
||||||
At least one category is required
|
|
||||||
</TextBlock>
|
|
||||||
<!-- <TextBlock Theme="{StaticResource CaptionTextBlockStyle}" Margin="0 -5 0 0">Pick one or more categories that suit your submission</TextBlock> -->
|
|
||||||
|
|
||||||
<Label>Tags</Label>
|
|
||||||
<tagsInput:TagsInput Tags="{CompiledBinding Tags}" />
|
|
||||||
<!-- <TextBlock Theme="{StaticResource CaptionTextBlockStyle}" Margin="0 -5 0 0">Tags are used by the search engine, use keywords that match your submission</TextBlock> -->
|
|
||||||
|
|
||||||
<Label Target="Description" Margin="0 28 0 0">Description</Label>
|
|
||||||
<TextBox AcceptsReturn="True" Name="Description" Text="{CompiledBinding Description}" Height="250"></TextBox>
|
|
||||||
<TextBlock Theme="{StaticResource CaptionTextBlockStyle}">Markdown supported, a better editor planned</TextBlock>
|
|
||||||
</StackPanel>
|
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -1,93 +1,42 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Reactive.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Artemis.UI.Extensions;
|
using Artemis.UI.Extensions;
|
||||||
using Artemis.UI.Screens.Workshop.Categories;
|
using Artemis.UI.Screens.Workshop.Entries;
|
||||||
using Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Profile;
|
using Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Profile;
|
||||||
using Artemis.UI.Shared.Services;
|
|
||||||
using Artemis.WebClient.Workshop;
|
using Artemis.WebClient.Workshop;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
using DynamicData.Aggregation;
|
|
||||||
using DynamicData.Binding;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Validation.Extensions;
|
using ReactiveUI.Validation.Extensions;
|
||||||
using ReactiveUI.Validation.Helpers;
|
|
||||||
using StrawberryShake;
|
|
||||||
using Bitmap = Avalonia.Media.Imaging.Bitmap;
|
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
|
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
|
||||||
|
|
||||||
public class SpecificationsStepViewModel : SubmissionViewModel
|
public class SpecificationsStepViewModel : SubmissionViewModel
|
||||||
{
|
{
|
||||||
private readonly IWindowService _windowService;
|
public SpecificationsStepViewModel(EntrySpecificationsViewModel entrySpecificationsViewModel)
|
||||||
private ObservableAsPropertyHelper<bool>? _categoriesValid;
|
|
||||||
private ObservableAsPropertyHelper<bool>? _iconValid;
|
|
||||||
private string _description = string.Empty;
|
|
||||||
private string _name = string.Empty;
|
|
||||||
private string _summary = string.Empty;
|
|
||||||
private Bitmap? _iconBitmap;
|
|
||||||
|
|
||||||
public SpecificationsStepViewModel(IWorkshopClient workshopClient, IWindowService windowService)
|
|
||||||
{
|
{
|
||||||
_windowService = windowService;
|
EntrySpecificationsViewModel = entrySpecificationsViewModel;
|
||||||
GoBack = ReactiveCommand.Create(ExecuteGoBack);
|
GoBack = ReactiveCommand.Create(ExecuteGoBack);
|
||||||
Continue = ReactiveCommand.Create(ExecuteContinue, ValidationContext.Valid);
|
Continue = ReactiveCommand.Create(ExecuteContinue, EntrySpecificationsViewModel.ValidationContext.Valid);
|
||||||
SelectIcon = ReactiveCommand.CreateFromTask(ExecuteSelectIcon);
|
|
||||||
|
|
||||||
this.WhenActivated(d =>
|
this.WhenActivated((CompositeDisposable d) =>
|
||||||
{
|
{
|
||||||
DisplayName = $"{State.EntryType} Information";
|
DisplayName = $"{State.EntryType} Information";
|
||||||
|
|
||||||
// Load categories
|
|
||||||
Observable.FromAsync(workshopClient.GetCategories.ExecuteAsync).Subscribe(PopulateCategories).DisposeWith(d);
|
|
||||||
|
|
||||||
// Apply the state
|
// Apply the state
|
||||||
ApplyFromState();
|
ApplyFromState();
|
||||||
|
|
||||||
this.ClearValidationRules();
|
EntrySpecificationsViewModel.ClearValidationRules();
|
||||||
Disposable.Create(ClearIcon).DisposeWith(d);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EntrySpecificationsViewModel EntrySpecificationsViewModel { get; }
|
||||||
public override ReactiveCommand<Unit, Unit> Continue { get; }
|
public override ReactiveCommand<Unit, Unit> Continue { get; }
|
||||||
public override ReactiveCommand<Unit, Unit> GoBack { get; }
|
public override ReactiveCommand<Unit, Unit> GoBack { get; }
|
||||||
public ReactiveCommand<Unit, Unit> SelectIcon { get; }
|
|
||||||
|
|
||||||
public ObservableCollection<CategoryViewModel> Categories { get; } = new();
|
|
||||||
public ObservableCollection<string> Tags { get; } = new();
|
|
||||||
public bool CategoriesValid => _categoriesValid?.Value ?? true;
|
|
||||||
public bool IconValid => _iconValid?.Value ?? true;
|
|
||||||
|
|
||||||
public string Name
|
|
||||||
{
|
|
||||||
get => _name;
|
|
||||||
set => RaiseAndSetIfChanged(ref _name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Summary
|
|
||||||
{
|
|
||||||
get => _summary;
|
|
||||||
set => RaiseAndSetIfChanged(ref _summary, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Description
|
|
||||||
{
|
|
||||||
get => _description;
|
|
||||||
set => RaiseAndSetIfChanged(ref _description, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bitmap? IconBitmap
|
|
||||||
{
|
|
||||||
get => _iconBitmap;
|
|
||||||
set => RaiseAndSetIfChanged(ref _iconBitmap, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ExecuteGoBack()
|
private void ExecuteGoBack()
|
||||||
{
|
{
|
||||||
@ -110,101 +59,61 @@ public class SpecificationsStepViewModel : SubmissionViewModel
|
|||||||
|
|
||||||
private void ExecuteContinue()
|
private void ExecuteContinue()
|
||||||
{
|
{
|
||||||
if (!ValidationContext.Validations.Any())
|
if (!EntrySpecificationsViewModel.ValidationContext.Validations.Any())
|
||||||
{
|
{
|
||||||
// The ValidationContext seems to update asynchronously, so stop and schedule a retry
|
// The ValidationContext seems to update asynchronously, so stop and schedule a retry
|
||||||
SetupDataValidation();
|
EntrySpecificationsViewModel.SetupDataValidation();
|
||||||
Dispatcher.UIThread.Post(ExecuteContinue);
|
Dispatcher.UIThread.Post(ExecuteContinue);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplyToState();
|
ApplyToState();
|
||||||
|
|
||||||
if (!ValidationContext.GetIsValid())
|
if (!EntrySpecificationsViewModel.ValidationContext.GetIsValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
State.ChangeScreen<SubmitStepViewModel>();
|
State.ChangeScreen<SubmitStepViewModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ExecuteSelectIcon()
|
|
||||||
{
|
|
||||||
string[]? result = await _windowService.CreateOpenFileDialog()
|
|
||||||
.HavingFilter(f => f.WithExtension("png").WithExtension("jpg").WithExtension("bmp").WithName("Bitmap image"))
|
|
||||||
.ShowAsync();
|
|
||||||
|
|
||||||
if (result == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
IconBitmap?.Dispose();
|
|
||||||
IconBitmap = BitmapExtensions.LoadAndResize(result[0], 128);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ClearIcon()
|
|
||||||
{
|
|
||||||
IconBitmap?.Dispose();
|
|
||||||
IconBitmap = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PopulateCategories(IOperationResult<IGetCategoriesResult> result)
|
|
||||||
{
|
|
||||||
Categories.Clear();
|
|
||||||
if (result.Data != null)
|
|
||||||
Categories.AddRange(result.Data.Categories.Select(c => new CategoryViewModel(c) {IsSelected = State.Categories.Contains(c.Id)}));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetupDataValidation()
|
|
||||||
{
|
|
||||||
// Hopefully this can be avoided in the future
|
|
||||||
// https://github.com/reactiveui/ReactiveUI.Validation/discussions/558
|
|
||||||
this.ValidationRule(vm => vm.Name, s => !string.IsNullOrWhiteSpace(s), "Name is required");
|
|
||||||
this.ValidationRule(vm => vm.Summary, s => !string.IsNullOrWhiteSpace(s), "Summary is required");
|
|
||||||
this.ValidationRule(vm => vm.Description, s => !string.IsNullOrWhiteSpace(s), "Description is required");
|
|
||||||
|
|
||||||
// These don't use inputs that support validation messages, do so manually
|
|
||||||
ValidationHelper iconRule = this.ValidationRule(vm => vm.IconBitmap, s => s != null, "Icon required");
|
|
||||||
ValidationHelper categoriesRule = this.ValidationRule(vm => vm.Categories, Categories.ToObservableChangeSet().AutoRefresh(c => c.IsSelected).Filter(c => c.IsSelected).IsNotEmpty(),
|
|
||||||
"At least one category must be selected"
|
|
||||||
);
|
|
||||||
_iconValid = iconRule.ValidationChanged.Select(c => c.IsValid).ToProperty(this, vm => vm.IconValid);
|
|
||||||
_categoriesValid = categoriesRule.ValidationChanged.Select(c => c.IsValid).ToProperty(this, vm => vm.CategoriesValid);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ApplyFromState()
|
private void ApplyFromState()
|
||||||
{
|
{
|
||||||
// Basic fields
|
// Basic fields
|
||||||
Name = State.Name;
|
EntrySpecificationsViewModel.Name = State.Name;
|
||||||
Summary = State.Summary;
|
EntrySpecificationsViewModel.Summary = State.Summary;
|
||||||
Description = State.Description;
|
EntrySpecificationsViewModel.Description = State.Description;
|
||||||
|
|
||||||
// Tags
|
// Tags
|
||||||
Tags.Clear();
|
EntrySpecificationsViewModel.Tags.Clear();
|
||||||
Tags.AddRange(State.Tags);
|
EntrySpecificationsViewModel.Tags.AddRange(State.Tags);
|
||||||
|
|
||||||
|
// Categories
|
||||||
|
EntrySpecificationsViewModel.PreselectedCategories = State.Categories;
|
||||||
|
|
||||||
// Icon
|
// Icon
|
||||||
if (State.Icon != null)
|
if (State.Icon != null)
|
||||||
{
|
{
|
||||||
State.Icon.Seek(0, SeekOrigin.Begin);
|
State.Icon.Seek(0, SeekOrigin.Begin);
|
||||||
IconBitmap = BitmapExtensions.LoadAndResize(State.Icon, 128);
|
EntrySpecificationsViewModel.IconBitmap = BitmapExtensions.LoadAndResize(State.Icon, 128);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyToState()
|
private void ApplyToState()
|
||||||
{
|
{
|
||||||
// Basic fields
|
// Basic fields
|
||||||
State.Name = Name;
|
State.Name = EntrySpecificationsViewModel.Name;
|
||||||
State.Summary = Summary;
|
State.Summary = EntrySpecificationsViewModel.Summary;
|
||||||
State.Description = Description;
|
State.Description = EntrySpecificationsViewModel.Description;
|
||||||
|
|
||||||
// Categories and tasks
|
// Categories and tasks
|
||||||
State.Categories = Categories.Where(c => c.IsSelected).Select(c => c.Id).ToList();
|
State.Categories = EntrySpecificationsViewModel.Categories.Where(c => c.IsSelected).Select(c => c.Id).ToList();
|
||||||
State.Tags = new List<string>(Tags);
|
State.Tags = new List<string>(EntrySpecificationsViewModel.Tags);
|
||||||
|
|
||||||
// Icon
|
// Icon
|
||||||
State.Icon?.Dispose();
|
State.Icon?.Dispose();
|
||||||
if (IconBitmap != null)
|
if (EntrySpecificationsViewModel.IconBitmap != null)
|
||||||
{
|
{
|
||||||
State.Icon = new MemoryStream();
|
State.Icon = new MemoryStream();
|
||||||
IconBitmap.Save(State.Icon);
|
EntrySpecificationsViewModel.IconBitmap.Save(State.Icon);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -152,13 +152,13 @@ public class UploadStepViewModel : SubmissionViewModel
|
|||||||
switch (State.EntryType)
|
switch (State.EntryType)
|
||||||
{
|
{
|
||||||
case EntryType.Layout:
|
case EntryType.Layout:
|
||||||
await _router.Navigate($"workshop/layouts/{_entryId.Value}");
|
await _router.Navigate($"workshop/entries/layouts/{_entryId.Value}");
|
||||||
break;
|
break;
|
||||||
case EntryType.Plugin:
|
case EntryType.Plugin:
|
||||||
await _router.Navigate($"workshop/plugins/{_entryId.Value}");
|
await _router.Navigate($"workshop/entries/plugins/{_entryId.Value}");
|
||||||
break;
|
break;
|
||||||
case EntryType.Profile:
|
case EntryType.Profile:
|
||||||
await _router.Navigate($"workshop/profiles/{_entryId.Value}");
|
await _router.Navigate($"workshop/entries/profiles/{_entryId.Value}");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
|
|||||||
@ -22,7 +22,8 @@ public class DebugService : IDebugService
|
|||||||
|
|
||||||
private void CreateDebugger()
|
private void CreateDebugger()
|
||||||
{
|
{
|
||||||
_debugViewModel = _windowService.ShowWindow<DebugViewModel>();
|
_windowService.ShowWindow(out DebugViewModel debugViewModel);
|
||||||
|
_debugViewModel = debugViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearDebugger()
|
public void ClearDebugger()
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
<Styles xmlns="https://github.com/avaloniaui"
|
<Styles xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:styling="clr-namespace:FluentAvalonia.Styling;assembly=FluentAvalonia"
|
xmlns:styling="clr-namespace:FluentAvalonia.Styling;assembly=FluentAvalonia"
|
||||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia">
|
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||||
|
xmlns:aedit="using:AvaloniaEdit"
|
||||||
|
xmlns:aedit2="using:AvaloniaEdit.Editing">
|
||||||
<!-- Third party styles -->
|
<!-- Third party styles -->
|
||||||
<styling:FluentAvaloniaTheme PreferSystemTheme="False" PreferUserAccentColor="True"/>
|
<styling:FluentAvaloniaTheme PreferSystemTheme="False" PreferUserAccentColor="True"/>
|
||||||
<avalonia:MaterialIconStyles />
|
<avalonia:MaterialIconStyles />
|
||||||
@ -9,6 +11,18 @@
|
|||||||
<!-- <FluentTheme Mode="Dark"></FluentTheme> -->
|
<!-- <FluentTheme Mode="Dark"></FluentTheme> -->
|
||||||
<StyleInclude Source="avares://Artemis.UI.Shared/Styles/Artemis.axaml" />
|
<StyleInclude Source="avares://Artemis.UI.Shared/Styles/Artemis.axaml" />
|
||||||
<StyleInclude Source="avares://AsyncImageLoader.Avalonia/AdvancedImage.axaml" />
|
<StyleInclude Source="avares://AsyncImageLoader.Avalonia/AdvancedImage.axaml" />
|
||||||
|
<StyleInclude Source="avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml" />
|
||||||
|
|
||||||
|
<!-- Adjust the ScrollViewer padding in AvaloniaEdit so scrollbar doesn't overlap text -->
|
||||||
|
<Style Selector="aedit|TextEditor /template/ ScrollViewer ScrollContentPresenter">
|
||||||
|
<Setter Property="Padding" Value="0 0 0 20" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- set the selection color for the AvaloniaEdit boxes -->
|
||||||
|
<Style Selector="aedit2|TextArea">
|
||||||
|
<Setter Property="SelectionBrush" Value="{DynamicResource TextControlSelectionHighlightColor}" />
|
||||||
|
<Setter Property="SelectionForeground" Value="{DynamicResource TextOnAccentFillColorSelectedTextBrush}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
<Styles.Resources>
|
<Styles.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user