-
Notifications
You must be signed in to change notification settings - Fork 53
/
tns-oauth-page-provider.ts
45 lines (33 loc) · 1.32 KB
/
tns-oauth-page-provider.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/// <reference path="references.d.ts" />
import { Page } from 'ui/page';
import { GridLayout } from 'ui/layouts/grid-layout';
import { StackLayout } from 'ui/layouts/stack-layout';
import { isAndroid } from 'tns-core-modules/platform';
import { TnsOauthWebView } from './tns-oauth-webview';
//import { TnsOAuthWebViewDelegateImpl } from './tns-oauth-webview';
import { TnsOAuthWebViewHelper } from './tns-oauth-webview-helper';
export class TnsOAuthPageProvider {
private _checkCodeIntercept: (WebView, error?, url?) => boolean;
private _cancelEventHandler: (error?) => void;
private _authUrl: string;
constructor(checkCodeIntercept, authUrl, cancelEventHandler) {
this._checkCodeIntercept = checkCodeIntercept;
this._cancelEventHandler = cancelEventHandler;
this._authUrl = authUrl;
}
public loginPageFunc() {
let wv = new TnsOauthWebView(this._cancelEventHandler);
TnsOAuthWebViewHelper.initWithWebViewAndIntercept(wv, this._checkCodeIntercept);
let grid = new GridLayout();
grid.addChild(wv);
let stack = new StackLayout();
stack.addChild(grid);
let page = new Page();
page.content = stack;
if (isAndroid) {
page.actionBarHidden = true;
}
wv.src = this._authUrl;
return page;
};
}