mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use dependency injection instead of navigation parameter
This commit is contained in:
parent
57f20aeaea
commit
92e6e53ab4
8 changed files with 21 additions and 41 deletions
|
|
@ -445,7 +445,7 @@ namespace Flow.Launcher
|
|||
|
||||
private void OpenWelcomeWindow()
|
||||
{
|
||||
var WelcomeWindow = new WelcomeWindow(_settings);
|
||||
var WelcomeWindow = new WelcomeWindow();
|
||||
WelcomeWindow.Show();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Navigation;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.Core.Resource;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
|
||||
namespace Flow.Launcher.Resources.Pages
|
||||
{
|
||||
|
|
@ -10,10 +10,7 @@ namespace Flow.Launcher.Resources.Pages
|
|||
{
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
if (e.ExtraData is Settings settings)
|
||||
Settings = settings;
|
||||
else
|
||||
throw new ArgumentException("Unexpected Navigation Parameter for Settings");
|
||||
Settings = Ioc.Default.GetRequiredService<Settings>();
|
||||
InitializeComponent();
|
||||
}
|
||||
private Internationalization _translater => InternationalizationManager.Instance;
|
||||
|
|
@ -37,4 +34,4 @@ namespace Flow.Launcher.Resources.Pages
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
using Flow.Launcher.Helper;
|
||||
using Flow.Launcher.Infrastructure.Hotkey;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using System;
|
||||
using System.Windows.Navigation;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Flow.Launcher.ViewModel;
|
||||
using System.Windows.Media;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
|
||||
namespace Flow.Launcher.Resources.Pages
|
||||
{
|
||||
|
|
@ -15,11 +15,7 @@ namespace Flow.Launcher.Resources.Pages
|
|||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
if (e.ExtraData is Settings settings)
|
||||
Settings = settings;
|
||||
else
|
||||
throw new ArgumentException("Unexpected Parameter setting.");
|
||||
|
||||
Settings = Ioc.Default.GetRequiredService<Settings>();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using System;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Navigation;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
|
||||
namespace Flow.Launcher.Resources.Pages
|
||||
|
|
@ -8,10 +8,7 @@ namespace Flow.Launcher.Resources.Pages
|
|||
{
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
if (e.ExtraData is Settings settings)
|
||||
Settings = settings;
|
||||
else if(Settings is null)
|
||||
throw new ArgumentException("Unexpected Navigation Parameter for Settings");
|
||||
Settings = Ioc.Default.GetRequiredService<Settings>();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using System;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace Flow.Launcher.Resources.Pages
|
||||
|
|
@ -8,10 +8,7 @@ namespace Flow.Launcher.Resources.Pages
|
|||
{
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
if (e.ExtraData is Settings settings)
|
||||
Settings = settings;
|
||||
else
|
||||
throw new ArgumentException("Unexpected Navigation Parameter for Settings");
|
||||
Settings = Ioc.Default.GetRequiredService<Settings>();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
using System.Windows.Navigation;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Microsoft.Win32;
|
||||
using Flow.Launcher.Infrastructure;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
|
||||
namespace Flow.Launcher.Resources.Pages
|
||||
{
|
||||
|
|
@ -15,10 +15,7 @@ namespace Flow.Launcher.Resources.Pages
|
|||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
if (e.ExtraData is Settings settings)
|
||||
Settings = settings;
|
||||
else
|
||||
throw new ArgumentException("Unexpected Navigation Parameter for Settings");
|
||||
Settings = Ioc.Default.GetRequiredService<Settings>();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public partial class SettingsPaneAboutViewModel : BaseModel
|
|||
[RelayCommand]
|
||||
private void OpenWelcomeWindow()
|
||||
{
|
||||
var window = new WelcomeWindow(_settings);
|
||||
var window = new WelcomeWindow();
|
||||
window.ShowDialog();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Controls;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.Resources.Pages;
|
||||
using ModernWpf.Media.Animation;
|
||||
|
||||
|
|
@ -10,13 +9,10 @@ namespace Flow.Launcher
|
|||
{
|
||||
public partial class WelcomeWindow : Window
|
||||
{
|
||||
private readonly Settings settings;
|
||||
|
||||
public WelcomeWindow(Settings settings)
|
||||
public WelcomeWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
BackButton.IsEnabled = false;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
private NavigationTransitionInfo _transitionInfo = new SlideNavigationTransitionInfo()
|
||||
|
|
@ -57,7 +53,7 @@ namespace Flow.Launcher
|
|||
pageNum++;
|
||||
UpdateView();
|
||||
|
||||
ContentFrame.Navigate(PageTypeSelector(pageNum), settings, _transitionInfo);
|
||||
ContentFrame.Navigate(PageTypeSelector(pageNum), null, _transitionInfo);
|
||||
}
|
||||
|
||||
private void BackwardButton_Click(object sender, RoutedEventArgs e)
|
||||
|
|
@ -66,7 +62,7 @@ namespace Flow.Launcher
|
|||
{
|
||||
pageNum--;
|
||||
UpdateView();
|
||||
ContentFrame.Navigate(PageTypeSelector(pageNum), settings, _backTransitionInfo);
|
||||
ContentFrame.Navigate(PageTypeSelector(pageNum), null, _backTransitionInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -109,7 +105,7 @@ namespace Flow.Launcher
|
|||
|
||||
private void ContentFrame_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ContentFrame.Navigate(PageTypeSelector(1), settings); /* Set First Page */
|
||||
ContentFrame.Navigate(PageTypeSelector(1)); /* Set First Page */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue