Fixing some IsBusy corner cases.
This commit is contained in:
@@ -100,6 +100,7 @@ _dialogService.InfoBarMessage(Translator.Info_MissingFolderTitle, message);
|
|||||||
- **NEVER** create IValueConverter classes or add them to Converters.xaml
|
- **NEVER** create IValueConverter classes or add them to Converters.xaml
|
||||||
- **NEVER** use BoolToVisibilityConverter - WinUI 3 SDK automatically converts bool to Visibility
|
- **NEVER** use BoolToVisibilityConverter - WinUI 3 SDK automatically converts bool to Visibility
|
||||||
- Direct binding: `Visibility="{x:Bind IsVisible, Mode=OneWay}"`
|
- Direct binding: `Visibility="{x:Bind IsVisible, Mode=OneWay}"`
|
||||||
|
- Register control events (for example `Loaded`, `Unloaded`, `SizeChanged`, `PointerEntered`) in XAML markup, not with `+=` in `.xaml.cs`.
|
||||||
|
|
||||||
### XamlHelpers for Complex Conversions
|
### XamlHelpers for Complex Conversions
|
||||||
- **ALWAYS** use XamlHelpers static methods instead of converters
|
- **ALWAYS** use XamlHelpers static methods instead of converters
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ public interface IMailItemDisplayInformation : INotifyPropertyChanged
|
|||||||
DateTime CreationDate { get; }
|
DateTime CreationDate { get; }
|
||||||
string Base64ContactPicture { get; }
|
string Base64ContactPicture { get; }
|
||||||
bool ThumbnailUpdatedEvent { get; }
|
bool ThumbnailUpdatedEvent { get; }
|
||||||
bool IsBusy { get; }
|
|
||||||
bool IsThreadExpanded { get; }
|
bool IsThreadExpanded { get; }
|
||||||
AccountContact SenderContact { get; }
|
AccountContact SenderContact { get; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ public interface IMailListItem : IMailHashContainer, IMailListItemSorting, INoti
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsSelected { get; set; }
|
bool IsSelected { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets whether this item is currently processing a network operation.
|
||||||
|
/// </summary>
|
||||||
|
bool IsBusy { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets all selected mail items within this list item.
|
/// Gets all selected mail items within this list item.
|
||||||
/// For MailItemViewModel: returns itself if IsSelected is true, otherwise empty
|
/// For MailItemViewModel: returns itself if IsSelected is true, otherwise empty
|
||||||
|
|||||||
@@ -19,7 +19,8 @@
|
|||||||
FocusVisualSecondaryBrush="{StaticResource SystemControlFocusVisualSecondaryBrush}"
|
FocusVisualSecondaryBrush="{StaticResource SystemControlFocusVisualSecondaryBrush}"
|
||||||
FocusVisualSecondaryThickness="1"
|
FocusVisualSecondaryThickness="1"
|
||||||
PointerEntered="ControlPointerEntered"
|
PointerEntered="ControlPointerEntered"
|
||||||
PointerExited="ControlPointerExited">
|
PointerExited="ControlPointerExited"
|
||||||
|
Unloaded="OnUnloaded">
|
||||||
|
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<Style
|
<Style
|
||||||
@@ -59,7 +60,8 @@
|
|||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
BorderBrush="Transparent"
|
BorderBrush="Transparent"
|
||||||
BorderThickness="0.5"
|
BorderThickness="0.5"
|
||||||
CornerRadius="4" />
|
CornerRadius="4"
|
||||||
|
SizeChanged="RootContainerVisualWrapperSizeChanged" />
|
||||||
|
|
||||||
<Grid x:Name="MainContentContainer">
|
<Grid x:Name="MainContentContainer">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@@ -247,7 +249,7 @@
|
|||||||
Height="3"
|
Height="3"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
VerticalAlignment="Bottom"
|
VerticalAlignment="Bottom"
|
||||||
IsActive="{x:Bind MailItemInformation.IsBusy, Mode=OneWay}" />
|
IsActive="{x:Bind ActionItem.IsBusy, Mode=OneWay, FallbackValue=False}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using CommunityToolkit.WinUI;
|
using CommunityToolkit.WinUI;
|
||||||
@@ -26,6 +27,8 @@ public sealed partial class MailItemDisplayInformationControl : UserControl
|
|||||||
private Compositor? _compositor;
|
private Compositor? _compositor;
|
||||||
private Visual? _contentVisual;
|
private Visual? _contentVisual;
|
||||||
private ScalarKeyFrameAnimation? _opacityAnimation;
|
private ScalarKeyFrameAnimation? _opacityAnimation;
|
||||||
|
private SpriteVisual? _leftBackgroundVisual;
|
||||||
|
private INotifyPropertyChanged? _actionItemPropertySource;
|
||||||
|
|
||||||
[GeneratedDependencyProperty(DefaultValue = MailListDisplayMode.Spacious)]
|
[GeneratedDependencyProperty(DefaultValue = MailListDisplayMode.Spacious)]
|
||||||
public partial MailListDisplayMode DisplayMode { get; set; }
|
public partial MailListDisplayMode DisplayMode { get; set; }
|
||||||
@@ -83,8 +86,8 @@ public sealed partial class MailItemDisplayInformationControl : UserControl
|
|||||||
|
|
||||||
var compositor = this.Visual().Compositor;
|
var compositor = this.Visual().Compositor;
|
||||||
|
|
||||||
var leftBackgroundVisual = compositor.CreateSpriteVisual();
|
_leftBackgroundVisual = compositor.CreateSpriteVisual();
|
||||||
RootContainerVisualWrapper.SetChildVisual(leftBackgroundVisual);
|
RootContainerVisualWrapper.SetChildVisual(_leftBackgroundVisual);
|
||||||
MainContentContainer.EnableImplicitAnimation(VisualPropertyType.Offset, 400);
|
MainContentContainer.EnableImplicitAnimation(VisualPropertyType.Offset, 400);
|
||||||
|
|
||||||
RootContainer.EnableImplicitAnimation(VisualPropertyType.Offset, 400);
|
RootContainer.EnableImplicitAnimation(VisualPropertyType.Offset, 400);
|
||||||
@@ -92,8 +95,6 @@ public sealed partial class MailItemDisplayInformationControl : UserControl
|
|||||||
ContentStackpanel.EnableImplicitAnimation(VisualPropertyType.Offset, 400);
|
ContentStackpanel.EnableImplicitAnimation(VisualPropertyType.Offset, 400);
|
||||||
IconsContainer.EnableImplicitAnimation(VisualPropertyType.Offset, 400);
|
IconsContainer.EnableImplicitAnimation(VisualPropertyType.Offset, 400);
|
||||||
|
|
||||||
RootContainerVisualWrapper.SizeChanged += (s, e) => leftBackgroundVisual.Size = e.NewSize.ToVector2();
|
|
||||||
|
|
||||||
// Initialize shimmer effect compositor
|
// Initialize shimmer effect compositor
|
||||||
_compositor = this.Visual().Compositor;
|
_compositor = this.Visual().Compositor;
|
||||||
}
|
}
|
||||||
@@ -108,6 +109,23 @@ public sealed partial class MailItemDisplayInformationControl : UserControl
|
|||||||
UpdateBusyAnimationState();
|
UpdateBusyAnimationState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
partial void OnActionItemPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (_actionItemPropertySource != null)
|
||||||
|
{
|
||||||
|
_actionItemPropertySource.PropertyChanged -= ActionItemPropertyChanged;
|
||||||
|
_actionItemPropertySource = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.NewValue is INotifyPropertyChanged propertyChangedSource)
|
||||||
|
{
|
||||||
|
_actionItemPropertySource = propertyChangedSource;
|
||||||
|
_actionItemPropertySource.PropertyChanged += ActionItemPropertyChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateBusyAnimationState();
|
||||||
|
}
|
||||||
|
|
||||||
private void StartBusyAnimation()
|
private void StartBusyAnimation()
|
||||||
{
|
{
|
||||||
if (_compositor == null) return;
|
if (_compositor == null) return;
|
||||||
@@ -144,7 +162,7 @@ public sealed partial class MailItemDisplayInformationControl : UserControl
|
|||||||
|
|
||||||
private void UpdateBusyAnimationState()
|
private void UpdateBusyAnimationState()
|
||||||
{
|
{
|
||||||
if (MailItemInformation?.IsBusy == true)
|
if (ActionItem?.IsBusy == true)
|
||||||
{
|
{
|
||||||
StartBusyAnimation();
|
StartBusyAnimation();
|
||||||
return;
|
return;
|
||||||
@@ -153,6 +171,33 @@ public sealed partial class MailItemDisplayInformationControl : UserControl
|
|||||||
StopBusyAnimation();
|
StopBusyAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ActionItemPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(e.PropertyName) || e.PropertyName == nameof(IMailListItem.IsBusy))
|
||||||
|
{
|
||||||
|
UpdateBusyAnimationState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnUnloaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (_actionItemPropertySource != null)
|
||||||
|
{
|
||||||
|
_actionItemPropertySource.PropertyChanged -= ActionItemPropertyChanged;
|
||||||
|
_actionItemPropertySource = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
StopBusyAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RootContainerVisualWrapperSizeChanged(object sender, SizeChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (_leftBackgroundVisual != null)
|
||||||
|
{
|
||||||
|
_leftBackgroundVisual.Size = e.NewSize.ToVector2();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ControlPointerEntered(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e)
|
private void ControlPointerEntered(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (IsHoverActionsEnabled)
|
if (IsHoverActionsEnabled)
|
||||||
|
|||||||
Reference in New Issue
Block a user