Fixing some issues with ItemsView and selections.

This commit is contained in:
Burak Kaan Köse
2025-10-21 22:08:56 +02:00
parent ae7d576967
commit 449c1d3f4d
11 changed files with 657 additions and 187 deletions
+2 -1
View File
@@ -104,10 +104,11 @@ public partial class App : WinoApplication, IRecipient<NewMailSynchronizationReq
bool isStartupTaskLaunch = IsStartupTaskLaunch();
shellWindow.HandleAppActivation(args);
// Do not actiavate window if launched from startup task. Keep running in the system tray.
if (!isStartupTaskLaunch)
{
shellWindow.HandleAppActivation(args);
MainWindow.Activate();
}
}
@@ -6,8 +6,8 @@ public class MailAuthenticatorConfiguration : IAuthenticatorConfig
{
public string OutlookAuthenticatorClientId => "b19c2035-d740-49ff-b297-de6ec561b208";
public string[] OutlookScope => new string[]
{
public string[] OutlookScope =>
[
"email",
"mail.readwrite",
"offline_access",
@@ -15,17 +15,17 @@ public class MailAuthenticatorConfiguration : IAuthenticatorConfig
"Mail.Send.Shared",
"Mail.ReadWrite.Shared",
"User.Read"
};
];
public string GmailAuthenticatorClientId => "973025879644-s7b4ur9p3rlgop6a22u7iuptdc0brnrn.apps.googleusercontent.com";
public string[] GmailScope => new string[]
{
public string[] GmailScope =>
[
"https://mail.google.com/",
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/gmail.labels",
"https://www.googleapis.com/auth/userinfo.email"
};
];
public string GmailTokenStoreIdentifier => "WinoMailGmailTokenStore";
}
+3 -6
View File
@@ -10,6 +10,7 @@ using EmailValidation;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media.Animation;
using Microsoft.UI.Xaml.Navigation;
using MimeKit;
using Windows.ApplicationModel.DataTransfer;
@@ -34,12 +35,10 @@ public sealed partial class ComposePage : ComposePageAbstract,
public WebView2 GetWebView() => WebViewEditor.GetUnderlyingWebView();
private readonly List<IDisposable> _disposables = [];
private readonly SystemNavigationManagerPreview _navManagerPreview = SystemNavigationManagerPreview.GetForCurrentView();
public ComposePage()
{
InitializeComponent();
_navManagerPreview.CloseRequested += OnClose;
}
private async void GlobalFocusManagerGotFocus(object sender, FocusManagerGotFocusEventArgs e)
@@ -235,9 +234,8 @@ public sealed partial class ComposePage : ComposePageAbstract,
FocusManager.GotFocus += GlobalFocusManagerGotFocus;
// TODO: disabled animation for now, since it's still not working properly.
//var anim = ConnectedAnimationService.GetForCurrentView().GetAnimation("WebViewConnectedAnimation");
//anim?.TryStart(GetWebView());
var anim = ConnectedAnimationService.GetForCurrentView().GetAnimation("WebViewConnectedAnimation");
anim?.TryStart(GetWebView());
_disposables.Add(GetSuggestionBoxDisposable(ToBox));
_disposables.Add(GetSuggestionBoxDisposable(CCBox));
@@ -371,7 +369,6 @@ public sealed partial class ComposePage : ComposePageAbstract,
base.OnNavigatingFrom(e);
FocusManager.GotFocus -= GlobalFocusManagerGotFocus;
_navManagerPreview.CloseRequested -= OnClose;
await ViewModel.UpdateMimeChangesAsync();
DisposeDisposables();
+9 -4
View File
@@ -33,6 +33,7 @@
mc:Ignorable="d">
<Page.Resources>
<x:Double x:Key="ItemContainerDisabledOpacity">1</x:Double>
<Thickness x:Key="ExpanderHeaderPadding">0,0,0,0</Thickness>
<Thickness x:Key="ExpanderChevronMargin">0,0,12,0</Thickness>
@@ -58,6 +59,7 @@
<ItemContainer
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
CanUserInvoke="UserCanInvoke"
IsSelected="{x:Bind IsSelected, Mode=TwoWay}">
<animations:Implicit.ShowAnimations>
<animations:OpacityAnimation To="1.0" Duration="0:0:1" />
@@ -129,12 +131,16 @@
</DataTemplate>
<DataTemplate x:Key="DateGroupHeaderTemplate" x:DataType="data:DateGroupHeader">
<ItemContainer CanUserSelect="UserCannotSelect" IsHitTestVisible="False">
<ItemContainer
CanUserSelect="UserCannotSelect"
IsHitTestVisible="False"
IsSelected="False">
<Grid Padding="12,8" Background="{ThemeResource CardBackgroundFillColorDefaultBrush}">
<TextBlock
FontSize="14"
FontWeight="SemiBold"
Foreground="{ThemeResource TextFillColorPrimaryBrush}"
Opacity="1"
Style="{ThemeResource CaptionTextBlockStyle}"
Text="{x:Bind DisplayName, Mode=OneWay}" />
</Grid>
@@ -251,7 +257,7 @@
<CommandBar
HorizontalAlignment="Left"
DefaultLabelPosition="Collapsed"
IsEnabled="{x:Bind helpers:XamlHelpers.CountToBooleanConverter(ViewModel.SelectedItemCount), Mode=OneWay}"
IsEnabled="{x:Bind helpers:XamlHelpers.CountToBooleanConverter(ViewModel.MailCollection.SelectedVisibleItems.Count), Mode=OneWay}"
OverflowButtonVisibility="Auto">
<interactivity:Interaction.Behaviors>
<local:BindableCommandBarBehavior ItemClickedCommand="{x:Bind ViewModel.ExecuteTopBarActionCommand}" PrimaryCommands="{x:Bind ViewModel.ActionItems, Mode=OneWay}" />
@@ -436,10 +442,9 @@
ItemsSource="{x:Bind ViewModel.MailCollection.Items, Mode=OneTime}"
Layout="{StaticResource DefaultItemsViewLayout}"
LoadMoreCommand="{x:Bind ViewModel.LoadMoreItemsCommand}"
SelectionChanged="ListSelectionChanged"
ProcessKeyboardAccelerators="MailListView_ProcessKeyboardAccelerators"
SelectionMode="Extended" />
<!-- Try online search panel. -->
<Grid Grid.Row="1" Visibility="{x:Bind ViewModel.IsOnlineSearchButtonVisible, Mode=OneWay}">
<Button
+44 -14
View File
@@ -481,7 +481,7 @@ public sealed partial class MailListPage : MailListPageAbstract,
if (StatePersistenceService.IsReaderNarrowed)
{
if (ViewModel.HasSingleItemSelection && !isMultiSelectionEnabled)
if (ViewModel.MailCollection.HasSingleItemSelected && !isMultiSelectionEnabled)
{
VisualStateManager.GoToState(this, "NarrowRenderer", true);
}
@@ -492,7 +492,7 @@ public sealed partial class MailListPage : MailListPageAbstract,
}
else
{
if (ViewModel.HasSingleItemSelection && !isMultiSelectionEnabled)
if (ViewModel.MailCollection.HasSingleItemSelected && !isMultiSelectionEnabled)
{
VisualStateManager.GoToState(this, "BothPanelsMailSelected", true);
}
@@ -505,6 +505,8 @@ public sealed partial class MailListPage : MailListPageAbstract,
private void SelectAllInvoked(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args)
{
// MailListView.SelectAllWino();
}
@@ -554,19 +556,19 @@ public sealed partial class MailListPage : MailListPageAbstract,
private static object _selectedItemsLock = new object();
private void SynchronizeSelectedItems()
{
lock (_selectedItemsLock)
{
ViewModel.SelectedItems.Clear();
//lock (_selectedItemsLock)
//{
// ViewModel.SelectedItems.Clear();
foreach (var item in MailListView.SelectedItems)
{
if (item is MailItemViewModel mailItem)
{
if (!mailItem.IsSelected) mailItem.IsSelected = true;
if (!ViewModel.SelectedItems.Contains(mailItem)) ViewModel.SelectedItems.Add(mailItem);
}
}
}
// foreach (var item in MailListView.SelectedItems)
// {
// if (item is MailItemViewModel mailItem)
// {
// if (!mailItem.IsSelected) mailItem.IsSelected = true;
// if (!ViewModel.SelectedItems.Contains(mailItem)) ViewModel.SelectedItems.Add(mailItem);
// }
// }
//}
}
private void ThreadContainerRightTapped(object sender, RightTappedRoutedEventArgs e)
@@ -596,4 +598,32 @@ public sealed partial class MailListPage : MailListPageAbstract,
}
}
}
private void MailListView_ProcessKeyboardAccelerators(UIElement sender, ProcessKeyboardAcceleratorEventArgs args)
{
// ItemsView have weird logic for selection inversion. We need to handle it manually.
args.Handled = true;
ViewModel.MailCollection.SelectAll();
// If not all items are selected, select all. Otherwise clear selection.
// Handle selections in the GroupedEmailCollection.
//if (MailListView.SelectedItems.Count < MailListView.CastedItemsSource?.Count())
//{
// // MailListView.SelectAllWino();
//}
//else
//{
// // MailListView.ClearSelections();
//}
}
private void SingleItemInvoked(ItemsView sender, ItemsViewItemInvokedEventArgs args)
{
if (args.InvokedItem is MailItemViewModel mailItem)
{
mailItem.IsSelected = !mailItem.IsSelected;
}
}
}