mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-25 12:05:59 +01:00
This commit is contained in:
parent
04c7409418
commit
adb8bb4f1b
@ -4,6 +4,9 @@ using Bit.App.Services;
|
|||||||
using Bit.App.Styles;
|
using Bit.App.Styles;
|
||||||
using Bit.Core;
|
using Bit.Core;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
#if !FDROID
|
||||||
|
using Microsoft.AppCenter.Crashes;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Bit.App.Utilities
|
namespace Bit.App.Utilities
|
||||||
{
|
{
|
||||||
@ -13,6 +16,8 @@ namespace Bit.App.Utilities
|
|||||||
public static Func<ResourceDictionary> Resources = () => null;
|
public static Func<ResourceDictionary> Resources = () => null;
|
||||||
|
|
||||||
public static void SetThemeStyle(string name, ResourceDictionary resources)
|
public static void SetThemeStyle(string name, ResourceDictionary resources)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Resources = () => resources;
|
Resources = () => resources;
|
||||||
|
|
||||||
@ -71,6 +76,22 @@ namespace Bit.App.Utilities
|
|||||||
resources.MergedDictionaries.Add(new iOS());
|
resources.MergedDictionaries.Add(new iOS());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (InvalidOperationException ioex) when (ioex.Message != null && ioex.Message.StartsWith("Collection was modified"))
|
||||||
|
{
|
||||||
|
// https://github.com/bitwarden/mobile/issues/1689 There are certain scenarios where this might cause "collection was modified; enumeration operation may not execute"
|
||||||
|
// the way I found to prevent this for now was to catch the exception here and move on.
|
||||||
|
// Because on the screens that I found it to happen, the screen is being closed while trying to apply the resources
|
||||||
|
// so we shouldn't be introducing any issues.
|
||||||
|
// TODO: Maybe something like this https://github.com/matteobortolazzo/HtmlLabelPlugin/pull/113 can be implemented to avoid this
|
||||||
|
// on html labels.
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
#if !FDROID
|
||||||
|
Crashes.TrackError(ex);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void SetTheme(bool android, ResourceDictionary resources)
|
public static void SetTheme(bool android, ResourceDictionary resources)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.ComponentModel;
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
using Bit.iOS.Core.Renderers;
|
using Bit.iOS.Core.Renderers;
|
||||||
using Bit.iOS.Core.Utilities;
|
using Bit.iOS.Core.Utilities;
|
||||||
using UIKit;
|
using UIKit;
|
||||||
@ -20,8 +21,20 @@ namespace Bit.iOS.Core.Renderers
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
base.OnElementPropertyChanged(sender, e);
|
base.OnElementPropertyChanged(sender, e);
|
||||||
|
}
|
||||||
|
catch (NullReferenceException)
|
||||||
|
{
|
||||||
|
// Do nothing...
|
||||||
|
// There is an issue on Xamarin Forms which throws a null reference
|
||||||
|
// https://appcenter.ms/users/kspearrin/apps/bitwarden/crashes/errors/534094859u/overview
|
||||||
|
// TODO: Maybe something like this https://github.com/matteobortolazzo/HtmlLabelPlugin/pull/113 can be implemented to avoid this
|
||||||
|
// on html labels.
|
||||||
|
}
|
||||||
|
|
||||||
if (e.PropertyName == Label.FontProperty.PropertyName ||
|
if (e.PropertyName == Label.FontProperty.PropertyName ||
|
||||||
e.PropertyName == Label.TextProperty.PropertyName ||
|
e.PropertyName == Label.TextProperty.PropertyName ||
|
||||||
e.PropertyName == Label.FormattedTextProperty.PropertyName)
|
e.PropertyName == Label.FormattedTextProperty.PropertyName)
|
||||||
@ -32,6 +45,9 @@ namespace Bit.iOS.Core.Renderers
|
|||||||
|
|
||||||
private void UpdateFont()
|
private void UpdateFont()
|
||||||
{
|
{
|
||||||
|
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)
|
if (pointSize != null)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user