diff --git a/demo/Semi.Avalonia.Demo/Pages/AboutUs.axaml b/demo/Semi.Avalonia.Demo/Pages/AboutUs.axaml new file mode 100644 index 0000000..9d6b0f2 --- /dev/null +++ b/demo/Semi.Avalonia.Demo/Pages/AboutUs.axaml @@ -0,0 +1,219 @@ + + + + + + + #FFFDB7A5 + #FFF6A0B5 + #FFDD9BE0 + #FFC4A7E9 + #FFA7B3E1 + #FF98CDFD + #FF95D8F8 + + + + + + + + + + + #FFB42019 + #FFA41751 + #FF731F8A + #FF582EA0 + #FF29368E + #FF135CB8 + #FF0366A9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo/Semi.Avalonia.Demo/Pages/AboutUs.axaml.cs b/demo/Semi.Avalonia.Demo/Pages/AboutUs.axaml.cs new file mode 100644 index 0000000..eb0a539 --- /dev/null +++ b/demo/Semi.Avalonia.Demo/Pages/AboutUs.axaml.cs @@ -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(OnNavigateAsync); + } + + private static readonly IReadOnlyDictionary _keyToUrlMapping = new Dictionary() + { + ["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)); + } + + } +} \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/Pages/Overview.axaml.cs b/demo/Semi.Avalonia.Demo/Pages/Overview.axaml.cs index b7a5aa4..0bb4e36 100644 --- a/demo/Semi.Avalonia.Demo/Pages/Overview.axaml.cs +++ b/demo/Semi.Avalonia.Demo/Pages/Overview.axaml.cs @@ -1,4 +1,5 @@ using Avalonia.Controls; +using Avalonia.Media; namespace Semi.Avalonia.Demo.Pages; diff --git a/demo/Semi.Avalonia.Demo/Semi.Avalonia.Demo.csproj b/demo/Semi.Avalonia.Demo/Semi.Avalonia.Demo.csproj index 38a0043..e4a0aa4 100644 --- a/demo/Semi.Avalonia.Demo/Semi.Avalonia.Demo.csproj +++ b/demo/Semi.Avalonia.Demo/Semi.Avalonia.Demo.csproj @@ -19,6 +19,7 @@ All + diff --git a/demo/Semi.Avalonia.Demo/Views/MainView.axaml b/demo/Semi.Avalonia.Demo/Views/MainView.axaml index bc1422b..fdbe2bd 100644 --- a/demo/Semi.Avalonia.Demo/Views/MainView.axaml +++ b/demo/Semi.Avalonia.Demo/Views/MainView.axaml @@ -111,6 +111,9 @@ + + +