Browse Source

make extension checkbox toggle when you click anywhere & make downloads tab taller

pull/438/head
JT 10 months ago
parent
commit
8f1d28bd3f
  1. 8
      StabilityMatrix.Avalonia/Models/SelectableItem.cs
  2. 1
      StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageExtensionBrowserViewModel.cs
  3. 287
      StabilityMatrix.Avalonia/Views/PackageManager/PackageExtensionBrowserView.axaml
  4. 15
      StabilityMatrix.Avalonia/Views/ProgressManagerPage.axaml

8
StabilityMatrix.Core/Models/SelectableItem.cs → StabilityMatrix.Avalonia/Models/SelectableItem.cs

@ -1,7 +1,11 @@
using System;
using System.Collections.Generic;
using System.Windows.Input;
using CommunityToolkit.Mvvm.Input;
using DynamicData.Binding;
using JetBrains.Annotations;
namespace StabilityMatrix.Core.Models;
namespace StabilityMatrix.Avalonia.Models;
[PublicAPI]
public class SelectableItem<T>(T item) : AbstractNotifyPropertyChanged, IEquatable<SelectableItem<T>>
@ -16,6 +20,8 @@ public class SelectableItem<T>(T item) : AbstractNotifyPropertyChanged, IEquatab
set => SetAndRaise(ref _isSelected, value);
}
public ICommand ToggleSelectedCommand => new RelayCommand(() => IsSelected = !IsSelected);
/// <inheritdoc />
public bool Equals(SelectableItem<T>? other)
{

1
StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageExtensionBrowserViewModel.cs

@ -19,6 +19,7 @@ using FluentAvalonia.UI.Controls;
using KGySoft.CoreLibraries;
using StabilityMatrix.Avalonia.Collections;
using StabilityMatrix.Avalonia.Languages;
using StabilityMatrix.Avalonia.Models;
using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.ViewModels.Dialogs;

287
StabilityMatrix.Avalonia/Views/PackageManager/PackageExtensionBrowserView.axaml

@ -15,6 +15,7 @@
xmlns:sg="clr-namespace:SpacedGridControl.Avalonia;assembly=SpacedGridControl.Avalonia"
xmlns:models="clr-namespace:StabilityMatrix.Core.Models;assembly=StabilityMatrix.Core"
xmlns:converters="clr-namespace:StabilityMatrix.Avalonia.Converters"
xmlns:models1="clr-namespace:StabilityMatrix.Avalonia.Models"
d:DataContext="{x:Static mocks:DesignData.PackageExtensionBrowserViewModel}"
x:DataType="packageManager:PackageExtensionBrowserViewModel"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
@ -22,135 +23,154 @@
<controls:UserControlBase.Resources>
<!--<input:StandardUICommand x:Key="InstallExtensionCommand"
Command="{Binding InstallExtensionCommand}" />-->
<converters:FileUriConverter x:Key="FileUriConverter"/>
<converters:FileUriConverter x:Key="FileUriConverter" />
<DataTemplate x:Key="PackageExtensionTemplate">
<DataTemplate.DataType>
<x:Type TypeName="models:SelectableItem" x:TypeArguments="extensions:PackageExtension"/>
<x:Type TypeName="models1:SelectableItem" x:TypeArguments="extensions:PackageExtension" />
</DataTemplate.DataType>
<controls:Card
Padding="12,12"
Margin="4"
Classes="transparent-full"
CornerRadius="8">
<Button Background="Transparent"
Padding="-5"
Margin="4, 0, 0, 8"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
Classes="transparent-full"
BorderBrush="Transparent"
CornerRadius="8"
Command="{Binding ToggleSelectedCommand}">
<controls:Card
Padding="12,12"
Margin="4"
Classes="transparent-full"
CornerRadius="8">
<sg:SpacedGrid ColumnDefinitions="Auto,*,Auto">
<!--<controls:BetterAdvancedImage
<sg:SpacedGrid ColumnDefinitions="Auto,*,Auto">
<!--<controls:BetterAdvancedImage
Grid.Column="0"
MaxHeight="128"
MaxWidth="128"
Stretch="UniformToFill"
CornerRadius="4"
Source="{Binding PreviewImageUri}" />-->
<StackPanel Grid.Column="1" Orientation="Vertical" Spacing="4">
<TextBlock Text="{Binding Item.Title}"
FontWeight="Light"
FontSize="16" />
<TextBlock Text="{Binding Item.Author}"
FontWeight="Light"
FontSize="13" />
<StackPanel Grid.Column="1" Orientation="Vertical" Spacing="4">
<TextBlock Text="{Binding Item.Title}"
FontWeight="Light"
FontSize="16" />
<TextBlock TextWrapping="Wrap"
Text="{Binding Item.Description}"
Foreground="{DynamicResource TextFillColorSecondary}"
FontWeight="Light"
FontSize="13" />
<controls:HyperlinkIconButton
Margin="0"
Padding="0,2"
NavigateUri="{Binding Item.Reference}"
Content="GitHub"
/>
</StackPanel>
<CheckBox
IsChecked="{Binding IsSelected}"
Margin="0,0,16,0"
Grid.Column="2"/>
</sg:SpacedGrid>
</controls:Card>
<TextBlock Text="{Binding Item.Author}"
FontWeight="Light"
FontSize="13" />
<TextBlock TextWrapping="Wrap"
Text="{Binding Item.Description}"
Foreground="{DynamicResource TextFillColorSecondary}"
FontWeight="Light"
FontSize="13" />
<controls:HyperlinkIconButton
Margin="0"
Padding="0,2"
NavigateUri="{Binding Item.Reference}"
Content="GitHub" />
</StackPanel>
<CheckBox
IsChecked="{Binding IsSelected}"
Margin="0,0,16,0"
Grid.Column="2" />
</sg:SpacedGrid>
</controls:Card>
</Button>
</DataTemplate>
<DataTemplate x:Key="InstalledPackageExtensionTemplate">
<DataTemplate.DataType>
<x:Type TypeName="models:SelectableItem" x:TypeArguments="extensions:InstalledPackageExtension"/>
<x:Type TypeName="models1:SelectableItem" x:TypeArguments="extensions:InstalledPackageExtension" />
</DataTemplate.DataType>
<controls:Card
Padding="12,12"
Margin="4"
Classes="transparent-full"
CornerRadius="8">
<Button Background="Transparent"
Padding="-5"
Margin="4, 0, 0, 8"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
Classes="transparent-full"
BorderBrush="Transparent"
CornerRadius="8"
Command="{Binding ToggleSelectedCommand}">
<controls:Card
Padding="12,12"
Margin="4"
Classes="transparent-full"
CornerRadius="8">
<sg:SpacedGrid ColumnDefinitions="*,Auto">
<StackPanel
DataContext="{Binding Item}"
Orientation="Vertical" Spacing="4">
<TextBlock
Text="{Binding Title}"
FontWeight="Light"
FontSize="16"/>
<TextBlock Text="{Binding Version, FallbackValue=''}"
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
FontSize="13" />
<TextBlock TextWrapping="Wrap"
Text="{Binding Definition.Description, FallbackValue=''}"
Foreground="{DynamicResource TextFillColorSecondary}"
FontWeight="Light"
FontSize="13" />
<StackPanel Orientation="Horizontal" Spacing="2">
<controls:HyperlinkIconButton
IsEnabled="{Binding Definition, Converter={x:Static ObjectConverters.IsNotNull}}"
Margin="0"
Padding="0,2"
NavigateUri="{Binding Definition.Reference, FallbackValue=''}"
Content="GitHub"/>
<Ellipse
Width="3"
Height="3"
Opacity="0.8"
VerticalAlignment="Center"
Fill="{DynamicResource TextFillColorTertiaryBrush}" />
<controls:HyperlinkIconButton
IsEnabled="{Binding Definition, Converter={x:Static ObjectConverters.IsNotNull}}"
Margin="0"
Padding="0,2"
NavigateUri="{Binding PrimaryPath.FullPath, Converter={StaticResource FileUriConverter}}"
Content="{Binding DisplayPath}"/>
<sg:SpacedGrid ColumnDefinitions="*,Auto">
<StackPanel
DataContext="{Binding Item}"
Orientation="Vertical" Spacing="4">
<TextBlock
Text="{Binding Title}"
FontWeight="Light"
FontSize="16" />
<TextBlock Text="{Binding Version, FallbackValue=''}"
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
FontSize="13" />
<TextBlock TextWrapping="Wrap"
Text="{Binding Definition.Description, FallbackValue=''}"
Foreground="{DynamicResource TextFillColorSecondary}"
FontWeight="Light"
FontSize="13" />
<StackPanel Orientation="Horizontal" Spacing="2">
<controls:HyperlinkIconButton
IsEnabled="{Binding Definition, Converter={x:Static ObjectConverters.IsNotNull}}"
Margin="0"
Padding="0,2"
NavigateUri="{Binding Definition.Reference, FallbackValue=''}"
Content="GitHub" />
<Ellipse
Width="3"
Height="3"
Opacity="0.8"
VerticalAlignment="Center"
Fill="{DynamicResource TextFillColorTertiaryBrush}" />
<controls:HyperlinkIconButton
IsEnabled="{Binding Definition, Converter={x:Static ObjectConverters.IsNotNull}}"
Margin="0"
Padding="0,2"
NavigateUri="{Binding PrimaryPath.FullPath, Converter={StaticResource FileUriConverter}}"
Content="{Binding DisplayPath}" />
</StackPanel>
</StackPanel>
</StackPanel>
<CheckBox
Grid.Column="1"
HorizontalAlignment="Right"
IsChecked="{Binding IsSelected}"
Margin="0,0,16,0"/>
</sg:SpacedGrid>
</controls:Card>
<CheckBox
Grid.Column="1"
HorizontalAlignment="Right"
IsChecked="{Binding IsSelected}"
Margin="0,0,16,0" />
</sg:SpacedGrid>
</controls:Card>
</Button>
</DataTemplate>
</controls:UserControlBase.Resources>
<TabControl TabStripPlacement="Top" SelectionChanged="TabControl_OnSelectionChanged">
<TabControl.Items>
<TabItem FontSize="18" Header="Available Extensions" Margin="8,0,0,0">
<sg:SpacedGrid
<sg:SpacedGrid
RowDefinitions="Auto,*,Auto"
RowSpacing="12"
Margin="8">
<sg:SpacedGrid
ColumnDefinitions="*,Auto,Auto"
<sg:SpacedGrid
ColumnDefinitions="*,Auto,Auto"
ColumnSpacing="8">
<TextBox
<TextBox
Classes="search"
Margin="4, 0,0,0"
Watermark="{x:Static lang:Resources.Action_Search}"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Text="{Binding AvailableItemsSearchCollection.Query, Mode=TwoWay}"/>
Watermark="{x:Static lang:Resources.Action_Search}"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Text="{Binding AvailableItemsSearchCollection.Query, Mode=TwoWay}" />
<!-- Refresh Button -->
<Button
Grid.Row="0"
@ -161,7 +181,7 @@
Command="{Binding RefreshCommand}">
<ui:SymbolIcon FontSize="16" Symbol="Refresh" />
</Button>
<!-- Settings / Edit Manifests Button -->
<Button
Grid.Row="0"
@ -173,11 +193,11 @@
<ui:SymbolIcon FontSize="16" Symbol="Settings" />
</Button>
</sg:SpacedGrid>
<ScrollViewer
<ScrollViewer
IsVisible="{Binding !IsLoading}"
Grid.Row="1">
<ItemsRepeater
<ItemsRepeater
DataContext="{Binding AvailableItemsSearchCollection}"
ItemTemplate="{StaticResource PackageExtensionTemplate}"
ItemsSource="{Binding FilteredItems}">
@ -186,7 +206,7 @@
</ItemsRepeater.Layout>
</ItemsRepeater>
</ScrollViewer>
<Panel
IsVisible="{Binding IsLoading}"
Grid.Row="1">
@ -194,49 +214,49 @@
Margin="32,16"
IsIndeterminate="True"
IsEnabled="{Binding IsLoading}"
IsVisible="{Binding IsLoading}"/>
IsVisible="{Binding IsLoading}" />
</Panel>
<ui:InfoBar
Grid.Row="2"
IsOpen="{Binding !!SelectedAvailableItems.Count}"
IsOpen="{Binding !!SelectedAvailableItems.Count}"
HorizontalContentAlignment="Right"
HorizontalAlignment="Right"
CloseButtonCommand="{Binding ClearSelection}"
IsIconVisible="False">
<ui:InfoBar.Title>
<MultiBinding StringFormat="{}{0} Selected">
<Binding Path="SelectedAvailableItems.Count"/>
<Binding Path="SelectedAvailableItems.Count" />
</MultiBinding>
</ui:InfoBar.Title>
<ui:InfoBar.ActionButton>
<Button
Classes="accent"
Command="{Binding InstallSelectedExtensionsCommand}"
Content="{x:Static lang:Resources.Action_Install}"/>
Content="{x:Static lang:Resources.Action_Install}" />
</ui:InfoBar.ActionButton>
</ui:InfoBar>
</sg:SpacedGrid>
</TabItem>
<TabItem FontSize="18" Header="Installed Extensions" Margin="0,0,0,0">
<sg:SpacedGrid
<sg:SpacedGrid
RowDefinitions="Auto,*,Auto"
RowSpacing="12"
Margin="8">
<sg:SpacedGrid
ColumnDefinitions="*,Auto"
<sg:SpacedGrid
ColumnDefinitions="*,Auto"
ColumnSpacing="8">
<TextBox
<TextBox
Classes="search"
Margin="4, 0,0,0"
DataContext="{Binding InstalledItemsSearchCollection}"
Watermark="{x:Static lang:Resources.Action_Search}"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Text="{Binding Query, Mode=TwoWay}"/>
DataContext="{Binding InstalledItemsSearchCollection}"
Watermark="{x:Static lang:Resources.Action_Search}"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Text="{Binding Query, Mode=TwoWay}" />
<!-- Refresh Button -->
<Button
@ -248,7 +268,7 @@
Command="{Binding RefreshCommand}">
<ui:SymbolIcon FontSize="16" Symbol="Refresh" />
</Button>
<!-- Settings / Edit Manifests Button -->
<!--<Button
Grid.Row="0"
@ -259,8 +279,8 @@
<ui:SymbolIcon FontSize="16" Symbol="Settings" />
</Button>-->
</sg:SpacedGrid>
<ScrollViewer
<ScrollViewer
IsVisible="{Binding !IsLoading}"
Grid.Row="1">
<ItemsRepeater
@ -272,28 +292,27 @@
</ItemsRepeater.Layout>
</ItemsRepeater>
</ScrollViewer>
<Panel
IsVisible="{Binding IsLoading}"
Grid.Row="1"
>
Grid.Row="1">
<ProgressBar
Margin="32,16"
IsIndeterminate="True"
IsEnabled="{Binding IsLoading}"
IsVisible="{Binding IsLoading}"/>
IsVisible="{Binding IsLoading}" />
</Panel>
<ui:InfoBar
Grid.Row="2"
IsOpen="{Binding !!SelectedInstalledItems.Count}"
IsOpen="{Binding !!SelectedInstalledItems.Count}"
HorizontalContentAlignment="Right"
HorizontalAlignment="Right"
CloseButtonCommand="{Binding ClearSelection}"
IsIconVisible="False">
<ui:InfoBar.Title>
<MultiBinding StringFormat="{}{0} Selected">
<Binding Path="SelectedInstalledItems.Count"/>
<Binding Path="SelectedInstalledItems.Count" />
</MultiBinding>
</ui:InfoBar.Title>
<ui:InfoBar.ActionButton>
@ -301,17 +320,17 @@
<Button
Classes="accent"
Command="{Binding UpdateSelectedExtensionsCommand}"
Content="{x:Static lang:Resources.Action_Update}"/>
Content="{x:Static lang:Resources.Action_Update}" />
<Button
Command="{Binding UninstallSelectedExtensionsCommand}"
Content="{x:Static lang:Resources.Action_Uninstall}"/>
Content="{x:Static lang:Resources.Action_Uninstall}" />
</StackPanel>
</ui:InfoBar.ActionButton>
</ui:InfoBar>
</sg:SpacedGrid>
</TabItem>
</TabControl.Items>
</TabControl>

15
StabilityMatrix.Avalonia/Views/ProgressManagerPage.axaml

@ -4,17 +4,14 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:StabilityMatrix.Avalonia.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:fluentAvalonia="clr-namespace:FluentIcons.FluentAvalonia;assembly=FluentIcons.FluentAvalonia"
xmlns:icons="clr-namespace:Projektanker.Icons.Avalonia;assembly=Projektanker.Icons.Avalonia"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mocks="clr-namespace:StabilityMatrix.Avalonia.DesignData"
xmlns:ui="using:FluentAvalonia.UI.Controls"
xmlns:vm="clr-namespace:StabilityMatrix.Avalonia.ViewModels"
xmlns:vmBase="clr-namespace:StabilityMatrix.Avalonia.ViewModels.Base"
xmlns:progress="clr-namespace:StabilityMatrix.Avalonia.ViewModels.Progress"
MaxHeight="250"
MaxHeight="550"
d:DataContext="{x:Static mocks:DesignData.ProgressManagerViewModel}"
d:DesignHeight="250"
d:DesignHeight="550"
d:DesignWidth="300"
x:DataType="progress:ProgressManagerViewModel"
mc:Ignorable="d">
@ -137,6 +134,8 @@
<!-- non-indeterminate progress -->
<TextBlock
Margin="0,0"
MaxWidth="250"
HorizontalAlignment="Left"
IsVisible="{Binding !Progress.IsIndeterminate}">
<Run Text="{Binding Progress.Text, Mode=OneWay}" />
<Run Text="{Binding Progress.Value, Mode=OneWay}" /><Run Text="%" />
@ -144,6 +143,8 @@
<!-- indeterminate progress -->
<TextBlock
MaxWidth="250"
HorizontalAlignment="Left"
Margin="0,4"
IsVisible="{Binding Progress.IsIndeterminate}"
Text="{Binding Progress.Text, Mode=OneWay}" />
@ -182,6 +183,10 @@
<StackPanel Grid.Row="0" Grid.Column="0">
<TextBlock Margin="0,0"
MaxWidth="250"
HorizontalAlignment="Left"
TextWrapping="NoWrap"
TextTrimming="CharacterEllipsis"
Text="{Binding Progress.Text, Mode=OneWay}" />
<!-- non-indeterminate progress -->

Loading…
Cancel
Save