diff --git a/doc/ReleaseNotes/_ReleaseNotes.md b/doc/ReleaseNotes/_ReleaseNotes.md index 114bae0d64f7..7b9bd53149b2 100644 --- a/doc/ReleaseNotes/_ReleaseNotes.md +++ b/doc/ReleaseNotes/_ReleaseNotes.md @@ -3,6 +3,7 @@ ## Next version ### Features +* [#2029](https://github.com/unoplatform/uno/pull/2029) Support for MenuFlyoutItem.Click * support /[file]/[name] format in ResourceLoader.GetForCurrentView().GetString() * [#2039] Added support for Xaml type conversions using CreateFromStringAttribute. * [#] Support for `Windows.Devices.Lights.Lamp` on iOS, Android. diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/UnoSamples_Test_Click.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/UnoSamples_Test_Click.cs new file mode 100644 index 000000000000..4c6b92f87281 --- /dev/null +++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/UnoSamples_Test_Click.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NUnit.Framework; +using SamplesApp.UITests.TestFramework; +using Uno.UITest.Helpers; +using Uno.UITest.Helpers.Queries; + +namespace SamplesApp.UITests.Windows_UI_Xaml_Controls.MenuFlyoutItemTests +{ + [TestFixture] + class UnoSamples_Test_Click: SampleControlUITestBase + { + [Test] + [AutoRetry] + [ActivePlatforms(Platform.Android, Platform.iOS)] + public void MenuFlyoutItem_ClickTest() + { + Run("UITests.Shared.Windows_UI_Xaml_Controls.MenuFlyoutItemTests.MenuFlyoutItem_Click"); + + _app.WaitForElement(_app.Marked("mfiButton")); + + TakeScreenshot("Initial"); + + // step 1: press button to show menu + _app.Tap(_app.Marked("mfiButton")); + + TakeScreenshot("menuShown"); + + // step 2: click MenuFlyoutItem + _app.Tap(_app.Marked("mfiItem")); + + // step 3: check result + _app.WaitForText(_app.Marked("mfiResult"), "success"); + + TakeScreenshot("AfterSuccess"); + } + } +} diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems index 482e339adcfa..a028c8782306 100644 --- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems +++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems @@ -509,6 +509,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -2944,6 +2948,9 @@ RotatedListView_WithRotatedItems.xaml + + MenuFlyoutItem_Click.xaml + Flyout_LargeContent.xaml diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml new file mode 100644 index 000000000000..e8681a64aa56 --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml.cs new file mode 100644 index 000000000000..868cd398705d --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; + +// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 + +namespace UITests.Shared.Windows_UI_Xaml_Controls.MenuFlyoutItemTests +{ + [Uno.UI.Samples.Controls.SampleControlInfo("MenuFlyoutItem", "MenuFlyoutItem_Click", description: "Testing click on MenuFlyoutItem")] + public sealed partial class MenuFlyoutItem_Click : UserControl + { + public MenuFlyoutItem_Click() + { + this.InitializeComponent(); + } + + public void FlyoutItem_Click(object sender, object args) + { + mfiResult.Text = "success"; + } + } +} diff --git a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.Android.cs b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.Android.cs index ca4d53263ced..a67ee165702c 100644 --- a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.Android.cs +++ b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.Android.cs @@ -54,7 +54,7 @@ private void OnMenuItemClick(object sender, PopupMenu.MenuItemClickEventArgs e) var items = Items.OfType().Where(i => i.Visibility == Visibility.Visible).ToArray(); var item = items[e.Item.ItemId]; - item.Command.ExecuteIfPossible(item.CommandParameter); + item.InvokeClick(); } private View GetActualTarget() diff --git a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS7.iOS.cs b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS7.iOS.cs index 951161578da9..acca56f76f66 100644 --- a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS7.iOS.cs +++ b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS7.iOS.cs @@ -40,7 +40,7 @@ private void ShowActionSheet(UIView placementTarget) if (item != null) { - item.Command.ExecuteIfPossible(item.CommandParameter); + item.InvokeClick(); Hide(); } }; diff --git a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS8.iOS.cs b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS8.iOS.cs index 9ff7b2b4c3d0..35877a879dcb 100644 --- a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS8.iOS.cs +++ b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS8.iOS.cs @@ -30,7 +30,7 @@ private void ShowAlert(UIView placementTarget) true == (item.GetValue(IsDestructiveProperty) as bool?) ? UIAlertActionStyle.Destructive : UIAlertActionStyle.Default, _ => { - item.Command.ExecuteIfPossible(item.CommandParameter); + item.InvokeClick(); Hide(); } )) diff --git a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyoutItem.cs b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyoutItem.cs index 45d71c8ce136..30b572d35a72 100644 --- a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyoutItem.cs +++ b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyoutItem.cs @@ -71,7 +71,7 @@ public string Text internal void InvokeClick() { Click?.Invoke(this, new RoutedEventArgs(this)); - Command.ExecuteIfPossible(); + Command.ExecuteIfPossible(this.CommandParameter); } } }