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.

249 lines
11 KiB

<controls:UserControlBase
x:Class="StabilityMatrix.Avalonia.Views.Dialogs.PythonPackagesDialog"
xmlns="https://github.com/avaloniaui"
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:lang="clr-namespace:StabilityMatrix.Avalonia.Languages"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mocks="clr-namespace:StabilityMatrix.Avalonia.DesignData"
xmlns:models="clr-namespace:StabilityMatrix.Core.Models;assembly=StabilityMatrix.Core"
xmlns:python="clr-namespace:StabilityMatrix.Core.Python;assembly=StabilityMatrix.Core"
xmlns:sg="clr-namespace:SpacedGridControl.Avalonia;assembly=SpacedGridControl.Avalonia"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
xmlns:ui="using:FluentAvalonia.UI.Controls"
xmlns:vm="clr-namespace:StabilityMatrix.Avalonia.ViewModels"
xmlns:vmDialogs="clr-namespace:StabilityMatrix.Avalonia.ViewModels.Dialogs"
xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight"
xmlns:fluentIcons="clr-namespace:FluentIcons.FluentAvalonia;assembly=FluentIcons.FluentAvalonia"
xmlns:input="clr-namespace:FluentAvalonia.UI.Input;assembly=FluentAvalonia"
d:DataContext="{x:Static mocks:DesignData.PythonPackagesViewModel}"
d:DesignHeight="450"
d:DesignWidth="800"
x:DataType="vmDialogs:PythonPackagesViewModel"
mc:Ignorable="d">
<sg:SpacedGrid
MinHeight="300"
Margin="8"
ColumnDefinitions="Auto,Auto,*"
RowDefinitions="Auto,Auto,*">
<!-- Title -->
<!--<TextBlock
Margin="16,16,16,0"
FontSize="24"
FontWeight="Bold"
Text="{x:Static lang:Resources.Label_PythonPackages}"
TextWrapping="Wrap" />-->
<!-- Close button -->
<!--<Button
Grid.Row="1"
Grid.Column="2"
HorizontalAlignment="Right"
VerticalAlignment="Top">
<ui:SymbolIcon
Foreground="LightGreen"
Symbol=""
ToolTip.Tip="{x:Static lang:Resources.Label_ConnectedModel}" />
</Button>-->
<ui:CommandBar Grid.Row="1" Grid.Column="0">
<ui:CommandBar.Styles>
<Style Selector="ui|CommandBarButton">
<Setter Property="Padding" Value="4" />
<Setter Property="Width" Value="35" />
<Setter Property="Height" Value="45" />
</Style>
</ui:CommandBar.Styles>
<ui:CommandBar.PrimaryCommands>
<ui:CommandBarButton
IconSource="Add"
Command="{Binding InstallPackageCommand}"
Label="{x:Static lang:Resources.Action_AddPackage}" />
<ui:CommandBarButton
IconSource="Remove"
Command="{Binding UninstallSelectedPackageCommand}"
IsEnabled="{Binding SelectedPackage, Converter={x:Static ObjectConverters.IsNotNull}}"
Label="{x:Static lang:Resources.Action_Uninstall}"/>
<ui:CommandBarSeparator />
<ui:CommandBarButton
IconSource="Refresh"
Command="{Binding RefreshBackgroundCommand}"
IsEnabled="{Binding SelectedPackage, Converter={x:Static ObjectConverters.IsNotNull}}"
Label="{x:Static lang:Resources.Action_Refresh}"/>
</ui:CommandBar.PrimaryCommands>
</ui:CommandBar>
<controls:Card
Grid.Row="2"
Grid.Column="0"
Padding="0"
MinWidth="270"
VerticalAlignment="Stretch"
VerticalContentAlignment="Stretch"
Classes="transparent">
<ScrollViewer
IsVisible="{Binding !IsLoading}">
<ListBox
ItemsSource="{Binding Packages}"
SelectedItem="{Binding SelectedPackage}"
SelectionMode="AlwaysSelected">
<ListBox.ItemTemplate>
<DataTemplate DataType="vmDialogs:PythonPackagesItemViewModel">
<sg:SpacedGrid Margin="0,4" ColumnDefinitions="Auto,Auto">
<TextBlock
VerticalAlignment="Center"
Text="{Binding Package.Name}" Theme="{DynamicResource BodyStrongTextBlockStyle}" />
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
FontSize="13"
Foreground="{StaticResource ThemeLightGreyColor}"
Text="{Binding Package.Version}"
TextTrimming="CharacterEllipsis" />
</sg:SpacedGrid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
</controls:Card>
<ProgressBar
Margin="32,16"
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="3"
IsIndeterminate="True"
IsEnabled="{Binding IsLoading}"
IsVisible="{Binding IsLoading}"/>
<GridSplitter
Grid.Row="0"
Grid.RowSpan="3"
Grid.Column="1"
IsEnabled="False"
Width="8" />
<TransitioningContentControl
Margin="8,0"
Grid.Row="1"
Grid.RowSpan="2"
Grid.Column="2"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
Content="{Binding SelectedPackage}">
<TransitioningContentControl.Resources>
<input:StandardUICommand
x:Key="ModifySelectedPackageCommand"
Command="{Binding ModifySelectedPackageCommand}"/>
</TransitioningContentControl.Resources>
<TransitioningContentControl.ContentTemplate>
<DataTemplate DataType="{x:Type vmDialogs:PythonPackagesItemViewModel}">
<sg:SpacedGrid RowDefinitions="Auto,Auto,*" RowSpacing="16">
<TextBlock
Text="{Binding Package.Name}"
Theme="{DynamicResource TitleTextBlockStyle}" />
<StackPanel
Grid.Row="1"
Spacing="4"
Orientation="Horizontal">
<ComboBox
ItemsSource="{Binding AvailableVersions}"
SelectedItem="{Binding SelectedVersion}"/>
<!-- Upgrade button -->
<Button
Command="{StaticResource ModifySelectedPackageCommand}"
CommandParameter="{Binding}"
ToolTip.Tip="{x:Static lang:Resources.Action_Upgrade}"
IsVisible="{Binding CanUpgrade}"
Padding="5,5">
<fluentIcons:SymbolIcon
VerticalAlignment="Center"
FontSize="18"
Foreground="#3592c4"
Symbol="ArrowCircleUpRight" />
</Button>
<!-- Downgrade button -->
<Button
Command="{StaticResource ModifySelectedPackageCommand}"
CommandParameter="{Binding}"
ToolTip.Tip="{x:Static lang:Resources.Action_Downgrade}"
IsVisible="{Binding CanDowngrade}"
Padding="5,5">
<fluentIcons:SymbolIcon
VerticalAlignment="Center"
FontSize="18"
Symbol="ArrowCircleDownRight" />
</Button>
</StackPanel>
<!-- Loaded content -->
<StackPanel
HorizontalAlignment="Left"
MaxWidth="200"
Grid.Row="2"
IsVisible="{Binding !IsLoading}">
<TextBlock
TextWrapping="WrapWithOverflow"
Text="{Binding PipShowResult.Author}" />
<TextBlock
TextWrapping="WrapWithOverflow"
Text="{Binding PipShowResult.License}" />
<ui:HyperlinkButton
NavigateUri="{Binding PipShowResult.HomePage}"/>
<TextBlock
TextWrapping="WrapWithOverflow"
Text="{Binding PipShowResult.Summary}" />
</StackPanel>
<!-- Loading indicator -->
<ProgressBar
Grid.Row="2"
Margin="32,16"
IsIndeterminate="True"
IsEnabled="{Binding IsLoading}"
IsVisible="{Binding IsLoading}"/>
</sg:SpacedGrid>
</DataTemplate>
</TransitioningContentControl.ContentTemplate>
</TransitioningContentControl>
<!--<Carousel
Grid.Row="2"
Grid.Column="2"
ItemsSource="{Binding Packages}"
AutoScrollToSelectedItem="True"
SelectedItem="{Binding SelectedPackage}">
<Carousel.PageTransition>
<CompositePageTransition>
<PageSlide Orientation="Vertical" Duration="0.167" >
~1~<PageSlide.SlideInEasing>
<SineEaseIn />
</PageSlide.SlideInEasing>
<PageSlide.SlideOutEasing>
<SineEaseOut />
</PageSlide.SlideOutEasing>@1@
</PageSlide>
~1~<CrossFade Duration="0.167" />@1@
</CompositePageTransition>
</Carousel.PageTransition>
<Carousel.ItemTemplate>
<DataTemplate DataType="{x:Type python:PipPackageInfo}">
<sg:SpacedGrid>
<TextBlock Theme="{DynamicResource BodyStrongTextBlockStyle}" Text="{Binding Name}"/>
</sg:SpacedGrid>
</DataTemplate>
</Carousel.ItemTemplate>
</Carousel>-->
</sg:SpacedGrid>
</controls:UserControlBase>