mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
review requests
This commit is contained in:
@@ -12,18 +12,18 @@ internal sealed partial class InfoBarDelayCloseBehavior : BehaviorBase<InfoBar>
|
||||
{
|
||||
protected override void OnAssociatedObjectLoaded()
|
||||
{
|
||||
DelayCoreAsync().SafeForget();
|
||||
if (MilliSecondsDelay > 0)
|
||||
{
|
||||
DelayCoreAsync().SafeForget();
|
||||
}
|
||||
}
|
||||
|
||||
private async ValueTask DelayCoreAsync()
|
||||
{
|
||||
if (MilliSecondsDelay > 0)
|
||||
await Delay.FromMilliSeconds(MilliSecondsDelay).ConfigureAwait(true);
|
||||
if (AssociatedObject is not null)
|
||||
{
|
||||
await Delay.FromMilliSeconds(MilliSecondsDelay).ConfigureAwait(true);
|
||||
if (AssociatedObject is not null)
|
||||
{
|
||||
AssociatedObject.IsOpen = false;
|
||||
}
|
||||
AssociatedObject.IsOpen = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Snap.Hutao.Service.Notification;
|
||||
|
||||
namespace Snap.Hutao.Control.Selector;
|
||||
|
||||
internal sealed class InfoBarTemplateSelector : DataTemplateSelector
|
||||
{
|
||||
public DataTemplate ActionButtonEnabled { get; set; } = default!;
|
||||
|
||||
public DataTemplate ActionButtonDisabled { get; set; } = default!;
|
||||
|
||||
protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
|
||||
{
|
||||
if (item is InfoBarOptions { ActionButtonContent: { }, ActionButtonCommand: { } })
|
||||
{
|
||||
return ActionButtonEnabled;
|
||||
}
|
||||
|
||||
return ActionButtonDisabled;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
xmlns:mxi="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
|
||||
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
||||
xmlns:shcs="using:Snap.Hutao.Control.Selector"
|
||||
xmlns:shsn="using:Snap.Hutao.Service.Notification"
|
||||
mc:Ignorable="d">
|
||||
|
||||
@@ -63,25 +64,38 @@
|
||||
<DataTemplate x:Key="InfoBarTemplate" x:DataType="shsn:InfoBarOptions">
|
||||
<InfoBar
|
||||
Title="{Binding Title}"
|
||||
Closed="OnInfoBarClosed"
|
||||
Content="{Binding Content}"
|
||||
IsOpen="True"
|
||||
Message="{Binding Message}"
|
||||
Severity="{Binding Severity}">
|
||||
<mxi:Interaction.Behaviors>
|
||||
<shcb:InfoBarDelayCloseBehavior MilliSecondsDelay="{Binding MilliSecondsDelay}"/>
|
||||
</mxi:Interaction.Behaviors>
|
||||
</InfoBar>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="InfoBarWithActionButtonTemplate" x:DataType="shsn:InfoBarOptions">
|
||||
<InfoBar
|
||||
Title="{Binding Title}"
|
||||
Closed="OnInfoBarClosed"
|
||||
Content="{Binding Content}"
|
||||
IsOpen="True"
|
||||
Message="{Binding Message}"
|
||||
Closed="OnInfoBarClosed"
|
||||
Severity="{Binding Severity}">
|
||||
<InfoBar.Transitions>
|
||||
<AddDeleteThemeTransition/>
|
||||
</InfoBar.Transitions>
|
||||
<InfoBar.ActionButton>
|
||||
<Button
|
||||
Command="{Binding ActionButtonCommand}"
|
||||
Content="{Binding ActionButtonContent}"
|
||||
Visibility="{Binding ActionButtonContent, Converter={StaticResource EmptyObjectToVisibilityConverter}}"/>
|
||||
<Button Command="{Binding ActionButtonCommand}" Content="{Binding ActionButtonContent}"/>
|
||||
</InfoBar.ActionButton>
|
||||
<mxi:Interaction.Behaviors>
|
||||
<shcb:InfoBarDelayCloseBehavior MilliSecondsDelay="{Binding MilliSecondsDelay}"/>
|
||||
</mxi:Interaction.Behaviors>
|
||||
</InfoBar>
|
||||
</DataTemplate>
|
||||
|
||||
<shcs:InfoBarTemplateSelector
|
||||
x:Key="InfoBarTemplateSelector"
|
||||
ActionButtonDisabled="{StaticResource InfoBarTemplate}"
|
||||
ActionButtonEnabled="{StaticResource InfoBarWithActionButtonTemplate}"/>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
|
||||
@@ -91,9 +105,13 @@
|
||||
Margin="32,48,32,32"
|
||||
VerticalAlignment="Bottom"
|
||||
ItemContainerTransitions="{StaticResource RepositionThemeTransitions}"
|
||||
ItemTemplate="{StaticResource InfoBarTemplate}"
|
||||
ItemTemplateSelector="{StaticResource InfoBarTemplateSelector}"
|
||||
ItemsSource="{x:Bind InfoBars}"
|
||||
Visibility="{x:Bind VisibilityButton.IsChecked, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}"/>
|
||||
Visibility="{x:Bind VisibilityButton.IsChecked, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
|
||||
<ItemsControl.Transitions>
|
||||
<AddDeleteThemeTransition/>
|
||||
</ItemsControl.Transitions>
|
||||
</ItemsControl>
|
||||
|
||||
<Border
|
||||
Margin="16"
|
||||
|
||||
Reference in New Issue
Block a user