diff --git a/Wino.Calendar.ViewModels/CalendarPageViewModel.cs b/Wino.Calendar.ViewModels/CalendarPageViewModel.cs index 230570f4..f8c684ef 100644 --- a/Wino.Calendar.ViewModels/CalendarPageViewModel.cs +++ b/Wino.Calendar.ViewModels/CalendarPageViewModel.cs @@ -633,6 +633,22 @@ public partial class CalendarPageViewModel : CalendarBaseViewModel, return ApplyDisplayRequestAsync(new CalendarDisplayRequest(CurrentVisibleRange.DisplayType, CurrentVisibleRange.AnchorDate), forceReload: true); } + public async Task> SearchCalendarItemsAsync(string queryText, int limit, CancellationToken cancellationToken) + { + var results = await _calendarService.SearchCalendarItemsAsync(queryText, limit, cancellationToken).ConfigureAwait(false); + var activeCalendarIds = AccountCalendarStateService.ActiveCalendars.Select(calendar => calendar.Id).ToHashSet(); + + return results + .Where(result => activeCalendarIds.Contains(result.CalendarId)) + .ToList(); + } + + public void OpenCalendarSearchResult(CalendarItem calendarItem) + { + ArgumentNullException.ThrowIfNull(calendarItem); + NavigateEvent(new CalendarItemViewModel(calendarItem), CalendarEventTargetType.Single); + } + private async Task> LoadCalendarItemsAsync(DateRange loadedDateWindow, long lifetimeVersion) { var loadedItems = new Dictionary(); diff --git a/Wino.Core.Domain/Interfaces/ICalendarService.cs b/Wino.Core.Domain/Interfaces/ICalendarService.cs index 8c41925d..fae3d08f 100644 --- a/Wino.Core.Domain/Interfaces/ICalendarService.cs +++ b/Wino.Core.Domain/Interfaces/ICalendarService.cs @@ -41,6 +41,7 @@ public interface ICalendarService Task> GetAttendeesAsync(Guid calendarEventTrackingId); Task> ManageEventAttendeesAsync(Guid calendarItemId, List allAttendees); Task UpdateCalendarItemAsync(CalendarItem calendarItem, List attendees); + Task> SearchCalendarItemsAsync(string searchQuery, int limit, CancellationToken cancellationToken = default); Task> GetRemindersAsync(Guid calendarItemId); Task SaveRemindersAsync(Guid calendarItemId, List reminders); Task SnoozeCalendarItemAsync(Guid calendarItemId, DateTime snoozedUntilLocal); diff --git a/Wino.Mail.WinUI/BasePage.cs b/Wino.Mail.WinUI/BasePage.cs index 1a6944c2..169a0ae6 100644 --- a/Wino.Mail.WinUI/BasePage.cs +++ b/Wino.Mail.WinUI/BasePage.cs @@ -13,14 +13,6 @@ namespace Wino.Mail.WinUI; public partial class BasePage : Page, IRecipient { - public UIElement ShellContent - { - get { return (UIElement)GetValue(ShellContentProperty); } - set { SetValue(ShellContentProperty, value); } - } - - public static readonly DependencyProperty ShellContentProperty = DependencyProperty.Register(nameof(ShellContent), typeof(UIElement), typeof(BasePage), new PropertyMetadata(null)); - public void Receive(LanguageChanged message) { OnLanguageChanged(); diff --git a/Wino.Mail.WinUI/Interfaces/ITitleBarSearchHost.cs b/Wino.Mail.WinUI/Interfaces/ITitleBarSearchHost.cs new file mode 100644 index 00000000..2d58f274 --- /dev/null +++ b/Wino.Mail.WinUI/Interfaces/ITitleBarSearchHost.cs @@ -0,0 +1,16 @@ +using System.Collections.ObjectModel; +using System.Threading.Tasks; +using Wino.Mail.WinUI.Models; + +namespace Wino.Mail.WinUI.Interfaces; + +public interface ITitleBarSearchHost +{ + string SearchText { get; set; } + string SearchPlaceholderText { get; } + ObservableCollection SearchSuggestions { get; } + + Task OnTitleBarSearchTextChangedAsync(); + void OnTitleBarSearchSuggestionChosen(TitleBarSearchSuggestion suggestion); + Task OnTitleBarSearchSubmittedAsync(string queryText, TitleBarSearchSuggestion? chosenSuggestion); +} diff --git a/Wino.Mail.WinUI/Interfaces/IWinoShellWindow.cs b/Wino.Mail.WinUI/Interfaces/IWinoShellWindow.cs index b0086ce2..6ee23b92 100644 --- a/Wino.Mail.WinUI/Interfaces/IWinoShellWindow.cs +++ b/Wino.Mail.WinUI/Interfaces/IWinoShellWindow.cs @@ -1,11 +1,10 @@ using CommunityToolkit.Mvvm.Messaging; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; -using Wino.Messaging.UI; namespace Wino.Mail.WinUI.Interfaces; -public interface IWinoShellWindow : IRecipient +public interface IWinoShellWindow { void HandleAppActivation(string? launchArguments, string? tileId = null, string? appId = null); TitleBar GetTitleBar(); diff --git a/Wino.Mail.WinUI/Models/TitleBarSearchSuggestion.cs b/Wino.Mail.WinUI/Models/TitleBarSearchSuggestion.cs new file mode 100644 index 00000000..2ff8b637 --- /dev/null +++ b/Wino.Mail.WinUI/Models/TitleBarSearchSuggestion.cs @@ -0,0 +1,8 @@ +namespace Wino.Mail.WinUI.Models; + +public sealed class TitleBarSearchSuggestion(string title, string subtitle = "", object? tag = null) +{ + public string Title { get; } = title; + public string Subtitle { get; } = subtitle; + public object? Tag { get; } = tag; +} diff --git a/Wino.Mail.WinUI/ShellWindow.xaml b/Wino.Mail.WinUI/ShellWindow.xaml index 6952db29..fd07e243 100644 --- a/Wino.Mail.WinUI/ShellWindow.xaml +++ b/Wino.Mail.WinUI/ShellWindow.xaml @@ -9,6 +9,7 @@ xmlns:helpers="using:Wino.Helpers" xmlns:local="using:Wino.Mail.WinUI" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:searchModels="using:Wino.Mail.WinUI.Models" xmlns:syncModels="using:Wino.Core.Domain.Models.Synchronization" xmlns:winuiex="using:WinUIEx" Title="ShellWindow" @@ -34,10 +35,39 @@ IsPaneToggleButtonVisible="True" PaneToggleRequested="PaneButtonClicked" Subtitle="{x:Bind StatePersistanceService.CoreWindowTitle, Mode=OneWay}"> - + + + + + + + + + + + + + + +