mirror of
https://github.com/bitwarden/android.git
synced 2024-12-18 23:31:52 +03:00
added custom font renderers for ios dynamic text
This commit is contained in:
parent
818b1c426f
commit
734d2632dc
3 changed files with 43 additions and 0 deletions
40
src/iOS/Controls/CustomLabelRenderer.cs
Normal file
40
src/iOS/Controls/CustomLabelRenderer.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using Bit.iOS.Controls;
|
||||
using UIKit;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.iOS;
|
||||
|
||||
[assembly: ExportRenderer(typeof(Label), typeof(CustomLabelRenderer))]
|
||||
namespace Bit.iOS.Controls
|
||||
{
|
||||
public class CustomLabelRenderer : LabelRenderer
|
||||
{
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
|
||||
{
|
||||
base.OnElementChanged(e);
|
||||
|
||||
var view = e.NewElement as Label;
|
||||
if(Control != null && view != null)
|
||||
{
|
||||
var descriptor = UIFontDescriptor.PreferredBody;
|
||||
var pointSize = descriptor.PointSize;
|
||||
|
||||
var size = view.FontSize;
|
||||
if(size == Device.GetNamedSize(NamedSize.Large, typeof(Label)))
|
||||
{
|
||||
pointSize *= 1.7f;
|
||||
}
|
||||
else if(size == Device.GetNamedSize(NamedSize.Small, typeof(Label)))
|
||||
{
|
||||
pointSize *= .8f;
|
||||
}
|
||||
else if(size == Device.GetNamedSize(NamedSize.Micro, typeof(Label)))
|
||||
{
|
||||
pointSize *= .6f;
|
||||
}
|
||||
|
||||
UIFont.FromDescriptor(descriptor, pointSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,6 +21,8 @@ namespace Bit.iOS.Controls
|
|||
var view = e.NewElement as ExtendedEntry;
|
||||
if(view != null)
|
||||
{
|
||||
UIFont.FromDescriptor(UIFontDescriptor.PreferredBody, 1.0f);
|
||||
|
||||
SetBorder(view);
|
||||
SetMaxLength(view);
|
||||
UpdateKeyboard();
|
||||
|
|
|
@ -101,6 +101,7 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controls\ContentPageRenderer.cs" />
|
||||
<Compile Include="Controls\CustomLabelRenderer.cs" />
|
||||
<Compile Include="Controls\ExtendedSwitchCellRenderer.cs" />
|
||||
<Compile Include="Controls\ListViewRenderer.cs" />
|
||||
<Compile Include="Controls\ExtendedViewCellRenderer.cs" />
|
||||
|
|
Loading…
Reference in a new issue