Last active
June 24, 2020 21:00
-
-
Save Pujolsluis/942720123e07df1046cb5ed695dd0024 to your computer and use it in GitHub Desktop.
Device open's the provided PDF URL with the Device Browser, and style it to look like it's inside the app. making use of Xamarin.Essentials
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Xamarin.Essentials; | |
public Task OpenPdf(string url, BrowserLaunchOptions? browserLaunchOptions = null) | |
{ | |
return MainThread.InvokeOnMainThreadAsync(() => | |
{ | |
var currentTheme = (BaseTheme?)Application.Current?.Resources; | |
if (currentTheme != null) | |
{ | |
browserLaunchOptions ??= new Xamarin.Essentials.BrowserLaunchOptions | |
{ | |
PreferredControlColor = currentTheme.NavigationBarTextColor, | |
PreferredToolbarColor = currentTheme.NavigationBarBackgroundColor, | |
Flags = BrowserLaunchFlags.PresentAsFormSheet | |
}; | |
} | |
return Browser.OpenAsync(url, browserLaunchOptions); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment