2026-01-11 13:34:36 -05:00
|
|
|
// App.xaml.cs - Main Application with NavigationPage and Theme Support
|
|
|
|
|
|
|
|
|
|
using Microsoft.Maui.Controls;
|
|
|
|
|
|
|
|
|
|
namespace WebViewDemo;
|
|
|
|
|
|
|
|
|
|
public partial class App : Application
|
|
|
|
|
{
|
|
|
|
|
public static NavigationPage? NavigationPage { get; private set; }
|
|
|
|
|
|
|
|
|
|
public App()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2026-01-17 05:42:44 +00:00
|
|
|
}
|
2026-01-11 13:34:36 -05:00
|
|
|
|
2026-01-17 05:42:44 +00:00
|
|
|
protected override Window CreateWindow(IActivationState? activationState)
|
|
|
|
|
{
|
2026-01-11 13:34:36 -05:00
|
|
|
// Determine current theme for navigation bar colors
|
2026-01-17 05:42:44 +00:00
|
|
|
var isDarkMode = Current?.RequestedTheme == AppTheme.Dark;
|
2026-01-11 13:34:36 -05:00
|
|
|
var barBackground = isDarkMode ? Color.FromArgb("#3949AB") : Color.FromArgb("#5C6BC0");
|
|
|
|
|
|
|
|
|
|
NavigationPage = new NavigationPage(new WebViewPage())
|
|
|
|
|
{
|
|
|
|
|
Title = "OpenMaui WebView Demo",
|
|
|
|
|
BarBackgroundColor = barBackground,
|
|
|
|
|
BarTextColor = Colors.White
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Update navigation bar when theme changes
|
2026-01-17 05:42:44 +00:00
|
|
|
Current!.RequestedThemeChanged += (s, e) =>
|
2026-01-11 13:34:36 -05:00
|
|
|
{
|
|
|
|
|
var dark = e.RequestedTheme == AppTheme.Dark;
|
|
|
|
|
NavigationPage.BarBackgroundColor = dark ? Color.FromArgb("#3949AB") : Color.FromArgb("#5C6BC0");
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-17 05:42:44 +00:00
|
|
|
return new Window(NavigationPage);
|
2026-01-11 13:34:36 -05:00
|
|
|
}
|
|
|
|
|
}
|