mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Add debounce for installer navigation buttons
This commit is contained in:
parent
4c29b1b6e6
commit
4bb623c64e
@ -31,9 +31,7 @@ namespace Bloxstrap.UI.Elements.Installer
|
|||||||
/// - MainWindow has a single-set Func<bool> property named NextPageCallback which is reset on every page load
|
/// - MainWindow has a single-set Func<bool> property named NextPageCallback which is reset on every page load
|
||||||
/// - This callback is called when the next page button is pressed
|
/// - This callback is called when the next page button is pressed
|
||||||
/// - Page CodeBehind gets MainWindow and sets the callback to its own local function on page load
|
/// - Page CodeBehind gets MainWindow and sets the callback to its own local function on page load
|
||||||
/// - CodeBehind's local function then directly calls the ViewModel to do whatever it needs to do
|
/// - CodeBehind's local function then directly calls its ViewModel to do whatever it needs to do
|
||||||
///
|
|
||||||
/// TODO: theme selection
|
|
||||||
|
|
||||||
public partial class MainWindow : WpfUiWindow, INavigationWindow
|
public partial class MainWindow : WpfUiWindow, INavigationWindow
|
||||||
{
|
{
|
||||||
@ -43,6 +41,8 @@ namespace Bloxstrap.UI.Elements.Installer
|
|||||||
|
|
||||||
private List<Type> _pages = new() { typeof(WelcomePage), typeof(InstallPage), typeof(CompletionPage) };
|
private List<Type> _pages = new() { typeof(WelcomePage), typeof(InstallPage), typeof(CompletionPage) };
|
||||||
|
|
||||||
|
private DateTimeOffset _lastNavigation = DateTimeOffset.Now;
|
||||||
|
|
||||||
public Func<bool>? NextPageCallback;
|
public Func<bool>? NextPageCallback;
|
||||||
|
|
||||||
public NextAction CloseAction = NextAction.Terminate;
|
public NextAction CloseAction = NextAction.Terminate;
|
||||||
@ -55,10 +55,16 @@ namespace Bloxstrap.UI.Elements.Installer
|
|||||||
|
|
||||||
_viewModel.PageRequest += (_, type) =>
|
_viewModel.PageRequest += (_, type) =>
|
||||||
{
|
{
|
||||||
|
// debounce
|
||||||
|
if (DateTimeOffset.Now.Subtract(_lastNavigation).TotalMilliseconds < 500)
|
||||||
|
return;
|
||||||
|
|
||||||
if (type == "next")
|
if (type == "next")
|
||||||
NextPage();
|
NextPage();
|
||||||
else if (type == "back")
|
else if (type == "back")
|
||||||
BackPage();
|
BackPage();
|
||||||
|
|
||||||
|
_lastNavigation = DateTimeOffset.Now;
|
||||||
};
|
};
|
||||||
|
|
||||||
DataContext = _viewModel;
|
DataContext = _viewModel;
|
||||||
|
Loading…
Reference in New Issue
Block a user