Skip to content

Commit

Permalink
Improve navigation by removing redundant calls
Browse files Browse the repository at this point in the history
  • Loading branch information
sabihoshi committed May 30, 2021
1 parent 2af27d6 commit 235a808
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion GenshinLyreMidiPlayer.WPF/GenshinLyreMidiPlayer.WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<UseWPF>true</UseWPF>
<StartupObject>GenshinLyreMidiPlayer.WPF.App</StartupObject>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Version>2.2.0</Version>
<Version>2.2.0.1</Version>
<ApplicationIcon>item_windsong_lyre.ico</ApplicationIcon>
<Nullable>enable</Nullable>
<RepositoryUrl>https://github.com/sabihoshi/GenshinLyreMidiPlayer</RepositoryUrl>
Expand Down
21 changes: 7 additions & 14 deletions GenshinLyreMidiPlayer.WPF/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ private void AutoSuggestBoxOnTextChanged(AutoSuggestBox sender, AutoSuggestBoxTe

private void NavigateBack(NavigationView sender, NavigationViewBackRequestedEventArgs args)
{
GoBack();

// Work around to select the navigation item that this IScreen is a part of
_history.Pop();
sender.SelectedItem = _history.Pop();
sender.IsBackEnabled = _history.Count > 1;
Expand All @@ -86,22 +83,18 @@ private void NavigateBack(NavigationView sender, NavigationViewBackRequestedEven
private void Navigate(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
{
if (args.IsSettingsSelected)
NavigateToSettings();
Activate(SettingsView);
else if ((args.SelectedItem as NavigationViewItem)?.Tag is IScreen viewModel)
{
ActivateItem(viewModel);
_history.Push((NavigationViewItem) sender.SelectedItem);
}
Activate(viewModel);

sender.IsBackEnabled = _history.Count > 1;
NotifyOfPropertyChange(() => ShowUpdate);
}

public void NavigateToSettings()
{
ActivateItem(SettingsView);
_history.Push((NavigationViewItem) _navView.SettingsItem);
_navView.SelectedItem = _navView.SettingsItem;
void Activate(IScreen viewModel)
{
ActivateItem(viewModel);
_history.Push((NavigationViewItem) sender.SelectedItem);
}
}
}
}

0 comments on commit 235a808

Please sign in to comment.