Added workshop home, changed VM routing structure

This commit is contained in:
Robert committed 2023-07-08 21:44:39 +02:00
1 parent 99a365be0b
commit 65f81ab768
34 files changed
+667 -75

No files matched your search

+10 -13
View File
@@ -15,20 +15,17 @@
Height="200"
Stretch="UniformToFill"
RenderOptions.BitmapInterpolationMode="HighQuality"/>
<!-- TODO: Replace with a shadow when available -->
<TextBlock Grid.Row="0"
TextWrapping="Wrap"
Foreground="Black"
FontSize="32"
Margin="32"
Text=" Welcome to Artemis, the unified RGB platform." />
<TextBlock Grid.Row="0"
TextWrapping="Wrap"
Foreground="White"
FontSize="32"
Margin="30"
Text=" Welcome to Artemis, the unified RGB platform." />
TextWrapping="Wrap"
Foreground="White"
FontSize="32"
Margin="30"
Text=" Welcome to Artemis, the unified RGB platform.">
<TextBlock.Effect>
<DropShadowEffect Color="Black" OffsetX="2" OffsetY="2" BlurRadius="5"></DropShadowEffect>
</TextBlock.Effect>
</TextBlock>
<Grid Grid.Row="1" MaxWidth="840" Margin="30" VerticalAlignment="Bottom" ColumnDefinitions="*,*" RowDefinitions="*,*">
<Border Classes="card" Margin="8" Grid.ColumnSpan="2" ClipToBounds="True">
@@ -7,7 +7,7 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Sidebar.SidebarScreenView"
x:DataType="vm:SidebarScreenViewModel">
<StackPanel Orientation="Horizontal" Background="Transparent" PointerReleased="InputElement_OnPointerReleased" DoubleTapped="InputElement_OnDoubleTapped">
<StackPanel Orientation="Horizontal" Height="34" Background="Transparent" PointerPressed="InputElement_OnPointerPressed" DoubleTapped="InputElement_OnDoubleTapped" >
<avalonia:MaterialIcon Kind="{CompiledBinding Icon}" Width="18" Height="18" />
<TextBlock Margin="10 0" VerticalAlignment="Center" FontSize="13" Text="{CompiledBinding DisplayName}" />
</StackPanel>
@@ -1,6 +1,4 @@
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Sidebar;
@@ -14,12 +12,18 @@ public partial class SidebarScreenView : ReactiveUserControl<SidebarScreenViewMo
private void InputElement_OnPointerReleased(object? sender, PointerReleasedEventArgs e)
{
// if (ViewModel != null)
// ViewModel.IsExpanded = !ViewModel.IsExpanded;
if (ViewModel != null)
ViewModel.IsExpanded = !ViewModel.IsExpanded;
}
private void InputElement_OnDoubleTapped(object? sender, TappedEventArgs e)
{
e.Handled = true;
}
private void InputElement_OnPointerPressed(object? sender, PointerPressedEventArgs e)
{
if (ViewModel != null)
ViewModel.IsExpanded = !ViewModel.IsExpanded;
}
}
@@ -2,11 +2,7 @@
using System.Collections.ObjectModel;
using System.Linq;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Routing;
using Artemis.UI.Shared.Services;
using Avalonia.Threading;
using Material.Icons;
using ReactiveUI;
namespace Artemis.UI.Screens.Sidebar;
@@ -22,7 +18,7 @@ public class SidebarScreenViewModel : ViewModelBase
DisplayName = displayName;
Screens = screens ?? new ObservableCollection<SidebarScreenViewModel>();
}
public MaterialIconKind Icon { get; }
public string Path { get; }
public string RootPath { get; }
@@ -56,15 +52,12 @@ public class SidebarScreenViewModel : ViewModelBase
public void ExpandIfRequired(SidebarScreenViewModel selected)
{
if (selected == this && Screens.Any())
{
IsExpanded = true;
if (selected == this)
return;
}
if (Screens.Contains(selected))
IsExpanded = true;
foreach (SidebarScreenViewModel sidebarScreenViewModel in Screens)
sidebarScreenViewModel.ExpandIfRequired(selected);
}
@@ -0,0 +1,8 @@
<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"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Workshop.Categories.CategoriesView">
Welcome to Avalonia!
</UserControl>
@@ -0,0 +1,19 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Workshop.Categories;
public partial class CategoriesView : ReactiveUserControl<CategoriesViewModel>
{
public CategoriesView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
@@ -0,0 +1,14 @@
using Artemis.UI.Shared;
using Artemis.WebClient.Workshop;
namespace Artemis.UI.Screens.Workshop.Categories;
public class CategoriesViewModel : ActivatableViewModelBase
{
private readonly IWorkshopClient _client;
public CategoriesViewModel(IWorkshopClient client)
{
_client = client;
}
}
@@ -0,0 +1,58 @@
<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:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:home="clr-namespace:Artemis.UI.Screens.Workshop.Home"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Workshop.Home.WorkshopHomeView"
x:DataType="home:WorkshopHomeViewModel">
<Border Classes="router-container">
<Grid RowDefinitions="200,*">
<Image Grid.Row="0"
Grid.RowSpan="2"
VerticalAlignment="Top"
Source="/Assets/Images/workshop-banner.jpg"
Height="200"
Stretch="UniformToFill"
RenderOptions.BitmapInterpolationMode="HighQuality">
<Image.OpacityMask>
<LinearGradientBrush StartPoint="0%,70%" EndPoint="0%,100%">
<GradientStops>
<GradientStop Color="Black" Offset="0"></GradientStop>
<GradientStop Color="Transparent" Offset="100"></GradientStop>
</GradientStops>
</LinearGradientBrush>
</Image.OpacityMask>
</Image>
<TextBlock Grid.Row="0"
TextWrapping="Wrap"
Foreground="White"
FontSize="32"
Margin="30"
Text="Welcome to the Artemis Workshop!">
<TextBlock.Effect>
<DropShadowEffect Color="Black" OffsetX="2" OffsetY="2" BlurRadius="5"></DropShadowEffect>
</TextBlock.Effect>
</TextBlock>
<StackPanel Grid.Row="1" Margin="30 -75 30 0" Spacing="10" Orientation="Horizontal" VerticalAlignment="Top">
<Button Width="150" Height="180" Command="{CompiledBinding Navigate}" CommandParameter="workshop/profiles/1" VerticalContentAlignment="Top">
<StackPanel>
<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="12" Opacity="0.8">Browse new profiles created by other users.</TextBlock>
</StackPanel>
</Button>
<Button Width="150" Height="180" Command="{CompiledBinding Navigate}" CommandParameter="workshop/layouts/1" VerticalContentAlignment="Top">
<StackPanel>
<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="12" Opacity="0.8">Layouts make your devices look great in the editor.</TextBlock>
</StackPanel>
</Button>
</StackPanel>
</Grid>
</Border>
</UserControl>
@@ -0,0 +1,19 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Workshop.Home;
public partial class WorkshopHomeView : ReactiveUserControl<WorkshopHomeViewModel>
{
public WorkshopHomeView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
@@ -0,0 +1,20 @@
using System.Reactive;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Routing;
using Artemis.WebClient.Workshop;
using ReactiveUI;
namespace Artemis.UI.Screens.Workshop.Home;
public class WorkshopHomeViewModel : ActivatableViewModelBase, IWorkshopViewModel
{
public WorkshopHomeViewModel(IRouter router)
{
Navigate = ReactiveCommand.CreateFromTask<string>(async r => await router.Navigate(r));
}
public ReactiveCommand<string, Unit> Navigate { get; set; }
public EntryType? EntryType => null;
}
@@ -2,20 +2,24 @@
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:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:ui="clr-namespace:Artemis.UI"
xmlns:layout="clr-namespace:Artemis.UI.Screens.Workshop.Layout"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Workshop.Layout.LayoutDetailsView">
x:Class="Artemis.UI.Screens.Workshop.Layout.LayoutDetailsView"
x:DataType="layout:LayoutDetailsViewModel">
<Border Classes="router-container">
<Grid ColumnDefinitions="300,*" Margin="10">
<Border Classes="card-condensed" Grid.Column="0" Margin="0 0 10 0">
<Grid ColumnDefinitions="300,*" RowDefinitions="Auto,*" Margin="10">
<StackPanel Grid.Row="0" Grid.ColumnSpan="2" >
<TextBlock Text="{CompiledBinding Entry.Name, FallbackValue=Layout}" Classes="h3 no-margin"/>
<TextBlock Text="{CompiledBinding Entry.Author, FallbackValue=Author}" Classes="subtitle" Margin="0 0 0 5"/>
</StackPanel>
<Border Classes="card-condensed" Grid.Row="1" Grid.Column="0" Margin="0 0 10 0">
<TextBlock>Side panel</TextBlock>
</Border>
<Border Classes="card-condensed" Grid.Column="1">
<TextBlock>Main panel</TextBlock>
<Border Classes="card-condensed" Grid.Row="1" Grid.Column="1">
<TextBlock>Layout details panel</TextBlock>
</Border>
</Grid>
</Border>
</UserControl>
@@ -1,8 +1,43 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Artemis.UI.Screens.Workshop.Parameters;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Routing;
using Artemis.WebClient.Workshop;
using StrawberryShake;
namespace Artemis.UI.Screens.Workshop.Layout;
public class LayoutDetailsViewModel : ActivatableViewModelBase
public class LayoutDetailsViewModel : RoutableScreen<ActivatableViewModelBase, WorkshopDetailParameters>, IWorkshopViewModel
{
private readonly IWorkshopClient _client;
private IGetEntryById_Entry? _entry;
public LayoutDetailsViewModel(IWorkshopClient client)
{
_client = client;
}
public EntryType? EntryType => null;
public IGetEntryById_Entry? Entry
{
get => _entry;
set => RaiseAndSetIfChanged(ref _entry, value);
}
public override async Task OnNavigating(WorkshopDetailParameters parameters, NavigationArguments args, CancellationToken cancellationToken)
{
await GetEntry(parameters.EntryId, cancellationToken);
}
private async Task GetEntry(Guid entryId, CancellationToken cancellationToken)
{
IOperationResult<IGetEntryByIdResult> result = await _client.GetEntryById.ExecuteAsync(entryId, cancellationToken);
if (result.IsErrorResult())
return;
Entry = result.Data?.Entry;
}
}
@@ -1,15 +1,23 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Artemis.UI.Screens.Workshop.Parameters;
using Artemis.UI.Screens.Workshop.Search;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Routing;
using Artemis.WebClient.Workshop;
namespace Artemis.UI.Screens.Workshop.Layout;
public class LayoutListViewModel : RoutableScreen<ActivatableViewModelBase, WorkshopListParameters>, IMainScreenViewModel
public class LayoutListViewModel : RoutableScreen<ActivatableViewModelBase, WorkshopListParameters>, IWorkshopViewModel
{
private int _page;
/// <inheritdoc />
public LayoutListViewModel()
{
}
public int Page
{
get => _page;
@@ -22,5 +30,5 @@ public class LayoutListViewModel : RoutableScreen<ActivatableViewModelBase, Work
return Task.CompletedTask;
}
public ViewModelBase? TitleBarViewModel => null;
public EntryType? EntryType => WebClient.Workshop.EntryType.Layout;
}
@@ -0,0 +1,8 @@
using System;
namespace Artemis.UI.Screens.Workshop.Parameters;
public class WorkshopDetailParameters
{
public Guid EntryId { get; set; }
}
@@ -1,4 +1,4 @@
namespace Artemis.UI.Screens.Workshop;
namespace Artemis.UI.Screens.Workshop.Parameters;
public class WorkshopListParameters
{
@@ -2,7 +2,24 @@
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"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Workshop.Profile.ProfileDetailsView">
Welcome to Avalonia!
</UserControl>
x:Class="Artemis.UI.Screens.Workshop.Profile.ProfileDetailsView"
x:DataType="profile:ProfileDetailsViewModel">
<Border Classes="router-container">
<Grid ColumnDefinitions="300,*" RowDefinitions="Auto,*" Margin="10">
<StackPanel Grid.Row="0" Grid.ColumnSpan="2" >
<TextBlock Text="{CompiledBinding Entry.Name, FallbackValue=Profile}" Classes="h3 no-margin"/>
<TextBlock Text="{CompiledBinding Entry.Author, FallbackValue=Author}" Classes="subtitle" Margin="0 0 0 5"/>
</StackPanel>
<Border Classes="card-condensed" Grid.Row="1" Grid.Column="0" Margin="0 0 10 0">
<TextBlock>Side panel</TextBlock>
</Border>
<Border Classes="card-condensed" Grid.Row="1" Grid.Column="1">
<TextBlock>Profile details panel</TextBlock>
</Border>
</Grid>
</Border>
</UserControl>
@@ -1,8 +1,43 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Artemis.UI.Screens.Workshop.Parameters;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Routing;
using Artemis.WebClient.Workshop;
using StrawberryShake;
namespace Artemis.UI.Screens.Workshop.Profile;
public class ProfileDetailsViewModel : ActivatableViewModelBase
public class ProfileDetailsViewModel : RoutableScreen<ActivatableViewModelBase, WorkshopDetailParameters>, IWorkshopViewModel
{
private readonly IWorkshopClient _client;
private IGetEntryById_Entry? _entry;
public ProfileDetailsViewModel(IWorkshopClient client)
{
_client = client;
}
public EntryType? EntryType => null;
public IGetEntryById_Entry? Entry
{
get => _entry;
set => RaiseAndSetIfChanged(ref _entry, value);
}
public override async Task OnNavigating(WorkshopDetailParameters parameters, NavigationArguments args, CancellationToken cancellationToken)
{
await GetEntry(parameters.EntryId, cancellationToken);
}
private async Task GetEntry(Guid entryId, CancellationToken cancellationToken)
{
IOperationResult<IGetEntryByIdResult> result = await _client.GetEntryById.ExecuteAsync(entryId, cancellationToken);
if (result.IsErrorResult())
return;
Entry = result.Data?.Entry;
}
}
@@ -1,15 +1,24 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Artemis.UI.Screens.Workshop.Parameters;
using Artemis.UI.Screens.Workshop.Search;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Routing;
using Artemis.WebClient.Workshop;
namespace Artemis.UI.Screens.Workshop.Profile;
public class ProfileListViewModel : RoutableScreen<ActivatableViewModelBase, WorkshopListParameters>, IMainScreenViewModel
public class ProfileListViewModel : RoutableScreen<ActivatableViewModelBase, WorkshopListParameters>, IWorkshopViewModel
{
private int _page;
/// <inheritdoc />
public ProfileListViewModel()
{
}
public int Page
{
get => _page;
@@ -21,6 +30,6 @@ public class ProfileListViewModel : RoutableScreen<ActivatableViewModelBase, Wor
Page = Math.Max(1, parameters.Page);
return Task.CompletedTask;
}
public ViewModelBase? TitleBarViewModel => null;
public EntryType? EntryType => null;
}
@@ -0,0 +1,55 @@
<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:search="clr-namespace:Artemis.UI.Screens.Workshop.Search"
xmlns:workshop="clr-namespace:Artemis.WebClient.Workshop;assembly=Artemis.WebClient.Workshop"
xmlns:windowing="clr-namespace:FluentAvalonia.UI.Windowing;assembly=FluentAvalonia"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Workshop.Search.SearchView"
x:DataType="search:SearchViewModel">
<UserControl.Styles>
<StyleInclude Source="SearchViewStyles.axaml" />
</UserControl.Styles>
<Panel>
<AutoCompleteBox Name="SearchBox"
MaxWidth="500"
Watermark="Search"
Margin="0 5"
ValueMemberBinding="{CompiledBinding Name, DataType=workshop:ISearchEntries_Entries_Nodes}"
AsyncPopulator="{CompiledBinding SearchAsync}"
SelectedItem="{CompiledBinding SelectedEntry}"
FilterMode="None"
windowing:AppWindow.AllowInteractionInTitleBar="True">
<AutoCompleteBox.ItemTemplate>
<DataTemplate x:DataType="workshop:ISearchEntries_Entries_Nodes">
<Panel>
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Center">
<TextBlock Text="{CompiledBinding Name}" />
<TextBlock Text="{CompiledBinding Summary}" Foreground="{DynamicResource TextFillColorSecondary}" />
<ItemsControl ItemsSource="{CompiledBinding Categories}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" Spacing="5"></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Classes="category">
<TextBlock Text="{CompiledBinding Name}"></TextBlock>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Panel>
</DataTemplate>
</AutoCompleteBox.ItemTemplate>
</AutoCompleteBox>
<ContentControl HorizontalAlignment="Right"
Margin="0 0 50 0"
Content="{CompiledBinding CurrentUserViewModel}"
windowing:AppWindow.AllowInteractionInTitleBar="True"/>
</Panel>
</UserControl>
@@ -0,0 +1,18 @@
using System;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.Workshop.Search;
public partial class SearchView : UserControl
{
public SearchView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Artemis.UI.Screens.Workshop.CurrentUser;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Routing;
using Artemis.WebClient.Workshop;
using ReactiveUI;
using StrawberryShake;
namespace Artemis.UI.Screens.Workshop.Search;
public class SearchViewModel : ViewModelBase
{
public CurrentUserViewModel CurrentUserViewModel { get; }
private readonly IRouter _router;
private readonly IWorkshopClient _workshopClient;
private EntryType? _entryType;
private ISearchEntries_Entries_Nodes? _selectedEntry;
public SearchViewModel(IWorkshopClient workshopClient, IRouter router, CurrentUserViewModel currentUserViewModel)
{
CurrentUserViewModel = currentUserViewModel;
_workshopClient = workshopClient;
_router = router;
SearchAsync = ExecuteSearchAsync;
this.WhenAnyValue(vm => vm.SelectedEntry).WhereNotNull().Subscribe(NavigateToEntry);
}
public Func<string?, CancellationToken, Task<IEnumerable<object>>> SearchAsync { get; }
public ISearchEntries_Entries_Nodes? SelectedEntry
{
get => _selectedEntry;
set => RaiseAndSetIfChanged(ref _selectedEntry, value);
}
public EntryType? EntryType
{
get => _entryType;
set => RaiseAndSetIfChanged(ref _entryType, value);
}
private void NavigateToEntry(ISearchEntries_Entries_Nodes entry)
{
string? url = null;
if (entry.EntryType == WebClient.Workshop.EntryType.Profile)
url = $"workshop/profiles/{entry.Id}";
if (entry.EntryType == WebClient.Workshop.EntryType.Layout)
url = $"workshop/layouts/{entry.Id}";
if (url != null)
Task.Run(() => _router.Navigate(url));
}
private async Task<IEnumerable<object>> ExecuteSearchAsync(string? input, CancellationToken cancellationToken)
{
if (string.IsNullOrWhiteSpace(input))
return new List<object>();
EntryFilterInput filter;
if (EntryType != null)
filter = new EntryFilterInput
{
And = new[]
{
new EntryFilterInput {EntryType = new EntryTypeOperationFilterInput {Eq = EntryType}},
new EntryFilterInput {Name = new StringOperationFilterInput {Contains = input}}
}
};
else
filter = new EntryFilterInput {Name = new StringOperationFilterInput {Contains = input}};
IOperationResult<ISearchEntriesResult> results = await _workshopClient.SearchEntries.ExecuteAsync(filter, cancellationToken);
return results.Data?.Entries?.Nodes?.Cast<object>() ?? new List<object>();
}
}
@@ -0,0 +1,28 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border Padding="10">
<StackPanel Orientation="Horizontal" Spacing="5">
<Border Classes="category">
<TextBlock Text="Media"></TextBlock>
</Border>
<Border Classes="category">
<TextBlock Text="Audio"></TextBlock>
</Border>
<Border Classes="category">
<TextBlock Text="Interaction"></TextBlock>
</Border>
</StackPanel>
</Border>
</Design.PreviewWith>
<!-- Add Styles Here -->
<Style Selector="Border.category">
<Setter Property="Background" Value="{DynamicResource ControlSolidFillColorDefaultBrush}" />
<Setter Property="CornerRadius" Value="12" />
<Setter Property="Padding" Value="6 1"></Setter>
<Setter Property="TextBlock.FontSize" Value="12" />
</Style>
</Styles>
@@ -8,7 +8,9 @@
mc:Ignorable="d" d:DesignWidth="800"
x:Class="Artemis.UI.Screens.Workshop.WorkshopView"
x:DataType="workshop:WorkshopViewModel">
<Border Classes="router-container">
<TextBlock>Workshop overview</TextBlock>
</Border>
<controls:Frame Name="WorkshopFrame" IsNavigationStackEnabled="False" CacheSize="0">
<controls:Frame.NavigationPageFactory>
<ui:PageFactory/>
</controls:Frame.NavigationPageFactory>
</controls:Frame>
</UserControl>
@@ -1,4 +1,8 @@
using System;
using System.Reactive.Disposables;
using Avalonia.ReactiveUI;
using Avalonia.Threading;
using ReactiveUI;
namespace Artemis.UI.Screens.Workshop;
@@ -7,5 +11,6 @@ public partial class WorkshopView : ReactiveUserControl<WorkshopViewModel>
public WorkshopView()
{
InitializeComponent();
this.WhenActivated(d => ViewModel.WhenAnyValue(vm => vm.Screen).Subscribe(vm => WorkshopFrame.NavigateFromObject(vm ?? ViewModel?.HomeViewModel)).DisposeWith(d));
}
}
@@ -1,13 +1,38 @@
using Artemis.UI.Shared;
using System;
using System.Threading;
using System.Threading.Tasks;
using Artemis.UI.Screens.Workshop.Home;
using Artemis.UI.Screens.Workshop.Search;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Routing;
using Artemis.WebClient.Workshop;
namespace Artemis.UI.Screens.Workshop;
public class WorkshopViewModel : RoutableScreen<object>, IMainScreenViewModel
public class WorkshopViewModel : RoutableScreen<IWorkshopViewModel>, IMainScreenViewModel
{
public WorkshopViewModel()
private readonly SearchViewModel _searchViewModel;
public WorkshopViewModel(SearchViewModel searchViewModel, WorkshopHomeViewModel homeViewModel)
{
_searchViewModel = searchViewModel;
TitleBarViewModel = searchViewModel;
HomeViewModel = homeViewModel;
}
public ViewModelBase? TitleBarViewModel => null;
public ViewModelBase TitleBarViewModel { get; }
public WorkshopHomeViewModel HomeViewModel { get; }
/// <inheritdoc />
public override Task OnNavigating(NavigationArguments args, CancellationToken cancellationToken)
{
_searchViewModel.EntryType = Screen?.EntryType;
return Task.CompletedTask;
}
}
public interface IWorkshopViewModel
{
public EntryType? EntryType { get; }
}