display results v1
This commit is contained in:
@@ -24,7 +24,7 @@ public class NugetClientService
|
||||
foreach (var source in packageSources)
|
||||
{
|
||||
var repository = Repository.Factory.GetCoreV3(source.Source);
|
||||
var searchResource = await repository.GetResourceAsync<PackageSearchResource>(cancellationToken);
|
||||
var searchResource = await repository.GetResourceAsync<PackageSearchResource>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (searchResource == null)
|
||||
continue;
|
||||
@@ -36,7 +36,7 @@ public class NugetClientService
|
||||
skip: 0,
|
||||
take: 100,
|
||||
log: logger,
|
||||
cancellationToken: cancellationToken);
|
||||
cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
|
||||
packagesResult.AddRange(results.Select(s => new IdePackageResult(s, [source])));
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class NugetClientService
|
||||
foreach (var source in packageSources.Except(package.PackageSources).ToList())
|
||||
{
|
||||
var repository = Repository.Factory.GetCoreV3(source.Source);
|
||||
var searchResource = await repository.GetResourceAsync<PackageSearchResource>(cancellationToken);
|
||||
var searchResource = await repository.GetResourceAsync<PackageSearchResource>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (searchResource == null)
|
||||
continue;
|
||||
@@ -68,7 +68,7 @@ public class NugetClientService
|
||||
skip: 0,
|
||||
take: 2,
|
||||
log: logger,
|
||||
cancellationToken: cancellationToken);
|
||||
cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
var foundPackage = results.SingleOrDefault(r => r.Identity.Id.Equals(packageId, StringComparison.OrdinalIgnoreCase));
|
||||
if (foundPackage != null)
|
||||
{
|
||||
|
||||
@@ -13,6 +13,8 @@ public partial class NugetPanel : Control
|
||||
public SharpIdeSolutionModel? Solution { get; set; }
|
||||
|
||||
[Inject] private readonly NugetClientService _nugetClientService = null!;
|
||||
|
||||
private readonly PackedScene _packageEntryScene = ResourceLoader.Load<PackedScene>("uid://cqc2xlt81ju8s");
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -25,6 +27,20 @@ public partial class NugetPanel : Control
|
||||
await Task.Delay(300);
|
||||
var result = await _nugetClientService.GetTop100Results(Solution!.DirectoryPath);
|
||||
;
|
||||
await this.InvokeAsync(() => _availablePackagesItemList.QueueFreeChildren());
|
||||
var scenes = result.Select(s =>
|
||||
{
|
||||
var scene = _packageEntryScene.Instantiate<PackageEntry>();
|
||||
scene.PackageResult = s;
|
||||
return scene;
|
||||
}).ToList();
|
||||
await this.InvokeAsync(() =>
|
||||
{
|
||||
foreach (var scene in scenes)
|
||||
{
|
||||
_availablePackagesItemList.AddChild(scene);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
48
src/SharpIDE.Godot/Features/Nuget/PackageEntry.cs
Normal file
48
src/SharpIDE.Godot/Features/Nuget/PackageEntry.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Godot;
|
||||
using SharpIDE.Application.Features.Nuget;
|
||||
|
||||
namespace SharpIDE.Godot.Features.Nuget;
|
||||
|
||||
public partial class PackageEntry : MarginContainer
|
||||
{
|
||||
private Label _packageNameLabel = null!;
|
||||
private Label _currentVersionLabel = null!;
|
||||
private Label _latestVersionLabel = null!;
|
||||
private HBoxContainer _sourceNamesContainer = null!;
|
||||
|
||||
private static readonly Color Source_NugetOrg_Color = new Color("629655");
|
||||
private static readonly Color Source_2_Color = new Color("008989");
|
||||
private static readonly Color Source_3_Color = new Color("8d75a8");
|
||||
private static readonly Color Source_4_Color = new Color("966a00");
|
||||
private static readonly Color Source_5_Color = new Color("efaeae");
|
||||
|
||||
public IdePackageResult PackageResult { get; set; } = null!;
|
||||
public override void _Ready()
|
||||
{
|
||||
_packageNameLabel = GetNode<Label>("%PackageNameLabel");
|
||||
_currentVersionLabel = GetNode<Label>("%CurrentVersionLabel");
|
||||
_latestVersionLabel = GetNode<Label>("%LatestVersionLabel");
|
||||
_sourceNamesContainer = GetNode<HBoxContainer>("%SourceNamesHBoxContainer");
|
||||
ApplyValues();
|
||||
}
|
||||
|
||||
private void ApplyValues()
|
||||
{
|
||||
if (PackageResult is null) return;
|
||||
_packageNameLabel.Text = PackageResult.PackageSearchMetadata.Identity.Id;
|
||||
_currentVersionLabel.Text = string.Empty;
|
||||
//_latestVersionLabel.Text = $"Latest: {PackageResult.PackageSearchMetadata.vers.LatestVersion}";
|
||||
_sourceNamesContainer.QueueFreeChildren();
|
||||
foreach (var source in PackageResult.PackageSources)
|
||||
{
|
||||
var label = new Label { Text = source.Name };
|
||||
label.AddThemeColorOverride("font_color", source.Name switch
|
||||
{
|
||||
"nuget.org" => Source_NugetOrg_Color,
|
||||
"Microsoft Visual Studio Offline Packages" => Source_2_Color,
|
||||
_ => Source_3_Color
|
||||
});
|
||||
_sourceNamesContainer.AddChild(label);
|
||||
}
|
||||
}
|
||||
}
|
||||
1
src/SharpIDE.Godot/Features/Nuget/PackageEntry.cs.uid
Normal file
1
src/SharpIDE.Godot/Features/Nuget/PackageEntry.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cwriljtokcujb
|
||||
@@ -1,5 +1,6 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cqc2xlt81ju8s"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://cqc2xlt81ju8s"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cwriljtokcujb" path="res://Features/Nuget/PackageEntry.cs" id="1_gehww"]
|
||||
[ext_resource type="Texture2D" uid="uid://b5ih61vdjv5e6" path="res://Features/LeftSideBar/Resources/Nuget.svg" id="1_kw1n7"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_6ov2c"]
|
||||
@@ -21,6 +22,7 @@ offset_top = -4.0
|
||||
offset_bottom = 4.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_gehww")
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
custom_minimum_size = Vector2(0, 26)
|
||||
@@ -45,7 +47,8 @@ theme_override_constants/margin_top = 4
|
||||
theme_override_constants/margin_right = 3
|
||||
theme_override_constants/margin_bottom = 4
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="MarginContainer/HBoxContainer/MarginContainer"]
|
||||
[node name="IconTextureRect" type="TextureRect" parent="MarginContainer/HBoxContainer/MarginContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
texture = ExtResource("1_kw1n7")
|
||||
expand_mode = 3
|
||||
@@ -63,7 +66,11 @@ layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.6706895, 0.6706895, 0.6706895, 1)
|
||||
text = "1.12.0"
|
||||
|
||||
[node name="SourceNameLabel" type="Label" parent="MarginContainer/HBoxContainer"]
|
||||
[node name="SourceNamesHBoxContainer" type="HBoxContainer" parent="MarginContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="SourceNameLabel" type="Label" parent="MarginContainer/HBoxContainer/SourceNamesHBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.38431373, 0.5882353, 0.33333334, 1)
|
||||
@@ -73,7 +80,7 @@ text = "nuget"
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="NewestVersionLabel" type="Label" parent="MarginContainer/HBoxContainer"]
|
||||
[node name="LatestVersionLabel" type="Label" parent="MarginContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.16862746, 0.6666667, 0.9098039, 1)
|
||||
|
||||
Reference in New Issue
Block a user