mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
Merge pull request #1444 from DGP-Studio/feat/refresh_ui_for_team_appearence
This commit is contained in:
24
src/Snap.Hutao/Snap.Hutao/Control/Helper/UIElementHelper.cs
Normal file
24
src/Snap.Hutao/Snap.Hutao/Control/Helper/UIElementHelper.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Microsoft.UI.Xaml;
|
||||
|
||||
namespace Snap.Hutao.Control.Helper;
|
||||
|
||||
[SuppressMessage("", "SH001")]
|
||||
[DependencyProperty("VisibilityObject", typeof(object), null, nameof(OnVisibilityObjectChanged), IsAttached = true, AttachedType = typeof(UIElement))]
|
||||
[DependencyProperty("OpacityObject", typeof(object), null, nameof(OnOpacityObjectChanged), IsAttached = true, AttachedType = typeof(UIElement))]
|
||||
public sealed partial class UIElementHelper
|
||||
{
|
||||
private static void OnVisibilityObjectChanged(DependencyObject dp, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
UIElement element = (UIElement)dp;
|
||||
element.Visibility = e.NewValue is null ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
|
||||
private static void OnOpacityObjectChanged(DependencyObject dp, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
UIElement element = (UIElement)dp;
|
||||
element.Opacity = e.NewValue is null ? 0D : 1D;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,9 @@
|
||||
<ItemsPanelTemplate x:Key="HorizontalStackPanelSpacing2Template">
|
||||
<StackPanel Orientation="Horizontal" Spacing="2"/>
|
||||
</ItemsPanelTemplate>
|
||||
<ItemsPanelTemplate x:Key="HorizontalStackPanelSpacing4Template">
|
||||
<StackPanel Orientation="Horizontal" Spacing="4"/>
|
||||
</ItemsPanelTemplate>
|
||||
<ItemsPanelTemplate x:Key="StackPanelSpacing4Template">
|
||||
<StackPanel Spacing="4"/>
|
||||
</ItemsPanelTemplate>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
xmlns:mxi="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:shc="using:Snap.Hutao.Control"
|
||||
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
|
||||
xmlns:shch="using:Snap.Hutao.Control.Helper"
|
||||
xmlns:shci="using:Snap.Hutao.Control.Image"
|
||||
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
||||
xmlns:shcp="using:Snap.Hutao.Control.Panel"
|
||||
@@ -503,42 +504,42 @@
|
||||
</mxi:Interaction.Behaviors>
|
||||
|
||||
<Grid.Resources>
|
||||
<DataTemplate x:Key="AvatarViewTemplate" d:DataType="shvcom:AvatarView">
|
||||
<shvcon:ItemIcon
|
||||
Width="40"
|
||||
Height="40"
|
||||
shch:UIElementHelper.OpacityObject="{Binding Icon}"
|
||||
Icon="{Binding Icon}"
|
||||
Opacity="0"
|
||||
Quality="{Binding Quality}"/>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="TeamItemTemplate" d:DataType="shvcom:Team">
|
||||
<Border Margin="0,0,16,8" Style="{StaticResource BorderCardStyle}">
|
||||
<Grid Margin="6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="184"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ItemsControl
|
||||
MinWidth="210"
|
||||
HorizontalAlignment="Left"
|
||||
ItemsSource="{Binding}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" Spacing="6"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<shvcon:ItemIcon
|
||||
Width="40"
|
||||
Height="40"
|
||||
Icon="{Binding Icon}"
|
||||
Quality="{Binding Quality}"/>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<Viewbox
|
||||
Grid.Column="1"
|
||||
Height="40"
|
||||
Stretch="Uniform">
|
||||
<TextBlock
|
||||
Margin="4,8"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Rate}"/>
|
||||
<Border Style="{StaticResource BorderCardStyle}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Viewbox Stretch="Uniform">
|
||||
<ItemsControl
|
||||
Margin="4"
|
||||
HorizontalAlignment="Left"
|
||||
ItemTemplate="{StaticResource AvatarViewTemplate}"
|
||||
ItemsPanel="{ThemeResource HorizontalStackPanelSpacing4Template}"
|
||||
ItemsSource="{Binding}"/>
|
||||
</Viewbox>
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
Background="{ThemeResource SolidBackgroundFillColorBaseBrush}"
|
||||
CornerRadius="{ThemeResource ControlCornerRadiusBottom}"
|
||||
Opacity="0.7"/>
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
Margin="4"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Rate}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
@@ -692,27 +693,35 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<ListView
|
||||
Grid.Column="0"
|
||||
Padding="0,0,0,0"
|
||||
Padding="0"
|
||||
ItemContainerStyle="{ThemeResource NoneSelectionListViewItemStyle}"
|
||||
ItemTemplate="{StaticResource TeamItemTemplate}"
|
||||
ItemsSource="{Binding Up}"
|
||||
SelectionMode="None">
|
||||
<ListView.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<shcp:UniformPanel MinItemWidth="240"/>
|
||||
<shcp:UniformPanel
|
||||
Padding="0,0,16,0"
|
||||
ColumnSpacing="6"
|
||||
MinItemWidth="240"
|
||||
RowSpacing="2"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListView.ItemsPanel>
|
||||
</ListView>
|
||||
<ListView
|
||||
Grid.Column="1"
|
||||
Padding="0,0,0,0"
|
||||
Padding="0"
|
||||
ItemContainerStyle="{ThemeResource NoneSelectionListViewItemStyle}"
|
||||
ItemTemplate="{StaticResource TeamItemTemplate}"
|
||||
ItemsSource="{Binding Down}"
|
||||
SelectionMode="None">
|
||||
<ListView.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<shcp:UniformPanel MinItemWidth="240"/>
|
||||
<shcp:UniformPanel
|
||||
Padding="0,0,16,0"
|
||||
ColumnSpacing="6"
|
||||
MinItemWidth="240"
|
||||
RowSpacing="2"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListView.ItemsPanel>
|
||||
</ListView>
|
||||
|
||||
@@ -5,6 +5,7 @@ using Microsoft.Extensions.Primitives;
|
||||
using Snap.Hutao.Model.Metadata.Avatar;
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Snap.Hutao.ViewModel.Complex;
|
||||
@@ -29,6 +30,8 @@ internal sealed class Team : List<AvatarView>
|
||||
Add(new(idAvatarMap[id]));
|
||||
}
|
||||
|
||||
AddRange(new AvatarView[4 - Count]);
|
||||
|
||||
Rate = SH.FormatModelBindingHutaoTeamUpCountFormat(team.Rate);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user