diff options
author | Samantha Houts <samantha@teamredwall.com> | 2017-01-12 11:48:30 -0800 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2017-01-12 11:48:30 -0800 |
commit | 3af99cbbe145a876cc9839af0adead83695b5445 (patch) | |
tree | a94639d66151591abac7ecc356cf947e12c8f4a2 /Xamarin.Forms.Controls.Issues | |
parent | e7a7a57e4b2f7db71137e702be2663cf4f37d1b4 (diff) | |
download | xamarin-forms-3af99cbbe145a876cc9839af0adead83695b5445.tar.gz xamarin-forms-3af99cbbe145a876cc9839af0adead83695b5445.tar.bz2 xamarin-forms-3af99cbbe145a876cc9839af0adead83695b5445.zip |
[iOS] Labels with WordWrap or CharacterWrap will Expand (#529)
* Add reproduction for 28650
* [iOS] Expand the label to fill width if wrapping
Also, simplify the `if` statement, since `LineBreakMode` is not a flags
enum and the only excluded member was `None`.
* Test two small labels next to each other in horizontal layout
Diffstat (limited to 'Xamarin.Forms.Controls.Issues')
2 files changed, 166 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla28650.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla28650.cs new file mode 100644 index 00000000..6415d902 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla28650.cs @@ -0,0 +1,165 @@ +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; +using System.Collections.Generic; +using System; +using System.Threading.Tasks; + +#if UITEST +using Xamarin.UITest; +using NUnit.Framework; +#endif + +namespace Xamarin.Forms.Controls +{ + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Bugzilla, 928650, "In a Listview on iOS, \"andExpand\" does not expand when text is two lines long")] + public class Bugzilla28650 : TestContentPage + { + const string caret_image = "caret_r.png"; + + [Preserve(AllMembers = true)] + internal class MyTextCell : ViewCell + { + StackLayout _viewLayout; + Label _descriptionLabel; + Image _caret; + + public MyTextCell() + { + _descriptionLabel = new Label + { + HorizontalOptions = LayoutOptions.FillAndExpand, + FontSize = 14, + }; + _descriptionLabel.SetBinding(Label.TextProperty, "."); + + _caret = new Image + { + HorizontalOptions = LayoutOptions.End, + Source = ImageSource.FromFile(caret_image), + HeightRequest = 20, + Aspect = Aspect.AspectFit, + BackgroundColor = Color.Green + }; + + _viewLayout = new StackLayout + { + Orientation = StackOrientation.Horizontal, + HorizontalOptions = LayoutOptions.FillAndExpand, + Children = { _descriptionLabel, _caret }, + }; + + View = _viewLayout; + } + } + + protected override void Init() + { + var items = new List<string> + { + "Short Desc", + "Thisis averylong description withwords thatarelong", + "Item Three", + "Item Four", + "Short Desc again", + }; + + var cell = new DataTemplate(typeof(MyTextCell)); + var menuView = new ListView + { + ItemTemplate = cell, + ItemsSource = items, + HasUnevenRows = true + }; + + // let's try the same configuration outside of a ListView + var grid = new Grid(); + grid.ColumnDefinitions.Add(new ColumnDefinition { Width = 300 }); + + const int column = 0; + int currentRow = 0; + grid.AddChild(new Label { Text = "If the carets do not ALL align, this test has failed." }, column, currentRow++, columnspan: 2); + grid.AddChild(menuView, column, currentRow++); + grid.AddChild(GetStackLayout("Thisis averylong description withwords thatarelong", LineBreakMode.NoWrap), column, currentRow++); + grid.AddChild(GetStackLayout("Thisis averylong description withwords thatarelong", LineBreakMode.CharacterWrap), column, currentRow++); + grid.AddChild(GetStackLayout("Thisis averylong description withwords thatarelong", LineBreakMode.HeadTruncation), column, currentRow++); + grid.AddChild(GetStackLayout("Thisis averylong description withwords thatarelong", LineBreakMode.MiddleTruncation), column, currentRow++); + grid.AddChild(GetStackLayout("Thisis averylong description withwords thatarelong", LineBreakMode.TailTruncation), column, currentRow++); + grid.AddChild(GetStackLayout("Thisis averylong description withwords thatarelong", LineBreakMode.WordWrap), column, currentRow++); + grid.AddChild(GetStackLayout("Short desc", LineBreakMode.WordWrap), column, currentRow++); + + + grid.AddChild(new StackLayout + { + Orientation = StackOrientation.Horizontal, + HorizontalOptions = LayoutOptions.FillAndExpand, + Children = { + new Label + { + HorizontalOptions = LayoutOptions.FillAndExpand, + FontSize = 14, + Text = "1", + LineBreakMode = LineBreakMode.WordWrap, + BackgroundColor = Color.Red + }, new Label + { + HorizontalOptions = LayoutOptions.FillAndExpand, + FontSize = 14, + Text = "2", + LineBreakMode = LineBreakMode.WordWrap, + BackgroundColor = Color.Blue + } + }, + }, column, currentRow++); + + grid.AddChild(new StackLayout + { + Orientation = StackOrientation.Horizontal, + HorizontalOptions = LayoutOptions.FillAndExpand, + Children = { + new Label + { + HorizontalOptions = LayoutOptions.FillAndExpand, + FontSize = 14, + Text = "1", + LineBreakMode = LineBreakMode.WordWrap, + BackgroundColor = Color.Red + }, new Label + { + HorizontalOptions = LayoutOptions.Start, + FontSize = 14, + Text = "2", + LineBreakMode = LineBreakMode.WordWrap, + BackgroundColor = Color.Blue + } + }, + }, column, currentRow++); + + Content = grid; + } + private static StackLayout GetStackLayout(string Text, LineBreakMode breakMode) + { + return new StackLayout + { + Orientation = StackOrientation.Horizontal, + HorizontalOptions = LayoutOptions.FillAndExpand, + Children = { + new Label + { + HorizontalOptions = LayoutOptions.FillAndExpand, + FontSize = 14, + Text = Text, + LineBreakMode = breakMode + }, new Image + { + HorizontalOptions = LayoutOptions.End, + Source = ImageSource.FromFile(caret_image), + HeightRequest = 20, + Aspect = Aspect.AspectFit, + BackgroundColor = Color.Green + } + }, + }; + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index 16a2199d..e040a049 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -219,6 +219,7 @@ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla40722.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla41153.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla44129.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Bugzilla28650.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla37431.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla44777.cs" /> <Compile Include="$(MSBuildThisFileDirectory)_Template.cs" /> |