mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-04-25 21:47:42 +02:00
misc: chore: optimize UserSelectorDialog closed handler
This commit is contained in:
parent
e8e1dc6619
commit
06d34a5992
2 changed files with 11 additions and 15 deletions
|
@ -283,8 +283,7 @@ namespace Ryujinx.Ava.UI.Applet
|
||||||
Profiles = profiles,
|
Profiles = profiles,
|
||||||
SelectedUserId = _parent.AccountManager.LastOpenedUser.UserId
|
SelectedUserId = _parent.AccountManager.LastOpenedUser.UserId
|
||||||
};
|
};
|
||||||
UserSelectorDialog content = new(viewModel);
|
(selected, _) = await UserSelectorDialog.ShowInputDialog(viewModel);
|
||||||
(selected, _) = await UserSelectorDialog.ShowInputDialog(content);
|
|
||||||
|
|
||||||
dialogCloseEvent.Set();
|
dialogCloseEvent.Set();
|
||||||
});
|
});
|
||||||
|
|
|
@ -79,7 +79,7 @@ namespace Ryujinx.Ava.UI.Applet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<(UserId Id, bool Result)> ShowInputDialog(UserSelectorDialog content)
|
public static async Task<(UserId Id, bool Result)> ShowInputDialog(UserSelectorDialogViewModel viewModel)
|
||||||
{
|
{
|
||||||
ContentDialog contentDialog = new()
|
ContentDialog contentDialog = new()
|
||||||
{
|
{
|
||||||
|
@ -87,35 +87,32 @@ namespace Ryujinx.Ava.UI.Applet
|
||||||
PrimaryButtonText = LocaleManager.Instance[LocaleKeys.Continue],
|
PrimaryButtonText = LocaleManager.Instance[LocaleKeys.Continue],
|
||||||
SecondaryButtonText = string.Empty,
|
SecondaryButtonText = string.Empty,
|
||||||
CloseButtonText = LocaleManager.Instance[LocaleKeys.Cancel],
|
CloseButtonText = LocaleManager.Instance[LocaleKeys.Cancel],
|
||||||
Content = content,
|
Content = new UserSelectorDialog(viewModel),
|
||||||
Padding = new Thickness(0)
|
Padding = new Thickness(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
UserId result = UserId.Null;
|
UserId result = UserId.Null;
|
||||||
bool input = false;
|
bool input = false;
|
||||||
|
|
||||||
|
contentDialog.Closed += Handler;
|
||||||
|
|
||||||
|
await ContentDialogHelper.ShowAsync(contentDialog);
|
||||||
|
|
||||||
|
return (result, input);
|
||||||
|
|
||||||
void Handler(ContentDialog sender, ContentDialogClosedEventArgs eventArgs)
|
void Handler(ContentDialog sender, ContentDialogClosedEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
if (eventArgs.Result == ContentDialogResult.Primary)
|
if (eventArgs.Result == ContentDialogResult.Primary)
|
||||||
{
|
{
|
||||||
if (contentDialog.Content is UserSelectorDialog view)
|
result = viewModel.SelectedUserId;
|
||||||
{
|
|
||||||
result = view.ViewModel.SelectedUserId;
|
|
||||||
input = true;
|
input = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = UserId.Null;
|
result = UserId.Null;
|
||||||
input = false;
|
input = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contentDialog.Closed += Handler;
|
|
||||||
|
|
||||||
await ContentDialogHelper.ShowAsync(contentDialog);
|
|
||||||
|
|
||||||
return (result, input);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue