Main app aot compatibility.
This commit is contained in:
@@ -28,8 +28,8 @@ public partial class AccountNavigationItem : WinoNavigationViewItem
|
||||
private const string PART_NavigationViewItemMenuItemsHost = "NavigationViewItemMenuItemsHost";
|
||||
private const string PART_SelectionIndicator = "CustomSelectionIndicator";
|
||||
|
||||
private ItemsRepeater _itemsRepeater;
|
||||
private Microsoft.UI.Xaml.Shapes.Rectangle _selectionIndicator;
|
||||
private ItemsRepeater _itemsRepeater = null!;
|
||||
private Microsoft.UI.Xaml.Shapes.Rectangle _selectionIndicator = null!;
|
||||
|
||||
public AccountNavigationItem()
|
||||
{
|
||||
@@ -40,8 +40,8 @@ public partial class AccountNavigationItem : WinoNavigationViewItem
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
_itemsRepeater = GetTemplateChild(PART_NavigationViewItemMenuItemsHost) as ItemsRepeater;
|
||||
_selectionIndicator = GetTemplateChild(PART_SelectionIndicator) as Microsoft.UI.Xaml.Shapes.Rectangle;
|
||||
_itemsRepeater = (GetTemplateChild(PART_NavigationViewItemMenuItemsHost) as ItemsRepeater)!;
|
||||
_selectionIndicator = (GetTemplateChild(PART_SelectionIndicator) as Microsoft.UI.Xaml.Shapes.Rectangle)!;
|
||||
|
||||
UpdateSelectionBorder();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public partial class WinoItemsView : ItemsView
|
||||
private ScrollView? _internalScrollView;
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial ICommand LoadMoreCommand { get; set; }
|
||||
public partial ICommand? LoadMoreCommand { get; set; }
|
||||
|
||||
public IEnumerable<object>? CastedItemsSource => ItemsSource as IEnumerable<object>;
|
||||
|
||||
|
||||
@@ -60,13 +60,13 @@ public partial class ImagePreviewControl : Control
|
||||
|
||||
#endregion
|
||||
|
||||
private Ellipse Ellipse;
|
||||
private Grid InitialsGrid;
|
||||
private TextBlock InitialsTextblock;
|
||||
private Image KnownHostImage;
|
||||
private Border FaviconSquircle;
|
||||
private Image FaviconImage;
|
||||
private CancellationTokenSource contactPictureLoadingCancellationTokenSource;
|
||||
private Ellipse Ellipse = null!;
|
||||
private Grid InitialsGrid = null!;
|
||||
private TextBlock InitialsTextblock = null!;
|
||||
private Image KnownHostImage = null!;
|
||||
private Border FaviconSquircle = null!;
|
||||
private Image FaviconImage = null!;
|
||||
private CancellationTokenSource contactPictureLoadingCancellationTokenSource = null!;
|
||||
|
||||
public ImagePreviewControl()
|
||||
{
|
||||
@@ -77,12 +77,12 @@ public partial class ImagePreviewControl : Control
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
InitialsGrid = GetTemplateChild(PART_EllipseInitialsGrid) as Grid;
|
||||
InitialsTextblock = GetTemplateChild(PART_InitialsTextBlock) as TextBlock;
|
||||
KnownHostImage = GetTemplateChild(PART_KnownHostImage) as Image;
|
||||
Ellipse = GetTemplateChild(PART_Ellipse) as Ellipse;
|
||||
FaviconSquircle = GetTemplateChild(PART_FaviconSquircle) as Border;
|
||||
FaviconImage = GetTemplateChild(PART_FaviconImage) as Image;
|
||||
InitialsGrid = (GetTemplateChild(PART_EllipseInitialsGrid) as Grid)!;
|
||||
InitialsTextblock = (GetTemplateChild(PART_InitialsTextBlock) as TextBlock)!;
|
||||
KnownHostImage = (GetTemplateChild(PART_KnownHostImage) as Image)!;
|
||||
Ellipse = (GetTemplateChild(PART_Ellipse) as Ellipse)!;
|
||||
FaviconSquircle = (GetTemplateChild(PART_FaviconSquircle) as Border)!;
|
||||
FaviconImage = (GetTemplateChild(PART_FaviconImage) as Image)!;
|
||||
|
||||
UpdateInformation();
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public partial class ImagePreviewControl : Control
|
||||
// Cancel active image loading if exists.
|
||||
if (!contactPictureLoadingCancellationTokenSource?.IsCancellationRequested ?? false)
|
||||
{
|
||||
contactPictureLoadingCancellationTokenSource.Cancel();
|
||||
contactPictureLoadingCancellationTokenSource!.Cancel();
|
||||
}
|
||||
|
||||
string contactPicture = SenderContactPicture;
|
||||
@@ -120,8 +120,10 @@ public partial class ImagePreviewControl : Control
|
||||
{
|
||||
// Show favicon in squircle
|
||||
FaviconSquircle.Visibility = Visibility.Visible;
|
||||
InitialsGrid.Visibility = Visibility.Collapsed;
|
||||
KnownHostImage.Visibility = Visibility.Collapsed;
|
||||
if (InitialsGrid != null)
|
||||
InitialsGrid.Visibility = Visibility.Collapsed;
|
||||
if (KnownHostImage != null)
|
||||
KnownHostImage.Visibility = Visibility.Collapsed;
|
||||
|
||||
var bitmapImage = await GetBitmapImageAsync(contactPicture);
|
||||
|
||||
@@ -133,9 +135,12 @@ public partial class ImagePreviewControl : Control
|
||||
else
|
||||
{
|
||||
// Show normal avatar (tondo)
|
||||
FaviconSquircle.Visibility = Visibility.Collapsed;
|
||||
KnownHostImage.Visibility = Visibility.Collapsed;
|
||||
InitialsGrid.Visibility = Visibility.Visible;
|
||||
if (FaviconSquircle != null)
|
||||
FaviconSquircle.Visibility = Visibility.Collapsed;
|
||||
if (KnownHostImage != null)
|
||||
KnownHostImage.Visibility = Visibility.Collapsed;
|
||||
if (InitialsGrid != null)
|
||||
InitialsGrid.Visibility = Visibility.Visible;
|
||||
contactPictureLoadingCancellationTokenSource = new CancellationTokenSource();
|
||||
try
|
||||
{
|
||||
@@ -145,8 +150,10 @@ public partial class ImagePreviewControl : Control
|
||||
{
|
||||
if (!contactPictureLoadingCancellationTokenSource?.Token.IsCancellationRequested ?? false)
|
||||
{
|
||||
Ellipse.Fill = brush;
|
||||
InitialsTextblock.Text = string.Empty;
|
||||
if (Ellipse != null)
|
||||
Ellipse.Fill = brush;
|
||||
if (InitialsTextblock != null)
|
||||
InitialsTextblock.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -158,19 +165,24 @@ public partial class ImagePreviewControl : Control
|
||||
}
|
||||
else
|
||||
{
|
||||
FaviconSquircle.Visibility = Visibility.Collapsed;
|
||||
KnownHostImage.Visibility = Visibility.Collapsed;
|
||||
InitialsGrid.Visibility = Visibility.Visible;
|
||||
if (FaviconSquircle != null)
|
||||
FaviconSquircle.Visibility = Visibility.Collapsed;
|
||||
if (KnownHostImage != null)
|
||||
KnownHostImage.Visibility = Visibility.Collapsed;
|
||||
if (InitialsGrid != null)
|
||||
InitialsGrid.Visibility = Visibility.Visible;
|
||||
|
||||
var colorHash = new ColorHash();
|
||||
var rgb = colorHash.Rgb(FromAddress);
|
||||
|
||||
Ellipse.Fill = new SolidColorBrush(Color.FromArgb(rgb.A, rgb.R, rgb.G, rgb.B));
|
||||
InitialsTextblock.Text = ExtractInitialsFromName(FromName);
|
||||
if (Ellipse != null)
|
||||
Ellipse.Fill = new SolidColorBrush(Color.FromArgb(rgb.A, rgb.R, rgb.G, rgb.B));
|
||||
if (InitialsTextblock != null)
|
||||
InitialsTextblock.Text = ExtractInitialsFromName(FromName);
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<ImageBrush> GetContactImageBrushAsync(string base64)
|
||||
private static async Task<ImageBrush?> GetContactImageBrushAsync(string base64)
|
||||
{
|
||||
// Load the image from base64 string.
|
||||
|
||||
@@ -181,7 +193,7 @@ public partial class ImagePreviewControl : Control
|
||||
return new ImageBrush() { ImageSource = bitmapImage };
|
||||
}
|
||||
|
||||
private static async Task<BitmapImage> GetBitmapImageAsync(string base64)
|
||||
private static async Task<BitmapImage?> GetBitmapImageAsync(string base64)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -15,6 +15,6 @@ public partial class WinoMailItemContainerStyleSelector : StyleSelector
|
||||
if (item is ThreadMailItemViewModel)
|
||||
return ThreadStyle ?? throw new Exception($"Missing style for {nameof(ThreadMailItemViewModel)}");
|
||||
|
||||
return null;
|
||||
return base.SelectStyleCore(item, container);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ namespace Wino.Mail.Controls;
|
||||
|
||||
public sealed partial class WebViewEditorControl : Control, IDisposable
|
||||
{
|
||||
private readonly INativeAppService _nativeAppService = App.Current.Services.GetService<INativeAppService>();
|
||||
private readonly IFontService _fontService = App.Current.Services.GetService<IFontService>();
|
||||
private readonly IPreferencesService _preferencesService = App.Current.Services.GetService<IPreferencesService>();
|
||||
private readonly INativeAppService _nativeAppService = App.Current.Services.GetService<INativeAppService>()!;
|
||||
private readonly IFontService _fontService = App.Current.Services.GetService<IFontService>()!;
|
||||
private readonly IPreferencesService _preferencesService = App.Current.Services.GetService<IPreferencesService>()!;
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial bool IsEditorDarkMode { get; set; }
|
||||
@@ -131,7 +131,7 @@ public sealed partial class WebViewEditorControl : Control, IDisposable
|
||||
}
|
||||
|
||||
private const string PART_WebView = "WebView";
|
||||
private WebView2 _chromium;
|
||||
private WebView2 _chromium = null!;
|
||||
private bool _disposedValue;
|
||||
private readonly TaskCompletionSource<bool> _domLoadedTask = new();
|
||||
|
||||
@@ -146,7 +146,7 @@ public sealed partial class WebViewEditorControl : Control, IDisposable
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
_chromium = GetTemplateChild(PART_WebView) as WebView2;
|
||||
_chromium = (GetTemplateChild(PART_WebView) as WebView2)!;
|
||||
|
||||
await InitializeComponent();
|
||||
}
|
||||
@@ -175,7 +175,7 @@ public sealed partial class WebViewEditorControl : Control, IDisposable
|
||||
IsEditorDarkMode = !IsEditorDarkMode;
|
||||
}
|
||||
|
||||
public async Task<string> GetHtmlBodyAsync()
|
||||
public async Task<string?> GetHtmlBodyAsync()
|
||||
{
|
||||
var editorContent = await _chromium.ExecuteScriptFunctionSafeAsync("GetHTMLContent");
|
||||
|
||||
@@ -273,6 +273,8 @@ public sealed partial class WebViewEditorControl : Control, IDisposable
|
||||
{
|
||||
var change = JsonSerializer.Deserialize(args.WebMessageAsJson, DomainModelsJsonContext.Default.WebViewMessage);
|
||||
|
||||
if (change == null) return;
|
||||
|
||||
if (change.Type == "bold")
|
||||
{
|
||||
_isEditorBoldInternal = change.Value == "true";
|
||||
|
||||
@@ -13,9 +13,9 @@ public partial class WinoExpander : Control
|
||||
private const string PART_ContentAreaWrapper = "ContentAreaWrapper";
|
||||
private const string PART_ContentArea = "ContentArea";
|
||||
|
||||
private ContentControl HeaderGrid;
|
||||
private ContentControl ContentArea;
|
||||
private Grid ContentAreaWrapper;
|
||||
private ContentControl HeaderGrid = null!;
|
||||
private ContentControl ContentArea = null!;
|
||||
private Grid ContentAreaWrapper = null!;
|
||||
|
||||
public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(nameof(Header), typeof(UIElement), typeof(WinoExpander), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty ContentProperty = DependencyProperty.Register(nameof(Content), typeof(UIElement), typeof(WinoExpander), new PropertyMetadata(null));
|
||||
@@ -50,9 +50,9 @@ public partial class WinoExpander : Control
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
HeaderGrid = GetTemplateChild(PART_HeaderGrid) as ContentControl;
|
||||
ContentAreaWrapper = GetTemplateChild(PART_ContentAreaWrapper) as Grid;
|
||||
ContentArea = GetTemplateChild(PART_ContentArea) as ContentControl;
|
||||
HeaderGrid = (GetTemplateChild(PART_HeaderGrid) as ContentControl)!;
|
||||
ContentAreaWrapper = (GetTemplateChild(PART_ContentAreaWrapper) as Grid)!;
|
||||
ContentArea = (GetTemplateChild(PART_ContentArea) as ContentControl)!;
|
||||
|
||||
Guard.IsNotNull(HeaderGrid, nameof(HeaderGrid));
|
||||
Guard.IsNotNull(ContentAreaWrapper, nameof(ContentAreaWrapper));
|
||||
|
||||
@@ -60,7 +60,7 @@ public partial class WinoSwipeControlItems : SwipeItems
|
||||
this.Add(swipeItem);
|
||||
}
|
||||
|
||||
private SwipeItem GetSwipeItem(MailOperation operation)
|
||||
private SwipeItem? GetSwipeItem(MailOperation operation)
|
||||
{
|
||||
if (MailItem == null) return null;
|
||||
|
||||
@@ -72,18 +72,18 @@ public partial class WinoSwipeControlItems : SwipeItems
|
||||
{
|
||||
var singleItem = MailItem as MailItemViewModel;
|
||||
|
||||
if (operation == MailOperation.MarkAsRead && singleItem.IsRead)
|
||||
if (singleItem != null && operation == MailOperation.MarkAsRead && singleItem.IsRead)
|
||||
finalOperation = MailOperation.MarkAsUnread;
|
||||
else if (operation == MailOperation.MarkAsUnread && !singleItem.IsRead)
|
||||
else if (singleItem != null && operation == MailOperation.MarkAsUnread && !singleItem.IsRead)
|
||||
finalOperation = MailOperation.MarkAsRead;
|
||||
}
|
||||
else
|
||||
{
|
||||
var threadItem = MailItem as ThreadMailItemViewModel;
|
||||
|
||||
if (operation == MailOperation.MarkAsRead && threadItem.ThreadEmails.All(a => a.IsRead))
|
||||
if (threadItem != null && operation == MailOperation.MarkAsRead && threadItem.ThreadEmails.All(a => a.IsRead))
|
||||
finalOperation = MailOperation.MarkAsUnread;
|
||||
else if (operation == MailOperation.MarkAsUnread && threadItem.ThreadEmails.All(a => !a.IsRead))
|
||||
else if (threadItem != null && operation == MailOperation.MarkAsUnread && threadItem.ThreadEmails.All(a => !a.IsRead))
|
||||
finalOperation = MailOperation.MarkAsRead;
|
||||
}
|
||||
|
||||
@@ -114,18 +114,21 @@ public partial class WinoSwipeControlItems : SwipeItems
|
||||
{
|
||||
var singleItem = MailItem as MailItemViewModel;
|
||||
|
||||
if (SwipeOperation == MailOperation.MarkAsRead && singleItem.IsRead)
|
||||
finalOperation = MailOperation.MarkAsUnread;
|
||||
else if (SwipeOperation == MailOperation.MarkAsUnread && !singleItem.IsRead)
|
||||
finalOperation = MailOperation.MarkAsRead;
|
||||
if (singleItem != null)
|
||||
{
|
||||
if (SwipeOperation == MailOperation.MarkAsRead && singleItem.IsRead)
|
||||
finalOperation = MailOperation.MarkAsUnread;
|
||||
else if (SwipeOperation == MailOperation.MarkAsUnread && !singleItem.IsRead)
|
||||
finalOperation = MailOperation.MarkAsRead;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var threadItem = MailItem as ThreadMailItemViewModel;
|
||||
|
||||
if (SwipeOperation == MailOperation.MarkAsRead && threadItem.ThreadEmails.All(a => a.IsRead))
|
||||
if (threadItem != null && SwipeOperation == MailOperation.MarkAsRead && threadItem.ThreadEmails.All(a => a.IsRead))
|
||||
finalOperation = MailOperation.MarkAsUnread;
|
||||
else if (SwipeOperation == MailOperation.MarkAsUnread && threadItem.ThreadEmails.All(a => !a.IsRead))
|
||||
else if (threadItem != null && SwipeOperation == MailOperation.MarkAsUnread && threadItem.ThreadEmails.All(a => !a.IsRead))
|
||||
finalOperation = MailOperation.MarkAsRead;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user