1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-17 08:43:21 +00:00

Fixed some Large Font Accessibility issues on Vault and Send screens for Icons Display #1774 (#1785)

This commit is contained in:
Federico Maccaroni
2022-02-17 19:34:22 -03:00
committed by GitHub
parent dbaa32b02c
commit ea471b0749
14 changed files with 81 additions and 17 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
using Bit.App.Controls;
using Bit.iOS.Core.Renderers;
using Bit.iOS.Core.Utilities;
using UIKit;
@@ -48,10 +49,19 @@ namespace Bit.iOS.Core.Renderers
if (Element is null || Control is null)
return;
var pointSize = iOSHelpers.GetAccessibleFont<Label>(Element.FontSize);
var pointSize = iOSHelpers.GetAccessibleFont<Label>(Element.FontSize);
if (pointSize != null)
{
Control.Font = UIFont.FromDescriptor(Element.Font.ToUIFont().FontDescriptor, pointSize.Value);
Control.Font = UIFont.FromDescriptor(Element.ToUIFont().FontDescriptor, pointSize.Value);
}
// TODO: For now, I'm only doing this for IconLabel with setup just in case I break the whole app labels.
// We need to revisit this when we address Accessibility Large Font issues across the app
// to check if we can left it more generic like
// else if (Element.FontFamily != null)
else if (Element is IconLabel iconLabel && iconLabel.ShouldUpdateFontSizeDynamicallyForAccesibility)
{
var customFont = Element.ToUIFont();
Control.Font = new UIFontMetrics(UIFontTextStyle.Body.GetConstant()).GetScaledFont(customFont);
}
}
}

View File

@@ -587,6 +587,13 @@ namespace Bit.iOS.Core.Services
throw new NotImplementedException();
}
public float GetSystemFontSizeScale()
{
var tempHeight = 20f;
var scaledHeight = (float)new UIFontMetrics(UIFontTextStyle.Body.GetConstant()).GetScaledValue(tempHeight);
return scaledHeight / tempHeight;
}
public class PickerDelegate : UIDocumentPickerDelegate
{
private readonly DeviceActionService _deviceActionService;

View File

@@ -0,0 +1,21 @@
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Internals;
using Xamarin.Forms.Platform.iOS;
namespace Bit.iOS.Core.Utilities
{
public static class FontElementExtensions
{
public static UIFont ToUIFont(this IFontElement fontElement)
{
var fontSize = fontElement.FontSize;
var fontAttributes = fontElement.FontAttributes;
var fontFamily = fontElement.FontFamily;
return fontFamily is null
? Font.SystemFontOfSize(fontSize, fontAttributes).ToUIFont()
: Font.OfSize(fontFamily, fontSize).WithAttributes(fontAttributes).ToUIFont();
}
}
}

View File

@@ -192,6 +192,7 @@
<Compile Include="Renderers\SelectableLabelRenderer.cs" />
<Compile Include="Effects\ScrollEnabledEffect.cs" />
<Compile Include="Services\ClipboardService.cs" />
<Compile Include="Utilities\FontElementExtensions.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\App\App.csproj">