sourcegit/src/Views/Welcome.axaml
2024-07-15 15:47:28 +08:00

110 lines
5.3 KiB
XML

<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:c="using:SourceGit.Converters"
xmlns:vm="using:SourceGit.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.Welcome"
x:DataType="vm:Welcome">
<Grid RowDefinitions="*,36">
<Grid Grid.Row="0" Margin="0,8" ColumnDefinitions="*,600,*">
<Grid Grid.Column="1" RowDefinitions="Auto,*">
<TextBox Grid.Row="0"
Height="32"
Padding="0"
CornerRadius="16"
BorderBrush="{DynamicResource Brush.Border0}"
BorderThickness="1"
Background="{DynamicResource Brush.Contents}"
Watermark="{DynamicResource Text.Welcome.Search}"
VerticalContentAlignment="Center"
Text="{Binding SearchFilter, Mode=TwoWay}">
<TextBox.InnerLeftContent>
<Path Width="16" Height="16" Margin="6,0,3,0" Data="{StaticResource Icons.Search}" Fill="{DynamicResource Brush.FG2}"/>
</TextBox.InnerLeftContent>
<TextBox.InnerRightContent>
<Button Classes="icon_button" IsVisible="{Binding SearchFilter, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" Command="{Binding ClearSearchFilter}">
<Path Width="16" Height="16" Margin="0,0,0,0" Data="{StaticResource Icons.Clear}" Fill="{DynamicResource Brush.FG1}"/>
</Button>
</TextBox.InnerRightContent>
</TextBox>
<TreeView Grid.Row="1"
Margin="0,8,8,0"
ItemsSource="{Binding RepositoryNodes}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto"
Loaded="SetupTreeViewDragAndDrop"
LostFocus="OnTreeViewLostFocus">
<TreeView.ContextMenu>
<ContextMenu>
<MenuItem Header="{DynamicResource Text.Welcome.AddRootFolder}" Command="{Binding AddRootNode}">
<MenuItem.Icon>
<Path Width="12" Height="12" Data="{DynamicResource Icons.Folder.Add}"/>
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</TreeView.ContextMenu>
<TreeView.Styles>
<Style Selector="TreeViewItem" x:DataType="vm:RepositoryNode">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
<Setter Property="IsVisible" Value="{Binding IsVisible}"/>
<Setter Property="CornerRadius" Value="4"/>
</Style>
</TreeView.Styles>
<TreeView.ItemTemplate>
<TreeDataTemplate ItemsSource="{Binding SubNodes}">
<Grid Height="30"
ColumnDefinitions="18,Auto,*"
Background="Transparent"
Loaded="SetupTreeNodeDragAndDrop"
ContextRequested="OnTreeNodeContextRequested"
PointerPressed="OnPointerPressedTreeNode"
PointerMoved="OnPointerMovedOverTreeNode"
PointerReleased="OnPointerReleasedOnTreeNode"
DoubleTapped="OnDoubleTappedTreeNode"
ClipToBounds="True">
<Path Grid.Column="0"
Width="14" Height="14"
Fill="{Binding Bookmark, Converter={x:Static c:BookmarkConverters.ToBrush}}"
HorizontalAlignment="Center"
Data="{StaticResource Icons.Bookmark}"
IsVisible="{Binding IsRepository}"/>
<ToggleButton Grid.Column="0"
Classes="folder"
Focusable="False"
Width="14" Height="14"
HorizontalAlignment="Left"
Foreground="{DynamicResource Brush.FG1}"
IsChecked="{Binding IsExpanded}"
IsVisible="{Binding !IsRepository}"/>
<TextBlock Grid.Column="1" Classes="monospace" VerticalAlignment="Center" Text="{Binding Name}"/>
<TextBlock Grid.Column="2"
Classes="monospace"
Margin="8,0"
HorizontalAlignment="Right" VerticalAlignment="Center"
Foreground="{DynamicResource Brush.FG2}"
Text="{Binding Id}"
IsVisible="{Binding IsRepository}"/>
</Grid>
</TreeDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
</Grid>
</Grid>
<TextBlock Grid.Row="1"
Classes="italic"
Margin="0,0,8,0"
HorizontalAlignment="Center" VerticalAlignment="Center"
FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFontSize, Converter={x:Static c:DoubleConverters.Decrease}}"
Text="{DynamicResource Text.Welcome.DragDropTip}"
Foreground="{DynamicResource Brush.FG2}"/>
</Grid>
</UserControl>