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.
[GH-12429] Fixed extra height on Shell Flyout and fix issues with fly…
…out items not updating layout (#12967) fixes #12429 fixes #12785 * Fixed extra height and added sample page * - fix some dynamic layouts * - fix android to resize * - get rid of cell reuse, allow buttons inside template, let cells resize dynamically * - Add UITests - Fix Android Measuring * - remove comments * - fix UWP Measuring * - Fix Automation Id to use Bindings on uwp * - fix language and iOS test * - cleanup * - fix iOS margin issue * - fix iOS type Co-authored-by: shane <shneuvil@microsoft.com> Co-authored-by: Javier Suárez <javiersuarezruiz@hotmail.com>
- Loading branch information
1 parent
4d4679a
commit acb4af5
Showing
14 changed files
with
414 additions
and
80 deletions.
There are no files selected for viewing
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
63 changes: 63 additions & 0 deletions
63
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12429.xaml
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,63 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<controls:TestShell | ||
x:Class="Xamarin.Forms.Controls.Issues.Issue12429" | ||
xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:controls="clr-namespace:Xamarin.Forms.Controls" | ||
xmlns:local="clr-namespace:Xamarin.Forms.Controls.Issues"> | ||
<FlyoutItem> | ||
<Shell.ItemTemplate> | ||
<DataTemplate> | ||
<StackLayout Orientation="Horizontal" AutomationId="SmallFlyoutItem" Spacing="0" HeightRequest="{Binding BindingContext.SmallFlyoutItem}" BackgroundColor="LightBlue" > | ||
<Label Text="I'm set to specific height: " TextColor="White" /> | ||
<Label Text="{Binding BindingContext.SmallFlyoutItem}" TextColor="White" /> | ||
</StackLayout> | ||
</DataTemplate> | ||
</Shell.ItemTemplate> | ||
<ShellContent> | ||
<local:Issue12429Page /> | ||
</ShellContent> | ||
</FlyoutItem> | ||
<FlyoutItem> | ||
<Shell.ItemTemplate> | ||
<DataTemplate> | ||
<StackLayout IsVisible="False" BackgroundColor="Black" > | ||
<Label Text="Not Visible" /> | ||
</StackLayout> | ||
</DataTemplate> | ||
</Shell.ItemTemplate> | ||
<ShellContent> | ||
<local:Issue12429Page /> | ||
</ShellContent> | ||
</FlyoutItem> | ||
<FlyoutItem> | ||
<Shell.ItemTemplate> | ||
<DataTemplate> | ||
<StackLayout BackgroundColor="Purple"> | ||
<Label Text="I'm sized to my layout" /> | ||
</StackLayout> | ||
</DataTemplate> | ||
</Shell.ItemTemplate> | ||
<ShellContent> | ||
<local:Issue12429Page /> | ||
</ShellContent> | ||
</FlyoutItem> | ||
<FlyoutItem> | ||
<Shell.ItemTemplate> | ||
<DataTemplate> | ||
<StackLayout AutomationId="ResizeMe" BackgroundColor="LightGray" HeightRequest="120"> | ||
<Button AutomationId="ResizeFlyoutItem" Text="Grow Me" Clicked="ResizeFlyoutItem" /> | ||
<Button AutomationId="ResizeFlyoutItemDown" Text="Shrink Me" Clicked="ResizeFlyoutItemDown" /> | ||
</StackLayout> | ||
</DataTemplate> | ||
</Shell.ItemTemplate> | ||
<ShellContent> | ||
<local:Issue12429Page /> | ||
</ShellContent> | ||
</FlyoutItem> | ||
<FlyoutItem Title="Default Flyout Item. Height is 44 on iOS and UWP. Height is 50 on Android)"> | ||
<ShellContent> | ||
<local:Issue12429Page /> | ||
</ShellContent> | ||
</FlyoutItem> | ||
</controls:TestShell> |
150 changes: 150 additions & 0 deletions
150
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12429.xaml.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,150 @@ | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
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, 12429, "[Bug] Shell flyout items have a minimum height", PlatformAffected.iOS)] | ||
#if UITEST | ||
[NUnit.Framework.Category(UITestCategories.Shell)] | ||
#endif | ||
public partial class Issue12429 : TestShell | ||
{ | ||
public double SmallFlyoutItem { get; } | ||
public double SizeToModifyBy { get; } | ||
|
||
public Issue12429() | ||
{ | ||
SmallFlyoutItem = 35d; | ||
SizeToModifyBy = 20d; | ||
|
||
#if APP | ||
InitializeComponent(); | ||
|
||
|
||
if (Device.RuntimePlatform == Device.Android) | ||
SmallFlyoutItem = SmallFlyoutItem / Device.info.ScalingFactor; | ||
|
||
if (Device.RuntimePlatform == Device.Android) | ||
SizeToModifyBy = SizeToModifyBy / Device.info.ScalingFactor; | ||
#endif | ||
|
||
|
||
this.BindingContext = this; | ||
} | ||
|
||
protected override void Init() | ||
{ | ||
} | ||
|
||
void ResizeFlyoutItem(System.Object sender, System.EventArgs e) | ||
{ | ||
((sender as Element).Parent as VisualElement).HeightRequest += SizeToModifyBy; | ||
} | ||
|
||
void ResizeFlyoutItemDown(System.Object sender, System.EventArgs e) | ||
{ | ||
((sender as Element).Parent as VisualElement).HeightRequest -= SizeToModifyBy; | ||
} | ||
|
||
#if UITEST | ||
[Test] | ||
public void FlyoutItemSizesToExplicitHeight() | ||
{ | ||
RunningApp.WaitForElement("PageLoaded"); | ||
this.ShowFlyout(); | ||
var height = RunningApp.WaitForElement("SmallFlyoutItem")[0].Rect.Height; | ||
Assert.That(height, Is.EqualTo(SmallFlyoutItem).Within(1)); | ||
} | ||
|
||
|
||
[Test] | ||
public void FlyoutItemHeightAndWidthIncreaseAndDecreaseCorrectly() | ||
{ | ||
RunningApp.WaitForElement("PageLoaded"); | ||
this.ShowFlyout(); | ||
var initialHeight = RunningApp.WaitForElement("ResizeMe")[0].Rect.Height; | ||
|
||
TapInFlyout("ResizeFlyoutItem", makeSureFlyoutStaysOpen: true); | ||
var newHeight = RunningApp.WaitForElement("ResizeMe")[0].Rect.Height; | ||
Assert.That(newHeight - initialHeight, Is.EqualTo(SizeToModifyBy).Within(1)); | ||
|
||
TapInFlyout("ResizeFlyoutItemDown", makeSureFlyoutStaysOpen: true); | ||
newHeight = RunningApp.WaitForElement("ResizeMe")[0].Rect.Height; | ||
Assert.That(initialHeight, Is.EqualTo(newHeight).Within(1)); | ||
|
||
TapInFlyout("ResizeFlyoutItemDown", makeSureFlyoutStaysOpen: true); | ||
newHeight = RunningApp.WaitForElement("ResizeMe")[0].Rect.Height; | ||
Assert.That(initialHeight - newHeight, Is.EqualTo(SizeToModifyBy).Within(1)); | ||
|
||
} | ||
#endif | ||
|
||
} | ||
|
||
|
||
[Preserve(AllMembers = true)] | ||
public class Issue12429Page : ContentPage | ||
{ | ||
public Issue12429Page() | ||
{ | ||
Background = SolidColorBrush.White; | ||
var label = new Label | ||
{ | ||
Text = "Flyout Item 1: Explicit Height of 35, Flyout Item 2: will grow and shrink when you click the buttons, Flyout Item 3: doesn't exist, and Flyout Item 4: uses the default platform sizes.", | ||
VerticalTextAlignment = TextAlignment.Center, | ||
TextColor = Color.Black, | ||
AutomationId = "PageLoaded" | ||
}; | ||
|
||
Content = new StackLayout() | ||
{ | ||
Children = | ||
{ | ||
new Label | ||
{ | ||
Text = "Flyout Item 1: Explicit Height of 35.", | ||
VerticalTextAlignment = TextAlignment.Center, | ||
TextColor = Color.Black, | ||
AutomationId = "PageLoaded" | ||
}, | ||
new Label | ||
{ | ||
Text = "Flyout Item 2: Height sizes to the content.", | ||
VerticalTextAlignment = TextAlignment.Center, | ||
TextColor = Color.Black | ||
}, | ||
new Label | ||
{ | ||
Text = "Flyout Item 3: will grow and shrink when you click the buttons.", | ||
VerticalTextAlignment = TextAlignment.Center, | ||
TextColor = Color.Black | ||
}, | ||
new Label | ||
{ | ||
Text = "Flyout Item 4: doesn't exist. You should only see 4 Flyout Items", | ||
VerticalTextAlignment = TextAlignment.Center, | ||
TextColor = Color.Black | ||
}, | ||
new Label | ||
{ | ||
Text = "Flyout Item 5: uses the default height if no templates are used.", | ||
VerticalTextAlignment = TextAlignment.Center, | ||
TextColor = Color.Black | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
|
||
} |
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.