async Task <Drawable> GetDrawable(IImageSourceService service, IImageSource imageSource) { var tcsDrawable = new TaskCompletionSource <Drawable>(); // get an image var result1 = await service.GetDrawableAsync(imageSource, MauiProgram.DefaultContext).ConfigureAwait(false); return(await tcsDrawable.Task.ConfigureAwait(false)); }
public static Task <IImageSourceServiceResult <PlatformImage>?> GetPlatformImageAsync(this IImageSourceService imageSourceService, IImageSource?imageSource, IMauiContext mauiContext) { if (imageSource == null) { return(Task.FromResult <IImageSourceServiceResult <PlatformImage>?>(null)); } #if IOS || MACCATALYST return(imageSourceService.GetImageAsync(imageSource)); #elif ANDROID return(imageSourceService.GetDrawableAsync(imageSource, mauiContext.Context !)); #elif WINDOWS return(imageSourceService.GetImageSourceAsync(imageSource)); #else throw new NotImplementedException(); #endif }