Multi-Platform Package Manager for Stable Diffusion
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

437 lines
22 KiB

<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:controls="clr-namespace:StabilityMatrix.Avalonia.Controls"
xmlns:viewModels="clr-namespace:StabilityMatrix.Avalonia.ViewModels"
xmlns:designData="clr-namespace:StabilityMatrix.Avalonia.DesignData"
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:vm="clr-namespace:StabilityMatrix.Avalonia.ViewModels.CheckpointManager"
xmlns:checkpointBrowser="clr-namespace:StabilityMatrix.Avalonia.ViewModels.CheckpointBrowser"
xmlns:avalonia="clr-namespace:Projektanker.Icons.Avalonia;assembly=Projektanker.Icons.Avalonia"
xmlns:lang="clr-namespace:StabilityMatrix.Avalonia.Languages"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="700"
x:DataType="viewModels:CheckpointBrowserViewModel"
d:DataContext="{x:Static designData:DesignData.CheckpointBrowserViewModel}"
x:CompileBindings="True"
x:Class="StabilityMatrix.Avalonia.Views.CheckpointBrowserPage">
<UserControl.Styles>
<Style Selector="Border#HoverBorder Border#ModelCardBottom">
<Setter Property="Background" Value="#99000000" />
</Style>
<Style Selector="Border#HoverBorder:pointerover Border#ModelCardBottom">
<Setter Property="Background" Value="#CC000000" />
</Style>
<Style Selector="Border#HoverBorder">
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Cursor" Value="Arrow" />
<Setter Property="Margin" Value="8" />
</Style>
<Style Selector="Border#HoverBorder:pointerover">
<Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColorDark1}" />
<Setter Property="BorderThickness" Value="0,0,0,1" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Margin" Value="8,4,8,12" />
</Style>
<Style Selector="Border#HoverBorder controls|BetterAdvancedImage">
</Style>
<Style Selector="Border#HoverBorder:pointerover controls|BetterAdvancedImage">
</Style>
</UserControl.Styles>
<UserControl.Resources>
<DataTemplate DataType="{x:Type checkpointBrowser:CheckpointBrowserCardViewModel}" x:Key="CivitModelTemplate">
<Border
Height="404"
Width="334"
Name="HoverBorder"
HorizontalAlignment="Center"
CornerRadius="8"
Padding="0">
<Button
Padding="-1"
CornerRadius="12"
Name="ModelCard"
IsEnabled="{Binding !IsImporting}"
Command="{Binding ShowVersionDialogCommand}"
CommandParameter="{Binding CivitModel}"
HorizontalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Top">
<Grid RowDefinitions="*, Auto"
HorizontalAlignment="Center">
<controls:BetterAdvancedImage Grid.RowSpan="2"
Height="400"
Width="330"
StretchDirection="Both"
CornerRadius="8"
VerticalContentAlignment="Top"
HorizontalContentAlignment="Center"
Source="{Binding CardImage}"
Stretch="UniformToFill" />
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right">
<Button
Command="{Binding ToggleFavoriteCommand}"
HorizontalAlignment="Right"
Margin="0,8,8,0"
FontSize="20"
Classes="transparent-info"
IsVisible="{Binding !IsFavorite}"
VerticalAlignment="Top">
<Grid>
<ui:SymbolIcon Symbol="StarAdd" />
</Grid>
</Button>
<Button
Command="{Binding ToggleFavoriteCommand}"
HorizontalAlignment="Right"
Margin="0,8,8,0"
FontSize="20"
Classes="success"
IsVisible="{Binding IsFavorite}"
VerticalAlignment="Top">
<Grid>
<ui:SymbolIcon Symbol="StarFilled" />
</Grid>
</Button>
</StackPanel>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<controls:Card
Classes="info"
Height="24"
HorizontalAlignment="Left"
Padding="4"
Margin="8,8,0,0"
VerticalAlignment="Top">
<TextBlock
FontSize="11"
FontWeight="Medium"
HorizontalAlignment="Center"
Text="{Binding CivitModel.Type}"
VerticalAlignment="Center" />
</controls:Card>
<controls:Card
Classes="info"
Height="24"
HorizontalAlignment="Left"
Padding="4"
Margin="4,8,0,0"
VerticalAlignment="Top">
<TextBlock
FontSize="11"
FontWeight="Medium"
HorizontalAlignment="Center"
Text="{Binding CivitModel.BaseModelType}"
VerticalAlignment="Center" />
</controls:Card>
<controls:Card
Classes="success"
Height="24"
HorizontalAlignment="Left"
Padding="4"
IsVisible="{Binding ShowUpdateCard}"
Margin="4,8,0,0"
VerticalAlignment="Top">
<TextBlock
FontSize="11"
FontWeight="Medium"
HorizontalAlignment="Center"
Text="{Binding UpdateCardText}"
VerticalAlignment="Center" />
</controls:Card>
</StackPanel>
<Border Grid.Row="0"
Grid.RowSpan="2"
Background="#DD000000"
CornerRadius="8"
HorizontalAlignment="Stretch"
Margin="0,0,0,0"
VerticalAlignment="Stretch"
ZIndex="1"
IsVisible="{Binding IsImporting}" />
<StackPanel Grid.Row="0"
Grid.RowSpan="2"
HorizontalAlignment="Stretch"
Orientation="Vertical"
VerticalAlignment="Center"
ZIndex="2"
IsVisible="{Binding IsImporting}">
<controls:ProgressRing
HorizontalAlignment="Center"
IsIndeterminate="False"
Width="120"
Height="120"
StartAngle="90"
EndAngle="450"
Value="{Binding Value}"
VerticalAlignment="Center" />
<TextBlock
HorizontalAlignment="Center"
Margin="0,8,0,0"
Text="{Binding Text, TargetNullValue=Importing...}"
VerticalAlignment="Center" />
</StackPanel>
<Border Grid.Row="1" Name="ModelCardBottom"
CornerRadius="0,0,8,8">
<Grid RowDefinitions="Auto, Auto, Auto"
ColumnDefinitions="*, Auto">
<TextBlock
Grid.ColumnSpan="2"
HorizontalAlignment="Left"
Margin="8,0,8,0"
FontWeight="SemiBold"
LetterSpacing="0.33"
Foreground="{DynamicResource TextControlForeground}"
Text="{Binding CivitModel.Name}"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap"
MaxWidth="250"
ToolTip.Tip="{Binding CivitModel.Name}"
VerticalAlignment="Center" />
<TextBlock Grid.Row="1"
Grid.Column="0"
FontSize="11"
Foreground="{DynamicResource TextControlForeground}"
Margin="8,-4,0,0"
Text="{Binding CivitModel.LatestModelVersionName, FallbackValue=''}"
VerticalAlignment="Center" />
<StackPanel Orientation="Horizontal"
Grid.Column="0"
Grid.Row="2">
<controls:StarsRating
FontSize="16"
Margin="8,8,0,8"
Value="{Binding CivitModel.Stats.Rating}"
Foreground="{DynamicResource ThemeEldenRingOrangeColor}"
Background="#66000000" />
<TextBlock Text="{Binding CivitModel.Stats.RatingCount}"
TextAlignment="Center"
Margin="4,0,0,0"
VerticalAlignment="Center"/>
</StackPanel>
<StackPanel Grid.Row="2"
Grid.Column="1"
Orientation="Horizontal"
HorizontalAlignment="Right">
<avalonia:Icon Value="fa-solid fa-heart"/>
<TextBlock Text="{Binding CivitModel.Stats.FavoriteCount}"
VerticalAlignment="Center"
Margin="4,0"/>
<avalonia:Icon Value="fa-solid fa-download"
Margin="4,0"/>
<TextBlock Text="{Binding CivitModel.Stats.DownloadCount}"
VerticalAlignment="Center"
Margin="0,0,4,0"/>
</StackPanel>
<Button
Grid.Row="0" Grid.Column="1"
HorizontalContentAlignment="Right"
HorizontalAlignment="Right"
VerticalContentAlignment="Top"
VerticalAlignment="Top"
Margin="0,4,4,0"
Classes="transparent"
Width="32"
BorderThickness="0">
<ui:SymbolIcon FontSize="18" Symbol="MoreVertical" />
<Button.Flyout>
<MenuFlyout>
<MenuItem Header="{x:Static lang:Resources.Action_OpenOnCivitAi}"
Command="{Binding OpenModelCommand}">
<MenuItem.Icon>
<ui:SymbolIcon Symbol="Open" />
</MenuItem.Icon>
</MenuItem>
</MenuFlyout>
</Button.Flyout>
</Button>
</Grid>
</Border>
</Grid>
</Button>
</Border>
</DataTemplate>
</UserControl.Resources>
<Grid RowDefinitions="Auto,*,Auto" Margin="0,8,0,0">
<StackPanel Margin="8" Orientation="Vertical">
<Grid ColumnDefinitions="*,Auto">
<TextBox
HorizontalAlignment="Stretch"
Margin="8,0,0,0"
KeyDown="InputElement_OnKeyDown"
Watermark="{x:Static lang:Resources.Label_ModelSearchWatermark}"
Text="{Binding SearchQuery, Mode=TwoWay}">
<TextBox.InnerRightContent>
<Button Classes="transparent-full"
IsVisible="{Binding SearchQuery.Length}"
Command="{Binding ClearSearchQuery}">
<ui:SymbolIcon Symbol="Cancel" />
</Button>
</TextBox.InnerRightContent>
</TextBox>
<Button
Classes="accent"
Command="{Binding SearchModelsCommand}"
Grid.Column="1"
IsDefault="True"
Margin="8,0,8,0"
VerticalAlignment="Stretch"
Width="80">
<Grid>
<controls:ProgressRing
MinHeight="16"
IsIndeterminate="True"
VerticalAlignment="Center"
BorderThickness="4"
IsVisible="{Binding SearchModelsCommand.IsRunning}"
MinWidth="16" />
<TextBlock
Text="{x:Static lang:Resources.Action_Search}"
VerticalAlignment="Center"
IsVisible="{Binding !SearchModelsCommand.IsRunning}" />
</Grid>
</Button>
</Grid>
<DockPanel>
<StackPanel Margin="8, 8,4,8" Orientation="Vertical">
<Label Content="{x:Static lang:Resources.Label_Sort}" />
<ComboBox
ItemsSource="{Binding AllSortModes}"
MinWidth="100"
SelectedItem="{Binding SortMode}" />
</StackPanel>
<StackPanel Margin="4, 8" Orientation="Vertical">
<Label Content="{x:Static lang:Resources.Label_TimePeriod}" />
<ComboBox
ItemsSource="{Binding AllCivitPeriods}"
MinWidth="100"
SelectedItem="{Binding SelectedPeriod}" />
</StackPanel>
<StackPanel Margin="4, 8" Orientation="Vertical">
<Label Content="{x:Static lang:Resources.Label_ModelType}" />
<ComboBox
ItemsSource="{Binding AllModelTypes}"
MinWidth="100"
SelectedItem="{Binding SelectedModelType}" />
</StackPanel>
<StackPanel Margin="4, 8" Orientation="Vertical">
<Label Content="{x:Static lang:Resources.Label_BaseModel}" />
<ComboBox
ItemsSource="{Binding BaseModelOptions}"
MinWidth="100"
SelectedItem="{Binding SelectedBaseModelType}" />
</StackPanel>
<CheckBox
Content="{x:Static lang:Resources.Label_ShowNsfwContent}"
HorizontalAlignment="Right"
IsChecked="{Binding ShowNsfw, Mode=TwoWay}"
Margin="8,8,8,0" />
</DockPanel>
</StackPanel>
<ScrollViewer Grid.Row="1"
Margin="8,0,8,0"
ScrollChanged="ScrollViewer_OnScrollChanged">
<ItemsRepeater ItemTemplate="{StaticResource CivitModelTemplate}"
ItemsSource="{Binding ModelCards}">
<ItemsRepeater.Layout>
<UniformGridLayout Orientation="Horizontal" />
</ItemsRepeater.Layout>
</ItemsRepeater>
</ScrollViewer>
<TextBlock
Grid.Row="2"
Margin="16,8"
Text="{x:Static lang:Resources.Label_DataProvidedByCivitAi}"
VerticalAlignment="Bottom" />
<StackPanel
Grid.Row="2"
HorizontalAlignment="Center"
Margin="8"
Orientation="Vertical"
IsVisible="{Binding HasSearched}">
<TextBlock Margin="0,0,4,4" TextAlignment="Center">
<Run Text="{x:Static lang:Resources.Label_Page}" />
<Run Text="{Binding CurrentPageNumber, FallbackValue=1}" />
<Run Text="/" />
<Run Text="{Binding TotalPages, FallbackValue=5}" />
</TextBlock>
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
<Button
Command="{Binding FirstPage}"
IsEnabled="{Binding CanGoToFirstPage}"
ToolTip.Tip="{x:Static lang:Resources.Label_FirstPage}"
Margin="0,0,8,0">
<avalonia:Icon Value="fa-solid fa-backward-fast" />
</Button>
<Button
Command="{Binding PreviousPage}"
ToolTip.Tip="{x:Static lang:Resources.Label_PreviousPage}"
IsEnabled="{Binding CanGoToPreviousPage}"
Margin="0,0,8,0">
<avalonia:Icon Value="fa-solid fa-caret-left" />
</Button>
<Button Command="{Binding NextPage}"
IsEnabled="{Binding CanGoToNextPage}"
ToolTip.Tip="{x:Static lang:Resources.Label_NextPage}"
Margin="0,0,8,0">
<avalonia:Icon Value="fa-solid fa-caret-right" />
</Button>
<Button
Command="{Binding LastPage}"
ToolTip.Tip="{x:Static lang:Resources.Label_LastPage}"
IsEnabled="{Binding CanGoToLastPage}">
<avalonia:Icon Value="fa-solid fa-forward-fast" />
</Button>
</StackPanel>
</StackPanel>
<TextBlock
Grid.Row="0"
Grid.RowSpan="3"
FontSize="20"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding NoResultsText, FallbackValue=No results found}"
IsVisible="{Binding NoResultsFound}" />
<controls:ProgressRing
Grid.Row="1"
IsIndeterminate="True"
Width="128"
Height="128"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
IsVisible="{Binding ShowMainLoadingSpinner, FallbackValue=False}" />
</Grid>
</UserControl>