New UI (not wired up)
This commit is contained in:
@@ -14,6 +14,6 @@ public partial class HomeViewModel(INavigationService navigationService) : Obser
|
||||
[RelayCommand]
|
||||
private void TestTransition()
|
||||
{
|
||||
_navigationService.NavigateTo<SettingsViewModel>();
|
||||
_navigationService.NavigateTo<SubsSettingsViewModel>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
@@ -15,8 +16,11 @@ public abstract partial class ServerItemViewModel : ObservableObject
|
||||
Id = server.Id;
|
||||
DefaultTitle = server.DefaultTitle;
|
||||
Title = server.Title;
|
||||
ConnectionString = server.ConnectionString;
|
||||
Region = server.Region;
|
||||
ConnectionString = server.ConnectionString;
|
||||
IsDeleted = server.IsDeleted;
|
||||
IsDisabled = server.IsDisabled;
|
||||
Tags = new ObservableCollection<string>(server.Tags);
|
||||
}
|
||||
|
||||
public int Id
|
||||
@@ -68,4 +72,16 @@ public abstract partial class ServerItemViewModel : ObservableObject
|
||||
}
|
||||
|
||||
public ObservableCollection<string> Tags { get; } = [];
|
||||
|
||||
[ObservableProperty]
|
||||
public partial bool IsDeleted
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
public partial bool IsDisabled
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public partial class SubsSettingsViewModel(ISubscriptionDbService dbService, ISu
|
||||
}
|
||||
|
||||
public ObservableCollection<SubscriptionViewModel> Subscriptions { get; } = [];
|
||||
public ObservableCollection<ServerItemViewModel> Servers { get; } = [];
|
||||
public ObservableCollection<StandaloneServerViewModel> Servers { get; } = [];
|
||||
|
||||
public async Task LoadSubscriptionsAsync()
|
||||
{
|
||||
@@ -37,8 +37,6 @@ public partial class SubsSettingsViewModel(ISubscriptionDbService dbService, ISu
|
||||
Subscriptions.Add(new SubscriptionViewModel(subscription));
|
||||
}
|
||||
|
||||
Servers.Add(new StandaloneServerViewModel(new StandaloneServer() { Region = "NO", Title = "Not default title", DefaultTitle = "Default title" }) { Tags = { "VLESS", "GRPC", "REALITY" } });
|
||||
|
||||
ShowLoadingIndicator = false;
|
||||
}
|
||||
|
||||
@@ -66,13 +64,10 @@ public partial class SubsSettingsViewModel(ISubscriptionDbService dbService, ISu
|
||||
subscription.Title = customName;
|
||||
subscription.UpdateInterval = updateInterval;
|
||||
|
||||
Subscriptions.Add(new SubscriptionViewModel(subscription));
|
||||
foreach (var server in subscription.Servers)
|
||||
{
|
||||
var serverVM = new SubscriptionServerViewModel(server);
|
||||
foreach (var tag in _fetcher.GetTags(server.ConnectionString)) serverVM.Tags.Add(tag);
|
||||
Servers.Add(serverVM);
|
||||
}
|
||||
var sub = new SubscriptionViewModel(subscription);
|
||||
|
||||
Subscriptions.Add(sub);
|
||||
|
||||
ShowLoadingIndicator = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user