mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix infobar view duplicate items
This commit is contained in:
@@ -11,6 +11,8 @@
|
|||||||
xmlns:shuxb="using:Snap.Hutao.UI.Xaml.Behavior"
|
xmlns:shuxb="using:Snap.Hutao.UI.Xaml.Behavior"
|
||||||
xmlns:shuxc="using:Snap.Hutao.UI.Xaml.Control"
|
xmlns:shuxc="using:Snap.Hutao.UI.Xaml.Control"
|
||||||
xmlns:shuxm="using:Snap.Hutao.UI.Xaml.Markup"
|
xmlns:shuxm="using:Snap.Hutao.UI.Xaml.Markup"
|
||||||
|
xmlns:shuxv="using:Snap.Hutao.UI.Xaml.View"
|
||||||
|
d:DataContext="{d:DesignInstance Type=shuxv:InfoBarView}"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
@@ -101,13 +103,16 @@
|
|||||||
<clw:TransitionHelper
|
<clw:TransitionHelper
|
||||||
x:Key="InfoBarPanelTransitionHelper"
|
x:Key="InfoBarPanelTransitionHelper"
|
||||||
x:Name="InfoBarPanelTransitionHelper"
|
x:Name="InfoBarPanelTransitionHelper"
|
||||||
|
DefaultEasingMode="EaseOut"
|
||||||
|
DefaultEasingType="Cubic"
|
||||||
Duration="0:0:0.3">
|
Duration="0:0:0.3">
|
||||||
<clw:TransitionConfig Id="Body" ScaleMode="Scale"/>
|
<clw:TransitionConfig Id="Body" ScaleMode="ScaleX"/>
|
||||||
|
<clw:TransitionConfig Id="Header" ScaleMode="ScaleX"/>
|
||||||
</clw:TransitionHelper>
|
</clw:TransitionHelper>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
|
|
||||||
<Grid>
|
<Grid Name="VisibilityRoot">
|
||||||
<Border
|
<Border
|
||||||
x:Name="ShowButtonBorder"
|
x:Name="ShowButtonBorder"
|
||||||
Margin="16"
|
Margin="16"
|
||||||
@@ -125,7 +130,7 @@
|
|||||||
Transition="{StaticResource InfoBarPanelTransitionHelper}"/>
|
Transition="{StaticResource InfoBarPanelTransitionHelper}"/>
|
||||||
</mxic:EventTriggerBehavior>
|
</mxic:EventTriggerBehavior>
|
||||||
</mxi:Interaction.Behaviors>
|
</mxi:Interaction.Behaviors>
|
||||||
<Grid>
|
<Grid clw:TransitionHelper.Id="Header">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="auto"/>
|
<ColumnDefinition Width="auto"/>
|
||||||
<ColumnDefinition MinWidth="32"/>
|
<ColumnDefinition MinWidth="32"/>
|
||||||
@@ -151,13 +156,23 @@
|
|||||||
Style="{ThemeResource AcrylicBorderCardStyle}"
|
Style="{ThemeResource AcrylicBorderCardStyle}"
|
||||||
Visibility="Collapsed">
|
Visibility="Collapsed">
|
||||||
|
|
||||||
<Grid RowSpacing="8">
|
<Grid RowSpacing="16">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="auto"/>
|
<RowDefinition Height="auto"/>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
<Grid ColumnSpacing="8">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition Width="auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
clw:TransitionHelper.Id="Header"
|
||||||
|
Style="{StaticResource SubtitleTextBlockStyle}"
|
||||||
|
Text="所有通知"/>
|
||||||
<StackPanel
|
<StackPanel
|
||||||
HorizontalAlignment="Right"
|
Grid.Column="1"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
Spacing="8">
|
Spacing="8">
|
||||||
<Button Click="OnClearAllButtonClick">
|
<Button Click="OnClearAllButtonClick">
|
||||||
@@ -195,13 +210,15 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<ScrollViewer Grid.Row="1">
|
<ScrollViewer Grid.Row="1">
|
||||||
<ItemsControl
|
<ItemsControl
|
||||||
MaxWidth="480"
|
MaxWidth="480"
|
||||||
ItemContainerTransitions="{StaticResource AddDeleteThemeTransitions}"
|
ItemContainerTransitions="{StaticResource AddDeleteThemeTransitions}"
|
||||||
ItemTemplateSelector="{StaticResource InfoBarTemplateSelector}"
|
ItemTemplateSelector="{StaticResource InfoBarTemplateSelector}"
|
||||||
ItemsPanel="{StaticResource StackPanelSpacing8Template}"
|
ItemsPanel="{StaticResource StackPanelSpacing8Template}"
|
||||||
ItemsSource="{x:Bind InfoBars}"/>
|
ItemsSource="{Binding InfoBars, Mode=OneWay}"/>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ internal sealed partial class InfoBarView : UserControl
|
|||||||
public InfoBarView()
|
public InfoBarView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
DataContext = this;
|
||||||
|
|
||||||
IServiceProvider serviceProvider = Ioc.Default;
|
IServiceProvider serviceProvider = Ioc.Default;
|
||||||
infoBarService = serviceProvider.GetRequiredService<IInfoBarService>();
|
infoBarService = serviceProvider.GetRequiredService<IInfoBarService>();
|
||||||
@@ -32,26 +33,32 @@ internal sealed partial class InfoBarView : UserControl
|
|||||||
|
|
||||||
private void OnInfoBarsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs args)
|
private void OnInfoBarsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs args)
|
||||||
{
|
{
|
||||||
|
HandleInfoBarsCollectionChangedAsync(args).SafeForget();
|
||||||
|
|
||||||
|
async ValueTask HandleInfoBarsCollectionChangedAsync(NotifyCollectionChangedEventArgs args)
|
||||||
|
{
|
||||||
|
if (InfoBars.Count > 0)
|
||||||
|
{
|
||||||
|
VisibilityRoot.Visibility = Visibility.Visible;
|
||||||
|
}
|
||||||
|
|
||||||
switch (args.Action)
|
switch (args.Action)
|
||||||
{
|
{
|
||||||
case NotifyCollectionChangedAction.Add:
|
case NotifyCollectionChangedAction.Add:
|
||||||
{
|
{
|
||||||
InfoBarPanelTransitionHelper.Source = ShowButtonBorder;
|
InfoBarPanelTransitionHelper.Source = ShowButtonBorder;
|
||||||
InfoBarPanelTransitionHelper.Target = InfoBarItemsBorder;
|
InfoBarPanelTransitionHelper.Target = InfoBarItemsBorder;
|
||||||
InfoBarPanelTransitionHelper.StartAsync();
|
await InfoBarPanelTransitionHelper.StartAsync().ConfigureAwait(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case NotifyCollectionChangedAction.Remove:
|
|
||||||
{
|
|
||||||
if (InfoBars.Count is 0)
|
if (InfoBars.Count is 0)
|
||||||
{
|
{
|
||||||
InfoBarPanelTransitionHelper.Source = InfoBarItemsBorder;
|
InfoBarPanelTransitionHelper.Source = InfoBarItemsBorder;
|
||||||
InfoBarPanelTransitionHelper.Target = ShowButtonBorder;
|
InfoBarPanelTransitionHelper.Target = ShowButtonBorder;
|
||||||
InfoBarPanelTransitionHelper.StartAsync();
|
await InfoBarPanelTransitionHelper.StartAsync().ConfigureAwait(true);
|
||||||
}
|
VisibilityRoot.Visibility = Visibility.Collapsed;
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user