-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS][Shell] Fix navigation lifecycle and back button for More tab (>5 tabs) #27932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| namespace Maui.Controls.Sample.Issues | ||
| { | ||
|
|
||
| [Issue(IssueTracker.Github, 27799, "[iOS] OnAppearing and OnNavigatedTo does not work when using extended Tabbar", PlatformAffected.iOS)] | ||
|
|
||
| public class Issue27799 : TestShell | ||
| { | ||
| private static int _onNavigatedToCount = 0; | ||
| private static int _onAppearingCount = 0; | ||
|
|
||
| protected override void Init() | ||
| { | ||
| Routing.RegisterRoute(nameof(Tab6Subpage), typeof(Tab6Subpage)); | ||
| AddBottomTab("tab1"); | ||
| AddBottomTab(new Tab2(), "tab2"); | ||
| AddBottomTab("tab3"); | ||
| AddBottomTab("tab4"); | ||
| AddBottomTab("tab5"); | ||
| AddBottomTab(new Tab6(), "Tab6"); | ||
| } | ||
|
|
||
| class Tab2 : ContentPage | ||
| { | ||
| Label _onNavigatedToCountLabel; | ||
| Label _onAppearingCountLabel; | ||
| public Tab2() | ||
| { | ||
| _onNavigatedToCountLabel = new Label { AutomationId = "OnNavigatedToCountLabel", Text = $"OnNavigatedTo: {_onNavigatedToCount}" }; | ||
| _onAppearingCountLabel = new Label { AutomationId = "OnAppearingCountLabel", Text = $"OnAppearing: {_onAppearingCount}" }; | ||
| Content = new StackLayout | ||
| { | ||
| Children = | ||
| { | ||
| _onNavigatedToCountLabel, | ||
| _onAppearingCountLabel | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| protected override void OnNavigatedTo(NavigatedToEventArgs e) | ||
| { | ||
| _onNavigatedToCount++; | ||
| _onNavigatedToCountLabel.Text = $"OnNavigatedTo: {_onNavigatedToCount}"; | ||
| } | ||
|
|
||
| protected override void OnAppearing() | ||
| { | ||
| _onAppearingCount++; | ||
| _onAppearingCountLabel.Text = $"OnAppearing: {_onAppearingCount}"; | ||
| } | ||
| } | ||
|
|
||
| class Tab6 : ContentPage | ||
| { | ||
| public Tab6() | ||
| { | ||
| Content = new Button | ||
| { | ||
| Text = "Go to subpage6", | ||
| AutomationId = "GoToSubpage6Button", | ||
| Command = new Command(async () => await Current.GoToAsync(nameof(Tab6Subpage))) | ||
| }; | ||
| } | ||
| protected override void OnNavigatedTo(NavigatedToEventArgs e) => _onNavigatedToCount++; | ||
| protected override void OnAppearing() => _onAppearingCount++; | ||
| } | ||
|
|
||
| class Tab6Subpage : ContentPage | ||
| { | ||
| protected override void OnNavigatedTo(NavigatedToEventArgs e) => _onNavigatedToCount++; | ||
| protected override void OnAppearing() => _onAppearingCount++; | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #if ANDROID || IOS | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 27800, "Shell.BackButtonBehavior does not work when using extended Tabbar", PlatformAffected.iOS)] | ||
| public class Issue27800 : TestShell | ||
| { | ||
|
|
||
| protected override void Init() | ||
| { | ||
| Routing.RegisterRoute(nameof(Tab6DetailPage), typeof(Tab6DetailPage)); | ||
| AddBottomTab("tab1"); | ||
| AddBottomTab("tab2"); | ||
| AddBottomTab("tab3"); | ||
| AddBottomTab("tab4"); | ||
| AddBottomTab("tab5"); | ||
| AddBottomTab(new Tab6(), "tab6"); | ||
| } | ||
|
|
||
| class Tab6 : ContentPage | ||
| { | ||
| Label _onNavigatedToCountLabel; | ||
| Label _onAppearingCountLabel; | ||
| int _onNavigatedToCount; | ||
| int _onAppearingCount; | ||
|
|
||
| public Tab6() | ||
| { | ||
| _onNavigatedToCountLabel = new Label { AutomationId = "OnNavigatedToCountLabel", Text = $"OnNavigatedTo: {_onNavigatedToCount}" }; | ||
| _onAppearingCountLabel = new Label { AutomationId = "OnAppearingCountLabel", Text = $"OnAppearing: {_onAppearingCount}" }; | ||
| Content = new StackLayout | ||
| { | ||
| Children = | ||
| { | ||
| _onNavigatedToCountLabel, | ||
| _onAppearingCountLabel, | ||
| new Button | ||
| { | ||
| AutomationId = "button", | ||
| Text = "Tap to navigate to a detail page", | ||
| Command = new Command(() => Shell.Current.GoToAsync(nameof(Tab6DetailPage))) | ||
| } | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| protected override void OnNavigatedTo(NavigatedToEventArgs e) | ||
| { | ||
| _onNavigatedToCount++; | ||
| _onNavigatedToCountLabel.Text = $"OnNavigatedTo: {_onNavigatedToCount}"; | ||
| } | ||
|
|
||
| protected override void OnAppearing() | ||
| { | ||
| _onAppearingCount++; | ||
| _onAppearingCountLabel.Text = $"OnAppearing: {_onAppearingCount}"; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| class Tab6DetailPage : ContentPage | ||
| { | ||
| public Tab6DetailPage() | ||
| { | ||
| Shell.SetBackButtonBehavior(this, new BackButtonBehavior | ||
| { | ||
| TextOverride = "Go Back", | ||
| Command = new Command(() => Shell.Current.GoToAsync("..")) | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| #endif |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,37 @@ | ||||||||||||||
| #if IOS // Navigation from the more page is iOS specific | ||||||||||||||
| using NUnit.Framework; | ||||||||||||||
| using NUnit.Framework.Legacy; | ||||||||||||||
| using UITest.Appium; | ||||||||||||||
| using UITest.Core; | ||||||||||||||
|
|
||||||||||||||
| namespace Microsoft.Maui.TestCases.Tests.Issues | ||||||||||||||
| { | ||||||||||||||
| public class Issue27799 : _IssuesUITest | ||||||||||||||
| { | ||||||||||||||
| public Issue27799(TestDevice testDevice) : base(testDevice) | ||||||||||||||
|
Comment on lines
+9
to
+11
|
||||||||||||||
| public class Issue27799 : _IssuesUITest | |
| { | |
| public Issue27799(TestDevice testDevice) : base(testDevice) | |
| public class Issue27999 : _IssuesUITest | |
| { | |
| public Issue27999(TestDevice testDevice) : base(testDevice) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #if IOS // Navigation from the more page is iOS specific | ||
| using NUnit.Framework; | ||
| using NUnit.Framework.Legacy; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues | ||
| { | ||
| public class Issue27800 : _IssuesUITest | ||
| { | ||
| public Issue27800(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "Shell.BackButtonBehavior does not work when using extended Tabbar"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Shell)] | ||
| public void ShellBackButtonBehaviorShouldWorkWithMoreTab() | ||
| { | ||
| App.WaitForElement("More"); | ||
| App.Click("More"); | ||
| App.WaitForElement("tab6"); | ||
| App.Click("tab6"); | ||
| App.WaitForElement("button"); | ||
| App.Click("button"); | ||
| App.WaitForElement("Go Back"); | ||
| App.Click("Go Back"); | ||
| App.WaitForElement("OnNavigatedToCountLabel"); | ||
| var onNavigatedToCountLabel = App.FindElement("OnNavigatedToCountLabel").GetText(); | ||
| var onAppearingCountLabel = App.FindElement("OnAppearingCountLabel").GetText(); | ||
|
|
||
| ClassicAssert.AreEqual("OnNavigatedTo: 2", onNavigatedToCountLabel); | ||
| ClassicAssert.AreEqual("OnAppearing: 2", onAppearingCountLabel); | ||
| } | ||
| } | ||
| } | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The filename is
Issue27999.csbut the class name and Issue attribute reference issue #27799. The filename should beIssue27799.csto match the issue number being tested.