mirror of
https://github.com/bitwarden/mobile
synced 2026-02-02 09:33:16 +00:00
* SG-210 Set up account switching on Autofill iOS * SG-210 Fix refresh after sync on autofill ciphers, also added account switching on lock view on autofill. Also fix possible crash when scrolling when no items were displayed and also fixed navigation when login in on an automatically logged out account. * SG-210 Added reference on iOS.Core project * Fix formatting on AccountManager * SG-210 Fix background color for dark theme
45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
using System;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using UIKit;
|
|
using Xamarin.Forms;
|
|
using Xamarin.Forms.Internals;
|
|
using Xamarin.Forms.Platform.iOS;
|
|
|
|
namespace Bit.iOS.Core.Utilities
|
|
{
|
|
public static class ImageSourceExtensions
|
|
{
|
|
/// <summary>
|
|
/// Gets the native image from the ImageSource.
|
|
/// Taken from https://github.com/xamarin/Xamarin.Forms/blob/02dee20dfa1365d0104758e534581d1fa5958990/Xamarin.Forms.Platform.iOS/Renderers/ImageElementManager.cs#L264
|
|
/// </summary>
|
|
public static async Task<UIImage> GetNativeImageAsync(this ImageSource source, CancellationToken cancellationToken = default(CancellationToken))
|
|
{
|
|
if (source == null || source.IsEmpty)
|
|
return null;
|
|
|
|
var handler = Xamarin.Forms.Internals.Registrar.Registered.GetHandlerForObject<IImageSourceHandler>(source);
|
|
if (handler == null)
|
|
return null;
|
|
|
|
try
|
|
{
|
|
float scale = (float)UIScreen.MainScreen.Scale;
|
|
|
|
return await handler.LoadImageAsync(source, scale: scale, cancelationToken: cancellationToken);
|
|
}
|
|
catch (OperationCanceledException)
|
|
{
|
|
Log.Warning("Image loading", "Image load cancelled");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Warning("Image loading", $"Image load failed: {ex}");
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|