Initial commit
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WinWARP.Core.Services;
|
||||
|
||||
public interface ILocalizationService
|
||||
{
|
||||
IEnumerable<string> GetSupportedLanguages();
|
||||
string GetCurrentLanguage();
|
||||
Task SetLanguageAsync(string languageCode);
|
||||
string GetString(string resourceKey);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace WinWARP.Core.Services;
|
||||
|
||||
public interface INavigationService
|
||||
{
|
||||
void NavigateTo<TViewModel>(object parameter = null) where TViewModel : class;
|
||||
void GoBack();
|
||||
bool CanGoBack
|
||||
{
|
||||
get;
|
||||
}
|
||||
Type CurrentViewModelType { get; }
|
||||
event EventHandler<Type> NavigatedToViewModel;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace WinWARP.Core.ViewModels.ConfigSettings;
|
||||
|
||||
public partial class DnsSettingsViewModel : ObservableObject
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace WinWARP.Core.ViewModels.ConfigSettings;
|
||||
|
||||
public partial class InboundSettingsViewModel : ObservableObject
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace WinWARP.Core.ViewModels.ConfigSettings;
|
||||
|
||||
public partial class RoutingSettingsViewModel : ObservableObject
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace WinWARP.Core.ViewModels.ConfigSettings;
|
||||
|
||||
public partial class TlsSettingsViewModel : ObservableObject
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace WinWARP.Core.ViewModels.ConfigSettings;
|
||||
|
||||
public partial class WarpSettingsViewModel : ObservableObject
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace WinWARP.Core.ViewModels;
|
||||
|
||||
public class ConfigSettingsViewModel : ObservableObject
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using WinWARP.Core.Services;
|
||||
|
||||
namespace WinWARP.Core.ViewModels;
|
||||
|
||||
public partial class HomeViewModel : ObservableObject
|
||||
{
|
||||
private readonly INavigationService _navigationService;
|
||||
|
||||
public HomeViewModel(INavigationService navigationService)
|
||||
{
|
||||
_navigationService = navigationService;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void TestTransition()
|
||||
{
|
||||
_navigationService.NavigateTo<SettingsViewModel>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using WinWARP.Core.Services;
|
||||
|
||||
namespace WinWARP.Core.ViewModels;
|
||||
|
||||
public partial class MainViewModel : ObservableObject
|
||||
{
|
||||
private readonly INavigationService _navigationService;
|
||||
|
||||
public MainViewModel(INavigationService navigationService)
|
||||
{
|
||||
_navigationService = navigationService;
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string Title { get; set; } = "WinWARP";
|
||||
|
||||
[ObservableProperty]
|
||||
public partial Type CurrentViewModelType { get; set; }
|
||||
|
||||
[RelayCommand]
|
||||
private void Navigate(object? tagParameter)
|
||||
{
|
||||
if (tagParameter is Type viewModelType)
|
||||
{
|
||||
var method = _navigationService.GetType().GetMethod("NavigateTo")?.MakeGenericMethod(viewModelType);
|
||||
method?.Invoke(_navigationService, [null]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace WinWARP.Core.ViewModels.Settings;
|
||||
|
||||
public partial class GeneralSettingsViewModel : ObservableObject
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace WinWARP.Core.ViewModels.Settings;
|
||||
|
||||
public partial class UpdateSettingsViewModel : ObservableObject
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using WinWARP.Core.Services;
|
||||
|
||||
namespace WinWARP.Core.ViewModels;
|
||||
|
||||
public partial class SettingsViewModel : ObservableObject
|
||||
{
|
||||
private readonly ILocalizationService _localizationService;
|
||||
private readonly INavigationService _navigationService;
|
||||
|
||||
public SettingsViewModel(ILocalizationService localizationService, INavigationService navigationService)
|
||||
{
|
||||
_navigationService = navigationService;
|
||||
_localizationService = localizationService;
|
||||
SelectedLanguage = _localizationService.GetCurrentLanguage();
|
||||
Languages = new ObservableCollection<string>(_localizationService.GetSupportedLanguages());
|
||||
}
|
||||
|
||||
|
||||
[RelayCommand]
|
||||
private void Navigate(object? tagParameter)
|
||||
{
|
||||
if (tagParameter is Type viewModelType)
|
||||
{
|
||||
var method = _navigationService.GetType().GetMethod("NavigateTo")?.MakeGenericMethod(viewModelType);
|
||||
method?.Invoke(_navigationService, [null]);
|
||||
}
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string SelectedLanguage
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
partial void OnSelectedLanguageChanged(string value)
|
||||
{
|
||||
_localizationService.SetLanguageAsync(value);
|
||||
}
|
||||
|
||||
public ObservableCollection<string> Languages;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace WinWARP.Core.ViewModels;
|
||||
|
||||
public class SubsSettingsViewModel : ObservableObject
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.2" />
|
||||
<PackageReference Include="SingBoxLib" Version="1.2.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\Navigation\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user