ui(manager)+manager: improve display version

This commit is contained in:
2025-11-18 07:20:05 +01:00
parent 49845e841d
commit 07bb19771a
6 changed files with 61 additions and 42 deletions

View File

@@ -1,18 +1,30 @@
using System.ComponentModel;
using ModpackUpdater.Manager;
namespace ModpackUpdater.Apps.Manager.Ui.Models.UpdatesCollectorViewMode;
public record ModUpdateInfo(KeyValuePair<string, string>[] AvailableVersions, InstallAction Origin) : INotifyPropertyChanged
public record ModUpdateInfo(ModVersionInfo[] AvailableVersions, InstallAction Origin) : INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged;
public int NewVersion { get; set; }
public bool Visible { get; set; } = true;
public string? OldVersion
{
get
{
if (AvailableVersions.FirstOrDefault(n => n.Tag.Equals(Origin.SourceTag)) is { } old
&& !old.Name.Equals(old.Tag, StringComparison.InvariantCulture))
return $"{old.Name} ({old.Tag})";
return Origin.SourceTag;
}
}
public IEnumerable<string> DisplayVersions { get; } = AvailableVersions.Select(n =>
{
if (string.IsNullOrWhiteSpace(n.Value) || n.Value.Equals(n.Key, StringComparison.InvariantCulture))
return n.Key;
return $"{n.Value} ({n.Value})";
if (string.IsNullOrWhiteSpace(n.Tag) || n.Tag.Equals(n.Name, StringComparison.InvariantCulture))
return n.Name;
return $"{n.Name} ({n.Tag})";
});
}

View File

@@ -56,7 +56,7 @@
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
Text="{Binding Origin.SourceTag}"/>
Text="{Binding OldVersion}"/>
<!-- ComboBox: Version (new) -->
<ComboBox

View File

@@ -33,7 +33,7 @@ public partial class UpdatesCollectorView : AvaloniaFlyoutBase
Model.Progress.Increment();
if (updates == null || updates.Length == 0 || updates[0].Value == action.SourceTag)
if (updates == null || updates.Length == 0 || updates[0].Tag == action.SourceTag)
continue;
Model.Updates.Add(new(updates, action));