Remove BackdropMaterial usage in XAML for WinUI 3
This commit is contained in:
@@ -7,5 +7,6 @@
|
|||||||
bool ContainsResourceKey(string resourceKey);
|
bool ContainsResourceKey(string resourceKey);
|
||||||
void ReplaceResource(string resourceKey, object resource);
|
void ReplaceResource(string resourceKey, object resource);
|
||||||
T GetLastResource();
|
T GetLastResource();
|
||||||
|
TReturn GetResource<TReturn>(string resourceKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="..\Wino.Mail\AppShell.xaml.cs" Link="AppShell.xaml.cs" />
|
||||||
<Compile Include="..\Wino.Mail\Behaviors\BindableCommandBarBehavior.cs" Link="Behaviors\BindableCommandBarBehavior.cs" />
|
<Compile Include="..\Wino.Mail\Behaviors\BindableCommandBarBehavior.cs" Link="Behaviors\BindableCommandBarBehavior.cs" />
|
||||||
<Compile Include="..\Wino.Mail\Behaviors\CreateMailNavigationItemBehavior.cs" Link="Behaviors\CreateMailNavigationItemBehavior.cs" />
|
<Compile Include="..\Wino.Mail\Behaviors\CreateMailNavigationItemBehavior.cs" Link="Behaviors\CreateMailNavigationItemBehavior.cs" />
|
||||||
<Compile Include="..\Wino.Mail\Controls\AccountNavigationItem.cs" Link="Controls\AccountNavigationItem.cs" />
|
<Compile Include="..\Wino.Mail\Controls\AccountNavigationItem.cs" Link="Controls\AccountNavigationItem.cs" />
|
||||||
@@ -118,6 +119,7 @@
|
|||||||
<PackageReference Include="CommunityToolkit.WinUI.Animations" Version="8.0.240109" />
|
<PackageReference Include="CommunityToolkit.WinUI.Animations" Version="8.0.240109" />
|
||||||
<PackageReference Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.0.240109" />
|
<PackageReference Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.0.240109" />
|
||||||
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.0.240109" />
|
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.0.240109" />
|
||||||
|
<PackageReference Include="CommunityToolkit.WinUI.Controls.Sizers" Version="8.0.240109" />
|
||||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
|
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
|
||||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240701003-experimental2" />
|
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240701003-experimental2" />
|
||||||
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
|
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
|
||||||
@@ -162,6 +164,9 @@
|
|||||||
<None Include="..\Wino.Mail\JS\libs\jodit.min.js" Link="JS\libs\jodit.min.js" />
|
<None Include="..\Wino.Mail\JS\libs\jodit.min.js" Link="JS\libs\jodit.min.js" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Page Include="..\Wino.Mail\AppShell.xaml" Link="AppShell.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="..\Wino.Mail\Controls\Advanced\WinoAppTitleBar.xaml" Link="Controls\Advanced\WinoAppTitleBar.xaml">
|
<Page Include="..\Wino.Mail\Controls\Advanced\WinoAppTitleBar.xaml" Link="Controls\Advanced\WinoAppTitleBar.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||||
xmlns:selectors="using:Wino.Selectors"
|
xmlns:selectors="using:Wino.Selectors"
|
||||||
x:Name="Root"
|
x:Name="Root"
|
||||||
muxc:BackdropMaterial.ApplyToRootOrPageBackground="{ThemeResource UseMica}"
|
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
<Page.Resources>
|
<Page.Resources>
|
||||||
|
|||||||
@@ -6,10 +6,7 @@ using CommunityToolkit.Mvvm.Input;
|
|||||||
using CommunityToolkit.Mvvm.Messaging;
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
using Windows.ApplicationModel.Core;
|
using Windows.ApplicationModel.Core;
|
||||||
using Windows.Foundation;
|
using Windows.Foundation;
|
||||||
using Windows.UI.Xaml;
|
|
||||||
using Windows.UI.Xaml.Controls;
|
|
||||||
using Windows.UI.Xaml.Controls.Primitives;
|
|
||||||
using Windows.UI.Xaml.Input;
|
|
||||||
using Wino.Controls;
|
using Wino.Controls;
|
||||||
using Wino.Core.Domain;
|
using Wino.Core.Domain;
|
||||||
using Wino.Core.Domain.Entities;
|
using Wino.Core.Domain.Entities;
|
||||||
@@ -25,6 +22,20 @@ using Wino.Mail.ViewModels.Data;
|
|||||||
using Wino.MenuFlyouts;
|
using Wino.MenuFlyouts;
|
||||||
using Wino.MenuFlyouts.Context;
|
using Wino.MenuFlyouts.Context;
|
||||||
using Wino.Views.Abstract;
|
using Wino.Views.Abstract;
|
||||||
|
using Microsoft.UI.Xaml.Controls;
|
||||||
|
|
||||||
|
#if NET8_0
|
||||||
|
using Microsoft.UI.Xaml;
|
||||||
|
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||||
|
using Microsoft.UI.Xaml.Input;
|
||||||
|
using Microsoft.UI.Xaml.Navigation;
|
||||||
|
#else
|
||||||
|
using Windows.UI.Xaml;
|
||||||
|
using Windows.UI.Xaml.Controls;
|
||||||
|
using Windows.UI.Xaml.Controls.Primitives;
|
||||||
|
using Windows.UI.Xaml.Input;
|
||||||
|
using Windows.UI.Xaml.Navigation;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Wino.Views
|
namespace Wino.Views
|
||||||
{
|
{
|
||||||
@@ -32,7 +43,8 @@ namespace Wino.Views
|
|||||||
IRecipient<AccountMenuItemExtended>,
|
IRecipient<AccountMenuItemExtended>,
|
||||||
IRecipient<NavigateMailFolderEvent>,
|
IRecipient<NavigateMailFolderEvent>,
|
||||||
IRecipient<CreateNewMailWithMultipleAccountsRequested>,
|
IRecipient<CreateNewMailWithMultipleAccountsRequested>,
|
||||||
IRecipient<InfoBarMessageRequested>
|
IRecipient<InfoBarMessageRequested>,
|
||||||
|
IRecipient<ApplicationThemeChanged>
|
||||||
{
|
{
|
||||||
public AppShell() : base()
|
public AppShell() : base()
|
||||||
{
|
{
|
||||||
@@ -40,6 +52,12 @@ namespace Wino.Views
|
|||||||
|
|
||||||
var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
|
var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
|
||||||
coreTitleBar.LayoutMetricsChanged += TitleBarLayoutUpdated;
|
coreTitleBar.LayoutMetricsChanged += TitleBarLayoutUpdated;
|
||||||
|
|
||||||
|
#if !NET8_0
|
||||||
|
// BackdropMaterial is not available in WinUI 3.0.
|
||||||
|
// We manually apply it for UWP version only.
|
||||||
|
SetupMica();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TitleBarLayoutUpdated(CoreApplicationViewTitleBar sender, object args) => UpdateTitleBarLayout(sender);
|
private void TitleBarLayoutUpdated(CoreApplicationViewTitleBar sender, object args) => UpdateTitleBarLayout(sender);
|
||||||
@@ -200,7 +218,7 @@ namespace Wino.Views
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShellFrameContentNavigated(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e)
|
private void ShellFrameContentNavigated(object sender, NavigationEventArgs e)
|
||||||
=> RealAppBar.ShellFrameContent = (e.Content as BasePage).ShellContent;
|
=> RealAppBar.ShellFrameContent = (e.Content as BasePage).ShellContent;
|
||||||
|
|
||||||
private void BackButtonClicked(Controls.Advanced.WinoAppTitleBar sender, RoutedEventArgs args)
|
private void BackButtonClicked(Controls.Advanced.WinoAppTitleBar sender, RoutedEventArgs args)
|
||||||
@@ -298,5 +316,22 @@ namespace Wino.Views
|
|||||||
ShellInfoBar.IsOpen = true;
|
ShellInfoBar.IsOpen = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void SetupMica()
|
||||||
|
{
|
||||||
|
#if !NET8_0
|
||||||
|
var resourceManager = App.Current.Services.GetService<IApplicationResourceManager<ResourceDictionary>>();
|
||||||
|
|
||||||
|
if (resourceManager.ContainsResourceKey("UseMica"))
|
||||||
|
{
|
||||||
|
bool isMicaEnabled = resourceManager.GetResource<bool>("UseMica");
|
||||||
|
|
||||||
|
BackdropMaterial.SetApplyToRootOrPageBackground(this, isMicaEnabled);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Receive(ApplicationThemeChanged message) => SetupMica();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ using Wino.Core.Domain.Models.MailItem;
|
|||||||
using Wino.Core.Domain.Models.Reader;
|
using Wino.Core.Domain.Models.Reader;
|
||||||
using Windows.UI.Text;
|
using Windows.UI.Text;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if NET8_0
|
#if NET8_0
|
||||||
using Microsoft.UI;
|
using Microsoft.UI;
|
||||||
using Microsoft.UI.Text;
|
using Microsoft.UI.Text;
|
||||||
@@ -28,6 +26,7 @@ using Windows.UI.Xaml.Media;
|
|||||||
using Microsoft.Toolkit.Uwp.Helpers;
|
using Microsoft.Toolkit.Uwp.Helpers;
|
||||||
using Windows.UI.Xaml.Shapes;
|
using Windows.UI.Xaml.Shapes;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Wino.Helpers
|
namespace Wino.Helpers
|
||||||
{
|
{
|
||||||
public static class XamlHelpers
|
public static class XamlHelpers
|
||||||
|
|||||||
@@ -23,5 +23,8 @@ namespace Wino.Services
|
|||||||
|
|
||||||
public void ReplaceResource(string resourceKey, object resource)
|
public void ReplaceResource(string resourceKey, object resource)
|
||||||
=> App.Current.Resources[resourceKey] = resource;
|
=> App.Current.Resources[resourceKey] = resource;
|
||||||
|
|
||||||
|
public TReturn GetResource<TReturn>(string resourceKey)
|
||||||
|
=> (TReturn)App.Current.Resources[resourceKey];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user