-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<Nullable>enable</Nullable> | ||
<AvaloniaVersion>11.0.11</AvaloniaVersion> | ||
<AvaloniaVersion>11.1.0</AvaloniaVersion> | ||
</PropertyGroup> | ||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using ReactiveUI; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reactive; | ||
using System.Reactive.Linq; | ||
|
||
namespace Vocup.ViewModels; | ||
|
||
public class LicensesViewModel | ||
{ | ||
public LicensesViewModel() | ||
{ | ||
NavigateToUri = ReactiveCommand.Create<string>(async uri => | ||
{ | ||
await LaunchUri.Handle(new Uri(uri)); | ||
}); | ||
} | ||
|
||
public ReactiveCommand<string, Unit> NavigateToUri { get; } | ||
|
||
public Interaction<Uri, bool> LaunchUri { get; } = new(); | ||
|
||
public List<Component> Components { get; } = [ | ||
new() | ||
{ | ||
Name = "Avalonia", | ||
License = "", | ||
Url = "https://avaloniaui.net" | ||
}, | ||
new() | ||
{ | ||
Name = "CsvHelper", | ||
License = "MS-PL; Apache-2.0", | ||
Url = "https://joshclose.github.io/CsvHelper", | ||
}, | ||
new() | ||
{ | ||
Name = "CsWin32", | ||
License = "MIT", | ||
Url = "https://github.com/microsoft/CsWin32", | ||
}, | ||
new() | ||
{ | ||
Name = "Losttech Settings", | ||
License = "Apache-2.0", | ||
Url = "https://github.com/losttech/Settings", | ||
}, | ||
new() | ||
{ | ||
Name = "Office Icons", | ||
License = "CC BY-ND 3.0", | ||
Url = "https://icons8.com/icons/office", | ||
}, | ||
]; | ||
|
||
public class Component | ||
{ | ||
public required string Name { get; init; } | ||
public required string License { get; init; } | ||
public required string Url { get; init; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:vm="clr-namespace:Vocup.ViewModels;assembly=Vocup.Avalonia" | ||
mc:Ignorable="d" d:DesignWidth="327" d:DesignHeight="244" | ||
x:Class="Vocup.Views.LicensesControl" | ||
x:DataType="vm:LicensesViewModel" | ||
Name="control"> | ||
<Design.DataContext> | ||
<vm:LicensesViewModel /> | ||
</Design.DataContext> | ||
|
||
<UserControl.Styles> | ||
<Style Selector="HyperlinkButton.link"> | ||
<Setter Property="CornerRadius" Value="0" /> | ||
<Setter Property="Padding" Value="0" /> | ||
</Style> | ||
<Style Selector="HyperlinkButton.link:pointerover"> | ||
<Setter Property="Background" Value="Transparent" /> | ||
</Style> | ||
</UserControl.Styles> | ||
|
||
<ItemsControl ItemsSource="{Binding Components}"> | ||
<ItemsControl.ItemTemplate> | ||
<DataTemplate> | ||
<StackPanel> | ||
<HyperlinkButton Classes="link" Content="{Binding Name}" Command="{Binding #control.ViewModel.NavigateToUri}" CommandParameter="{Binding Url}"> | ||
<ToolTip> | ||
<TextBlock Text="{Binding Url}" /> | ||
</ToolTip> | ||
</HyperlinkButton> | ||
<TextBlock Text="{Binding License}" /> | ||
</StackPanel> | ||
</DataTemplate> | ||
</ItemsControl.ItemTemplate> | ||
</ItemsControl> | ||
</UserControl> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.ReactiveUI; | ||
using ReactiveUI; | ||
using Vocup.ViewModels; | ||
|
||
namespace Vocup.Views | ||
{ | ||
public partial class LicensesControl : ReactiveUserControl<LicensesViewModel> | ||
{ | ||
public LicensesControl() | ||
{ | ||
InitializeComponent(); | ||
|
||
this.WhenActivated(d => d(ViewModel.LaunchUri.RegisterHandler(async interaction => | ||
Check warning on line 14 in src/Vocup/Views/LicensesControl.axaml.cs
|
||
{ | ||
var topLevel = TopLevel.GetTopLevel(this); | ||
bool success = await topLevel.Launcher.LaunchUriAsync(interaction.Input); | ||
Check warning on line 17 in src/Vocup/Views/LicensesControl.axaml.cs
|
||
interaction.SetOutput(success); | ||
}))); | ||
} | ||
} | ||
} |