mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix possible issue in welcome pages
This commit is contained in:
parent
d0e799b8ed
commit
ad94ebadcf
5 changed files with 30 additions and 55 deletions
|
|
@ -9,24 +9,19 @@ namespace Flow.Launcher.Resources.Pages
|
|||
{
|
||||
public partial class WelcomePage1
|
||||
{
|
||||
public Settings Settings { get; private set; }
|
||||
private WelcomeViewModel _viewModel;
|
||||
public Settings Settings { get; } = Ioc.Default.GetRequiredService<Settings>();
|
||||
private readonly WelcomeViewModel _viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
// If the navigation is not triggered by button click, view model will be null again
|
||||
if (_viewModel == null)
|
||||
{
|
||||
Settings = Ioc.Default.GetRequiredService<Settings>();
|
||||
_viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
|
||||
}
|
||||
// Sometimes the navigation is not triggered by button click,
|
||||
// so we need to reset the page number
|
||||
_viewModel.PageNum = 1;
|
||||
|
||||
if (!IsInitialized)
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
// Sometimes the navigation is not triggered by button click,
|
||||
// so we need to reset the page number
|
||||
_viewModel.PageNum = 1;
|
||||
base.OnNavigatedTo(e);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,24 +11,19 @@ namespace Flow.Launcher.Resources.Pages
|
|||
{
|
||||
public partial class WelcomePage2
|
||||
{
|
||||
public Settings Settings { get; private set; }
|
||||
private WelcomeViewModel _viewModel;
|
||||
public Settings Settings { get; } = Ioc.Default.GetRequiredService<Settings>();
|
||||
private readonly WelcomeViewModel _viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
// If the navigation is not triggered by button click, view model will be null again
|
||||
if (_viewModel == null)
|
||||
{
|
||||
Settings = Ioc.Default.GetRequiredService<Settings>();
|
||||
_viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
|
||||
}
|
||||
// Sometimes the navigation is not triggered by button click,
|
||||
// so we need to reset the page number
|
||||
_viewModel.PageNum = 2;
|
||||
|
||||
if (!IsInitialized)
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
// Sometimes the navigation is not triggered by button click,
|
||||
// so we need to reset the page number
|
||||
_viewModel.PageNum = 2;
|
||||
base.OnNavigatedTo(e);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,24 +7,19 @@ namespace Flow.Launcher.Resources.Pages
|
|||
{
|
||||
public partial class WelcomePage3
|
||||
{
|
||||
public Settings Settings { get; private set; }
|
||||
private WelcomeViewModel _viewModel;
|
||||
public Settings Settings { get; } = Ioc.Default.GetRequiredService<Settings>();
|
||||
private readonly WelcomeViewModel _viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
// If the navigation is not triggered by button click, view model will be null again
|
||||
if (_viewModel == null)
|
||||
{
|
||||
Settings = Ioc.Default.GetRequiredService<Settings>();
|
||||
_viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
|
||||
}
|
||||
// Sometimes the navigation is not triggered by button click,
|
||||
// so we need to reset the page number
|
||||
_viewModel.PageNum = 3;
|
||||
|
||||
if (!IsInitialized)
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
// Sometimes the navigation is not triggered by button click,
|
||||
// so we need to reset the page number
|
||||
_viewModel.PageNum = 3;
|
||||
base.OnNavigatedTo(e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,24 +7,19 @@ namespace Flow.Launcher.Resources.Pages
|
|||
{
|
||||
public partial class WelcomePage4
|
||||
{
|
||||
public Settings Settings { get; private set; }
|
||||
private WelcomeViewModel _viewModel;
|
||||
public Settings Settings { get; } = Ioc.Default.GetRequiredService<Settings>();
|
||||
private readonly WelcomeViewModel _viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
// If the navigation is not triggered by button click, view model will be null again
|
||||
if (_viewModel == null)
|
||||
{
|
||||
Settings = Ioc.Default.GetRequiredService<Settings>();
|
||||
_viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
|
||||
}
|
||||
// Sometimes the navigation is not triggered by button click,
|
||||
// so we need to reset the page number
|
||||
_viewModel.PageNum = 4;
|
||||
|
||||
if (!IsInitialized)
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
// Sometimes the navigation is not triggered by button click,
|
||||
// so we need to reset the page number
|
||||
_viewModel.PageNum = 4;
|
||||
base.OnNavigatedTo(e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,24 +10,19 @@ namespace Flow.Launcher.Resources.Pages
|
|||
{
|
||||
public partial class WelcomePage5
|
||||
{
|
||||
public Settings Settings { get; private set; }
|
||||
private WelcomeViewModel _viewModel;
|
||||
public Settings Settings { get; } = Ioc.Default.GetRequiredService<Settings>();
|
||||
private readonly WelcomeViewModel _viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
// If the navigation is not triggered by button click, view model will be null again
|
||||
if (_viewModel == null)
|
||||
{
|
||||
Settings = Ioc.Default.GetRequiredService<Settings>();
|
||||
_viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
|
||||
}
|
||||
// Sometimes the navigation is not triggered by button click,
|
||||
// so we need to reset the page number
|
||||
_viewModel.PageNum = 5;
|
||||
|
||||
if (!IsInitialized)
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
// Sometimes the navigation is not triggered by button click,
|
||||
// so we need to reset the page number
|
||||
_viewModel.PageNum = 5;
|
||||
base.OnNavigatedTo(e);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue