1
- import { Color } from 'tns-core-modules/color' ;
2
- import { ios } from 'tns-core-modules/utils/utils' ;
1
+ import { Color , Utils } from '@nativescript/core' ;
3
2
4
3
import {
5
4
BrowserResult ,
@@ -46,7 +45,7 @@ const getPresentationStyle = function (styleKey: string): UIModalPresentationSty
46
45
overCurrentContext : UIModalPresentationStyle . OverCurrentContext ,
47
46
popover : UIModalPresentationStyle . Popover
48
47
} ;
49
- const defaultModalPresentationStyle = ios . MajorVersion >= 13 ?
48
+ const defaultModalPresentationStyle = Utils . ios . MajorVersion >= 13 ?
50
49
UIModalPresentationStyle . Automatic : UIModalPresentationStyle . FullScreen ;
51
50
return styles [ styleKey ] !== undefined ? styles [ styleKey ] : defaultModalPresentationStyle ;
52
51
} ;
@@ -65,7 +64,7 @@ const DEFAULT_PROTOCOLS = [
65
64
SFSafariViewControllerDelegate ,
66
65
UIAdaptivePresentationControllerDelegate
67
66
] ;
68
- const protocols = ios . MajorVersion >= 13 ? [
67
+ const protocols = Utils . ios . MajorVersion >= 13 ? [
69
68
...DEFAULT_PROTOCOLS ,
70
69
ASWebAuthenticationPresentationContextProviding
71
70
] : DEFAULT_PROTOCOLS ;
@@ -81,7 +80,7 @@ class InAppBrowserModule extends NSObject {
81
80
private animated = false ;
82
81
83
82
public isAvailable ( ) : Promise < boolean > {
84
- return Promise . resolve ( ios . MajorVersion >= 9 ) ;
83
+ return Promise . resolve ( Utils . ios . MajorVersion >= 9 ) ;
85
84
}
86
85
public open (
87
86
authURL : string ,
@@ -94,7 +93,7 @@ class InAppBrowserModule extends NSObject {
94
93
this . animated = inAppBrowserOptions . animated ;
95
94
96
95
const url = NSURL . URLWithString ( inAppBrowserOptions [ 'url' ] ) ;
97
- if ( ios . MajorVersion >= 11 ) {
96
+ if ( Utils . ios . MajorVersion >= 11 ) {
98
97
const config = SFSafariViewControllerConfiguration . alloc ( ) . init ( ) ;
99
98
config . barCollapsingEnabled = inAppBrowserOptions . enableBarCollapsing ;
100
99
config . entersReaderIfAvailable = inAppBrowserOptions . readerMode ;
@@ -107,7 +106,7 @@ class InAppBrowserModule extends NSObject {
107
106
}
108
107
this . safariVC . delegate = this ;
109
108
110
- if ( ios . MajorVersion >= 11 ) {
109
+ if ( Utils . ios . MajorVersion >= 11 ) {
111
110
if ( inAppBrowserOptions . dismissButtonStyle === 'done' ) {
112
111
this . safariVC . dismissButtonStyle = SFSafariViewControllerDismissButtonStyle . Done ;
113
112
}
@@ -119,7 +118,7 @@ class InAppBrowserModule extends NSObject {
119
118
}
120
119
}
121
120
122
- if ( ios . MajorVersion >= 10 ) {
121
+ if ( Utils . ios . MajorVersion >= 10 ) {
123
122
if ( inAppBrowserOptions . preferredBarTintColor ) {
124
123
this . safariVC . preferredBarTintColor = new Color ( inAppBrowserOptions . preferredBarTintColor ) . ios ;
125
124
}
@@ -138,7 +137,7 @@ class InAppBrowserModule extends NSObject {
138
137
if ( this . animated ) {
139
138
safariHackVC . modalTransitionStyle = getTransitionStyle ( inAppBrowserOptions . modalTransitionStyle ) ;
140
139
}
141
- if ( ios . MajorVersion >= 13 ) {
140
+ if ( Utils . ios . MajorVersion >= 13 ) {
142
141
safariHackVC . modalInPresentation = true ;
143
142
if ( safariHackVC [ 'setModalInPresentation' ] )
144
143
safariHackVC [ 'setModalInPresentation' ] ( true ) ;
@@ -172,13 +171,13 @@ class InAppBrowserModule extends NSObject {
172
171
...options ,
173
172
ephemeralWebSession : options . ephemeralWebSession !== undefined ? options . ephemeralWebSession : false ,
174
173
} ;
175
- if ( ios . MajorVersion >= 11 ) {
174
+ if ( Utils . ios . MajorVersion >= 11 ) {
176
175
return new Promise < AuthSessionResult > ( ( resolve , reject ) => {
177
176
if ( ! this . initializeWebBrowser ( resolve , reject ) ) return ;
178
177
179
178
const url = NSURL . URLWithString ( authUrl ) ;
180
179
this . authSession = (
181
- ios . MajorVersion >= 12 ? ASWebAuthenticationSession : SFAuthenticationSession
180
+ Utils . ios . MajorVersion >= 12 ? ASWebAuthenticationSession : SFAuthenticationSession
182
181
) . alloc ( ) . initWithURLCallbackURLSchemeCompletionHandler (
183
182
url ,
184
183
redirectUrl ,
@@ -197,7 +196,7 @@ class InAppBrowserModule extends NSObject {
197
196
this . flowDidFinish ( ) ;
198
197
}
199
198
) ;
200
- if ( ios . MajorVersion >= 13 ) {
199
+ if ( Utils . ios . MajorVersion >= 13 ) {
201
200
const webAuthSession = this . authSession as ASWebAuthenticationSession ;
202
201
// Prevent re-use cookie from last auth session
203
202
webAuthSession . prefersEphemeralWebBrowserSession = inAppBrowserOptions . ephemeralWebSession ;
@@ -216,7 +215,7 @@ class InAppBrowserModule extends NSObject {
216
215
}
217
216
}
218
217
public closeAuth ( ) {
219
- if ( ios . MajorVersion >= 11 ) {
218
+ if ( Utils . ios . MajorVersion >= 11 ) {
220
219
const authSession : SFAuthenticationSession | ASWebAuthenticationSession = this . authSession ;
221
220
authSession . cancel ( ) ;
222
221
if ( this . redirectResolve ) {
0 commit comments