ux: make Welcome page responsive (#821)

This commit is contained in:
leo 2024-12-17 09:36:06 +08:00
parent f418b72c64
commit 707a227aca
No known key found for this signature in database

View file

@ -9,149 +9,148 @@
x:Class="SourceGit.Views.Welcome" x:Class="SourceGit.Views.Welcome"
x:DataType="vm:Welcome"> x:DataType="vm:Welcome">
<Grid RowDefinitions="*,36"> <Grid RowDefinitions="*,36">
<Grid Grid.Row="0" Margin="0,8" ColumnDefinitions="*,600,*"> <!-- Managed Repositories -->
<Grid Grid.Column="1" RowDefinitions="Auto,*"> <Grid Grid.Column="1" MinWidth="600" Margin="8" RowDefinitions="Auto,*" HorizontalAlignment="Center">
<!-- Search Box --> <!-- Search Box -->
<TextBox Grid.Row="0" <TextBox Grid.Row="0"
x:Name="SearchBox" x:Name="SearchBox"
Height="32" Height="32"
Padding="0" Padding="0"
CornerRadius="16" CornerRadius="16"
BorderBrush="{DynamicResource Brush.Border0}" BorderBrush="{DynamicResource Brush.Border0}"
BorderThickness="1" BorderThickness="1"
Background="{DynamicResource Brush.Contents}" Background="{DynamicResource Brush.Contents}"
Watermark="{DynamicResource Text.Welcome.Search}" Watermark="{DynamicResource Text.Welcome.Search}"
VerticalContentAlignment="Center" VerticalContentAlignment="Center"
Text="{Binding SearchFilter, Mode=TwoWay}" Text="{Binding SearchFilter, Mode=TwoWay}"
v:AutoFocusBehaviour.IsEnabled="True"> v:AutoFocusBehaviour.IsEnabled="True">
<TextBox.Styles> <TextBox.Styles>
<Style Selector="TextBox:pointerover /template/ Border#PART_BorderElement"> <Style Selector="TextBox:pointerover /template/ Border#PART_BorderElement">
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Border0}"/> <Setter Property="BorderBrush" Value="{DynamicResource Brush.Border0}"/>
</Style> </Style>
<Style Selector="TextBox:focus /template/ Border#PART_BorderElement"> <Style Selector="TextBox:focus /template/ Border#PART_BorderElement">
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Border0}"/> <Setter Property="BorderBrush" Value="{DynamicResource Brush.Border0}"/>
</Style> </Style>
</TextBox.Styles> </TextBox.Styles>
<TextBox.InnerLeftContent> <TextBox.InnerLeftContent>
<Path Width="16" Height="16" Margin="6,0,3,0" Data="{StaticResource Icons.Search}" Fill="{DynamicResource Brush.FG2}"/> <Path Width="16" Height="16" Margin="6,0,3,0" Data="{StaticResource Icons.Search}" Fill="{DynamicResource Brush.FG2}"/>
</TextBox.InnerLeftContent> </TextBox.InnerLeftContent>
<TextBox.InnerRightContent> <TextBox.InnerRightContent>
<Button Classes="icon_button" IsVisible="{Binding SearchFilter, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" Command="{Binding ClearSearchFilter}"> <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}"/> <Path Width="16" Height="16" Margin="0,0,0,0" Data="{StaticResource Icons.Clear}" Fill="{DynamicResource Brush.FG1}"/>
</Button> </Button>
</TextBox.InnerRightContent> </TextBox.InnerRightContent>
</TextBox> </TextBox>
<!-- Repository Tree --> <!-- Repository Tree -->
<v:RepositoryListBox Grid.Row="1" <v:RepositoryListBox Grid.Row="1"
x:Name="TreeContainer" x:Name="TreeContainer"
Margin="0,8,8,0" Margin="0,8,8,0"
Focusable="True" Focusable="True"
Background="Transparent" Background="Transparent"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"
ItemsSource="{Binding Rows}" ItemsSource="{Binding Rows}"
SelectionMode="Single" SelectionMode="Single"
Loaded="SetupTreeViewDragAndDrop" Loaded="SetupTreeViewDragAndDrop"
LostFocus="OnTreeViewLostFocus" LostFocus="OnTreeViewLostFocus"
KeyDown="OnTreeViewKeyDown"> KeyDown="OnTreeViewKeyDown">
<ListBox.Styles> <ListBox.Styles>
<Style Selector="ListBox"> <Style Selector="ListBox">
<Setter Property="FocusAdorner"> <Setter Property="FocusAdorner">
<FocusAdornerTemplate> <FocusAdornerTemplate>
<Border Background="Transparent" BorderThickness="0"/> <Border Background="Transparent" BorderThickness="0"/>
</FocusAdornerTemplate> </FocusAdornerTemplate>
</Setter> </Setter>
</Style> </Style>
<Style Selector="ListBoxItem" x:DataType="vm:RepositoryNode"> <Style Selector="ListBoxItem" x:DataType="vm:RepositoryNode">
<Setter Property="Margin" Value="0"/> <Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="0"/> <Setter Property="Padding" Value="0"/>
<Setter Property="Height" Value="30"/> <Setter Property="Height" Value="30"/>
<Setter Property="CornerRadius" Value="4"/> <Setter Property="CornerRadius" Value="4"/>
<Setter Property="FocusAdorner"> <Setter Property="FocusAdorner">
<FocusAdornerTemplate> <FocusAdornerTemplate>
<Border Background="Transparent" BorderThickness="0"/> <Border Background="Transparent" BorderThickness="0"/>
</FocusAdornerTemplate> </FocusAdornerTemplate>
</Setter> </Setter>
</Style> </Style>
</ListBox.Styles> </ListBox.Styles>
<ListBox.ItemsPanel> <ListBox.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical"/> <VirtualizingStackPanel Orientation="Vertical"/>
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ListBox.ItemsPanel> </ListBox.ItemsPanel>
<ListBox.ContextMenu> <ListBox.ContextMenu>
<ContextMenu> <ContextMenu>
<MenuItem Header="{DynamicResource Text.Welcome.AddRootFolder}" Command="{Binding AddRootNode}"> <MenuItem Header="{DynamicResource Text.Welcome.AddRootFolder}" Command="{Binding AddRootNode}">
<MenuItem.Icon> <MenuItem.Icon>
<Path Width="12" Height="12" Data="{DynamicResource Icons.Folder.Add}"/> <Path Width="12" Height="12" Data="{DynamicResource Icons.Folder.Add}"/>
</MenuItem.Icon> </MenuItem.Icon>
</MenuItem> </MenuItem>
</ContextMenu> </ContextMenu>
</ListBox.ContextMenu> </ListBox.ContextMenu>
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate DataType="vm:RepositoryNode"> <DataTemplate DataType="vm:RepositoryNode">
<Grid Background="Transparent" <Grid Background="Transparent"
Height="30" Height="30"
ColumnDefinitions="16,18,Auto,*" ColumnDefinitions="16,18,Auto,*"
Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}" Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}"
Loaded="SetupTreeNodeDragAndDrop" Loaded="SetupTreeNodeDragAndDrop"
ContextRequested="OnTreeNodeContextRequested" ContextRequested="OnTreeNodeContextRequested"
PointerPressed="OnPointerPressedTreeNode" PointerPressed="OnPointerPressedTreeNode"
PointerMoved="OnPointerMovedOverTreeNode" PointerMoved="OnPointerMovedOverTreeNode"
PointerReleased="OnPointerReleasedOnTreeNode" PointerReleased="OnPointerReleasedOnTreeNode"
DoubleTapped="OnDoubleTappedTreeNode" DoubleTapped="OnDoubleTappedTreeNode"
ClipToBounds="True"> ClipToBounds="True">
<v:RepositoryTreeNodeToggleButton Grid.Column="0" <v:RepositoryTreeNodeToggleButton Grid.Column="0"
Classes="tree_expander" Classes="tree_expander"
Focusable="False" Focusable="False"
HorizontalAlignment="Center" HorizontalAlignment="Center"
IsChecked="{Binding IsExpanded, Mode=OneWay}" IsChecked="{Binding IsExpanded, Mode=OneWay}"
IsVisible="{Binding !IsRepository}"/> IsVisible="{Binding !IsRepository}"/>
<Path Grid.Column="1" <Path Grid.Column="1"
Width="14" Height="14" Width="14" Height="14"
Fill="{Binding Bookmark, Converter={x:Static c:IntConverters.ToBookmarkBrush}}" Fill="{Binding Bookmark, Converter={x:Static c:IntConverters.ToBookmarkBrush}}"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Data="{StaticResource Icons.Bookmark}" Data="{StaticResource Icons.Bookmark}"
IsVisible="{Binding IsRepository}"/> IsVisible="{Binding IsRepository}"/>
<ToggleButton Grid.Column="1" <ToggleButton Grid.Column="1"
Classes="folder" Classes="folder"
Focusable="False" Focusable="False"
Width="14" Height="14" Width="14" Height="14"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Foreground="{DynamicResource Brush.FG1}" Foreground="{DynamicResource Brush.FG1}"
IsChecked="{Binding IsExpanded}" IsChecked="{Binding IsExpanded}"
IsVisible="{Binding !IsRepository}"/> IsVisible="{Binding !IsRepository}"/>
<StackPanel Grid.Column="2" Orientation="Horizontal"> <StackPanel Grid.Column="2" Orientation="Horizontal">
<TextBlock Classes="primary" VerticalAlignment="Center" Text="{Binding Name}"/> <TextBlock Classes="primary" VerticalAlignment="Center" Text="{Binding Name}"/>
<Path Margin="2,0,0,0" <Path Margin="2,0,0,0"
Width="12" Height="12" Width="12" Height="12"
Data="{StaticResource Icons.Error}" Data="{StaticResource Icons.Error}"
Fill="Orange" Fill="Orange"
IsVisible="{Binding IsInvalid}"/> IsVisible="{Binding IsInvalid}"/>
</StackPanel> </StackPanel>
<TextBlock Grid.Column="3" <Border Grid.Column="3" Margin="8,0" VerticalAlignment="Center" ClipToBounds="True">
Classes="primary" <TextBlock Classes="primary"
Margin="8,0" HorizontalAlignment="Right"
HorizontalAlignment="Right" VerticalAlignment="Center"
Foreground="{DynamicResource Brush.FG2}" Foreground="{DynamicResource Brush.FG2}"
Text="{Binding Id, Converter={x:Static c:PathConverters.RelativeToHome}}" Text="{Binding Id, Converter={x:Static c:PathConverters.RelativeToHome}}"
IsVisible="{Binding IsRepository}"/> IsVisible="{Binding IsRepository}"/>
</Grid> </Border>
</DataTemplate> </Grid>
</ListBox.ItemTemplate> </DataTemplate>
</v:RepositoryListBox> </ListBox.ItemTemplate>
</Grid> </v:RepositoryListBox>
</Grid> </Grid>
<!-- Tips --> <!-- Tips -->