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:
committed by
GitHub
parent
dbaa32b02c
commit
ea471b0749
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
21
src/iOS.Core/Utilities/FontElementExtensions.cs
Normal file
21
src/iOS.Core/Utilities/FontElementExtensions.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user