nativescript-oauth2
nativescript-oauth2 copied to clipboard
Expose Webview to allow custom config/handlers
Hi, I see that you closed #33 citing that "Providing a custom UI goes against the Oauth2 spec", but there are other reasons that exposing the Webview would be very useful:
- Set Android WebView settings:
-
webview.android.setWebChromeClient(new android.webkit.WebChromeClient());
-
android.getSettings().setBuiltInZoomControls(false);
-
android.getSettings().setUserAgentString('CUSTOM_UA_STRING');
-
- Set custom
loadStartedEvent
andloadFinishedEvent
handlers
Are there other ways to accomplish the tasks above without accessing the Webview?
Here's how I messily satisfied this need in the original nativescript-oauth plugin: https://github.com/alexziskind1/nativescript-oauth/pull/58
The main one for me is to be able to set the navigation button back text to the same title as the previous page.
https://github.com/alexziskind1/nativescript-oauth2/blob/accee37c3d387f7e03b83b20d2350251599ff042/src/tns-oauth-login-webview-controller.ts#L101
@alexziskind1 Is this something you would be happy to PR if I made options configurable?
May we also allow config to add an activity indicator while the Webview is still loading the content and hide on pageLoadFinished?
var myloadingObject = { isLoading: true };
var indicator = new loading_indicator_1.ActivityIndicator();
indicator.bind({
sourceProperty: "isLoading",
targetProperty: "busy"
}, myloadingObject);
var stack = new stack_layout_1.StackLayout();
var grid = new grid_layout_1.GridLayout();
grid.addChild(webView)
stack.addChild(indicator);
stack.addChild(grid);