display package versions
This commit is contained in:
@@ -7,18 +7,24 @@ public partial class NugetPackageDetails : VBoxContainer
|
||||
{
|
||||
private TextureRect _packageIconTextureRect = null!;
|
||||
private Label _packageNameLabel = null!;
|
||||
private OptionButton _versionOptionButton = null!;
|
||||
private OptionButton _nugetSourceOptionButton = null!;
|
||||
|
||||
private IdePackageResult? _package;
|
||||
|
||||
private readonly Texture2D _defaultIconTextureRect = ResourceLoader.Load<Texture2D>("uid://b5ih61vdjv5e6");
|
||||
|
||||
[Inject] private readonly NugetPackageIconCacheService _nugetPackageIconCacheService = null!;
|
||||
[Inject] private readonly NugetClientService _nugetClientService = null!;
|
||||
public override void _Ready()
|
||||
{
|
||||
_packageIconTextureRect = GetNode<TextureRect>("%PackageIconTextureRect");
|
||||
_packageNameLabel = GetNode<Label>("%PackageNameLabel");
|
||||
_versionOptionButton = GetNode<OptionButton>("%VersionOptionButton");
|
||||
_nugetSourceOptionButton = GetNode<OptionButton>("%NugetSourceOptionButton");
|
||||
_nugetSourceOptionButton.ItemSelected += OnNugetSourceSelected;
|
||||
}
|
||||
|
||||
|
||||
public async Task SetPackage(IdePackageResult package)
|
||||
{
|
||||
_package = package;
|
||||
@@ -30,6 +36,37 @@ public partial class NugetPackageDetails : VBoxContainer
|
||||
});
|
||||
var (iconBytes, iconFormat) = await iconTask;
|
||||
var imageTexture = ImageTextureHelper.GetImageTextureFromBytes(iconBytes, iconFormat) ?? _defaultIconTextureRect;
|
||||
await this.InvokeAsync(() => _packageIconTextureRect.Texture = imageTexture);
|
||||
await this.InvokeAsync(() =>
|
||||
{
|
||||
_packageIconTextureRect.Texture = imageTexture;
|
||||
|
||||
_versionOptionButton.Clear();
|
||||
_nugetSourceOptionButton.Clear();
|
||||
foreach (var packageFromSource in package.PackageFromSources)
|
||||
{
|
||||
_nugetSourceOptionButton.AddItem(packageFromSource.Source.Name);
|
||||
}
|
||||
_nugetSourceOptionButton.Selected = 0;
|
||||
OnNugetSourceSelected(0);
|
||||
});
|
||||
}
|
||||
|
||||
private async void OnNugetSourceSelected(long index)
|
||||
{
|
||||
var source = _package!.PackageFromSources[(int)index];
|
||||
var results = await _nugetClientService.GetAllVersionsOfPackageInSource(source.PackageSearchMetadata.Identity.Id, source.Source);
|
||||
await this.InvokeAsync(() =>
|
||||
{
|
||||
_versionOptionButton.Clear();
|
||||
var versions = results
|
||||
.Select(p => p.Identity.Version)
|
||||
.Distinct()
|
||||
.OrderByDescending(v => v);
|
||||
foreach (var version in versions)
|
||||
{
|
||||
_versionOptionButton.AddItem(version.ToNormalizedString());
|
||||
}
|
||||
_versionOptionButton.Selected = 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user