This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new xplat event to to propagate FlyoutItemsChanged events to the …
…platforms (#13195) fixes #11214 * Add new xplat event to update FlyoutItems from * - always send flyout item changes * - fix flyout changed propagation * - add additional scenario for Sending Flyout Items Changed Event
- Loading branch information
Showing
11 changed files
with
197 additions
and
23 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue11214.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Text; | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
|
||
|
||
#if UITEST | ||
using Xamarin.UITest; | ||
using NUnit.Framework; | ||
using Xamarin.Forms.Core.UITests; | ||
#endif | ||
|
||
namespace Xamarin.Forms.Controls.Issues | ||
{ | ||
[Preserve(AllMembers = true)] | ||
[Issue(IssueTracker.Github, 11214, "When adding FlyoutItems during Navigating only first one is shown", | ||
PlatformAffected.iOS)] | ||
#if UITEST | ||
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github10000)] | ||
[NUnit.Framework.Category(UITestCategories.Shell)] | ||
#endif | ||
public class Issue11214 : TestShell | ||
{ | ||
FlyoutItem _itemexpanderItems; | ||
protected override void Init() | ||
{ | ||
_itemexpanderItems = new FlyoutItem() | ||
{ | ||
Title = "Expando Magic", | ||
FlyoutDisplayOptions = FlyoutDisplayOptions.AsMultipleItems | ||
}; | ||
|
||
ContentPage contentPage = new ContentPage() | ||
{ | ||
Content = new StackLayout() | ||
{ | ||
Children = | ||
{ | ||
new Label() | ||
{ | ||
Text = "Open the Flyout", | ||
AutomationId = "PageLoaded" | ||
} | ||
} | ||
} | ||
}; | ||
|
||
AddFlyoutItem(contentPage, "Top Item"); | ||
|
||
var flyoutItem = AddFlyoutItem("Click Me and You Should see 2 Items show up"); | ||
flyoutItem.Route = "ExpandMe"; | ||
flyoutItem.AutomationId = "ExpandMe"; | ||
Items.Add(_itemexpanderItems); | ||
} | ||
|
||
protected override void OnNavigating(ShellNavigatingEventArgs args) | ||
{ | ||
base.OnNavigating(args); | ||
|
||
if(!args.Target.FullLocation.ToString().Contains("ExpandMe")) | ||
{ | ||
return; | ||
} | ||
|
||
args.Cancel(); | ||
|
||
if (_itemexpanderItems.Items.Count == 0 || | ||
_itemexpanderItems.Items[0].Items.Count == 0) | ||
{ | ||
for (int i = 0; i < 2; i++) | ||
{ | ||
_itemexpanderItems.Items.Add(new ShellContent() | ||
{ | ||
Title = $"Some Item: {i}", | ||
Content = new ContentPage() | ||
}); | ||
} | ||
} | ||
else | ||
{ | ||
_itemexpanderItems.Items.Clear(); | ||
} | ||
} | ||
|
||
#if UITEST | ||
[Test] | ||
public void FlyoutItemChangesPropagateCorrectlyToPlatformForShellElementsNotCurrentlyActive() | ||
{ | ||
RunningApp.WaitForElement("PageLoaded"); | ||
TapInFlyout("ExpandMe", makeSureFlyoutStaysOpen: true); | ||
|
||
for (int i = 0; i < 2; i++) | ||
RunningApp.WaitForElement($"Some Item: {i}"); | ||
|
||
TapInFlyout("ExpandMe", makeSureFlyoutStaysOpen: true); | ||
|
||
for (int i = 0; i < 2; i++) | ||
RunningApp.WaitForNoElement($"Some Item: {i}"); | ||
} | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.