Skip to content

Commit

Permalink
Workshop - Visual pass
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertBeekman committed Apr 14, 2024
1 parent 7b71ee0 commit 74c24c8
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<Border Grid.Row="0" Classes="card" Margin="0 0 0 10">
<StackPanel>
<Grid ColumnDefinitions="*,Auto">
<TextBlock Classes="h4 no-margin">Release info</TextBlock>
<TextBlock Theme="{StaticResource SubtitleTextBlockStyle}">Release info</TextBlock>

<Panel Grid.Column="1" IsVisible="{CompiledBinding InstallationAvailable}">
<!-- Install progress -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,7 @@ public EntrySpecificationsViewModel(IWorkshopClient workshopClient, IWindowServi
_categoriesValid = categoriesRule.ValidationChanged.Select(c => c.IsValid).ToProperty(this, vm => vm.CategoriesValid);
_descriptionValid = descriptionRule.ValidationChanged.Select(c => c.IsValid).ToProperty(this, vm => vm.DescriptionValid);

this.WhenActivatedAsync(async d =>
{
// Load categories
await PopulateCategories();
Disposable.Create(ClearIcon).DisposeWith(d);
});
this.WhenActivatedAsync(async _ => await PopulateCategories());
}

public ReactiveCommand<Unit, Unit> SelectIcon { get; }
Expand Down Expand Up @@ -98,12 +93,6 @@ private async Task ExecuteSelectIcon()
IconChanged = true;
}

private void ClearIcon()
{
IconBitmap?.Dispose();
IconBitmap = null;
}

private async Task PopulateCategories()
{
IOperationResult<IGetCategoriesResult> categories = await _workshopClient.GetCategories.ExecuteAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
<Border Grid.Row="0" Classes="card" Margin="0 0 0 10">
<StackPanel>
<Grid ColumnDefinitions="Auto,*,Auto">
<Button Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Classes="icon-button" Command="{CompiledBinding Close}">
<Button Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Classes="icon-button" Margin="0 0 5 0" Command="{CompiledBinding Close}">
<avalonia:MaterialIcon Kind="ArrowBack" />
</Button>
<TextBlock Grid.Row="0" Grid.Column="1" Classes="h4 no-margin">Release info</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="1" Theme="{StaticResource SubtitleTextBlockStyle}">Release info</TextBlock>
<StackPanel Grid.Column="2">
<!-- Install progress -->
<StackPanel Orientation="Horizontal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
x:Class="Artemis.UI.Screens.Workshop.Library.SubmissionDetailsView"
x:DataType="library:SubmissionDetailsViewModel">
<Grid ColumnDefinitions="*,300" RowDefinitions="*, Auto">
<ContentControl Grid.Column="0" Grid.Row="0" Content="{CompiledBinding EntrySpecificationsViewModel}"></ContentControl>

<Border Classes="card" Grid.Column="0" Grid.Row="0">
<ContentControl Content="{CompiledBinding EntrySpecificationsViewModel}"></ContentControl>
</Border>

<Border Grid.Column="1" Grid.Row="0" Classes="card" Margin="10 0 0 0">
<Grid RowDefinitions="*,Auto">
<ScrollViewer Grid.Row="0" Classes="with-padding" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public async Task OnClosing(NavigationArguments args)
bool confirmed = await _windowService.ShowConfirmContentDialog("You have unsaved changes", "Do you want to discard your unsaved changes?");
if (!confirmed)
args.Cancel();
else
await ExecuteDiscardChanges();
}

private async Task ApplyDetailsFromEntry(CancellationToken cancellationToken)
Expand All @@ -94,6 +96,7 @@ private async Task ApplyDetailsFromEntry(CancellationToken cancellationToken)
if (Entry == null)
{
EntrySpecificationsViewModel = null;
ApplyImagesFromEntry();
return;
}

Expand Down Expand Up @@ -176,7 +179,6 @@ private void UpdateHasChanges()
private async Task ExecuteDiscardChanges()
{
await ApplyDetailsFromEntry(CancellationToken.None);
ApplyImagesFromEntry();
}

private async Task ExecuteSaveChanges(CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,18 @@ public override async Task OnNavigating(WorkshopDetailParameters parameters, Nav
{
// If there is a 2nd parameter, it's a release ID
SelectedRelease = args.RouteParameters.Length > 1 ? Releases?.FirstOrDefault(r => r.Id == (long) args.RouteParameters[1]) : null;


// OnNavigating may just be getting called to update the selected release
if (Entry?.Id == parameters.EntryId)
{
// Reapply the entry when closing a release, this is mainly because the entry icon probably got disposed
if (SelectedRelease == null)
await _detailsViewModel.SetEntry(Entry, cancellationToken);

// No need to reload the entry since it's the same
return;
}

IOperationResult<IGetSubmittedEntryByIdResult> result = await _client.GetSubmittedEntryById.ExecuteAsync(parameters.EntryId, cancellationToken);
if (result.IsErrorResult())
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,95 @@
xmlns:library="clr-namespace:Artemis.UI.Screens.Workshop.Library"
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:controls1="clr-namespace:Artemis.UI.Controls"
xmlns:converters="clr-namespace:Artemis.UI.Converters"
xmlns:sharedConverters="clr-namespace:Artemis.UI.Shared.Converters;assembly=Artemis.UI.Shared"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Workshop.Library.SubmissionReleaseView"
x:DataType="library:SubmissionReleaseViewModel">
<UserControl.Resources>
<converters:DateTimeConverter x:Key="DateTimeConverter" />
<sharedConverters:BytesToStringConverter x:Key="BytesToStringConverter" />
</UserControl.Resources>
<UserControl.Styles>
<Style Selector="Grid.info-container">
<Setter Property="Margin" Value="10" />
</Style>
<Style Selector="avalonia|MaterialIcon.info-icon">
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Margin" Value="0 3 10 0" />
</Style>
<Style Selector="TextBlock.info-title">
<Setter Property="Margin" Value="0 0 0 5" />
<Setter Property="Opacity" Value="0.8" />
</Style>
<Style Selector="TextBlock.info-body">
</Style>
<Style Selector="TextBlock.info-link">
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Foreground" Value="{DynamicResource SystemAccentColorLight3}" />
</Style>
<Style Selector="TextBlock.info-link:pointerover">
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Foreground" Value="{DynamicResource SystemAccentColorLight1}" />
</Style>
</UserControl.Styles>

<Grid RowDefinitions="Auto,*,Auto">
<StackPanel Grid.Row="0" Orientation="Horizontal" Spacing="5">
<Button VerticalAlignment="Center" Classes="icon-button" Command="{CompiledBinding Close}">
<avalonia:MaterialIcon Kind="ArrowBack" />
</Button>
<TextBlock Classes="h3 no-margin" Text="{CompiledBinding Release.Version}" />
</StackPanel>
<Border Grid.Row="0" Classes="card" Margin="0 0 0 10">
<StackPanel>
<Grid ColumnDefinitions="Auto,*,Auto">
<Button Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Classes="icon-button" Command="{CompiledBinding Close}" Margin="0 0 5 0">
<avalonia:MaterialIcon Kind="ArrowBack" />
</Button>
<TextBlock Grid.Row="0" Grid.Column="1" Theme="{StaticResource SubtitleTextBlockStyle}">Release management</TextBlock>
<Button Grid.Row="0" Grid.Column="2" HorizontalAlignment="Right" Classes="danger" Command="{CompiledBinding DeleteRelease}">Delete release</Button>
</Grid>
<Border Classes="card-separator" />
<Grid Margin="-5 -10" ColumnDefinitions="*,*,*">
<Grid Grid.Column="0" ColumnDefinitions="*,*" RowDefinitions="*,*" Classes="info-container" HorizontalAlignment="Left">
<avalonia:MaterialIcon Kind="TickNetworkOutline" Grid.Column="0" Grid.RowSpan="2" Classes="info-icon" />
<TextBlock Grid.Column="1" Grid.Row="0" Classes="info-title">Version</TextBlock>
<TextBlock Grid.Column="1"
Grid.Row="1"
Classes="info-body"
Cursor="Hand"
Text="{CompiledBinding Release.Version}" />
</Grid>

<Grid Grid.Column="1" ColumnDefinitions="*,*" RowDefinitions="*,*,*" Classes="info-container" HorizontalAlignment="Center">
<avalonia:MaterialIcon Kind="Calendar" Grid.Column="0" Grid.RowSpan="2" Classes="info-icon" />
<TextBlock Grid.Column="1" Grid.Row="0" Classes="info-title">Release date</TextBlock>
<TextBlock Grid.Column="1"
Grid.Row="1"
Classes="info-body"
Text="{CompiledBinding Release.CreatedAt, Converter={StaticResource DateTimeConverter}}" />
</Grid>

<Grid Grid.Column="2" ColumnDefinitions="*,*" RowDefinitions="*,*" Classes="info-container" HorizontalAlignment="Right">
<avalonia:MaterialIcon Kind="File" Grid.Column="0" Grid.RowSpan="2" Classes="info-icon" />
<TextBlock Grid.Column="1" Grid.Row="0" Classes="info-title">File size</TextBlock>
<TextBlock Grid.Column="1"
Grid.Row="1"
Classes="info-body"
Text="{CompiledBinding Release.DownloadSize, Converter={StaticResource BytesToStringConverter}, Mode=OneWay}" />
</Grid>
</Grid>

<controls1:SplitMarkdownEditor Grid.Row="1" Title="Changelog" Markdown="{CompiledBinding Changelog}"/>
</StackPanel>
</Border>

<Border Grid.Row="1" Classes="card">
<Grid RowDefinitions="Auto,Auto,*">
<TextBlock Grid.Row="0" Classes="h5 no-margin">Release notes</TextBlock>
<Border Grid.Row="1" Classes="card-separator" />

<controls1:SplitMarkdownEditor Grid.Row="2" Title="Changelog" Markdown="{CompiledBinding Changelog}"/>
</Grid>
</Border>

<StackPanel Grid.Row="2" Margin="0 10 0 0" Orientation="Horizontal" Spacing="5" HorizontalAlignment="Right">
<Button Classes="danger" Command="{CompiledBinding DeleteRelease}">Delete release</Button>
<Button Command="{CompiledBinding Discard}">Discard changes</Button>
<Button Command="{CompiledBinding Save}">Save</Button>
</StackPanel>
</Grid>

</UserControl>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Reactive.Disposables;
using Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Layout;
using Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Plugin;
using Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Profile;
using Artemis.WebClient.Workshop;
using PropertyChanged.SourceGenerator;
Expand Down Expand Up @@ -32,7 +33,7 @@ private void ExecuteGoBack()
if (State.EntryType == EntryType.Layout)
State.ChangeScreen<LayoutInfoStepViewModel>();
else if (State.EntryType == EntryType.Plugin)
State.ChangeScreen<SpecificationsStepViewModel>();
State.ChangeScreen<PluginSelectionStepViewModel>();
else if (State.EntryType == EntryType.Profile)
State.ChangeScreen<ProfileAdaptionHintsStepViewModel>();
}
Expand Down

0 comments on commit 74c24c8

Please sign in to comment.