New UI (not wired up)

This commit is contained in:
2026-09-22 15:23:39 +03:00 Unverified
parent 8ab8dde837
commit 5cb8eee38c
14 changed files with 426 additions and 54 deletions
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
@@ -21,6 +22,8 @@ public partial class SubscriptionViewModel : ObservableValidator
Title = subscription.Title;
UpdateInterval = subscription.UpdateInterval;
SupportURL = subscription.SupportURL;
Servers = new ObservableCollection<SubscriptionServerViewModel>(subscription.Servers.Select(s => new SubscriptionServerViewModel(s)));
}
[ObservableProperty]
@@ -30,12 +33,16 @@ public partial class SubscriptionViewModel : ObservableValidator
public partial string WebPage { get; set; }
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(GetTitle))]
[NotifyPropertyChangedFor(nameof(IsNotDefaultTitle))]
public partial string DefaultTitle { get; set; }
[ObservableProperty]
public partial int DefaultUpdateInterval { get; set; }
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(GetTitle))]
[NotifyPropertyChangedFor(nameof(IsNotDefaultTitle))]
public partial string Title { get; set; }
[ObservableProperty]
@@ -63,4 +70,70 @@ public partial class SubscriptionViewModel : ObservableValidator
{
return IsDirty && !HasErrors;
}
public ObservableCollection<SubscriptionServerViewModel> Servers
{
get; set;
}
[RelayCommand]
public async Task DeleteAsync()
{
}
public async Task EditNameAsync()
{
}
[ObservableProperty]
public partial bool IsNameEditing
{
get; set;
} = false;
[RelayCommand]
public void EditName()
{
if (IsNameEditing)
EditNameAsync();
IsNameEditing = !IsNameEditing;
}
[ObservableProperty]
public partial bool IsDeleted
{
get; set;
}
[ObservableProperty]
public partial bool IsDisabled
{
get; set;
}
public string GetUidForNameEditing(bool isNameEditing)
{
if (isNameEditing) return "ServerListElementMenuFlyoutSave";
else return "ServerListElementMenuFlyoutEdit";
}
public string GetGlyphForNameEditing(bool isNameEditing)
{
if (isNameEditing) return "\uE792";
else return "\uE70F";
}
public string GetTitle
{
get => string.IsNullOrEmpty(Title) ? (string.IsNullOrEmpty(DefaultTitle) ? string.Empty : DefaultTitle) : Title;
set => throw new InvalidOperationException();
}
public bool IsNotDefaultTitle
{
get => (!string.IsNullOrEmpty(Title) && Title != DefaultTitle);
set => throw new InvalidOperationException();
}
}