feat: add about us page.
This commit is contained in:
37
demo/Ursa.Demo/ViewModels/AboutUsDemoViewModel.cs
Normal file
37
demo/Ursa.Demo/ViewModels/AboutUsDemoViewModel.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Avalonia.Platform.Storage;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
|
||||
public partial class AboutUsDemoViewModel: ObservableObject
|
||||
{
|
||||
public ICommand NavigateCommand { get; set; }
|
||||
|
||||
internal ILauncher? Launcher { get; set; }
|
||||
|
||||
public AboutUsDemoViewModel()
|
||||
{
|
||||
NavigateCommand = new AsyncRelayCommand<string>(OnNavigateAsync);
|
||||
}
|
||||
|
||||
private static readonly IReadOnlyDictionary<string, string> _keyToUrlMapping = new Dictionary<string, string>()
|
||||
{
|
||||
["semi"] = "https://github.com/irihitech/Semi.Avalonia",
|
||||
["ursa"] = "https://github.com/irihitech/Ursa.Avalonia",
|
||||
["mantra"] = "https://www.bilibili.com/video/BV15pfKYbEEQ",
|
||||
};
|
||||
|
||||
private async Task OnNavigateAsync(string? arg)
|
||||
{
|
||||
if (Launcher is not null && arg is not null && _keyToUrlMapping.TryGetValue(arg.ToLower(), out var uri))
|
||||
{
|
||||
await Launcher.LaunchUriAsync(new Uri(uri));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ public partial class MainViewViewModel : ViewModelBase
|
||||
Content = s switch
|
||||
{
|
||||
MenuKeys.MenuKeyIntroduction => new IntroductionDemoViewModel(),
|
||||
MenuKeys.MenuKeyAboutUs => new AboutUsDemoViewModel(),
|
||||
MenuKeys.MenuKeyAutoCompleteBox => new AutoCompleteBoxDemoViewModel(),
|
||||
MenuKeys.MenuKeyAvatar => new AvatarDemoViewModel(),
|
||||
MenuKeys.MenuKeyBadge => new BadgeDemoViewModel(),
|
||||
|
||||
@@ -9,6 +9,7 @@ public class MenuViewModel : ViewModelBase
|
||||
MenuItems = new ObservableCollection<MenuItemViewModel>
|
||||
{
|
||||
new() { MenuHeader = "Introduction", Key = MenuKeys.MenuKeyIntroduction, IsSeparator = false },
|
||||
new() { MenuHeader = "About Us", Key = MenuKeys.MenuKeyAboutUs, IsSeparator = false },
|
||||
new() { MenuHeader = "Controls", IsSeparator = true },
|
||||
new()
|
||||
{
|
||||
@@ -102,6 +103,7 @@ public class MenuViewModel : ViewModelBase
|
||||
public static class MenuKeys
|
||||
{
|
||||
public const string MenuKeyIntroduction = "Introduction";
|
||||
public const string MenuKeyAboutUs = "AboutUs";
|
||||
public const string MenuKeyAutoCompleteBox = "AutoCompleteBox";
|
||||
public const string MenuKeyAvatar = "Avatar";
|
||||
public const string MenuKeyBadge = "Badge";
|
||||
|
||||
Reference in New Issue
Block a user