File tree Expand file tree Collapse file tree 14 files changed +168
-47
lines changed Expand file tree Collapse file tree 14 files changed +168
-47
lines changed Original file line number Diff line number Diff line change @@ -9,20 +9,19 @@ namespace Flow.Launcher.Resources.Pages
99{
1010 public partial class WelcomePage1
1111 {
12- public Settings Settings { get ; private set ; }
13- private WelcomeViewModel _viewModel ;
12+ public Settings Settings { get ; } = Ioc . Default . GetRequiredService < Settings > ( ) ;
13+ private readonly WelcomeViewModel _viewModel = Ioc . Default . GetRequiredService < WelcomeViewModel > ( ) ;
1414
1515 protected override void OnNavigatedTo ( NavigationEventArgs e )
1616 {
17+ // Sometimes the navigation is not triggered by button click,
18+ // so we need to reset the page number
19+ _viewModel . PageNum = 1 ;
20+
1721 if ( ! IsInitialized )
1822 {
19- Settings = Ioc . Default . GetRequiredService < Settings > ( ) ;
20- _viewModel = Ioc . Default . GetRequiredService < WelcomeViewModel > ( ) ;
2123 InitializeComponent ( ) ;
2224 }
23- // Sometimes the navigation is not triggered by button click,
24- // so we need to reset the page number
25- _viewModel . PageNum = 1 ;
2625 base . OnNavigatedTo ( e ) ;
2726 }
2827
Original file line number Diff line number Diff line change @@ -11,20 +11,19 @@ namespace Flow.Launcher.Resources.Pages
1111{
1212 public partial class WelcomePage2
1313 {
14- public Settings Settings { get ; private set ; }
15- private WelcomeViewModel _viewModel ;
14+ public Settings Settings { get ; } = Ioc . Default . GetRequiredService < Settings > ( ) ;
15+ private readonly WelcomeViewModel _viewModel = Ioc . Default . GetRequiredService < WelcomeViewModel > ( ) ;
1616
1717 protected override void OnNavigatedTo ( NavigationEventArgs e )
1818 {
19+ // Sometimes the navigation is not triggered by button click,
20+ // so we need to reset the page number
21+ _viewModel . PageNum = 2 ;
22+
1923 if ( ! IsInitialized )
2024 {
21- Settings = Ioc . Default . GetRequiredService < Settings > ( ) ;
22- _viewModel = Ioc . Default . GetRequiredService < WelcomeViewModel > ( ) ;
2325 InitializeComponent ( ) ;
2426 }
25- // Sometimes the navigation is not triggered by button click,
26- // so we need to reset the page number
27- _viewModel . PageNum = 2 ;
2827 base . OnNavigatedTo ( e ) ;
2928 }
3029
Original file line number Diff line number Diff line change @@ -7,20 +7,19 @@ namespace Flow.Launcher.Resources.Pages
77{
88 public partial class WelcomePage3
99 {
10- public Settings Settings { get ; private set ; }
11- private WelcomeViewModel _viewModel ;
10+ public Settings Settings { get ; } = Ioc . Default . GetRequiredService < Settings > ( ) ;
11+ private readonly WelcomeViewModel _viewModel = Ioc . Default . GetRequiredService < WelcomeViewModel > ( ) ;
1212
1313 protected override void OnNavigatedTo ( NavigationEventArgs e )
1414 {
15+ // Sometimes the navigation is not triggered by button click,
16+ // so we need to reset the page number
17+ _viewModel . PageNum = 3 ;
18+
1519 if ( ! IsInitialized )
1620 {
17- Settings = Ioc . Default . GetRequiredService < Settings > ( ) ;
18- _viewModel = Ioc . Default . GetRequiredService < WelcomeViewModel > ( ) ;
1921 InitializeComponent ( ) ;
2022 }
21- // Sometimes the navigation is not triggered by button click,
22- // so we need to reset the page number
23- _viewModel . PageNum = 3 ;
2423 base . OnNavigatedTo ( e ) ;
2524 }
2625 }
Original file line number Diff line number Diff line change @@ -7,20 +7,19 @@ namespace Flow.Launcher.Resources.Pages
77{
88 public partial class WelcomePage4
99 {
10- public Settings Settings { get ; private set ; }
11- private WelcomeViewModel _viewModel ;
10+ public Settings Settings { get ; } = Ioc . Default . GetRequiredService < Settings > ( ) ;
11+ private readonly WelcomeViewModel _viewModel = Ioc . Default . GetRequiredService < WelcomeViewModel > ( ) ;
1212
1313 protected override void OnNavigatedTo ( NavigationEventArgs e )
1414 {
15+ // Sometimes the navigation is not triggered by button click,
16+ // so we need to reset the page number
17+ _viewModel . PageNum = 4 ;
18+
1519 if ( ! IsInitialized )
1620 {
17- Settings = Ioc . Default . GetRequiredService < Settings > ( ) ;
18- _viewModel = Ioc . Default . GetRequiredService < WelcomeViewModel > ( ) ;
1921 InitializeComponent ( ) ;
2022 }
21- // Sometimes the navigation is not triggered by button click,
22- // so we need to reset the page number
23- _viewModel . PageNum = 4 ;
2423 base . OnNavigatedTo ( e ) ;
2524 }
2625 }
Original file line number Diff line number Diff line change @@ -10,20 +10,19 @@ namespace Flow.Launcher.Resources.Pages
1010{
1111 public partial class WelcomePage5
1212 {
13- public Settings Settings { get ; private set ; }
14- private WelcomeViewModel _viewModel ;
13+ public Settings Settings { get ; } = Ioc . Default . GetRequiredService < Settings > ( ) ;
14+ private readonly WelcomeViewModel _viewModel = Ioc . Default . GetRequiredService < WelcomeViewModel > ( ) ;
1515
1616 protected override void OnNavigatedTo ( NavigationEventArgs e )
1717 {
18+ // Sometimes the navigation is not triggered by button click,
19+ // so we need to reset the page number
20+ _viewModel . PageNum = 5 ;
21+
1822 if ( ! IsInitialized )
1923 {
20- Settings = Ioc . Default . GetRequiredService < Settings > ( ) ;
21- _viewModel = Ioc . Default . GetRequiredService < WelcomeViewModel > ( ) ;
2224 InitializeComponent ( ) ;
2325 }
24- // Sometimes the navigation is not triggered by button click,
25- // so we need to reset the page number
26- _viewModel . PageNum = 5 ;
2726 base . OnNavigatedTo ( e ) ;
2827 }
2928
Original file line number Diff line number Diff line change 11using System . Windows . Navigation ;
22using CommunityToolkit . Mvvm . DependencyInjection ;
33using Flow . Launcher . SettingPages . ViewModels ;
4+ using Flow . Launcher . ViewModel ;
45
56namespace Flow . Launcher . SettingPages . Views ;
67
78public partial class SettingsPaneAbout
89{
910 private SettingsPaneAboutViewModel _viewModel = null ! ;
11+ private readonly SettingWindowViewModel _settingViewModel = Ioc . Default . GetRequiredService < SettingWindowViewModel > ( ) ;
1012
1113 protected override void OnNavigatedTo ( NavigationEventArgs e )
1214 {
13- if ( ! IsInitialized )
15+ // Sometimes the navigation is not triggered by button click,
16+ // so we need to reset the page type
17+ _settingViewModel . PageType = typeof ( SettingsPaneAbout ) ;
18+
19+ // If the navigation is not triggered by button click, view model will be null again
20+ if ( _viewModel == null )
1421 {
1522 _viewModel = Ioc . Default . GetRequiredService < SettingsPaneAboutViewModel > ( ) ;
1623 DataContext = _viewModel ;
24+ }
25+ if ( ! IsInitialized )
26+ {
1727 InitializeComponent ( ) ;
1828 }
1929 base . OnNavigatedTo ( e ) ;
Original file line number Diff line number Diff line change 11using System . Windows . Navigation ;
22using CommunityToolkit . Mvvm . DependencyInjection ;
33using Flow . Launcher . SettingPages . ViewModels ;
4+ using Flow . Launcher . ViewModel ;
45
56namespace Flow . Launcher . SettingPages . Views ;
67
78public partial class SettingsPaneGeneral
89{
910 private SettingsPaneGeneralViewModel _viewModel = null ! ;
11+ private readonly SettingWindowViewModel _settingViewModel = Ioc . Default . GetRequiredService < SettingWindowViewModel > ( ) ;
1012
1113 protected override void OnNavigatedTo ( NavigationEventArgs e )
1214 {
13- if ( ! IsInitialized )
15+ // Sometimes the navigation is not triggered by button click,
16+ // so we need to reset the page type
17+ _settingViewModel . PageType = typeof ( SettingsPaneGeneral ) ;
18+
19+ // If the navigation is not triggered by button click, view model will be null again
20+ if ( _viewModel == null )
1421 {
1522 _viewModel = Ioc . Default . GetRequiredService < SettingsPaneGeneralViewModel > ( ) ;
1623 DataContext = _viewModel ;
24+ }
25+ if ( ! IsInitialized )
26+ {
1727 InitializeComponent ( ) ;
1828 }
1929 base . OnNavigatedTo ( e ) ;
Original file line number Diff line number Diff line change 11using System . Windows . Navigation ;
22using CommunityToolkit . Mvvm . DependencyInjection ;
33using Flow . Launcher . SettingPages . ViewModels ;
4+ using Flow . Launcher . ViewModel ;
45
56namespace Flow . Launcher . SettingPages . Views ;
67
78public partial class SettingsPaneHotkey
89{
910 private SettingsPaneHotkeyViewModel _viewModel = null ! ;
11+ private readonly SettingWindowViewModel _settingViewModel = Ioc . Default . GetRequiredService < SettingWindowViewModel > ( ) ;
1012
1113 protected override void OnNavigatedTo ( NavigationEventArgs e )
1214 {
13- if ( ! IsInitialized )
15+ // Sometimes the navigation is not triggered by button click,
16+ // so we need to reset the page type
17+ _settingViewModel . PageType = typeof ( SettingsPaneHotkey ) ;
18+
19+ // If the navigation is not triggered by button click, view model will be null again
20+ if ( _viewModel == null )
1421 {
1522 _viewModel = Ioc . Default . GetRequiredService < SettingsPaneHotkeyViewModel > ( ) ;
1623 DataContext = _viewModel ;
24+ }
25+ if ( ! IsInitialized )
26+ {
1727 InitializeComponent ( ) ;
1828 }
1929 base . OnNavigatedTo ( e ) ;
Original file line number Diff line number Diff line change @@ -11,13 +11,22 @@ namespace Flow.Launcher.SettingPages.Views;
1111public partial class SettingsPanePluginStore
1212{
1313 private SettingsPanePluginStoreViewModel _viewModel = null ! ;
14+ private readonly SettingWindowViewModel _settingViewModel = Ioc . Default . GetRequiredService < SettingWindowViewModel > ( ) ;
1415
1516 protected override void OnNavigatedTo ( NavigationEventArgs e )
1617 {
17- if ( ! IsInitialized )
18+ // Sometimes the navigation is not triggered by button click,
19+ // so we need to reset the page type
20+ _settingViewModel . PageType = typeof ( SettingsPanePluginStore ) ;
21+
22+ // If the navigation is not triggered by button click, view model will be null again
23+ if ( _viewModel == null )
1824 {
1925 _viewModel = Ioc . Default . GetRequiredService < SettingsPanePluginStoreViewModel > ( ) ;
2026 DataContext = _viewModel ;
27+ }
28+ if ( ! IsInitialized )
29+ {
2130 InitializeComponent ( ) ;
2231 }
2332 _viewModel . PropertyChanged += ViewModel_PropertyChanged ;
Original file line number Diff line number Diff line change @@ -11,13 +11,22 @@ namespace Flow.Launcher.SettingPages.Views;
1111public partial class SettingsPanePlugins
1212{
1313 private SettingsPanePluginsViewModel _viewModel = null ! ;
14+ private readonly SettingWindowViewModel _settingViewModel = Ioc . Default . GetRequiredService < SettingWindowViewModel > ( ) ;
1415
1516 protected override void OnNavigatedTo ( NavigationEventArgs e )
1617 {
17- if ( ! IsInitialized )
18+ // Sometimes the navigation is not triggered by button click,
19+ // so we need to reset the page type
20+ _settingViewModel . PageType = typeof ( SettingsPanePlugins ) ;
21+
22+ // If the navigation is not triggered by button click, view model will be null again
23+ if ( _viewModel == null )
1824 {
1925 _viewModel = Ioc . Default . GetRequiredService < SettingsPanePluginsViewModel > ( ) ;
2026 DataContext = _viewModel ;
27+ }
28+ if ( ! IsInitialized )
29+ {
2130 InitializeComponent ( ) ;
2231 }
2332 _viewModel . PropertyChanged += ViewModel_PropertyChanged ;
You can’t perform that action at this time.
0 commit comments