mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-18 18:35:00 +03:00
ViewModel-First (#9621)
* Interaction * Remove view action * ViewModel-first * MainGirdOrientation Hot Reload * Fix avalonia preview * Remove CloseWindowInteraction * Fix * Avoid threading issues * Fix * ProfilesSelect * Try fix previewer * Remove AppEvents.ProfilesRefreshRequested * Remove AppEvents.SubscriptionsRefreshRequested * Remove AppEvents.ProxiesReloadRequested * Remove AppEvents.AdjustMainLvColWidthRequested * Remove AppEvents.SetDefaultServerRequested * Remove AppEvents.RoutingsMenuRefreshRequested * Remove AppEvents.TestServerRequested * Remove AppEvents.InboundDisplayRequested * Remove AppEvents.SubscriptionsUpdateRequested * Remove AppEvents.ShowHideWindowRequested * Remove AppEvents.ReloadRequested * Remove AppEvents.AddServerRequested * Fix
This commit is contained in:
@@ -16,7 +16,6 @@ public partial class SubSettingWindow : WindowBase<SubSettingViewModel>
|
||||
Loaded += Window_Loaded;
|
||||
Closing += SubSettingWindow_Closing;
|
||||
KeyDown += SubSettingWindow_KeyDown;
|
||||
ViewModel = new SubSettingViewModel(UpdateViewHandler);
|
||||
lstSubscription.DoubleTapped += LstSubscription_DoubleTapped;
|
||||
lstSubscription.SelectionChanged += LstSubscription_SelectionChanged;
|
||||
|
||||
@@ -34,46 +33,28 @@ public partial class SubSettingWindow : WindowBase<SubSettingViewModel>
|
||||
this.BindCommand(ViewModel, vm => vm.SubDeleteCmd, v => v.menuSubDelete2).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.SubEditCmd, v => v.menuSubEdit2).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.SubShareCmd, v => v.menuSubShare2).DisposeWith(disposables);
|
||||
|
||||
ViewModel.ShowYesNoInteraction.RegisterHandler(async interaction =>
|
||||
{
|
||||
var message = interaction.Input;
|
||||
var result = await UI.ShowYesNo(message);
|
||||
interaction.SetOutput(result == ButtonResult.Yes);
|
||||
}).DisposeWith(disposables);
|
||||
|
||||
ViewModel.ShareSubInteraction.RegisterHandler(async interaction =>
|
||||
{
|
||||
var url = interaction.Input;
|
||||
if (url.IsNullOrEmpty())
|
||||
{
|
||||
interaction.SetOutput(Unit.Default);
|
||||
return;
|
||||
}
|
||||
await ShareSub(url);
|
||||
interaction.SetOutput(Unit.Default);
|
||||
}).DisposeWith(disposables);
|
||||
});
|
||||
}
|
||||
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case EViewAction.CloseWindow:
|
||||
Close();
|
||||
break;
|
||||
|
||||
case EViewAction.ShowYesNo:
|
||||
if (await UI.ShowYesNo(this, ResUI.RemoveServer) != ButtonResult.Yes)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case EViewAction.SubEditWindow:
|
||||
if (obj is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var window = new SubEditWindow((SubItem)obj);
|
||||
await window.ShowDialog(this);
|
||||
break;
|
||||
|
||||
case EViewAction.ShareSub:
|
||||
if (obj is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
await ShareSub((string)obj);
|
||||
break;
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
private async Task ShareSub(string url)
|
||||
{
|
||||
if (url.IsNullOrEmpty())
|
||||
|
||||
Reference in New Issue
Block a user