Skip to content

Commit

Permalink
Merge pull request #25 from nalu-development/windows-desktop-support
Browse files Browse the repository at this point in the history
Add windows support (fixes #24)
  • Loading branch information
albyrock87 authored Apr 9, 2024
2 parents 95595d0 + 79f10dc commit 152fef2
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 21 deletions.
24 changes: 13 additions & 11 deletions Nalu.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{719809
Source\Directory.Build.props = Source\Directory.Build.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{00000000-0000-0000-0000-000000000000}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{3CC05E8E-99E0-471F-B74A-4B0307871648}"
ProjectSection(SolutionItems) = preProject
Samples\Directory.Build.props = Samples\Directory.Build.props
Samples\.editorconfig = Samples\.editorconfig
Samples\Directory.Build.props = Samples\Directory.Build.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F20E2797-D1E3-4321-91BB-FAE54954D2A0}"
Expand Down Expand Up @@ -39,9 +39,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{E1B24F25
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Images", "Images", "{26F71F5B-2940-4FB0-9681-A76060CBCEF9}"
ProjectSection(SolutionItems) = preProject
Images\NaluLogo.svg = Images\NaluLogo.svg
Images\Banner.png = Images\Banner.png
Images\Icon.png = Images\Icon.png
Images\NaluLogo.svg = Images\NaluLogo.svg
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ISSUE_TEMPLATE", "ISSUE_TEMPLATE", "{566DF0E2-1288-4083-9B55-4C8B69BB1432}"
Expand Down Expand Up @@ -71,17 +71,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
.github\workflows\release-drafter.yml = .github\workflows\release-drafter.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nalu.Maui", "Source\Nalu.Maui\Nalu.Maui.csproj", "{FF63DE33-999F-4045-B594-8BE9E7495C31}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nalu.Maui", "Source\Nalu.Maui\Nalu.Maui.csproj", "{FF63DE33-999F-4045-B594-8BE9E7495C31}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nalu.Maui.Test", "Tests\Nalu.Maui.Test\Nalu.Maui.Test.csproj", "{5067A8EE-4496-4F5A-A5FB-4D66B89363E1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nalu.Maui.Test", "Tests\Nalu.Maui.Test\Nalu.Maui.Test.csproj", "{5067A8EE-4496-4F5A-A5FB-4D66B89363E1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nalu.Maui.Sample", "Samples\Nalu.Maui.Sample\Nalu.Maui.Sample.csproj", "{959B003B-842C-473F-99E5-E905642AFDAF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nalu.Maui.Sample", "Samples\Nalu.Maui.Sample\Nalu.Maui.Sample.csproj", "{959B003B-842C-473F-99E5-E905642AFDAF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nalu.Maui.DefaultShellSample", "Samples\Nalu.Maui.DefaultShellSample\Nalu.Maui.DefaultShellSample.csproj", "{D64BF572-B11E-4068-8848-70F3FF0FF2DF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nalu.Maui.DefaultShellSample", "Samples\Nalu.Maui.DefaultShellSample\Nalu.Maui.DefaultShellSample.csproj", "{D64BF572-B11E-4068-8848-70F3FF0FF2DF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nalu.Maui.Navigation", "Source\Nalu.Maui.Navigation\Nalu.Maui.Navigation.csproj", "{CEB939B1-E5A5-462A-834F-7D32D1893444}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nalu.Maui.Navigation", "Source\Nalu.Maui.Navigation\Nalu.Maui.Navigation.csproj", "{CEB939B1-E5A5-462A-834F-7D32D1893444}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nalu.Maui.Core", "Source\Nalu.Maui.Core\Nalu.Maui.Core.csproj", "{BD63D735-B1BF-42CC-936E-A97991F29B1D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nalu.Maui.Core", "Source\Nalu.Maui.Core\Nalu.Maui.Core.csproj", "{BD63D735-B1BF-42CC-936E-A97991F29B1D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -99,9 +99,11 @@ Global
{5067A8EE-4496-4F5A-A5FB-4D66B89363E1}.Release|Any CPU.Build.0 = Release|Any CPU
{959B003B-842C-473F-99E5-E905642AFDAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{959B003B-842C-473F-99E5-E905642AFDAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{959B003B-842C-473F-99E5-E905642AFDAF}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{959B003B-842C-473F-99E5-E905642AFDAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D64BF572-B11E-4068-8848-70F3FF0FF2DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D64BF572-B11E-4068-8848-70F3FF0FF2DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D64BF572-B11E-4068-8848-70F3FF0FF2DF}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{D64BF572-B11E-4068-8848-70F3FF0FF2DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CEB939B1-E5A5-462A-834F-7D32D1893444}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CEB939B1-E5A5-462A-834F-7D32D1893444}.Debug|Any CPU.Build.0 = Debug|Any CPU
Expand All @@ -122,8 +124,8 @@ Global
{841C67EF-BBB2-4730-8E29-22FF3FD54306} = {EFE1E5ED-D337-4874-82EC-D9FA0BC7D3AB}
{FF63DE33-999F-4045-B594-8BE9E7495C31} = {719809C2-A551-4C4A-9EFD-B10FB5E35BC0}
{5067A8EE-4496-4F5A-A5FB-4D66B89363E1} = {E1B24F25-B8A4-46EE-B7EB-7803DCFC543F}
{959B003B-842C-473F-99E5-E905642AFDAF} = {00000000-0000-0000-0000-000000000000}
{D64BF572-B11E-4068-8848-70F3FF0FF2DF} = {00000000-0000-0000-0000-000000000000}
{959B003B-842C-473F-99E5-E905642AFDAF} = {3CC05E8E-99E0-471F-B74A-4B0307871648}
{D64BF572-B11E-4068-8848-70F3FF0FF2DF} = {3CC05E8E-99E0-471F-B74A-4B0307871648}
{CEB939B1-E5A5-462A-834F-7D32D1893444} = {719809C2-A551-4C4A-9EFD-B10FB5E35BC0}
{BD63D735-B1BF-42CC-936E-A97991F29B1D} = {719809C2-A551-4C4A-9EFD-B10FB5E35BC0}
EndGlobalSection
Expand Down
2 changes: 1 addition & 1 deletion Samples/Nalu.Maui.Sample/AppShell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Nalu.Maui.Sample;

public partial class AppShell : NaluShell
{
public AppShell(INavigationService navigationService) : base(navigationService, typeof(FivePage))
public AppShell(INavigationService navigationService) : base(navigationService, typeof(OnePage))
{
InitializeComponent();
}
Expand Down
29 changes: 28 additions & 1 deletion Samples/Nalu.Maui.Sample/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
namespace Nalu.Maui.Sample;
namespace Nalu.Maui.Sample;

using Microsoft.Extensions.Logging;

using CommunityToolkit.Maui;
using PopupModels;
using Popups;
using Microsoft.Maui.LifecycleEvents;

#if WINDOWS
using Microsoft.Maui.Platform;
#endif


public static class MauiProgram
{
Expand All @@ -13,6 +19,27 @@ public static MauiApp CreateMauiApp()
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureLifecycleEvents(events =>
{
#if WINDOWS
events.AddWindows(windowsLifecycleBuilder =>
{
// See https://github.com/dotnet/maui/issues/20976 and
windowsLifecycleBuilder.OnWindowCreated(window =>
{
var handle = WinRT.Interop.WindowNative.GetWindowHandle(window);
var id = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(handle);
var appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(id);
var titleBar = appWindow.TitleBar;
var color = Color.FromRgba("#2C479D");
titleBar.BackgroundColor = color.ToWindowsColor();
titleBar.ButtonBackgroundColor = color.ToWindowsColor();
titleBar.InactiveBackgroundColor = color.ToWindowsColor();
titleBar.ButtonInactiveBackgroundColor = color.ToWindowsColor();
});
});
#endif
})
.UseNaluNavigation<App>(nav => nav
.AddPages()
.WithBackImage(new FontImageSource
Expand Down
2 changes: 1 addition & 1 deletion Samples/Nalu.Maui.Sample/Nalu.Maui.Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Source\Nalu.Maui\Nalu.Maui.csproj" />
<ProjectReference Include="..\..\Source\Nalu.Maui.Navigation\Nalu.Maui.Navigation.csproj" />
</ItemGroup>
</Project>
17 changes: 15 additions & 2 deletions Samples/Nalu.Maui.Sample/Platforms/Windows/App.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
<maui:MauiWinUIApplication
<maui:MauiWinUIApplication
x:Class="Nalu.Maui.Sample.WinUI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:maui="using:Microsoft.Maui"
xmlns:local="using:Nalu.Maui.Sample.WinUI">

<maui:MauiWinUIApplication.Resources>
<ResourceDictionary>
<DataTemplate x:Key="MauiAppTitleBarTemplate">
<Grid>
<Border
Canvas.ZIndex="1"
VerticalAlignment="Stretch"
Background="#2C479D">
</Border>
</Grid>
</DataTemplate>
</ResourceDictionary>
</maui:MauiWinUIApplication.Resources>

</maui:MauiWinUIApplication>
6 changes: 3 additions & 3 deletions Samples/Nalu.Maui.Sample/Resources/Styles/Styles.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<?xaml-comp compile="true" ?>
<ResourceDictionary
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
Expand Down Expand Up @@ -399,9 +399,9 @@
</Style>

<Style TargetType="Shell" ApplyToDerivedTypes="True">
<Setter Property="Shell.BackgroundColor" Value="{AppThemeBinding Light={StaticResource PrimaryDark}, Dark={StaticResource OffBlack}}" />
<Setter Property="Shell.BackgroundColor" Value="{StaticResource PrimaryDark}" />
<Setter Property="Shell.ForegroundColor" Value="White" />
<Setter Property="Shell.TitleColor" Value="Yellow" />
<Setter Property="Shell.TitleColor" Value="White" />
<Setter Property="Shell.DisabledColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray950}}" />
<Setter Property="Shell.UnselectedColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray200}}" />
<Setter Property="Shell.NavBarHasShadow" Value="False" />
Expand Down
7 changes: 5 additions & 2 deletions Source/Nalu.Maui.Navigation/Internals/NavigationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,17 @@ private void ConfigureBackButtonBehavior(Page page)
if (backButtonBehavior is not null)
{
backButtonBehavior.Command ??= new Command(() => _ = GoToAsync(Navigation.Relative().Pop()));
backButtonBehavior.IconOverride ??= WithColor(Configuration.BackImage, ShellProxy.GetToolbarIconColor(page));
if (_shellProxy is not null)
{
backButtonBehavior.IconOverride ??= WithColor(Configuration.BackImage, _shellProxy.GetToolbarIconColor(page));
}
}
else
{
backButtonBehavior = new BackButtonBehavior
{
Command = new Command(() => _ = GoToAsync(Navigation.Relative().Pop())),
IconOverride = WithColor(Configuration.BackImage, ShellProxy.GetToolbarIconColor(page)),
IconOverride = _shellProxy is not null ? WithColor(Configuration.BackImage, _shellProxy.GetToolbarIconColor(page)) : null,
};
Shell.SetBackButtonBehavior(page, backButtonBehavior);
}
Expand Down

0 comments on commit 152fef2

Please sign in to comment.