mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Added acrylic blur test
This commit is contained in:
1 parent
0e077e31b3
commit
e03d6b20e9
10 files changed
+353
-92
No files matched your search
@@ -5,31 +5,40 @@
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
xmlns:entries="clr-namespace:Artemis.UI.Screens.Workshop.Profile"
|
||||
xmlns:entries1="clr-namespace:Artemis.UI.Screens.Workshop.Entries"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="120"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="110"
|
||||
x:Class="Artemis.UI.Screens.Workshop.Entries.EntryListView"
|
||||
x:DataType="entries1:EntryListViewModel">
|
||||
<Border Classes="card" MinHeight="120">
|
||||
<Button MinHeight="110"
|
||||
MaxHeight="140"
|
||||
Padding="16"
|
||||
CornerRadius="8"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
Command="{CompiledBinding NavigateToEntry}">
|
||||
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||
<!-- Icon -->
|
||||
<Border Grid.Column="0"
|
||||
Cursor="Hand"
|
||||
CornerRadius="12"
|
||||
Background="{StaticResource ControlStrokeColorOnAccentDefault}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0 0 10 0"
|
||||
Width="90"
|
||||
Height="90"
|
||||
PointerReleased="InputElement_OnPointerReleased">
|
||||
<avalonia:MaterialIcon Kind="HandOkay" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="80" Height="80"/>
|
||||
Width="80"
|
||||
Height="80">
|
||||
<avalonia:MaterialIcon Kind="HandOkay" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="70" Height="70" />
|
||||
</Border>
|
||||
|
||||
|
||||
|
||||
<!-- Body -->
|
||||
<Grid Grid.Column="1" VerticalAlignment="Stretch" RowDefinitions="Auto,*,Auto">
|
||||
<TextBlock Grid.Row="0" Margin="0 0 0 5" Cursor="Hand" PointerReleased="InputElement_OnPointerReleased">
|
||||
<Run Classes="h4" Text="{CompiledBinding Entry.Name, FallbackValue=Title}" />
|
||||
<TextBlock Grid.Row="0" Margin="0 0 0 5" TextTrimming="CharacterEllipsis" >
|
||||
<Run Classes="h5" Text="{CompiledBinding Entry.Name, FallbackValue=Title}" />
|
||||
<Run Classes="subtitle">by</Run>
|
||||
<Run Classes="subtitle" Text="{CompiledBinding Entry.Author, FallbackValue=Author}" />
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Row="1" FontSize="15" Classes="subtitle" Text="{CompiledBinding Entry.Summary, FallbackValue=Summary}"></TextBlock>
|
||||
<TextBlock Grid.Row="1"
|
||||
Classes="subtitle"
|
||||
TextWrapping="Wrap"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
Text="{CompiledBinding Entry.Summary, FallbackValue=Summary}"></TextBlock>
|
||||
|
||||
<ItemsControl Grid.Row="2" ItemsSource="{CompiledBinding Entry.Categories}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
@@ -41,12 +50,14 @@
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<avalonia:MaterialIcon Kind="{CompiledBinding Icon}" Margin="0 0 3 0"></avalonia:MaterialIcon>
|
||||
<TextBlock Text="{CompiledBinding Name}" />
|
||||
<TextBlock Text="{CompiledBinding Name}" TextTrimming="CharacterEllipsis" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
|
||||
<!-- Info -->
|
||||
<StackPanel Grid.Column="2">
|
||||
<TextBlock TextAlignment="Right" Text="{CompiledBinding Entry.CreatedAt, StringFormat={}{0:g}, FallbackValue=01-01-1337}" />
|
||||
<TextBlock TextAlignment="Right">
|
||||
@@ -54,8 +65,7 @@
|
||||
<Run Classes="h5" Text="{CompiledBinding Entry.Downloads, FallbackValue=0}" />
|
||||
<Run>downloads</Run>
|
||||
</TextBlock>
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Button>
|
||||
</UserControl>
|
||||
@@ -16,9 +16,4 @@ public partial class EntryListView : ReactiveUserControl<EntryListViewModel>
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
private async void InputElement_OnPointerReleased(object? sender, PointerReleasedEventArgs e)
|
||||
{
|
||||
await ViewModel.NavigateToEntry();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using Artemis.WebClient.Workshop;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Entries;
|
||||
|
||||
@@ -14,11 +16,13 @@ public class EntryListViewModel : ViewModelBase
|
||||
{
|
||||
_router = router;
|
||||
Entry = entry;
|
||||
NavigateToEntry = ReactiveCommand.CreateFromTask(ExecuteNavigateToEntry);
|
||||
}
|
||||
|
||||
public IGetEntries_Entries_Items Entry { get; }
|
||||
public ReactiveCommand<Unit,Unit> NavigateToEntry { get; }
|
||||
|
||||
public async Task NavigateToEntry()
|
||||
private async Task ExecuteNavigateToEntry()
|
||||
{
|
||||
switch (Entry.EntryType)
|
||||
{
|
||||
|
||||
@@ -4,55 +4,78 @@
|
||||
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"
|
||||
xmlns:controls="clr-namespace:Artemis.UI.Controls"
|
||||
xmlns:acrylicBlur="clr-namespace:Artemis.UI.Controls.AcrylicBlur"
|
||||
mc:Ignorable="d" d:DesignWidth="1200" d:DesignHeight="800"
|
||||
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"
|
||||
<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>
|
||||
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>
|
||||
<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">
|
||||
<Border CornerRadius="{DynamicResource ControlCornerRadius}" ClipToBounds="True">
|
||||
<acrylicBlur:AcrylicBlur Blur="17">
|
||||
<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>
|
||||
</acrylicBlur:AcrylicBlur>
|
||||
</Border>
|
||||
|
||||
<Border CornerRadius="{DynamicResource ControlCornerRadius}" ClipToBounds="True">
|
||||
<acrylicBlur:AcrylicBlur Blur="17">
|
||||
<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>
|
||||
</acrylicBlur:AcrylicBlur>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
<Grid Grid.Row="1" Width="320" Height="200">
|
||||
<Grid>
|
||||
<Rectangle Fill="Aqua" Height="200" Width="100" HorizontalAlignment="Left" VerticalAlignment="Top" />
|
||||
<Ellipse Fill="Magenta" Height="152" Width="152" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
<Rectangle Fill="Yellow" Height="100" Width="80" HorizontalAlignment="Right" VerticalAlignment="Bottom" />
|
||||
</Grid>
|
||||
<acrylicBlur:AcrylicBlur Margin="12" Blur="17">
|
||||
<TextBlock>Test</TextBlock>
|
||||
</acrylicBlur:AcrylicBlur>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
</UserControl>
|
||||
@@ -16,20 +16,10 @@
|
||||
<Border Classes="card" VerticalAlignment="Stretch" Margin="0,0,5,0">
|
||||
<ContentControl Content="{CompiledBinding CategoriesViewModel}"></ContentControl>
|
||||
</Border>
|
||||
|
||||
<TextBlock Classes="card-title">
|
||||
Filters
|
||||
</TextBlock>
|
||||
<Border Classes="card" VerticalAlignment="Stretch" Margin="0,0,5,0">
|
||||
<StackPanel>
|
||||
<Label>Author</Label>
|
||||
<AutoCompleteBox Watermark="Search authors.." />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<ScrollViewer Grid.Column="1" Grid.Row="0">
|
||||
|
||||
<ProgressBar Grid.Column="1" Grid.Row="0" VerticalAlignment="Top" Margin="0 26 20 0" IsVisible="{CompiledBinding IsLoading}" IsIndeterminate="True"/>
|
||||
<ScrollViewer Grid.Column="1" Grid.Row="0" Margin="0 26 0 0">
|
||||
<ItemsRepeater ItemsSource="{CompiledBinding Entries}" Margin="0 0 20 0">
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate>
|
||||
@@ -41,6 +31,7 @@
|
||||
|
||||
<pagination:Pagination Grid.Column="1"
|
||||
Grid.Row="1"
|
||||
Margin="0 20 0 10"
|
||||
IsVisible="{CompiledBinding ShowPagination}"
|
||||
Value="{CompiledBinding Page}"
|
||||
Maximum="{CompiledBinding TotalPages}"
|
||||
|
||||
@@ -10,6 +10,8 @@ using Artemis.UI.Screens.Workshop.Entries;
|
||||
using Artemis.UI.Screens.Workshop.Parameters;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.Builders;
|
||||
using Artemis.WebClient.Workshop;
|
||||
using ReactiveUI;
|
||||
using StrawberryShake;
|
||||
@@ -19,19 +21,24 @@ namespace Artemis.UI.Screens.Workshop.Profile;
|
||||
public class ProfileListViewModel : RoutableScreen<ActivatableViewModelBase, WorkshopListParameters>, IWorkshopViewModel
|
||||
{
|
||||
private readonly IRouter _router;
|
||||
private readonly INotificationService _notificationService;
|
||||
private readonly IWorkshopClient _workshopClient;
|
||||
private readonly ObservableAsPropertyHelper<bool> _showPagination;
|
||||
private readonly ObservableAsPropertyHelper<bool> _isLoading;
|
||||
private List<EntryListViewModel>? _entries;
|
||||
private int _page;
|
||||
private int _loadedPage = -1;
|
||||
private int _totalPages = 1;
|
||||
private int _entriesPerPage = 5;
|
||||
private int _entriesPerPage = 10;
|
||||
|
||||
public ProfileListViewModel(IWorkshopClient workshopClient, IRouter router, CategoriesViewModel categoriesViewModel)
|
||||
public ProfileListViewModel(IWorkshopClient workshopClient, IRouter router, CategoriesViewModel categoriesViewModel, INotificationService notificationService)
|
||||
{
|
||||
_workshopClient = workshopClient;
|
||||
_router = router;
|
||||
_notificationService = notificationService;
|
||||
_showPagination = this.WhenAnyValue(vm => vm.TotalPages).Select(t => t > 1).ToProperty(this, vm => vm.ShowPagination);
|
||||
|
||||
_isLoading = this.WhenAnyValue(vm => vm.Page, vm => vm.LoadedPage, (p, c) => p != c).ToProperty(this, vm => vm.IsLoading);
|
||||
|
||||
CategoriesViewModel = categoriesViewModel;
|
||||
|
||||
// Respond to page changes
|
||||
@@ -49,6 +56,8 @@ public class ProfileListViewModel : RoutableScreen<ActivatableViewModelBase, Wor
|
||||
}
|
||||
|
||||
public bool ShowPagination => _showPagination.Value;
|
||||
public bool IsLoading => _isLoading.Value;
|
||||
|
||||
public CategoriesViewModel CategoriesViewModel { get; }
|
||||
|
||||
public List<EntryListViewModel>? Entries
|
||||
@@ -63,6 +72,12 @@ public class ProfileListViewModel : RoutableScreen<ActivatableViewModelBase, Wor
|
||||
set => RaiseAndSetIfChanged(ref _page, value);
|
||||
}
|
||||
|
||||
public int LoadedPage
|
||||
{
|
||||
get => _loadedPage;
|
||||
set => RaiseAndSetIfChanged(ref _loadedPage, value);
|
||||
}
|
||||
|
||||
public int TotalPages
|
||||
{
|
||||
get => _totalPages;
|
||||
@@ -78,25 +93,42 @@ public class ProfileListViewModel : RoutableScreen<ActivatableViewModelBase, Wor
|
||||
public override async Task OnNavigating(WorkshopListParameters parameters, NavigationArguments args, CancellationToken cancellationToken)
|
||||
{
|
||||
Page = Math.Max(1, parameters.Page);
|
||||
|
||||
|
||||
// Throttle page changes
|
||||
await Task.Delay(200, cancellationToken);
|
||||
|
||||
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
await Query(cancellationToken);
|
||||
}
|
||||
|
||||
private async Task Query(CancellationToken cancellationToken)
|
||||
{
|
||||
EntryFilterInput filter = GetFilter();
|
||||
IOperationResult<IGetEntriesResult> entries = await _workshopClient.GetEntries.ExecuteAsync(filter, EntriesPerPage * (Page - 1), EntriesPerPage, cancellationToken);
|
||||
if (!entries.IsErrorResult() && entries.Data?.Entries?.Items != null)
|
||||
try
|
||||
{
|
||||
Entries = entries.Data.Entries.Items.Select(n => new EntryListViewModel(n, _router)).ToList();
|
||||
TotalPages = (int) Math.Ceiling(entries.Data.Entries.TotalCount / (double) EntriesPerPage);
|
||||
EntryFilterInput filter = GetFilter();
|
||||
IOperationResult<IGetEntriesResult> entries = await _workshopClient.GetEntries.ExecuteAsync(filter, EntriesPerPage * (Page - 1), EntriesPerPage, cancellationToken);
|
||||
entries.EnsureNoErrors();
|
||||
|
||||
if (entries.Data?.Entries?.Items != null)
|
||||
{
|
||||
Entries = entries.Data.Entries.Items.Select(n => new EntryListViewModel(n, _router)).ToList();
|
||||
TotalPages = (int) Math.Ceiling(entries.Data.Entries.TotalCount / (double) EntriesPerPage);
|
||||
}
|
||||
else
|
||||
TotalPages = 1;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_notificationService.CreateNotification()
|
||||
.WithTitle("Failed to load entries")
|
||||
.WithMessage(e.Message)
|
||||
.WithSeverity(NotificationSeverity.Error)
|
||||
.Show();
|
||||
}
|
||||
finally
|
||||
{
|
||||
LoadedPage = Page;
|
||||
}
|
||||
else
|
||||
TotalPages = 1;
|
||||
}
|
||||
|
||||
private EntryFilterInput GetFilter()
|
||||
|
||||
Reference in new issue
Block a user