Browse Source

Update UI layout of CheckpointFile cards

pull/5/head
Ionite 1 year ago
parent
commit
607b040555
No known key found for this signature in database
  1. 99
      StabilityMatrix/CheckpointManagerPage.xaml
  2. 23
      StabilityMatrix/DesignData/MockCheckpointManagerViewModel.cs

99
StabilityMatrix/CheckpointManagerPage.xaml

@ -4,7 +4,7 @@
Loaded="CheckpointManagerPage_OnLoaded" Loaded="CheckpointManagerPage_OnLoaded"
d:DataContext="{d:DesignInstance Type=designData:MockCheckpointManagerViewModel, d:DataContext="{d:DesignInstance Type=designData:MockCheckpointManagerViewModel,
IsDesignTimeCreatable=True}" IsDesignTimeCreatable=True}"
d:DesignHeight="500" d:DesignHeight="1000"
d:DesignWidth="650" d:DesignWidth="650"
mc:Ignorable="d" mc:Ignorable="d"
x:Class="StabilityMatrix.CheckpointManagerPage" x:Class="StabilityMatrix.CheckpointManagerPage"
@ -20,6 +20,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources> <Page.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<converters:StringNullOrEmptyToVisibilityConverter x:Key="StringNullOrEmptyToVisibilityConverter" />
<converters:BooleanToHiddenVisibleConverter x:Key="BoolToHiddenVisibleConverter" />
<converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
<converters:ValueConverterGroup x:Key="InvertAndVisibleOrHidden"> <converters:ValueConverterGroup x:Key="InvertAndVisibleOrHidden">
<converters:BoolNegationConverter /> <converters:BoolNegationConverter />
<converters:BooleanToHiddenVisibleConverter /> <converters:BooleanToHiddenVisibleConverter />
@ -34,14 +38,16 @@
x:Key="TextDropShadowEffect" /> x:Key="TextDropShadowEffect" />
<DataTemplate DataType="{x:Type models:CheckpointFile}" x:Key="CheckpointFileDataTemplate"> <DataTemplate DataType="{x:Type models:CheckpointFile}" x:Key="CheckpointFileDataTemplate">
<Border> <Border Background="Transparent" BorderThickness="0">
<i:Interaction.Behaviors> <i:Interaction.Behaviors>
<i:MouseDragElementBehavior /> <i:MouseDragElementBehavior />
</i:Interaction.Behaviors> </i:Interaction.Behaviors>
<ui:Card <ui:Card
Height="96" Margin="8,8,8,8"
Margin="8" MaxHeight="512"
Width="240"> MaxWidth="300"
MinWidth="240"
Padding="12,16">
<ui:Card.ContextMenu> <ui:Card.ContextMenu>
<ContextMenu> <ContextMenu>
<MenuItem Header="Rename" /> <MenuItem Header="Rename" />
@ -50,37 +56,42 @@
</ui:Card.ContextMenu> </ui:Card.ContextMenu>
<Grid> <Grid>
<!-- Main contents, hidden when IsLoading is true --> <!-- Main contents, hidden when IsLoading is true -->
<VirtualizingStackPanel Orientation="Vertical">
<ui:Image
CornerRadius="4"
Margin="0,0,0,8"
Source="{Binding PreviewImagePath}"
Stretch="Uniform"
Visibility="Collapsed" />
<Grid <Grid
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
Name="ModelInfoGrid"
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
Visibility="{Binding IsLoading, Converter={StaticResource InvertAndVisibleOrHidden}}"> Visibility="{Binding IsLoading, Converter={StaticResource InvertAndVisibleOrHidden}}">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="0.2*" /> <ColumnDefinition Width="0.6*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<ui:Image
CornerRadius="4"
Margin="4,4,4,8"
MinHeight="256"
MinWidth="200"
Source="{Binding PreviewImage}"
Stretch="UniformToFill"
Visibility="Collapsed"
Width="128" />
<TextBlock <TextBlock
Foreground="{DynamicResource TextFillColorPrimaryBrush}" Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Margin="0,0,0,0"
Text="{Binding Title}" Text="{Binding Title}"
VerticalAlignment="Center" /> TextWrapping="WrapWithOverflow" />
<TextBlock
FontSize="12"
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
Text="{Binding ConnectedModel.VersionName, FallbackValue=''}"
TextWrapping="WrapWithOverflow"
Visibility="{Binding IsConnectedModel, Converter={StaticResource BoolToVisibilityConverter}}" />
<TextBlock <TextBlock
FontSize="11" FontSize="11"
Foreground="{DynamicResource TextFillColorTertiaryBrush}" Foreground="{DynamicResource TextFillColorTertiaryBrush}"
Margin="0,2,0,0" Margin="0,4,0,4"
Text="{Binding FileName}" Text="{Binding FileName}"
VerticalAlignment="Center" /> TextWrapping="WrapWithOverflow"
VerticalAlignment="Bottom" />
</StackPanel> </StackPanel>
<Grid Grid.Column="1"> <Grid Grid.Column="1" Visibility="{Binding IsConnectedModel, Mode=OneWay, Converter={StaticResource BoolToHiddenVisibleConverter}}">
<Button <Button
Background="Transparent" Background="Transparent"
BorderBrush="Transparent" BorderBrush="Transparent"
@ -92,7 +103,7 @@
Padding="0" Padding="0"
ToolTip="Connected Model" ToolTip="Connected Model"
VerticalAlignment="Top" VerticalAlignment="Top"
Visibility="{Binding IsConnectedModel, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}"> Visibility="{Binding IsConnectedModel, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}">
<ui:SymbolIcon <ui:SymbolIcon
FontSize="12" FontSize="12"
Foreground="LightGreen" Foreground="LightGreen"
@ -118,8 +129,43 @@
ToolTip="Update Available" /> ToolTip="Update Available" />
</ui:Button.Icon> </ui:Button.Icon>
</ui:Button> </ui:Button>
<VirtualizingStackPanel
HorizontalAlignment="Right"
Orientation="Horizontal"
VerticalAlignment="Bottom"
Visibility="{Binding IsConnectedModel, Mode=OneWay, Converter={StaticResource BoolToHiddenVisibleConverter}}">
<ui:Card
Height="18"
Margin="4,0,0,0"
Padding="3"
Visibility="{Binding FpType, Converter={StaticResource StringNullOrEmptyToVisibilityConverter}, FallbackValue=Collapsed}"
Width="40">
<TextBlock
FontSize="10"
FontWeight="Medium"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
HorizontalAlignment="Center"
Text="{Binding FpType}"
VerticalAlignment="Center" />
</ui:Card>
<ui:Card
Height="18"
Margin="4,0,0,0"
Padding="3"
Visibility="{Binding BaseModel, Converter={StaticResource StringNullOrEmptyToVisibilityConverter}, FallbackValue=Collapsed}"
Width="40">
<TextBlock
FontSize="10"
FontWeight="Medium"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
HorizontalAlignment="Center"
Text="{Binding BaseModel}"
VerticalAlignment="Center" />
</ui:Card>
</VirtualizingStackPanel>
</Grid> </Grid>
</Grid> </Grid>
</VirtualizingStackPanel>
<!-- Progress ring --> <!-- Progress ring -->
<ui:ProgressRing <ui:ProgressRing
@ -240,8 +286,17 @@
</Page.Resources> </Page.Resources>
<!-- Folder Cards --> <!-- Folder Cards -->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.1*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<VirtualizingStackPanel Margin="16,8" Orientation="Horizontal">
<ui:ToggleSwitch Content="Preview Images" />
</VirtualizingStackPanel>
<ui:DynamicScrollViewer <ui:DynamicScrollViewer
CanContentScroll="True" CanContentScroll="True"
Grid.Row="1"
HorizontalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto"> VerticalScrollBarVisibility="Auto">
<Grid> <Grid>
@ -254,4 +309,6 @@
</StackPanel> </StackPanel>
</Grid> </Grid>
</ui:DynamicScrollViewer> </ui:DynamicScrollViewer>
</Grid>
</Page> </Page>

23
StabilityMatrix/DesignData/MockCheckpointManagerViewModel.cs

@ -1,4 +1,5 @@
using System.ComponentModel; using System.ComponentModel;
using StabilityMatrix.Models.Api;
using StabilityMatrix.ViewModels; using StabilityMatrix.ViewModels;
namespace StabilityMatrix.DesignData; namespace StabilityMatrix.DesignData;
@ -27,19 +28,35 @@ public class MockCheckpointManagerViewModel : CheckpointManagerViewModel
}, },
new() new()
{ {
Title = "Example Realistic", Title = "Some Model",
FilePath = "exr-v21.safetensors", FilePath = "exr-v3.safetensors",
ConnectedModel = new() ConnectedModel = new()
{ {
ModelName = "Example Realistic", ModelName = "Example Realistic",
VersionName = "Hybrid v41", VersionName = "v3.0-Inpainting",
ModelDescription = "Example Description", ModelDescription = "Example Description",
BaseModel = "SD 1.5",
FileMetadata = new()
{
Fp = CivitModelFpType.fp32,
}
} }
}, },
new() new()
{ {
Title = "Painting e12", Title = "Painting e12",
FilePath = "painting-e12.pt", FilePath = "painting-e12.pt",
ConnectedModel = new()
{
ModelName = "Long Name Model (Stuff)",
VersionName = "v42-Advanced-Hybrid",
ModelDescription = "Example Description",
BaseModel = "SD 2.0",
FileMetadata = new()
{
Fp = CivitModelFpType.fp16,
}
}
}, },
} }
}, },

Loading…
Cancel
Save