mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-27 04:41:15 +08:00
💄 通用控件功能完善
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
x:CompileBindings="True">
|
||||
<Design.PreviewWith>
|
||||
<Border Padding="50">
|
||||
<spp:ContentLoader />
|
||||
<spp:ContentLoader NoResultMessage="Test" />
|
||||
</Border>
|
||||
</Design.PreviewWith>
|
||||
<!-- Add Resources Here -->
|
||||
@@ -50,7 +50,9 @@
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Text="{TemplateBinding NoResultMessage}" />
|
||||
IsVisible="{TemplateBinding IsShowNoResultText}"
|
||||
Text="{TemplateBinding NoResultMessage}"
|
||||
Theme="{StaticResource SubtitleTextBlockStyle}" />
|
||||
|
||||
<ContentPresenter
|
||||
Name="ContentPresenter"
|
||||
|
||||
@@ -50,6 +50,25 @@
|
||||
Text="Toggle Theme" />
|
||||
</Panel>
|
||||
</Button>
|
||||
<ToggleButton
|
||||
Padding="8,4"
|
||||
DockPanel.Dock="Right"
|
||||
IsChecked="{Binding $parent[spp:PageBase].IsPaneOpen}"
|
||||
Theme="{StaticResource TransparentButton}">
|
||||
<Panel>
|
||||
<Viewbox
|
||||
Width="16"
|
||||
Height="16"
|
||||
HorizontalAlignment="Left">
|
||||
<ui:IconSourceElement IconSource="{StaticResource SwapThemeIcon}" />
|
||||
</Viewbox>
|
||||
<TextBlock
|
||||
Margin="28,4,0,4"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Text="Open Pane" />
|
||||
</Panel>
|
||||
</ToggleButton>
|
||||
<DropDownButton
|
||||
Padding="8"
|
||||
Content="{StaticResource More}"
|
||||
@@ -195,31 +214,42 @@
|
||||
</Grid>
|
||||
</Panel>
|
||||
|
||||
<ScrollViewer
|
||||
Name="PageScroller"
|
||||
Padding="{DynamicResource AppPageMargin}"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
|
||||
<DockPanel Margin="0,0,0,20">
|
||||
<TextBlock
|
||||
Margin="0,0,0,8"
|
||||
DockPanel.Dock="Top"
|
||||
IsVisible="{TemplateBinding ContentDescription,
|
||||
Converter={StaticResource IsNullConverter},
|
||||
ConverterParameter=invert}"
|
||||
Text="{TemplateBinding ContentDescription}"
|
||||
TextWrapping="Wrap" />
|
||||
<SplitView
|
||||
DisplayMode="Overlay"
|
||||
IsPaneOpen="{TemplateBinding IsPaneOpen}"
|
||||
PaneBackground="Transparent"
|
||||
PanePlacement="Right">
|
||||
<SplitView.Pane>
|
||||
<Border Background="{DynamicResource SolidBackgroundFillColorSecondaryBrush}" CornerRadius="4 0 0 4">
|
||||
<ContentPresenter HorizontalAlignment="Stretch" Content="{TemplateBinding PaneContent}" />
|
||||
</Border>
|
||||
</SplitView.Pane>
|
||||
<ScrollViewer
|
||||
Name="PageScroller"
|
||||
Padding="{DynamicResource AppPageMargin}"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
|
||||
<DockPanel Margin="0,0,0,20">
|
||||
<TextBlock
|
||||
Margin="0,0,0,8"
|
||||
DockPanel.Dock="Top"
|
||||
IsVisible="{TemplateBinding ContentDescription,
|
||||
Converter={StaticResource IsNullConverter},
|
||||
ConverterParameter=invert}"
|
||||
Text="{TemplateBinding ContentDescription}"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
<ContentPresenter
|
||||
Name="PART_ContentPresenter"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalContentAlignment="Stretch"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}" />
|
||||
</DockPanel>
|
||||
</ScrollViewer>
|
||||
<ContentPresenter
|
||||
Name="PART_ContentPresenter"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalContentAlignment="Stretch"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}" />
|
||||
</DockPanel>
|
||||
</ScrollViewer>
|
||||
</SplitView>
|
||||
</DockPanel>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Rendering.Composition;
|
||||
|
||||
namespace BD.WTTS.UI.Views.Pages;
|
||||
@@ -47,6 +46,12 @@ public class PageBase : UserControl
|
||||
public static readonly StyledProperty<IBrush?> HeaderBackgroundProperty =
|
||||
AvaloniaProperty.Register<PageBase, IBrush?>(nameof(HeaderBackground));
|
||||
|
||||
public static readonly StyledProperty<object?> PaneContentProperty =
|
||||
AvaloniaProperty.Register<PageBase, object?>(nameof(PaneContent));
|
||||
|
||||
public static readonly StyledProperty<bool> IsPaneOpenProperty =
|
||||
SplitView.IsPaneOpenProperty.AddOwner<PageBase>();
|
||||
|
||||
public string Title
|
||||
{
|
||||
get => GetValue(TitleProperty);
|
||||
@@ -89,12 +94,24 @@ public class PageBase : UserControl
|
||||
set => SetValue(ActionContentProperty, value);
|
||||
}
|
||||
|
||||
public object? PaneContent
|
||||
{
|
||||
get => GetValue(PaneContentProperty);
|
||||
set => SetValue(PaneContentProperty, value);
|
||||
}
|
||||
|
||||
public bool IsShowBackgroundImage
|
||||
{
|
||||
get => GetValue(IsShowBackgroundImageProperty);
|
||||
set => SetValue(IsShowBackgroundImageProperty, value);
|
||||
}
|
||||
|
||||
public bool IsPaneOpen
|
||||
{
|
||||
get => GetValue(IsPaneOpenProperty);
|
||||
set => SetValue(IsPaneOpenProperty, value);
|
||||
}
|
||||
|
||||
public IBrush? HeaderBackground
|
||||
{
|
||||
get => GetValue(HeaderBackgroundProperty);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Avalonia.Controls;
|
||||
using DynamicData;
|
||||
using FluentAvalonia.Core;
|
||||
|
||||
namespace BD.WTTS.UI.Views.Controls;
|
||||
|
||||
@@ -40,6 +42,18 @@ public class ContentLoader : ContentControl
|
||||
public static readonly StyledProperty<bool> IsIndeterminateProperty =
|
||||
AvaloniaProperty.Register<ContentLoader, bool>(nameof(IsIndeterminate), true);
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="IsShowNoResultText"/> property
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<bool> IsShowNoResultTextProperty =
|
||||
AvaloniaProperty.Register<ContentLoader, bool>(nameof(IsShowNoResultText), false);
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="ItemsSource"/> property.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<IEnumerable?> ItemsSourceProperty =
|
||||
ItemsControl.ItemsSourceProperty.AddOwner<ContentLoader>();
|
||||
|
||||
/// <summary>
|
||||
/// 是否正在加载中
|
||||
/// </summary>
|
||||
@@ -55,6 +69,12 @@ public class ContentLoader : ContentControl
|
||||
set => SetValue(IsIndeterminateProperty, value);
|
||||
}
|
||||
|
||||
public bool IsShowNoResultText
|
||||
{
|
||||
get => GetValue(IsShowNoResultTextProperty);
|
||||
set => SetValue(IsShowNoResultTextProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 无结果时提示
|
||||
/// </summary>
|
||||
@@ -85,6 +105,12 @@ public class ContentLoader : ContentControl
|
||||
set => SetValue(MaximumProperty, value);
|
||||
}
|
||||
|
||||
public IEnumerable? ItemsSource
|
||||
{
|
||||
get => GetValue(ItemsSourceProperty);
|
||||
set => SetValue(ItemsSourceProperty, value);
|
||||
}
|
||||
|
||||
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs e)
|
||||
{
|
||||
base.OnPropertyChanged(e);
|
||||
@@ -104,5 +130,29 @@ public class ContentLoader : ContentControl
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.Property == ItemsSourceProperty)
|
||||
{
|
||||
var items = e.GetNewValue<IEnumerable?>();
|
||||
if (items == null)
|
||||
{
|
||||
IsLoading = true;
|
||||
IsShowNoResultText = false;
|
||||
}
|
||||
else if (items.Count() == 0)
|
||||
{
|
||||
IsLoading = false;
|
||||
IsShowNoResultText = true;
|
||||
}
|
||||
else if (items.Count() != 0)
|
||||
{
|
||||
IsLoading = false;
|
||||
IsShowNoResultText = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsLoading = true;
|
||||
IsShowNoResultText = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,25 @@
|
||||
Text="Action Button" />
|
||||
</Panel>
|
||||
</Button>
|
||||
<ToggleButton
|
||||
Padding="8,4"
|
||||
DockPanel.Dock="Right"
|
||||
IsChecked="{Binding $parent[spp:PageBase].IsPaneOpen}"
|
||||
Theme="{StaticResource TransparentButton}">
|
||||
<Panel>
|
||||
<Viewbox
|
||||
Width="16"
|
||||
Height="16"
|
||||
HorizontalAlignment="Left">
|
||||
<ui:IconSourceElement IconSource="{StaticResource SwapThemeIcon}" />
|
||||
</Viewbox>
|
||||
<TextBlock
|
||||
Margin="28,4,0,4"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Text="Open Pane" />
|
||||
</Panel>
|
||||
</ToggleButton>
|
||||
<DropDownButton
|
||||
Padding="8"
|
||||
Content="{StaticResource More}"
|
||||
|
||||
@@ -130,7 +130,14 @@
|
||||
</spp:PageBase.ActionContent>
|
||||
<DockPanel>
|
||||
|
||||
<spp:ContentLoader IsLoading="{Binding !!!SteamApps.Count, Mode=OneWay}">
|
||||
<spp:ContentLoader
|
||||
IsLoading="{ReflectionBinding Source={x:Static s:SteamConnectService.Current},
|
||||
Path=IsLoadingGameList,
|
||||
Mode=OneWay}"
|
||||
IsShowNoResultText="{Binding IsSteamAppsEmpty}"
|
||||
NoResultMessage="{ReflectionBinding Path=Res.GameList_IsEmpty,
|
||||
Mode=OneWay,
|
||||
Source={x:Static s:ResourceService.Current}}">
|
||||
<spp:ContentLoader.GestureRecognizers>
|
||||
<ScrollGestureRecognizer CanHorizontallyScroll="True" CanVerticallyScroll="True" />
|
||||
</spp:ContentLoader.GestureRecognizers>
|
||||
|
||||
Reference in New Issue
Block a user