mirror of
https://github.com/bitwarden/mobile.git
synced 2025-03-12 13:19:10 +01:00
* Adding IDs for Vault Page sections * Removing extra spaces * Adding Matt's comments * Fixing Filters Id bug * Adding Fede's suggestions * Fixing Settings Ids issues * Fixing AutomationIds issues with RecyclerViews + implementing AutomationId helper class * Adding Fede's suggestion * Adding latest Fede's suggestions
66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using Bit.App.Controls;
|
|
using Bit.iOS.Core.Renderers;
|
|
using Bit.iOS.Core.Utilities;
|
|
using UIKit;
|
|
using Xamarin.Forms;
|
|
using Xamarin.Forms.Platform.iOS;
|
|
|
|
[assembly: ExportRenderer(typeof(Label), typeof(CustomLabelRenderer))]
|
|
namespace Bit.iOS.Core.Renderers
|
|
{
|
|
public class CustomLabelRenderer : LabelRenderer
|
|
{
|
|
protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
|
|
{
|
|
base.OnElementChanged(e);
|
|
if (Control != null && e.NewElement is Label)
|
|
{
|
|
UpdateFont();
|
|
}
|
|
}
|
|
|
|
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
{
|
|
var label = sender as CustomLabel;
|
|
switch (e.PropertyName)
|
|
{
|
|
case nameof(CustomLabel.AutomationId):
|
|
Control.AccessibilityIdentifier = label.AutomationId;
|
|
break;
|
|
}
|
|
|
|
base.OnElementPropertyChanged(sender, e);
|
|
|
|
if (e.PropertyName == Label.FontProperty.PropertyName ||
|
|
e.PropertyName == Label.TextProperty.PropertyName ||
|
|
e.PropertyName == Label.FormattedTextProperty.PropertyName)
|
|
{
|
|
UpdateFont();
|
|
}
|
|
}
|
|
|
|
private void UpdateFont()
|
|
{
|
|
if (Element is null || Control is null)
|
|
return;
|
|
|
|
var pointSize = iOSHelpers.GetAccessibleFont<Label>(Element.FontSize);
|
|
if (pointSize != null)
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|