@@ -150,6 +150,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
150
150
Automation::AutomationProperties::SetHelpText (OpenJsonNavItem (), RS_ (L" Nav_OpenJSON/[using:Windows.UI.Xaml.Controls]ToolTipService/ToolTip" ));
151
151
152
152
_breadcrumbs = single_threaded_observable_vector<IInspectable>();
153
+
154
+ contentFrame ().Navigated ({ this , &MainPage::_OnNavigated });
153
155
}
154
156
155
157
// Method Description:
@@ -683,33 +685,68 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
683
685
_settingsClone.WriteSettingsToDisk ();
684
686
}
685
687
688
+ void MainPage::BackButton_Click (winrt::Microsoft::UI::Xaml::Controls::NavigationView const & /* args*/ , winrt::Microsoft::UI::Xaml::Controls::NavigationViewBackRequestedEventArgs const & /* sender*/ )
689
+ {
690
+ if (!contentFrame ().CanGoBack ())
691
+ {
692
+ return ;
693
+ }
694
+ const auto backStack = contentFrame ().BackStack ();
695
+ const auto previousFrame = backStack.GetAt (backStack.Size () - 1 );
696
+ backStack.RemoveAt (backStack.Size () - 1 ); // 'simulate' navigating back (we need to manually do this so we can reuse the breadcrumbs logic)
697
+ if (_breadcrumbs.Size () > 1 )
698
+ { // Navigate Via Breadcrumbs
699
+ _NavigatePreviousPageForBreadcrumb (_breadcrumbs.GetAt (_breadcrumbs.Size () - 2 ).try_as <Breadcrumb>());
700
+ return ;
701
+ }
702
+ /* const auto param = previousFrame.Parameter().as <IPropertyValue>();
703
+ if (const auto g = param.try_as<Editor::GlobalAppearance>())
704
+ {
705
+ }
706
+ else if (const auto z = param.try_as<Editor::)*/
707
+ // TODO: get navString via tag? (i cant get the tag)...
708
+ // _Navigate(*navString, BreadcrumbSubPage::None);
709
+ // contentFrame().GoBack() -> Works but this wont achieve desired result with breadcrumbs being up to date
710
+ }
711
+
686
712
void MainPage::ResetButton_Click (const IInspectable& /* sender*/ , const RoutedEventArgs& /* args*/ )
687
713
{
688
714
UpdateSettings (_settingsSource);
689
715
}
690
716
717
+ void MainPage::_NavigatePreviousPageForBreadcrumb (const winrt::impl::com_ref<Breadcrumb>& breadcrumb)
718
+ {
719
+ const auto tag = breadcrumb->Tag ();
720
+ const auto subPage = breadcrumb->SubPage ();
721
+ if (const auto profileViewModel = tag.try_as <ProfileViewModel>())
722
+ {
723
+ _Navigate (*profileViewModel, subPage);
724
+ }
725
+ else if (const auto ntmEntryViewModel = tag.try_as <NewTabMenuEntryViewModel>())
726
+ {
727
+ _Navigate (*ntmEntryViewModel, subPage);
728
+ }
729
+ else if (const auto extPkgViewModel = tag.try_as <ExtensionPackageViewModel>())
730
+ {
731
+ _Navigate (*extPkgViewModel, subPage);
732
+ }
733
+ else
734
+ {
735
+ _Navigate (tag.as <hstring>(), subPage);
736
+ }
737
+ }
738
+
739
+ void MainPage::_OnNavigated (const IInspectable& /* sender*/ , const Windows::UI::Xaml::Navigation::INavigationEventArgs& /* args*/ )
740
+ {
741
+ const auto settingsNav = SettingsNav ();
742
+ settingsNav.IsBackEnabled (contentFrame ().CanGoBack ());
743
+ }
744
+
691
745
void MainPage::BreadcrumbBar_ItemClicked (const Microsoft::UI::Xaml::Controls::BreadcrumbBar& /* sender*/ , const Microsoft::UI::Xaml::Controls::BreadcrumbBarItemClickedEventArgs& args)
692
746
{
693
747
if (gsl::narrow_cast<uint32_t >(args.Index ()) < (_breadcrumbs.Size () - 1 ))
694
748
{
695
- const auto tag = args.Item ().as <Breadcrumb>()->Tag ();
696
- const auto subPage = args.Item ().as <Breadcrumb>()->SubPage ();
697
- if (const auto profileViewModel = tag.try_as <ProfileViewModel>())
698
- {
699
- _Navigate (*profileViewModel, subPage);
700
- }
701
- else if (const auto ntmEntryViewModel = tag.try_as <NewTabMenuEntryViewModel>())
702
- {
703
- _Navigate (*ntmEntryViewModel, subPage);
704
- }
705
- else if (const auto extPkgViewModel = tag.try_as <ExtensionPackageViewModel>())
706
- {
707
- _Navigate (*extPkgViewModel, subPage);
708
- }
709
- else
710
- {
711
- _Navigate (tag.as <hstring>(), subPage);
712
- }
749
+ _NavigatePreviousPageForBreadcrumb (args.Item ().as <Breadcrumb>());
713
750
}
714
751
}
715
752
0 commit comments