This commit is contained in:
kingces95 2017-11-09 20:19:11 -10:00 коммит произвёл Jason Smith
Родитель 2b5f91c628
Коммит f04d4d2a47
5 изменённых файлов: 173 добавлений и 12 удалений

Просмотреть файл

@ -0,0 +1,74 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 59925, "Issue Description", PlatformAffected.Default)]
public class Bugzilla59925 : TestContentPage // or TestMasterDetailPage, etc ...
{
const int Delta = 1;
Entry _entry;
private void ChangeFontSize(int delta)
{
_entry.FontSize += delta;
}
protected override void Init()
{
_entry = new Entry
{
Text = "Hello World!"
};
var buttonBigger = new Button
{
Text = "Bigger",
};
buttonBigger.Clicked += (x, o) => ChangeFontSize(Delta);
var buttonSmaller = new Button
{
Text = "Smaller"
};
buttonSmaller.Clicked += (x, o) => ChangeFontSize(-Delta);
var stack = new StackLayout
{
Children = {
buttonBigger,
buttonSmaller,
_entry
}
};
// Initialize ui here instead of ctor
Content = stack;
}
#if UITEST
[Test]
public void Issue123456Test ()
{
RunningApp.Screenshot ("I am at Issue 123456");
RunningApp.WaitForElement (q => q.Marked ("Bigger"));
RunningApp.Screenshot ("0");
RunningApp.Tap ("Bigger");
RunningApp.Screenshot("1");
RunningApp.Tap ("Bigger");
RunningApp.Screenshot("2");
RunningApp.Tap ("Bigger");
RunningApp.Screenshot("3");
}
#endif
}
}

Просмотреть файл

@ -0,0 +1,74 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 59925, "Font size does not change vertical height of Entry on iOS", PlatformAffected.Default)]
public class Bugzilla59925 : TestContentPage // or TestMasterDetailPage, etc ...
{
const int Delta = 1;
Entry _entry;
private void ChangeFontSize(int delta)
{
_entry.FontSize += delta;
}
protected override void Init()
{
_entry = new Entry
{
Text = "Hello World!"
};
var buttonBigger = new Button
{
Text = "Bigger",
};
buttonBigger.Clicked += (x, o) => ChangeFontSize(Delta);
var buttonSmaller = new Button
{
Text = "Smaller"
};
buttonSmaller.Clicked += (x, o) => ChangeFontSize(-Delta);
var stack = new StackLayout
{
Children = {
buttonBigger,
buttonSmaller,
_entry
}
};
// Initialize ui here instead of ctor
Content = stack;
}
#if UITEST
[Test]
public void Issue123456Test ()
{
RunningApp.Screenshot ("I am at Issue 59925");
RunningApp.WaitForElement (q => q.Marked ("Bigger"));
RunningApp.Screenshot ("0");
RunningApp.Tap ("Bigger");
RunningApp.Screenshot("1");
RunningApp.Tap ("Bigger");
RunningApp.Screenshot("2");
RunningApp.Tap ("Bigger");
RunningApp.Screenshot("3");
}
#endif
}
}

Просмотреть файл

@ -342,6 +342,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla56771.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla60382.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla60524.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla59925.cs" />
<Compile Include="$(MSBuildThisFileDirectory)_Template.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla42620.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1028.cs" />

Просмотреть файл

@ -1146,8 +1146,6 @@ namespace Xamarin.Forms.Platform.Android
}
return result;
{
}
}
}

Просмотреть файл

@ -2,6 +2,8 @@ using System;
using System.ComponentModel;
using System.Drawing;
using CoreGraphics;
using Foundation;
using UIKit;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
@ -12,21 +14,27 @@ namespace Xamarin.Forms.Platform.iOS
UIColor _defaultTextColor;
bool _disposed;
public EntryRenderer()
static readonly int baseHeight = 30;
static CGSize initialSize = CGSize.Empty;
public EntryRenderer()
{
Frame = new RectangleF(0, 20, 320, 40);
}
public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
{
//with borderStyle set to RoundedRect, iOS always returns a height of 30
//https://stackoverflow.com/a/36569247/1063783
//we get the current value, and restor it, to allow custom renderers to change the border style
var borderStyle = Control.BorderStyle;
Control.BorderStyle = UITextBorderStyle.None;
var size = Control.GetSizeRequest(widthConstraint, double.PositiveInfinity);
Control.BorderStyle = borderStyle;
return size;
var baseResult = base.GetDesiredSize(widthConstraint, heightConstraint);
if (Forms.IsiOS11OrNewer)
return baseResult;
NSString testString = new NSString("Tj");
var testSize = testString.GetSizeUsingAttributes(new UIStringAttributes { Font = Control.Font });
double height = baseHeight + testSize.Height - initialSize.Height;
height = Math.Round(height);
return new SizeRequest(new Size(baseResult.Request.Width, height));
}
IElementController ElementController => Element as IElementController;
@ -170,6 +178,12 @@ namespace Xamarin.Forms.Platform.iOS
void UpdateFont()
{
if (initialSize == CGSize.Empty)
{
NSString testString = new NSString("Tj");
initialSize = testString.StringSize(Control.Font);
}
Control.Font = Element.ToUIFont();
}