fix: support WASM.
This commit is contained in:
@@ -1,23 +0,0 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Ursa.Demo.Views;
|
|
||||||
|
|
||||||
namespace Ursa.Demo.Android;
|
|
||||||
|
|
||||||
public partial class App : Application
|
|
||||||
{
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnFrameworkInitializationCompleted()
|
|
||||||
{
|
|
||||||
if (ApplicationLifetime is ISingleViewApplicationLifetime single)
|
|
||||||
{
|
|
||||||
single.MainView = new MainView();
|
|
||||||
}
|
|
||||||
base.OnFrameworkInitializationCompleted();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<Application
|
|
||||||
x:Class="Ursa.Demo.Browser.App"
|
|
||||||
xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
||||||
<Application.Styles>
|
|
||||||
<StyleInclude Source="avares://Semi.Avalonia/Themes/Index.axaml" />
|
|
||||||
<StyleInclude Source="avares://Ursa.Themes.Semi/Index.axaml" />
|
|
||||||
</Application.Styles>
|
|
||||||
</Application>
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Ursa.Demo.Views;
|
|
||||||
|
|
||||||
namespace Ursa.Demo.Browser;
|
|
||||||
|
|
||||||
public partial class App : Application
|
|
||||||
{
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnFrameworkInitializationCompleted()
|
|
||||||
{
|
|
||||||
if (ApplicationLifetime is ISingleViewApplicationLifetime single)
|
|
||||||
{
|
|
||||||
single.MainView = new MainView();
|
|
||||||
}
|
|
||||||
base.OnFrameworkInitializationCompleted();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<Application
|
|
||||||
x:Class="Ursa.Demo.Desktop.App"
|
|
||||||
xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
||||||
<Application.Styles>
|
|
||||||
<StyleInclude Source="avares://Semi.Avalonia/Themes/Index.axaml" />
|
|
||||||
<StyleInclude Source="avares://Ursa.Themes.Semi/Index.axaml" />
|
|
||||||
</Application.Styles>
|
|
||||||
</Application>
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<!--If you are willing to use Windows/MacOS native APIs you will need to create 3 projects.
|
<!--If you are willing to use Windows/MacOS native APIs you will need to create 3 projects.
|
||||||
One for Windows with net7.0-windows TFM, one for MacOS with net7.0-macos and one with net7.0 TFM for Linux.-->
|
One for Windows with net7.0-windows TFM, one for MacOS with net7.0-macos and one with net7.0 TFM for Linux.-->
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@@ -21,11 +21,4 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Ursa.Demo\Ursa.Demo.csproj"/>
|
<ProjectReference Include="..\Ursa.Demo\Ursa.Demo.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="App.axaml.cs">
|
|
||||||
<DependentUpon>App.axaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using Avalonia;
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.iOS;
|
using Avalonia.iOS;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
using Avalonia.ReactiveUI;
|
|
||||||
|
|
||||||
namespace Ursa.Demo.iOS;
|
namespace Ursa.Demo.iOS;
|
||||||
|
|
||||||
@@ -16,8 +15,6 @@ public partial class AppDelegate : AvaloniaAppDelegate<App>
|
|||||||
{
|
{
|
||||||
protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
|
protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
|
||||||
{
|
{
|
||||||
return base.CustomizeAppBuilder(builder)
|
return base.CustomizeAppBuilder(builder);
|
||||||
.WithInterFont()
|
|
||||||
.UseReactiveUI();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<Application
|
<Application
|
||||||
x:Class="Ursa.Demo.Android.App"
|
x:Class="Ursa.Demo.App"
|
||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
<Application.Styles>
|
<Application.Styles>
|
||||||
@@ -4,7 +4,7 @@ using Avalonia.Markup.Xaml;
|
|||||||
using Ursa.Demo.ViewModels;
|
using Ursa.Demo.ViewModels;
|
||||||
using Ursa.Demo.Views;
|
using Ursa.Demo.Views;
|
||||||
|
|
||||||
namespace Ursa.Demo.Desktop;
|
namespace Ursa.Demo;
|
||||||
|
|
||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
@@ -17,11 +17,16 @@ public partial class App : Application
|
|||||||
{
|
{
|
||||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
{
|
{
|
||||||
// Line below is needed to remove Avalonia data validation.
|
desktop.MainWindow = new MainWindow()
|
||||||
// Without this line you will get duplicate validations from both Avalonia and CT
|
|
||||||
desktop.MainWindow = new MainWindow
|
|
||||||
{
|
{
|
||||||
DataContext = new MainWindowViewModel(),
|
DataContext = new MainViewViewModel(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleView)
|
||||||
|
{
|
||||||
|
singleView.MainView = new MainView()
|
||||||
|
{
|
||||||
|
DataContext = new MainViewViewModel(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,4 +26,11 @@
|
|||||||
<ProjectReference Include="..\..\src\Ursa.Themes.Semi\Ursa.Themes.Semi.csproj"/>
|
<ProjectReference Include="..\..\src\Ursa.Themes.Semi\Ursa.Themes.Semi.csproj"/>
|
||||||
<ProjectReference Include="..\..\src\Ursa\Ursa.csproj"/>
|
<ProjectReference Include="..\..\src\Ursa\Ursa.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="App.axaml.cs">
|
||||||
|
<DependentUpon>App.axaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
39
demo/Ursa.Demo/ViewModels/MainViewViewModel.cs
Normal file
39
demo/Ursa.Demo/ViewModels/MainViewViewModel.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
|
|
||||||
|
namespace Ursa.Demo.ViewModels;
|
||||||
|
|
||||||
|
public class MainViewViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
public MenuViewModel Menus { get; set; } = new MenuViewModel();
|
||||||
|
|
||||||
|
private object? _content;
|
||||||
|
|
||||||
|
public object? Content
|
||||||
|
{
|
||||||
|
get => _content;
|
||||||
|
set => SetProperty(ref _content, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MainViewViewModel()
|
||||||
|
{
|
||||||
|
WeakReferenceMessenger.Default.Register<MainViewViewModel, string>(this, OnNavigation);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void OnNavigation(MainViewViewModel vm, string s)
|
||||||
|
{
|
||||||
|
Content = s switch
|
||||||
|
{
|
||||||
|
MenuKeys.MenuKeyBadge => new BadgeDemoViewModel(),
|
||||||
|
MenuKeys.MenuKeyBanner => new BannerDemoViewModel(),
|
||||||
|
MenuKeys.MenuKeyButtonGroup => new ButtonGroupDemoViewModel(),
|
||||||
|
MenuKeys.MenuKeyDivider => new DividerDemoViewModel(),
|
||||||
|
MenuKeys.MenuKeyIpBox => new IPv4BoxDemoViewModel(),
|
||||||
|
MenuKeys.MenuKeyLoading => new LoadingDemoViewModel(),
|
||||||
|
MenuKeys.MenuKeyNavigation => new NavigationMenuDemoViewModel(),
|
||||||
|
MenuKeys.MenuKeyPagination => new PaginationDemoViewModel(),
|
||||||
|
MenuKeys.MenuKeyTagInput => new TagInputDemoViewModel(),
|
||||||
|
MenuKeys.MenuKeyTimeline => new TimelineDemoViewModel(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,40 +1,6 @@
|
|||||||
|
namespace Ursa.Demo.ViewModels;
|
||||||
using CommunityToolkit.Mvvm.Messaging;
|
|
||||||
|
|
||||||
namespace Ursa.Demo.ViewModels;
|
|
||||||
|
|
||||||
public class MainWindowViewModel : ViewModelBase
|
public class MainWindowViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
public MenuViewModel Menus { get; set; } = new MenuViewModel();
|
public MainViewViewModel MainViewViewModel { get; set; } = new MainViewViewModel();
|
||||||
|
|
||||||
private object? _content;
|
|
||||||
public object? Content
|
|
||||||
{
|
|
||||||
get => _content;
|
|
||||||
set => SetProperty(ref _content, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MainWindowViewModel()
|
|
||||||
{
|
|
||||||
WeakReferenceMessenger.Default.Register<MainWindowViewModel, string>(this, OnNavigation);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void OnNavigation(MainWindowViewModel vm, string s)
|
|
||||||
{
|
|
||||||
Content = s switch
|
|
||||||
{
|
|
||||||
MenuKeys.MenuKeyBadge => new BadgeDemoViewModel(),
|
|
||||||
MenuKeys.MenuKeyBanner => new BannerDemoViewModel(),
|
|
||||||
MenuKeys.MenuKeyButtonGroup => new ButtonGroupDemoViewModel(),
|
|
||||||
MenuKeys.MenuKeyDivider => new DividerDemoViewModel(),
|
|
||||||
MenuKeys.MenuKeyIpBox => new IPv4BoxDemoViewModel(),
|
|
||||||
MenuKeys.MenuKeyLoading => new LoadingDemoViewModel(),
|
|
||||||
MenuKeys.MenuKeyNavigation => new NavigationMenuDemoViewModel(),
|
|
||||||
MenuKeys.MenuKeyPagination => new PaginationDemoViewModel(),
|
|
||||||
MenuKeys.MenuKeyTagInput => new TagInputDemoViewModel(),
|
|
||||||
MenuKeys.MenuKeyTimeline => new TimelineDemoViewModel(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -10,11 +10,11 @@
|
|||||||
d:DesignHeight="450"
|
d:DesignHeight="450"
|
||||||
d:DesignWidth="800"
|
d:DesignWidth="800"
|
||||||
x:CompileBindings="True"
|
x:CompileBindings="True"
|
||||||
x:DataType="vm:MainWindowViewModel"
|
x:DataType="vm:MainViewViewModel"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
<Design.DataContext>
|
<Design.DataContext>
|
||||||
<vm:MainWindowViewModel />
|
<vm:MainViewViewModel />
|
||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
|
|
||||||
<Grid ColumnDefinitions="Auto, *" RowDefinitions="Auto, *">
|
<Grid ColumnDefinitions="Auto, *" RowDefinitions="Auto, *">
|
||||||
|
|||||||
@@ -5,10 +5,13 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:views="clr-namespace:Ursa.Demo.Views"
|
xmlns:views="clr-namespace:Ursa.Demo.Views"
|
||||||
|
xmlns:viewModels="clr-namespace:Ursa.Demo.ViewModels"
|
||||||
Title="Ursa.Demo"
|
Title="Ursa.Demo"
|
||||||
d:DesignHeight="450"
|
d:DesignHeight="450"
|
||||||
d:DesignWidth="800"
|
d:DesignWidth="800"
|
||||||
|
x:CompileBindings="True"
|
||||||
|
x:DataType="viewModels:MainWindowViewModel"
|
||||||
Icon="/Assets/Ursa.ico"
|
Icon="/Assets/Ursa.ico"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<views:MainView />
|
<views:MainView />
|
||||||
</Window>
|
</Window>
|
||||||
Reference in New Issue
Block a user