Browser work
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// App.xaml.cs - Main Application with NavigationPage and Theme Support
|
||||
// App.xaml.cs - Main Application with Theme Support
|
||||
|
||||
using Microsoft.Maui.Controls;
|
||||
|
||||
@@ -6,8 +6,6 @@ namespace WebViewDemo;
|
||||
|
||||
public partial class App : Application
|
||||
{
|
||||
public static NavigationPage? NavigationPage { get; private set; }
|
||||
|
||||
public App()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -15,24 +13,18 @@ public partial class App : Application
|
||||
|
||||
protected override Window CreateWindow(IActivationState? activationState)
|
||||
{
|
||||
// Determine current theme for navigation bar colors
|
||||
var isDarkMode = Current?.RequestedTheme == AppTheme.Dark;
|
||||
var barBackground = isDarkMode ? Color.FromArgb("#3949AB") : Color.FromArgb("#5C6BC0");
|
||||
|
||||
NavigationPage = new NavigationPage(new WebViewPage())
|
||||
return new Window(new WebViewPage())
|
||||
{
|
||||
Title = "OpenMaui WebView Demo",
|
||||
BarBackgroundColor = barBackground,
|
||||
BarTextColor = Colors.White
|
||||
Title = "OpenMaui Browser"
|
||||
};
|
||||
}
|
||||
|
||||
// Update navigation bar when theme changes
|
||||
Current!.RequestedThemeChanged += (s, e) =>
|
||||
{
|
||||
var dark = e.RequestedTheme == AppTheme.Dark;
|
||||
NavigationPage.BarBackgroundColor = dark ? Color.FromArgb("#3949AB") : Color.FromArgb("#5C6BC0");
|
||||
};
|
||||
public static void ToggleTheme()
|
||||
{
|
||||
if (Current is null) return;
|
||||
|
||||
return new Window(NavigationPage);
|
||||
Current.UserAppTheme = Current.UserAppTheme == AppTheme.Dark
|
||||
? AppTheme.Light
|
||||
: AppTheme.Dark;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user