sourcegit/src/Views/Statistics.axaml
leo a52ebffbf3
Some checks are pending
Continuous Integration / Build (push) Waiting to run
Continuous Integration / Prepare version string (push) Waiting to run
Continuous Integration / Package (push) Blocked by required conditions
ux: layout for Statistics window
2024-09-24 20:50:53 +08:00

219 lines
9.5 KiB
XML

<v:ChromelessWindow 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:m="using:SourceGit.Models"
xmlns:vm="using:SourceGit.ViewModels"
xmlns:v="using:SourceGit.Views"
xmlns:lvc="using:LiveChartsCore.SkiaSharpView.Avalonia"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.Statistics"
x:DataType="vm:Statistics"
x:Name="ThisControl"
Title="{DynamicResource Text.Statistics}"
Width="800" Height="500"
WindowStartupLocation="CenterOwner"
CanResize="False">
<Grid RowDefinitions="Auto,Auto,*">
<!-- Title bar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/>
<Path Grid.Column="0"
Width="14" Height="14"
Margin="10,0,0,0"
Data="{StaticResource Icons.Statistics}"
IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtonsMacOS Grid.Column="0"
Margin="0,2,0,0"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform False, macOS=True}"/>
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
Classes="bold"
Text="{DynamicResource Text.Statistics}"
HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/>
<v:CaptionButtons Grid.Column="2"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/>
</Grid>
<!-- View mode switcher -->
<ListBox Grid.Row="1"
Margin="0,8"
SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Transparent"
BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border2}"
CornerRadius="14"
Padding="3,0">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.Styles>
<Style Selector="ListBoxItem">
<Setter Property="Width" Value="100"/>
<Setter Property="Height" Value="28"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="ListBoxItem:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="ListBoxItem:selected /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="ListBoxItem Border.switcher_bg">
<Setter Property="Height" Value="22"/>
<Setter Property="CornerRadius" Value="11"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style Selector="ListBoxItem:selected Border.switcher_bg">
<Setter Property="Background" Value="{DynamicResource Brush.Accent}"/>
</Style>
<Style Selector="TextBlock.view_mode_switcher">
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Foreground" Value="{DynamicResource Brush.FG2}"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
<Style Selector="ListBoxItem:pointerover TextBlock.view_mode_switcher">
<Setter Property="Foreground" Value="{DynamicResource Brush.FG1}"/>
</Style>
<Style Selector="ListBoxItem:selected TextBlock.view_mode_switcher">
<Setter Property="Foreground" Value="White"/>
</Style>
</ListBox.Styles>
<ListBoxItem>
<Border Classes="switcher_bg">
<TextBlock Classes="view_mode_switcher" Text="{DynamicResource Text.Statistics.Overview}"/>
</Border>
</ListBoxItem>
<ListBoxItem>
<Border Classes="switcher_bg">
<TextBlock Classes="view_mode_switcher" Text="{DynamicResource Text.Statistics.ThisMonth}"/>
</Border>
</ListBoxItem>
<ListBoxItem>
<Border Classes="switcher_bg">
<TextBlock Classes="view_mode_switcher" Text="{DynamicResource Text.Statistics.ThisWeek}"/>
</Border>
</ListBoxItem>
</ListBox>
<!-- Color Picker -->
<Border Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center">
<Button Background="Transparent" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}" Width="28" Height="28" CornerRadius="14" Margin="0,0,24,0">
<Button.Flyout>
<Flyout>
<Border Padding="8">
<v:ColorPicker Value="{Binding SampleColor, Mode=TwoWay}"/>
</Border>
</Flyout>
</Button.Flyout>
<Path Width="14" Height="14" Data="{StaticResource Icons.ColorPicker}" Fill="{Binding SampleBrush}"/>
</Button>
</Border>
<!-- Contents -->
<ContentControl Grid.Row="2" Content="{Binding SelectedReport, Mode=OneWay}" Margin="8,8,8,16">
<ContentControl.DataTemplates>
<DataTemplate DataType="m:StatisticsReport">
<Grid ColumnDefinitions="256,*">
<Grid Grid.Column="0" RowDefinitions="*,16">
<!-- Table By Committer -->
<ListBox Grid.Column="0"
ItemsSource="{Binding Authors}"
SelectionMode="Single"
BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border2}"
Background="{DynamicResource Brush.Contents}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto">
<ListBox.Styles>
<Style Selector="ListBoxItem">
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Height" Value="26"/>
</Style>
</ListBox.Styles>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate DataType="m:StaticsticsAuthor">
<Border BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border2}">
<Grid ColumnDefinitions="*,100">
<Border Grid.Column="0" Padding="8,0" ClipToBounds="True">
<TextBlock Text="{Binding Name}" HorizontalAlignment="Left"/>
</Border>
<Border Grid.Column="1" Padding="8,0" ClipToBounds="True">
<TextBlock Text="{Binding Count}" HorizontalAlignment="Right"/>
</Border>
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!-- Summary -->
<Grid Grid.Row="1" ColumnDefinitions="*,*">
<!-- Total Committers -->
<StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Bottom">
<TextBlock Classes="primary" Text="{DynamicResource Text.Statistics.TotalAuthors}" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
<TextBlock Classes="primary" Text="{Binding Authors.Count}" FontSize="11" Margin="4,0,0,0"/>
</StackPanel>
<!-- Total Commits -->
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom">
<TextBlock Classes="primary" Text="{DynamicResource Text.Statistics.TotalCommits}" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
<TextBlock Classes="primary" Text="{Binding Total}" FontSize="11" Margin="4,0,0,0"/>
</StackPanel>
</Grid>
</Grid>
<!-- Graph -->
<lvc:CartesianChart Grid.Column="1"
Margin="0"
Padding="0"
Series="{Binding Series}"
XAxes="{Binding XAxes}" YAxes="{Binding YAxes}"
ZoomMode="X"/>
</Grid>
</DataTemplate>
</ContentControl.DataTemplates>
</ContentControl>
<!-- Loading Mask -->
<v:LoadingIcon Grid.Row="2"
Width="48" Height="48"
HorizontalAlignment="Center" VerticalAlignment="Center"
IsVisible="{Binding IsLoading}"/>
</Grid>
</v:ChromelessWindow>