From 3ef8a0477b671f90ffed70a5a755f3caa65bdcf0 Mon Sep 17 00:00:00 2001 From: Ed Giardina Date: Fri, 1 Mar 2024 19:41:37 -0500 Subject: [PATCH 1/5] Use Delayed Dispatch --- App.xaml.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/App.xaml.cs b/App.xaml.cs index 8b81eea..3cdce04 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -65,7 +65,10 @@ protected override async void OnAppLinkRequestReceived(Uri uri) if (!string.IsNullOrEmpty(id)) { - await Shell.Current.GoToAsync($"//rankings/player-details?playerId={id}"); + Current.Dispatcher.DispatchDelayed(TimeSpan.FromMilliseconds(500), async () => + { + await Shell.Current.GoToAsync($"//rankings/player-details?playerId={id}"); + }); } } //tournaments/view.php?t=46773 @@ -74,7 +77,10 @@ protected override async void OnAppLinkRequestReceived(Uri uri) var id = HttpUtility.ParseQueryString(uri.Query)["t"]; if (!string.IsNullOrEmpty(id)) { - await Shell.Current.GoToAsync($"//rankings/tournament-results?tournamentId={id}"); + Current.Dispatcher.DispatchDelayed(TimeSpan.FromMilliseconds(500), async () => + { + await Shell.Current.GoToAsync($"//rankings/tournament-results?tournamentId={id}"); + }); } } } From 69ac96737870d5ea91a08e0646752b94e9ffb7bc Mon Sep 17 00:00:00 2001 From: Ed Giardina Date: Fri, 1 Mar 2024 21:02:10 -0500 Subject: [PATCH 2/5] Add delay to Dispatch --- App.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/App.xaml.cs b/App.xaml.cs index 3cdce04..cf70c85 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -36,7 +36,7 @@ protected override async void OnStart() public static void HandleAppActions(AppAction appAction) { - App.Current.Dispatcher.Dispatch(async () => + Current.Dispatcher.DispatchDelayed(TimeSpan.FromMilliseconds(500), async () => { await Shell.Current.GoToAsync($"//{appAction.Id}"); }); From dd4597f6c5f0aecfbe91378a2126b9dd9d0a679d Mon Sep 17 00:00:00 2001 From: Ed Giardina Date: Sat, 2 Mar 2024 10:29:17 -0500 Subject: [PATCH 3/5] diasable shell animation --- App.xaml.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/App.xaml.cs b/App.xaml.cs index cf70c85..d4a7145 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -38,7 +38,7 @@ public static void HandleAppActions(AppAction appAction) { Current.Dispatcher.DispatchDelayed(TimeSpan.FromMilliseconds(500), async () => { - await Shell.Current.GoToAsync($"//{appAction.Id}"); + await Shell.Current.GoToAsync($"//{appAction.Id}", false); }); } @@ -67,7 +67,7 @@ protected override async void OnAppLinkRequestReceived(Uri uri) { Current.Dispatcher.DispatchDelayed(TimeSpan.FromMilliseconds(500), async () => { - await Shell.Current.GoToAsync($"//rankings/player-details?playerId={id}"); + await Shell.Current.GoToAsync($"//rankings/player-details?playerId={id}", false); }); } } @@ -79,7 +79,7 @@ protected override async void OnAppLinkRequestReceived(Uri uri) { Current.Dispatcher.DispatchDelayed(TimeSpan.FromMilliseconds(500), async () => { - await Shell.Current.GoToAsync($"//rankings/tournament-results?tournamentId={id}"); + await Shell.Current.GoToAsync($"//rankings/tournament-results?tournamentId={id}", false); }); } } From 468feee59d90e8095b23504df3218e90e125c72a Mon Sep 17 00:00:00 2001 From: Ed Giardina Date: Sat, 2 Mar 2024 10:45:49 -0500 Subject: [PATCH 4/5] correct tab brute force method --- App.xaml.cs | 15 ++++++++++++--- AppShell.xaml | 7 ++++++- AppShell.xaml.cs | 33 +++++++++++++++++++++++++++++---- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/App.xaml.cs b/App.xaml.cs index d4a7145..3a881c0 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -36,9 +36,12 @@ protected override async void OnStart() public static void HandleAppActions(AppAction appAction) { + var route = $"//{appAction.Id}"; + Current.Dispatcher.DispatchDelayed(TimeSpan.FromMilliseconds(500), async () => { - await Shell.Current.GoToAsync($"//{appAction.Id}", false); + await Shell.Current.GoToAsync(route); + ((AppShell)Shell.Current).ConfirmSelectedTabIsCorrect(route); }); } @@ -65,9 +68,12 @@ protected override async void OnAppLinkRequestReceived(Uri uri) if (!string.IsNullOrEmpty(id)) { + var route = $"//rankings/player-details?playerId={id}"; + Current.Dispatcher.DispatchDelayed(TimeSpan.FromMilliseconds(500), async () => { - await Shell.Current.GoToAsync($"//rankings/player-details?playerId={id}", false); + await Shell.Current.GoToAsync(route); + ((AppShell)Shell.Current).ConfirmSelectedTabIsCorrect(route); }); } } @@ -77,9 +83,12 @@ protected override async void OnAppLinkRequestReceived(Uri uri) var id = HttpUtility.ParseQueryString(uri.Query)["t"]; if (!string.IsNullOrEmpty(id)) { + var route = $"//rankings/tournament-results?tournamentId={id}"; + Current.Dispatcher.DispatchDelayed(TimeSpan.FromMilliseconds(500), async () => { - await Shell.Current.GoToAsync($"//rankings/tournament-results?tournamentId={id}", false); + await Shell.Current.GoToAsync(route); + ((AppShell)Shell.Current).ConfirmSelectedTabIsCorrect(route); }); } } diff --git a/AppShell.xaml b/AppShell.xaml index 9a47707..575d708 100644 --- a/AppShell.xaml +++ b/AppShell.xaml @@ -5,25 +5,30 @@ xmlns:local="clr-namespace:Ifpa" xmlns:views="clr-namespace:Ifpa.Views" Shell.FlyoutBehavior="Disabled"> - + diff --git a/AppShell.xaml.cs b/AppShell.xaml.cs index b5cf7f5..ec76b5f 100644 --- a/AppShell.xaml.cs +++ b/AppShell.xaml.cs @@ -6,9 +6,9 @@ namespace Ifpa; public partial class AppShell : Shell { - public AppShell() - { - InitializeComponent(); + public AppShell() + { + InitializeComponent(); Routing.RegisterRoute("rankings-filter", typeof(RankingsFilterModalPage)); Routing.RegisterRoute("player-search", typeof(PlayerSearchPage)); @@ -16,7 +16,7 @@ public AppShell() Routing.RegisterRoute("player-results", typeof(PlayerResultsPage)); Routing.RegisterRoute("activity-feed", typeof(ActivityFeedPage)); Routing.RegisterRoute("pvp", typeof(PlayerVersusPlayerPage)); - Routing.RegisterRoute("pvp-detail", typeof(PlayerVersusPlayerDetailPage)); + Routing.RegisterRoute("pvp-detail", typeof(PlayerVersusPlayerDetailPage)); Routing.RegisterRoute("tournament-results", typeof(TournamentResultsPage)); Routing.RegisterRoute("player-champ-series", typeof(PlayerChampionshipSeriesPage)); @@ -66,4 +66,29 @@ protected override async void OnNavigating(ShellNavigatingEventArgs args) token?.Complete(); } + // TODO: this is a hack to get the correct tab to show when navigating to a page + // https://github.com/dotnet/maui/issues/16568 + public void ConfirmSelectedTabIsCorrect(string route) + { + if (route.Contains("rankings")) + { + MainTabBar.CurrentItem = RankingsTab; + } + else if (route.Contains("champ-series-list")) + { + MainTabBar.CurrentItem = ChampionshipSeriesTab; + } + else if (route.Contains("calendar")) + { + MainTabBar.CurrentItem = CalendarTab; + } + else if (route.Contains("my-stats")) + { + MainTabBar.CurrentItem = MyStatsTab; + } + else if (route.Contains("more")) + { + MainTabBar.CurrentItem = MoreTab; + } + } } From b3dd928763a47472507ac68182dcc0e49cfe6311 Mon Sep 17 00:00:00 2001 From: Ed Giardina Date: Sat, 2 Mar 2024 12:11:56 -0500 Subject: [PATCH 5/5] Manual delay --- App.xaml.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/App.xaml.cs b/App.xaml.cs index 3a881c0..4793903 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -34,15 +34,16 @@ protected override async void OnStart() await NotificationManager.RequestAccess(); } - public static void HandleAppActions(AppAction appAction) + public static async void HandleAppActions(AppAction appAction) { var route = $"//{appAction.Id}"; Current.Dispatcher.DispatchDelayed(TimeSpan.FromMilliseconds(500), async () => { await Shell.Current.GoToAsync(route); - ((AppShell)Shell.Current).ConfirmSelectedTabIsCorrect(route); }); + await Task.Delay(500); + ((AppShell)Shell.Current).ConfirmSelectedTabIsCorrect(route); } //Some places we can't Dependency Inject so we add this static helper @@ -72,9 +73,10 @@ protected override async void OnAppLinkRequestReceived(Uri uri) Current.Dispatcher.DispatchDelayed(TimeSpan.FromMilliseconds(500), async () => { - await Shell.Current.GoToAsync(route); - ((AppShell)Shell.Current).ConfirmSelectedTabIsCorrect(route); + await Shell.Current.GoToAsync(route); }); + await Task.Delay(500); + ((AppShell)Shell.Current).ConfirmSelectedTabIsCorrect(route); } } //tournaments/view.php?t=46773 @@ -88,8 +90,9 @@ protected override async void OnAppLinkRequestReceived(Uri uri) Current.Dispatcher.DispatchDelayed(TimeSpan.FromMilliseconds(500), async () => { await Shell.Current.GoToAsync(route); - ((AppShell)Shell.Current).ConfirmSelectedTabIsCorrect(route); }); + await Task.Delay(500); + ((AppShell)Shell.Current).ConfirmSelectedTabIsCorrect(route); } } }