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. 227
      StabilityMatrix/CheckpointManagerPage.xaml
  2. 23
      StabilityMatrix/DesignData/MockCheckpointManagerViewModel.cs

227
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,76 +56,116 @@
</ui:Card.ContextMenu> </ui:Card.ContextMenu>
<Grid> <Grid>
<!-- Main contents, hidden when IsLoading is true --> <!-- Main contents, hidden when IsLoading is true -->
<Grid <VirtualizingStackPanel Orientation="Vertical">
HorizontalAlignment="Stretch" <ui:Image
VerticalAlignment="Stretch" CornerRadius="4"
Visibility="{Binding IsLoading, Converter={StaticResource InvertAndVisibleOrHidden}}"> Margin="0,0,0,8"
<Grid.ColumnDefinitions> Source="{Binding PreviewImagePath}"
<ColumnDefinition Width="*" /> Stretch="Uniform"
<ColumnDefinition Width="0.2*" /> Visibility="Collapsed" />
</Grid.ColumnDefinitions> <Grid
<StackPanel Orientation="Vertical"> HorizontalAlignment="Stretch"
<ui:Image Name="ModelInfoGrid"
CornerRadius="4" VerticalAlignment="Stretch"
Margin="4,4,4,8" Visibility="{Binding IsLoading, Converter={StaticResource InvertAndVisibleOrHidden}}">
MinHeight="256" <Grid.ColumnDefinitions>
MinWidth="200" <ColumnDefinition Width="*" />
Source="{Binding PreviewImage}" <ColumnDefinition Width="0.6*" />
Stretch="UniformToFill" </Grid.ColumnDefinitions>
Visibility="Collapsed" <StackPanel Orientation="Vertical">
Width="128" /> <TextBlock
<TextBlock Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Foreground="{DynamicResource TextFillColorPrimaryBrush}" Text="{Binding Title}"
Margin="0,0,0,0" TextWrapping="WrapWithOverflow" />
Text="{Binding Title}" <TextBlock
VerticalAlignment="Center" />
<TextBlock
FontSize="11"
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
Margin="0,2,0,0"
Text="{Binding FileName}"
VerticalAlignment="Center" />
</StackPanel>
<Grid Grid.Column="1">
<Button
Background="Transparent"
BorderBrush="Transparent"
FontSize="20"
HorizontalAlignment="Right"
IsEnabled="True"
MaxHeight="48"
MaxWidth="64"
Padding="0"
ToolTip="Connected Model"
VerticalAlignment="Top"
Visibility="{Binding IsConnectedModel, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}">
<ui:SymbolIcon
FontSize="12" FontSize="12"
Foreground="LightGreen" Foreground="{DynamicResource TextFillColorTertiaryBrush}"
Symbol="CloudCheckmark24" Text="{Binding ConnectedModel.VersionName, FallbackValue=''}"
ToolTip="Connected Model" /> TextWrapping="WrapWithOverflow"
</Button> Visibility="{Binding IsConnectedModel, Converter={StaticResource BoolToVisibilityConverter}}" />
<ui:Button <TextBlock
Background="Transparent" FontSize="11"
BorderBrush="Transparent" Foreground="{DynamicResource TextFillColorTertiaryBrush}"
FontSize="20" Margin="0,4,0,4"
HorizontalAlignment="Right" Text="{Binding FileName}"
IsEnabled="False" TextWrapping="WrapWithOverflow"
MaxHeight="48" VerticalAlignment="Bottom" />
MaxWidth="64" </StackPanel>
Padding="0" <Grid Grid.Column="1" Visibility="{Binding IsConnectedModel, Mode=OneWay, Converter={StaticResource BoolToHiddenVisibleConverter}}">
VerticalAlignment="Top" <Button
Visibility="Collapsed"> Background="Transparent"
<ui:Button.Icon> BorderBrush="Transparent"
FontSize="20"
HorizontalAlignment="Right"
IsEnabled="True"
MaxHeight="48"
MaxWidth="64"
Padding="0"
ToolTip="Connected Model"
VerticalAlignment="Top"
Visibility="{Binding IsConnectedModel, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}">
<ui:SymbolIcon <ui:SymbolIcon
FontSize="12" FontSize="12"
Foreground="OrangeRed" Foreground="LightGreen"
Symbol="CloudArrowUp24" Symbol="CloudCheckmark24"
ToolTip="Update Available" /> ToolTip="Connected Model" />
</ui:Button.Icon> </Button>
</ui:Button> <ui:Button
Background="Transparent"
BorderBrush="Transparent"
FontSize="20"
HorizontalAlignment="Right"
IsEnabled="False"
MaxHeight="48"
MaxWidth="64"
Padding="0"
VerticalAlignment="Top"
Visibility="Collapsed">
<ui:Button.Icon>
<ui:SymbolIcon
FontSize="12"
Foreground="OrangeRed"
Symbol="CloudArrowUp24"
ToolTip="Update Available" />
</ui:Button.Icon>
</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,18 +286,29 @@
</Page.Resources> </Page.Resources>
<!-- Folder Cards --> <!-- Folder Cards -->
<ui:DynamicScrollViewer <Grid>
CanContentScroll="True" <Grid.RowDefinitions>
HorizontalScrollBarVisibility="Disabled" <RowDefinition Height="0.1*" />
VerticalScrollBarVisibility="Auto"> <RowDefinition Height="*" />
<Grid> </Grid.RowDefinitions>
<StackPanel Orientation="Vertical"> <VirtualizingStackPanel Margin="16,8" Orientation="Horizontal">
<ItemsControl <ui:ToggleSwitch Content="Preview Images" />
HorizontalAlignment="Stretch" </VirtualizingStackPanel>
ItemTemplate="{StaticResource CheckpointFolderGridDataTemplate}" <ui:DynamicScrollViewer
ItemsSource="{Binding CheckpointFolders, Mode=OneWay}" CanContentScroll="True"
Margin="8" /> Grid.Row="1"
</StackPanel> HorizontalScrollBarVisibility="Disabled"
</Grid> VerticalScrollBarVisibility="Auto">
</ui:DynamicScrollViewer> <Grid>
<StackPanel Orientation="Vertical">
<ItemsControl
HorizontalAlignment="Stretch"
ItemTemplate="{StaticResource CheckpointFolderGridDataTemplate}"
ItemsSource="{Binding CheckpointFolders, Mode=OneWay}"
Margin="8" />
</StackPanel>
</Grid>
</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