Skip to content

Fix setting window navigation update issue #3547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,23 @@
{
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>();

Check warning on line 13 in Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Ioc` is not a recognized word. (unrecognized-spelling)

protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Sometimes the navigation is not triggered by button click,
// so we need to reset the page number
_viewModel.PageNum = 1;

if (!IsInitialized)
{
Settings = Ioc.Default.GetRequiredService<Settings>();
_viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
InitializeComponent();
}
// Sometimes the navigation is not triggered by button click,
// so we need to reset the page number
_viewModel.PageNum = 1;
base.OnNavigatedTo(e);
}

private readonly Internationalization _translater = Ioc.Default.GetRequiredService<Internationalization>();

Check warning on line 28 in Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Ioc` is not a recognized word. (unrecognized-spelling)

public List<Language> Languages => _translater.LoadAvailableLanguages();

Expand Down
13 changes: 6 additions & 7 deletions Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@
{
public partial class WelcomePage2
{
public Settings Settings { get; private set; }
private WelcomeViewModel _viewModel;
public Settings Settings { get; } = Ioc.Default.GetRequiredService<Settings>();

Check warning on line 14 in Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Ioc` is not a recognized word. (unrecognized-spelling)
private readonly WelcomeViewModel _viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();

Check warning on line 15 in Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Ioc` is not a recognized word. (unrecognized-spelling)

protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Sometimes the navigation is not triggered by button click,
// so we need to reset the page number
_viewModel.PageNum = 2;

if (!IsInitialized)
{
Settings = Ioc.Default.GetRequiredService<Settings>();
_viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
InitializeComponent();
}
// Sometimes the navigation is not triggered by button click,
// so we need to reset the page number
_viewModel.PageNum = 2;
base.OnNavigatedTo(e);
}

Expand Down
13 changes: 6 additions & 7 deletions Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +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)
{
// Sometimes the navigation is not triggered by button click,
// so we need to reset the page number
_viewModel.PageNum = 3;

if (!IsInitialized)
{
Settings = Ioc.Default.GetRequiredService<Settings>();
_viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
InitializeComponent();
}
// Sometimes the navigation is not triggered by button click,
// so we need to reset the page number
_viewModel.PageNum = 3;
base.OnNavigatedTo(e);
}
}
Expand Down
13 changes: 6 additions & 7 deletions Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +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)
{
// Sometimes the navigation is not triggered by button click,
// so we need to reset the page number
_viewModel.PageNum = 4;

if (!IsInitialized)
{
Settings = Ioc.Default.GetRequiredService<Settings>();
_viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
InitializeComponent();
}
// Sometimes the navigation is not triggered by button click,
// so we need to reset the page number
_viewModel.PageNum = 4;
base.OnNavigatedTo(e);
}
}
Expand Down
13 changes: 6 additions & 7 deletions Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +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)
{
// Sometimes the navigation is not triggered by button click,
// so we need to reset the page number
_viewModel.PageNum = 5;

if (!IsInitialized)
{
Settings = Ioc.Default.GetRequiredService<Settings>();
_viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
InitializeComponent();
}
// Sometimes the navigation is not triggered by button click,
// so we need to reset the page number
_viewModel.PageNum = 5;
base.OnNavigatedTo(e);
}

Expand Down
12 changes: 11 additions & 1 deletion Flow.Launcher/SettingPages/Views/SettingsPaneAbout.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
using System.Windows.Navigation;
using CommunityToolkit.Mvvm.DependencyInjection;
using Flow.Launcher.SettingPages.ViewModels;
using Flow.Launcher.ViewModel;

namespace Flow.Launcher.SettingPages.Views;

public partial class SettingsPaneAbout
{
private SettingsPaneAboutViewModel _viewModel = null!;
private readonly SettingWindowViewModel _settingViewModel = Ioc.Default.GetRequiredService<SettingWindowViewModel>();

protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (!IsInitialized)
// Sometimes the navigation is not triggered by button click,
// so we need to reset the page type
_settingViewModel.PageType = typeof(SettingsPaneAbout);

// If the navigation is not triggered by button click, view model will be null again
if (_viewModel == null)
{
_viewModel = Ioc.Default.GetRequiredService<SettingsPaneAboutViewModel>();
DataContext = _viewModel;
}
if (!IsInitialized)
{
InitializeComponent();
}
base.OnNavigatedTo(e);
Expand Down
12 changes: 11 additions & 1 deletion Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
using System.Windows.Navigation;
using CommunityToolkit.Mvvm.DependencyInjection;
using Flow.Launcher.SettingPages.ViewModels;
using Flow.Launcher.ViewModel;

namespace Flow.Launcher.SettingPages.Views;

public partial class SettingsPaneGeneral
{
private SettingsPaneGeneralViewModel _viewModel = null!;
private readonly SettingWindowViewModel _settingViewModel = Ioc.Default.GetRequiredService<SettingWindowViewModel>();

protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (!IsInitialized)
// Sometimes the navigation is not triggered by button click,
// so we need to reset the page type
_settingViewModel.PageType = typeof(SettingsPaneGeneral);

// If the navigation is not triggered by button click, view model will be null again
if (_viewModel == null)
{
_viewModel = Ioc.Default.GetRequiredService<SettingsPaneGeneralViewModel>();
DataContext = _viewModel;
}
if (!IsInitialized)
{
InitializeComponent();
}
base.OnNavigatedTo(e);
Expand Down
12 changes: 11 additions & 1 deletion Flow.Launcher/SettingPages/Views/SettingsPaneHotkey.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
using System.Windows.Navigation;
using CommunityToolkit.Mvvm.DependencyInjection;
using Flow.Launcher.SettingPages.ViewModels;
using Flow.Launcher.ViewModel;

namespace Flow.Launcher.SettingPages.Views;

public partial class SettingsPaneHotkey
{
private SettingsPaneHotkeyViewModel _viewModel = null!;
private readonly SettingWindowViewModel _settingViewModel = Ioc.Default.GetRequiredService<SettingWindowViewModel>();

protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (!IsInitialized)
// Sometimes the navigation is not triggered by button click,
// so we need to reset the page type
_settingViewModel.PageType = typeof(SettingsPaneHotkey);

// If the navigation is not triggered by button click, view model will be null again
if (_viewModel == null)
{
_viewModel = Ioc.Default.GetRequiredService<SettingsPaneHotkeyViewModel>();
DataContext = _viewModel;
}
if (!IsInitialized)
{
InitializeComponent();
}
base.OnNavigatedTo(e);
Expand Down
11 changes: 10 additions & 1 deletion Flow.Launcher/SettingPages/Views/SettingsPanePluginStore.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ namespace Flow.Launcher.SettingPages.Views;
public partial class SettingsPanePluginStore
{
private SettingsPanePluginStoreViewModel _viewModel = null!;
private readonly SettingWindowViewModel _settingViewModel = Ioc.Default.GetRequiredService<SettingWindowViewModel>();

protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (!IsInitialized)
// Sometimes the navigation is not triggered by button click,
// so we need to reset the page type
_settingViewModel.PageType = typeof(SettingsPanePluginStore);

// If the navigation is not triggered by button click, view model will be null again
if (_viewModel == null)
{
_viewModel = Ioc.Default.GetRequiredService<SettingsPanePluginStoreViewModel>();
DataContext = _viewModel;
}
if (!IsInitialized)
{
InitializeComponent();
}
_viewModel.PropertyChanged += ViewModel_PropertyChanged;
Expand Down
11 changes: 10 additions & 1 deletion Flow.Launcher/SettingPages/Views/SettingsPanePlugins.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ namespace Flow.Launcher.SettingPages.Views;
public partial class SettingsPanePlugins
{
private SettingsPanePluginsViewModel _viewModel = null!;
private readonly SettingWindowViewModel _settingViewModel = Ioc.Default.GetRequiredService<SettingWindowViewModel>();

protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (!IsInitialized)
// Sometimes the navigation is not triggered by button click,
// so we need to reset the page type
_settingViewModel.PageType = typeof(SettingsPanePlugins);

// If the navigation is not triggered by button click, view model will be null again
if (_viewModel == null)
{
_viewModel = Ioc.Default.GetRequiredService<SettingsPanePluginsViewModel>();
DataContext = _viewModel;
}
if (!IsInitialized)
{
InitializeComponent();
}
_viewModel.PropertyChanged += ViewModel_PropertyChanged;
Expand Down
12 changes: 11 additions & 1 deletion Flow.Launcher/SettingPages/Views/SettingsPaneProxy.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
using System.Windows.Navigation;
using CommunityToolkit.Mvvm.DependencyInjection;
using Flow.Launcher.SettingPages.ViewModels;
using Flow.Launcher.ViewModel;

namespace Flow.Launcher.SettingPages.Views;

public partial class SettingsPaneProxy
{
private SettingsPaneProxyViewModel _viewModel = null!;
private readonly SettingWindowViewModel _settingViewModel = Ioc.Default.GetRequiredService<SettingWindowViewModel>();

protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (!IsInitialized)
// Sometimes the navigation is not triggered by button click,
// so we need to reset the page type
_settingViewModel.PageType = typeof(SettingsPaneProxy);

// If the navigation is not triggered by button click, view model will be null again
if (_viewModel == null)
{
_viewModel = Ioc.Default.GetRequiredService<SettingsPaneProxyViewModel>();
DataContext = _viewModel;
}
if (!IsInitialized)
{
InitializeComponent();
}
base.OnNavigatedTo(e);
Expand Down
12 changes: 11 additions & 1 deletion Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
using System.Windows.Navigation;
using CommunityToolkit.Mvvm.DependencyInjection;
using Flow.Launcher.SettingPages.ViewModels;
using Flow.Launcher.ViewModel;

namespace Flow.Launcher.SettingPages.Views;

public partial class SettingsPaneTheme
{
private SettingsPaneThemeViewModel _viewModel = null!;
private readonly SettingWindowViewModel _settingViewModel = Ioc.Default.GetRequiredService<SettingWindowViewModel>();

protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (!IsInitialized)
// Sometimes the navigation is not triggered by button click,
// so we need to reset the page type
_settingViewModel.PageType = typeof(SettingsPaneTheme);

// If the navigation is not triggered by button click, view model will be null again
if (_viewModel == null)
{
_viewModel = Ioc.Default.GetRequiredService<SettingsPaneThemeViewModel>();
DataContext = _viewModel;
}
if (!IsInitialized)
{
InitializeComponent();
}
base.OnNavigatedTo(e);
Expand Down
Loading
Loading