File tree 14 files changed +168
-47
lines changed
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
9
9
{
10
10
public partial class WelcomePage1
11
11
{
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 > ( ) ;
14
14
15
15
protected override void OnNavigatedTo ( NavigationEventArgs e )
16
16
{
17
+ // Sometimes the navigation is not triggered by button click,
18
+ // so we need to reset the page number
19
+ _viewModel . PageNum = 1 ;
20
+
17
21
if ( ! IsInitialized )
18
22
{
19
- Settings = Ioc . Default . GetRequiredService < Settings > ( ) ;
20
- _viewModel = Ioc . Default . GetRequiredService < WelcomeViewModel > ( ) ;
21
23
InitializeComponent ( ) ;
22
24
}
23
- // Sometimes the navigation is not triggered by button click,
24
- // so we need to reset the page number
25
- _viewModel . PageNum = 1 ;
26
25
base . OnNavigatedTo ( e ) ;
27
26
}
28
27
Original file line number Diff line number Diff line change @@ -11,20 +11,19 @@ namespace Flow.Launcher.Resources.Pages
11
11
{
12
12
public partial class WelcomePage2
13
13
{
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 > ( ) ;
16
16
17
17
protected override void OnNavigatedTo ( NavigationEventArgs e )
18
18
{
19
+ // Sometimes the navigation is not triggered by button click,
20
+ // so we need to reset the page number
21
+ _viewModel . PageNum = 2 ;
22
+
19
23
if ( ! IsInitialized )
20
24
{
21
- Settings = Ioc . Default . GetRequiredService < Settings > ( ) ;
22
- _viewModel = Ioc . Default . GetRequiredService < WelcomeViewModel > ( ) ;
23
25
InitializeComponent ( ) ;
24
26
}
25
- // Sometimes the navigation is not triggered by button click,
26
- // so we need to reset the page number
27
- _viewModel . PageNum = 2 ;
28
27
base . OnNavigatedTo ( e ) ;
29
28
}
30
29
Original file line number Diff line number Diff line change @@ -7,20 +7,19 @@ namespace Flow.Launcher.Resources.Pages
7
7
{
8
8
public partial class WelcomePage3
9
9
{
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 > ( ) ;
12
12
13
13
protected override void OnNavigatedTo ( NavigationEventArgs e )
14
14
{
15
+ // Sometimes the navigation is not triggered by button click,
16
+ // so we need to reset the page number
17
+ _viewModel . PageNum = 3 ;
18
+
15
19
if ( ! IsInitialized )
16
20
{
17
- Settings = Ioc . Default . GetRequiredService < Settings > ( ) ;
18
- _viewModel = Ioc . Default . GetRequiredService < WelcomeViewModel > ( ) ;
19
21
InitializeComponent ( ) ;
20
22
}
21
- // Sometimes the navigation is not triggered by button click,
22
- // so we need to reset the page number
23
- _viewModel . PageNum = 3 ;
24
23
base . OnNavigatedTo ( e ) ;
25
24
}
26
25
}
Original file line number Diff line number Diff line change @@ -7,20 +7,19 @@ namespace Flow.Launcher.Resources.Pages
7
7
{
8
8
public partial class WelcomePage4
9
9
{
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 > ( ) ;
12
12
13
13
protected override void OnNavigatedTo ( NavigationEventArgs e )
14
14
{
15
+ // Sometimes the navigation is not triggered by button click,
16
+ // so we need to reset the page number
17
+ _viewModel . PageNum = 4 ;
18
+
15
19
if ( ! IsInitialized )
16
20
{
17
- Settings = Ioc . Default . GetRequiredService < Settings > ( ) ;
18
- _viewModel = Ioc . Default . GetRequiredService < WelcomeViewModel > ( ) ;
19
21
InitializeComponent ( ) ;
20
22
}
21
- // Sometimes the navigation is not triggered by button click,
22
- // so we need to reset the page number
23
- _viewModel . PageNum = 4 ;
24
23
base . OnNavigatedTo ( e ) ;
25
24
}
26
25
}
Original file line number Diff line number Diff line change @@ -10,20 +10,19 @@ namespace Flow.Launcher.Resources.Pages
10
10
{
11
11
public partial class WelcomePage5
12
12
{
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 > ( ) ;
15
15
16
16
protected override void OnNavigatedTo ( NavigationEventArgs e )
17
17
{
18
+ // Sometimes the navigation is not triggered by button click,
19
+ // so we need to reset the page number
20
+ _viewModel . PageNum = 5 ;
21
+
18
22
if ( ! IsInitialized )
19
23
{
20
- Settings = Ioc . Default . GetRequiredService < Settings > ( ) ;
21
- _viewModel = Ioc . Default . GetRequiredService < WelcomeViewModel > ( ) ;
22
24
InitializeComponent ( ) ;
23
25
}
24
- // Sometimes the navigation is not triggered by button click,
25
- // so we need to reset the page number
26
- _viewModel . PageNum = 5 ;
27
26
base . OnNavigatedTo ( e ) ;
28
27
}
29
28
Original file line number Diff line number Diff line change 1
1
using System . Windows . Navigation ;
2
2
using CommunityToolkit . Mvvm . DependencyInjection ;
3
3
using Flow . Launcher . SettingPages . ViewModels ;
4
+ using Flow . Launcher . ViewModel ;
4
5
5
6
namespace Flow . Launcher . SettingPages . Views ;
6
7
7
8
public partial class SettingsPaneAbout
8
9
{
9
10
private SettingsPaneAboutViewModel _viewModel = null ! ;
11
+ private readonly SettingWindowViewModel _settingViewModel = Ioc . Default . GetRequiredService < SettingWindowViewModel > ( ) ;
10
12
11
13
protected override void OnNavigatedTo ( NavigationEventArgs e )
12
14
{
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 )
14
21
{
15
22
_viewModel = Ioc . Default . GetRequiredService < SettingsPaneAboutViewModel > ( ) ;
16
23
DataContext = _viewModel ;
24
+ }
25
+ if ( ! IsInitialized )
26
+ {
17
27
InitializeComponent ( ) ;
18
28
}
19
29
base . OnNavigatedTo ( e ) ;
Original file line number Diff line number Diff line change 1
1
using System . Windows . Navigation ;
2
2
using CommunityToolkit . Mvvm . DependencyInjection ;
3
3
using Flow . Launcher . SettingPages . ViewModels ;
4
+ using Flow . Launcher . ViewModel ;
4
5
5
6
namespace Flow . Launcher . SettingPages . Views ;
6
7
7
8
public partial class SettingsPaneGeneral
8
9
{
9
10
private SettingsPaneGeneralViewModel _viewModel = null ! ;
11
+ private readonly SettingWindowViewModel _settingViewModel = Ioc . Default . GetRequiredService < SettingWindowViewModel > ( ) ;
10
12
11
13
protected override void OnNavigatedTo ( NavigationEventArgs e )
12
14
{
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 )
14
21
{
15
22
_viewModel = Ioc . Default . GetRequiredService < SettingsPaneGeneralViewModel > ( ) ;
16
23
DataContext = _viewModel ;
24
+ }
25
+ if ( ! IsInitialized )
26
+ {
17
27
InitializeComponent ( ) ;
18
28
}
19
29
base . OnNavigatedTo ( e ) ;
Original file line number Diff line number Diff line change 1
1
using System . Windows . Navigation ;
2
2
using CommunityToolkit . Mvvm . DependencyInjection ;
3
3
using Flow . Launcher . SettingPages . ViewModels ;
4
+ using Flow . Launcher . ViewModel ;
4
5
5
6
namespace Flow . Launcher . SettingPages . Views ;
6
7
7
8
public partial class SettingsPaneHotkey
8
9
{
9
10
private SettingsPaneHotkeyViewModel _viewModel = null ! ;
11
+ private readonly SettingWindowViewModel _settingViewModel = Ioc . Default . GetRequiredService < SettingWindowViewModel > ( ) ;
10
12
11
13
protected override void OnNavigatedTo ( NavigationEventArgs e )
12
14
{
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 )
14
21
{
15
22
_viewModel = Ioc . Default . GetRequiredService < SettingsPaneHotkeyViewModel > ( ) ;
16
23
DataContext = _viewModel ;
24
+ }
25
+ if ( ! IsInitialized )
26
+ {
17
27
InitializeComponent ( ) ;
18
28
}
19
29
base . OnNavigatedTo ( e ) ;
Original file line number Diff line number Diff line change @@ -11,13 +11,22 @@ namespace Flow.Launcher.SettingPages.Views;
11
11
public partial class SettingsPanePluginStore
12
12
{
13
13
private SettingsPanePluginStoreViewModel _viewModel = null ! ;
14
+ private readonly SettingWindowViewModel _settingViewModel = Ioc . Default . GetRequiredService < SettingWindowViewModel > ( ) ;
14
15
15
16
protected override void OnNavigatedTo ( NavigationEventArgs e )
16
17
{
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 )
18
24
{
19
25
_viewModel = Ioc . Default . GetRequiredService < SettingsPanePluginStoreViewModel > ( ) ;
20
26
DataContext = _viewModel ;
27
+ }
28
+ if ( ! IsInitialized )
29
+ {
21
30
InitializeComponent ( ) ;
22
31
}
23
32
_viewModel . PropertyChanged += ViewModel_PropertyChanged ;
Original file line number Diff line number Diff line change @@ -11,13 +11,22 @@ namespace Flow.Launcher.SettingPages.Views;
11
11
public partial class SettingsPanePlugins
12
12
{
13
13
private SettingsPanePluginsViewModel _viewModel = null ! ;
14
+ private readonly SettingWindowViewModel _settingViewModel = Ioc . Default . GetRequiredService < SettingWindowViewModel > ( ) ;
14
15
15
16
protected override void OnNavigatedTo ( NavigationEventArgs e )
16
17
{
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 )
18
24
{
19
25
_viewModel = Ioc . Default . GetRequiredService < SettingsPanePluginsViewModel > ( ) ;
20
26
DataContext = _viewModel ;
27
+ }
28
+ if ( ! IsInitialized )
29
+ {
21
30
InitializeComponent ( ) ;
22
31
}
23
32
_viewModel . PropertyChanged += ViewModel_PropertyChanged ;
Original file line number Diff line number Diff line change 1
1
using System . Windows . Navigation ;
2
2
using CommunityToolkit . Mvvm . DependencyInjection ;
3
3
using Flow . Launcher . SettingPages . ViewModels ;
4
+ using Flow . Launcher . ViewModel ;
4
5
5
6
namespace Flow . Launcher . SettingPages . Views ;
6
7
7
8
public partial class SettingsPaneProxy
8
9
{
9
10
private SettingsPaneProxyViewModel _viewModel = null ! ;
11
+ private readonly SettingWindowViewModel _settingViewModel = Ioc . Default . GetRequiredService < SettingWindowViewModel > ( ) ;
10
12
11
13
protected override void OnNavigatedTo ( NavigationEventArgs e )
12
14
{
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 ( SettingsPaneProxy ) ;
18
+
19
+ // If the navigation is not triggered by button click, view model will be null again
20
+ if ( _viewModel == null )
14
21
{
15
22
_viewModel = Ioc . Default . GetRequiredService < SettingsPaneProxyViewModel > ( ) ;
16
23
DataContext = _viewModel ;
24
+ }
25
+ if ( ! IsInitialized )
26
+ {
17
27
InitializeComponent ( ) ;
18
28
}
19
29
base . OnNavigatedTo ( e ) ;
Original file line number Diff line number Diff line change 1
1
using System . Windows . Navigation ;
2
2
using CommunityToolkit . Mvvm . DependencyInjection ;
3
3
using Flow . Launcher . SettingPages . ViewModels ;
4
+ using Flow . Launcher . ViewModel ;
4
5
5
6
namespace Flow . Launcher . SettingPages . Views ;
6
7
7
8
public partial class SettingsPaneTheme
8
9
{
9
10
private SettingsPaneThemeViewModel _viewModel = null ! ;
11
+ private readonly SettingWindowViewModel _settingViewModel = Ioc . Default . GetRequiredService < SettingWindowViewModel > ( ) ;
10
12
11
13
protected override void OnNavigatedTo ( NavigationEventArgs e )
12
14
{
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 ( SettingsPaneTheme ) ;
18
+
19
+ // If the navigation is not triggered by button click, view model will be null again
20
+ if ( _viewModel == null )
14
21
{
15
22
_viewModel = Ioc . Default . GetRequiredService < SettingsPaneThemeViewModel > ( ) ;
16
23
DataContext = _viewModel ;
24
+ }
25
+ if ( ! IsInitialized )
26
+ {
17
27
InitializeComponent ( ) ;
18
28
}
19
29
base . OnNavigatedTo ( e ) ;
You can’t perform that action at this time.
0 commit comments