refactor: use HyperlinkButton

This commit is contained in:
estrogen elf
2025-06-14 01:33:28 -05:00
parent 22ad838362
commit a7a4992907
4 changed files with 10 additions and 37 deletions

View File

@@ -1,9 +1,7 @@
using Avalonia.Platform;
using CommunityToolkit.Mvvm.Input;
using Needlework.Net.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
@@ -23,13 +21,4 @@ public partial class HomeViewModel : PageBase
{
return Task.CompletedTask;
}
[RelayCommand]
private void OpenUrl(string? value)
{
if (value == null) return;
var process = new Process() { StartInfo = new ProcessStartInfo(value) { UseShellExecute = true } };
process.Start();
}
}

View File

@@ -1,7 +1,5 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Needlework.Net.Models;
using System.Diagnostics;
namespace Needlework.Net.ViewModels.Pages.Home
{
@@ -13,12 +11,5 @@ namespace Needlework.Net.ViewModels.Pages.Home
}
public Library Library { get; }
[RelayCommand]
private void OpenUrl()
{
var process = new Process() { StartInfo = new ProcessStartInfo(Library.Link) { UseShellExecute = true } };
process.Start();
}
}
}

View File

@@ -48,29 +48,24 @@
<StackPanel>
<controls:Card Margin="12" Width="300">
<StackPanel>
<StackPanel.Styles>
<Style Selector="Button">
<Setter Property="Command" Value="{Binding OpenUrlCommand}"/>
</Style>
</StackPanel.Styles>
<TextBlock
Theme="{StaticResource SubtitleTextBlockStyle}"
Margin="0 0 0 8">Resources</TextBlock>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button CommandParameter="https://hextechdocs.dev/tag/lcu/" Margin="4">
<HyperlinkButton NavigateUri="https://hextechdocs.dev/tag/lcu/" Margin="4">
Hextech Docs
</Button>
<Button CommandParameter="https://hextechdocs.dev/getting-started-with-the-lcu-api/" Margin="4">
</HyperlinkButton>
<HyperlinkButton NavigateUri="https://hextechdocs.dev/getting-started-with-the-lcu-api/" Margin="4">
Getting Started
</Button>
</HyperlinkButton>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button CommandParameter="https://discord.com/channels/187652476080488449/516802588805431296" Margin="4">
<HyperlinkButton NavigateUri="https://discord.com/channels/187652476080488449/516802588805431296" Margin="4">
#lcu-api
</Button>
<Button CommandParameter="https://discord.com/channels/187652476080488449/543112946402721832" Margin="4">
</HyperlinkButton>
<HyperlinkButton NavigateUri="https://discord.com/channels/187652476080488449/543112946402721832" Margin="4">
#ingame-api
</Button>
</HyperlinkButton>
</StackPanel>
</StackPanel>
</controls:Card>

View File

@@ -19,9 +19,7 @@
TextAlignment="Left"
TextWrapping="WrapWithOverflow"
Width="350"/>
<Button Command="{Binding OpenUrlCommand}"
Margin="0 4 0 0">
<TextBlock Text="{Binding Library.Link}"/>
</Button>
<HyperlinkButton Content="{Binding Library.Link}" NavigateUri="{Binding Library.Link}"
Margin="0 4 0 0"/>
</StackPanel>
</UserControl>