diff --git a/Wino.Core.WinUI/Interfaces/IWinoShellWindow.cs b/Wino.Core.WinUI/Interfaces/IWinoShellWindow.cs index 67c07694..e124ebe1 100644 --- a/Wino.Core.WinUI/Interfaces/IWinoShellWindow.cs +++ b/Wino.Core.WinUI/Interfaces/IWinoShellWindow.cs @@ -1,9 +1,11 @@ -using Microsoft.UI.Xaml; +using CommunityToolkit.Mvvm.Messaging; +using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; +using Wino.Messaging.UI; namespace Wino.Core.WinUI.Interfaces; -public interface IWinoShellWindow +public interface IWinoShellWindow : IRecipient { void HandleAppActivation(LaunchActivatedEventArgs args); TitleBar GetTitleBar(); diff --git a/Wino.Mail.WinUI/AppShell.xaml.cs b/Wino.Mail.WinUI/AppShell.xaml.cs index db0a259c..621854f7 100644 --- a/Wino.Mail.WinUI/AppShell.xaml.cs +++ b/Wino.Mail.WinUI/AppShell.xaml.cs @@ -17,6 +17,7 @@ using Wino.Core.Domain.Interfaces; using Wino.Core.Domain.Models.Folders; using Wino.Core.Domain.Models.MailItem; using Wino.Core.Domain.Models.Navigation; +using Wino.Core.WinUI; using Wino.Core.WinUI.Controls; using Wino.Extensions; using Wino.Mail.ViewModels.Data; @@ -25,6 +26,7 @@ using Wino.MenuFlyouts.Context; using Wino.Messaging.Client.Accounts; using Wino.Messaging.Client.Mails; using Wino.Messaging.Client.Shell; +using Wino.Messaging.UI; using Wino.Views.Abstract; namespace Wino.Views; @@ -35,10 +37,14 @@ public sealed partial class AppShell : AppShellAbstract, IRecipient, IRecipient { + [GeneratedDependencyProperty] + public partial UIElement TopShellContent { get; set; } + public AppShell() : base() { InitializeComponent(); } + public Frame GetShellFrame() => ShellFrame; private async void ItemDroppedOnFolder(object sender, DragEventArgs e) { @@ -212,18 +218,9 @@ public sealed partial class AppShell : AppShellAbstract, } } - private void ShellFrameContentNavigated(object sender, Microsoft.UI.Xaml.Navigation.NavigationEventArgs e) - { - // => RealAppBar.ShellFrameContent = (e.Content as BasePage).ShellContent; + private void ShellFrameContentNavigated(object sender, Microsoft.UI.Xaml.Navigation.NavigationEventArgs e) => TopShellContent = ((BasePage)e.Content).ShellContent; - // TODO: WinUI3: Update shell content. Just remove it. - } - - private void BackButtonClicked(WinoAppTitleBar sender, RoutedEventArgs args) - { - WeakReferenceMessenger.Default.Send(new ClearMailSelectionsRequested()); - WeakReferenceMessenger.Default.Send(new DisposeRenderingFrameRequested()); - } + partial void OnTopShellContentChanged(UIElement newValue) => WeakReferenceMessenger.Default.Send(new TitleBarShellContentUpdated()); private async void MenuItemContextRequested(UIElement sender, ContextRequestedEventArgs args) { diff --git a/Wino.Mail.WinUI/ShellWindow.xaml b/Wino.Mail.WinUI/ShellWindow.xaml index 0302fd25..5cdb6a86 100644 --- a/Wino.Mail.WinUI/ShellWindow.xaml +++ b/Wino.Mail.WinUI/ShellWindow.xaml @@ -21,6 +21,8 @@ (this); + InitializeComponent(); MinWidth = 420; @@ -56,4 +59,12 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow { PreferencesService.IsNavigationPaneOpened = !PreferencesService.IsNavigationPaneOpened; } + + public void Receive(TitleBarShellContentUpdated message) + { + if (MainShellFrame.Content is AppShell shellPage) + { + ShellTitleBar.Content = shellPage.TopShellContent; + } + } } diff --git a/Wino.Mail.WinUI/Views/MailListPage.xaml b/Wino.Mail.WinUI/Views/MailListPage.xaml index 96327cbb..dab1109a 100644 --- a/Wino.Mail.WinUI/Views/MailListPage.xaml +++ b/Wino.Mail.WinUI/Views/MailListPage.xaml @@ -209,7 +209,7 @@ - +