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

@@ -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;
}