From d1d7987847d20df751b8c6d26344d7917e352e34 Mon Sep 17 00:00:00 2001
From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com>
Date: Wed, 19 Jul 2023 21:59:43 +0800
Subject: [PATCH] fix: support WASM.
---
demo/Ursa.Demo.Android/App.axaml.cs | 2 +-
demo/Ursa.Demo.Browser/App.axaml.cs | 2 +-
demo/Ursa.Demo/Views/MainView.axaml | 85 ++++++++++++++++++++++++
demo/Ursa.Demo/Views/MainView.axaml.cs | 24 +++++++
demo/Ursa.Demo/Views/MainWindow.axaml | 78 +---------------------
demo/Ursa.Demo/Views/MainWindow.axaml.cs | 13 ----
6 files changed, 113 insertions(+), 91 deletions(-)
create mode 100644 demo/Ursa.Demo/Views/MainView.axaml
create mode 100644 demo/Ursa.Demo/Views/MainView.axaml.cs
diff --git a/demo/Ursa.Demo.Android/App.axaml.cs b/demo/Ursa.Demo.Android/App.axaml.cs
index 02e2b50..61508ce 100644
--- a/demo/Ursa.Demo.Android/App.axaml.cs
+++ b/demo/Ursa.Demo.Android/App.axaml.cs
@@ -16,7 +16,7 @@ public partial class App : Application
{
if (ApplicationLifetime is ISingleViewApplicationLifetime single)
{
- single.MainView = new MainWindow();
+ single.MainView = new MainView();
}
base.OnFrameworkInitializationCompleted();
}
diff --git a/demo/Ursa.Demo.Browser/App.axaml.cs b/demo/Ursa.Demo.Browser/App.axaml.cs
index 409a54c..9c680b0 100644
--- a/demo/Ursa.Demo.Browser/App.axaml.cs
+++ b/demo/Ursa.Demo.Browser/App.axaml.cs
@@ -16,7 +16,7 @@ public partial class App : Application
{
if (ApplicationLifetime is ISingleViewApplicationLifetime single)
{
- single.MainView = new MainWindow();
+ single.MainView = new MainView();
}
base.OnFrameworkInitializationCompleted();
}
diff --git a/demo/Ursa.Demo/Views/MainView.axaml b/demo/Ursa.Demo/Views/MainView.axaml
new file mode 100644
index 0000000..1183ce5
--- /dev/null
+++ b/demo/Ursa.Demo/Views/MainView.axaml
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demo/Ursa.Demo/Views/MainView.axaml.cs b/demo/Ursa.Demo/Views/MainView.axaml.cs
new file mode 100644
index 0000000..563f7ea
--- /dev/null
+++ b/demo/Ursa.Demo/Views/MainView.axaml.cs
@@ -0,0 +1,24 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Interactivity;
+using Avalonia.Styling;
+
+namespace Ursa.Demo.Views;
+
+public partial class MainView : UserControl
+{
+ public MainView()
+ {
+ InitializeComponent();
+ }
+
+ private void ToggleButton_OnIsCheckedChanged(object? sender, RoutedEventArgs e)
+ {
+ var app = Application.Current;
+ if (app is not null)
+ {
+ var theme = app.ActualThemeVariant;
+ app.RequestedThemeVariant = theme == ThemeVariant.Dark ? ThemeVariant.Light : ThemeVariant.Dark;
+ }
+ }
+}
\ No newline at end of file
diff --git a/demo/Ursa.Demo/Views/MainWindow.axaml b/demo/Ursa.Demo/Views/MainWindow.axaml
index 7a80188..24c7b85 100644
--- a/demo/Ursa.Demo/Views/MainWindow.axaml
+++ b/demo/Ursa.Demo/Views/MainWindow.axaml
@@ -2,87 +2,13 @@
x:Class="Ursa.Demo.Views.MainWindow"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:converters="clr-namespace:Ursa.Demo.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:pages="clr-namespace:Ursa.Demo.Pages"
- xmlns:u="https://irihi.tech/ursa"
- xmlns:vm="using:Ursa.Demo.ViewModels"
+ xmlns:views="clr-namespace:Ursa.Demo.Views"
Title="Ursa.Demo"
d:DesignHeight="450"
d:DesignWidth="800"
- x:CompileBindings="True"
- x:DataType="vm:MainWindowViewModel"
Icon="/Assets/Ursa.ico"
mc:Ignorable="d">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/demo/Ursa.Demo/Views/MainWindow.axaml.cs b/demo/Ursa.Demo/Views/MainWindow.axaml.cs
index ff545b9..45aa4b8 100644
--- a/demo/Ursa.Demo/Views/MainWindow.axaml.cs
+++ b/demo/Ursa.Demo/Views/MainWindow.axaml.cs
@@ -1,7 +1,4 @@
-using Avalonia;
using Avalonia.Controls;
-using Avalonia.Interactivity;
-using Avalonia.Styling;
namespace Ursa.Demo.Views;
@@ -11,14 +8,4 @@ public partial class MainWindow : Window
{
InitializeComponent();
}
-
- private void ToggleButton_OnIsCheckedChanged(object? sender, RoutedEventArgs e)
- {
- var app = Application.Current;
- if (app is not null)
- {
- var theme = app.ActualThemeVariant;
- app.RequestedThemeVariant = theme == ThemeVariant.Dark ? ThemeVariant.Light : ThemeVariant.Dark;
- }
- }
}
\ No newline at end of file