feat: add aboutus page.

This commit is contained in:
Dong Bin
2025-05-05 22:07:20 +08:00
parent 7056894c03
commit d67c573535
5 changed files with 282 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows.Input;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.Platform.Storage;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
namespace Semi.Avalonia.Demo.Pages;
public partial class AboutUs : UserControl
{
public AboutUs()
{
InitializeComponent();
this.DataContext = new AboutUsViewModel();
}
protected override void OnLoaded(RoutedEventArgs e)
{
base.OnLoaded(e);
if (this.DataContext is AboutUsViewModel vm)
{
var launcher = TopLevel.GetTopLevel(this)?.Launcher;
vm.Launcher = launcher;
}
}
}
public partial class AboutUsViewModel: ObservableObject
{
public ICommand NavigateCommand { get; set; }
internal ILauncher? Launcher { get; set; }
public AboutUsViewModel()
{
NavigateCommand = new AsyncRelayCommand<string>(OnNavigateAsync);
}
private static readonly IReadOnlyDictionary<string, string> _keyToUrlMapping = new Dictionary<string, string>()
{
["semi"] = "https://github.com/irihitech/Semi.Avalonia",
};
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));
}
}
}