@applicaster/quick-brick-native-apple 5.20.5 → 5.20.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apple/QuickBrickApple.podspec.json +2 -2
- package/apple/ios/Extensions/ReactNativeOrientation+Extensions.swift +62 -0
- package/apple/ios/Extensions/UIInterfaceOrientationMask+ReactNative.swift +33 -0
- package/apple/ios/ReactNative/QuickBrickViewController.swift +75 -139
- package/apple/ios/ReactNativeEventEmitter.swift +5 -5
- package/apple/universal/Models/ReactNativeOrientation.swift +20 -0
- package/apple/universal/ReactNative/ReactNativeManager.swift +4 -2
- package/package.json +1 -1
- package/apple/ios/Extensions/UIDeviceOrientation+Extension.swift +0 -31
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "QuickBrickApple",
|
|
3
|
-
"version": "5.20.
|
|
3
|
+
"version": "5.20.7",
|
|
4
4
|
"platforms": {
|
|
5
5
|
"ios": "14.0",
|
|
6
6
|
"tvos": "14.0"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"authors": "Applicaster LTD.",
|
|
17
17
|
"source": {
|
|
18
18
|
"git": "https://github.com/applicaster/Zapp-Frameworks.git",
|
|
19
|
-
"tag": "@@applicaster/quick-brick-native-apple/5.20.
|
|
19
|
+
"tag": "@@applicaster/quick-brick-native-apple/5.20.7"
|
|
20
20
|
},
|
|
21
21
|
"requires_arc": true,
|
|
22
22
|
"source_files": "universal/**/*.{m,swift}",
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//
|
|
2
|
+
// ReactNativeOrientation+Extensions.swift
|
|
3
|
+
// QuickBrickApple
|
|
4
|
+
//
|
|
5
|
+
// Created by Anna Bauza on 03/02/2020.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import UIKit
|
|
9
|
+
import ZappCore
|
|
10
|
+
|
|
11
|
+
public extension ReactNativeOrientation {
|
|
12
|
+
static func fromInterfaceOrientation(orientation: UIInterfaceOrientation) -> ReactNativeOrientation {
|
|
13
|
+
switch orientation {
|
|
14
|
+
case .portrait:
|
|
15
|
+
return .portrait
|
|
16
|
+
case .landscapeLeft:
|
|
17
|
+
return .landscapeLeft
|
|
18
|
+
case .landscapeRight:
|
|
19
|
+
return .landscapeRight
|
|
20
|
+
case .portraitUpsideDown:
|
|
21
|
+
return .portraitUpsideDown
|
|
22
|
+
default:
|
|
23
|
+
return .unknown
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static func fromDeviceOrientation(orientation: UIDeviceOrientation) -> ReactNativeOrientation {
|
|
28
|
+
switch orientation {
|
|
29
|
+
case .portrait:
|
|
30
|
+
return .portrait
|
|
31
|
+
case .landscapeLeft:
|
|
32
|
+
return .landscapeRight
|
|
33
|
+
case .landscapeRight:
|
|
34
|
+
return .landscapeLeft
|
|
35
|
+
case .portraitUpsideDown:
|
|
36
|
+
return .portraitUpsideDown
|
|
37
|
+
default:
|
|
38
|
+
return .unknown
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
func toInterfaceOrientationMask() -> UIInterfaceOrientationMask {
|
|
43
|
+
switch self {
|
|
44
|
+
case .portrait:
|
|
45
|
+
return .portrait
|
|
46
|
+
case .landscapeLeft:
|
|
47
|
+
return .landscapeLeft
|
|
48
|
+
case .landscapeRight:
|
|
49
|
+
return .landscapeRight
|
|
50
|
+
case .landscape:
|
|
51
|
+
return .landscape
|
|
52
|
+
case .portraitUpsideDown:
|
|
53
|
+
return .portraitUpsideDown
|
|
54
|
+
case .all:
|
|
55
|
+
return .all
|
|
56
|
+
case .allButUpsideDown:
|
|
57
|
+
return .allButUpsideDown
|
|
58
|
+
default:
|
|
59
|
+
return .portrait
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// UIInterfaceOrientationMask+ReactNative.swift
|
|
3
|
+
// QuickBrickApple
|
|
4
|
+
//
|
|
5
|
+
// Created by Anton Kononenko on 10/11/22.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
extension UIInterfaceOrientationMask {
|
|
11
|
+
func toString() -> String {
|
|
12
|
+
switch self {
|
|
13
|
+
case .portrait:
|
|
14
|
+
return "portrait"
|
|
15
|
+
case .landscapeRight:
|
|
16
|
+
return "landscapeRight"
|
|
17
|
+
case .landscapeLeft:
|
|
18
|
+
return "landscapeLeft"
|
|
19
|
+
case .landscape:
|
|
20
|
+
return "landscape"
|
|
21
|
+
case .portraitUpsideDown:
|
|
22
|
+
return "portraitUpsideDown"
|
|
23
|
+
case .portrait:
|
|
24
|
+
return "portrait"
|
|
25
|
+
case .all:
|
|
26
|
+
return "all"
|
|
27
|
+
case .allButUpsideDown:
|
|
28
|
+
return "allButUpsideDown"
|
|
29
|
+
default:
|
|
30
|
+
return "all"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -17,7 +17,6 @@ class QuickBrickViewController: UIViewController, UILayerViewControllerProtocol
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
lazy var logger = Logger.getLogger(for: QuickBrickViewControllerLogs.subsystem)
|
|
20
|
-
var currentOrientation: UIDeviceOrientation = .unknown
|
|
21
20
|
|
|
22
21
|
var orientationStack = [UIInterfaceOrientationMask.all]
|
|
23
22
|
var orientationMask: UIInterfaceOrientationMask = QuickBrickViewController.initialOrientationMask
|
|
@@ -26,6 +25,10 @@ class QuickBrickViewController: UIViewController, UILayerViewControllerProtocol
|
|
|
26
25
|
orientationMask
|
|
27
26
|
}
|
|
28
27
|
|
|
28
|
+
override var prefersHomeIndicatorAutoHidden: Bool {
|
|
29
|
+
homeIndicatorAutoHidden
|
|
30
|
+
}
|
|
31
|
+
|
|
29
32
|
override public var shouldAutorotate: Bool {
|
|
30
33
|
true
|
|
31
34
|
}
|
|
@@ -51,6 +54,7 @@ class QuickBrickViewController: UIViewController, UILayerViewControllerProtocol
|
|
|
51
54
|
return value.boolValue
|
|
52
55
|
}
|
|
53
56
|
|
|
57
|
+
var currentInterfaceOrientation: UIInterfaceOrientation = .unknown
|
|
54
58
|
func getUIOrientation() -> UIInterfaceOrientation {
|
|
55
59
|
guard let interfaceOrientation = UIApplication.shared.windows.first?.windowScene?.interfaceOrientation else {
|
|
56
60
|
return .unknown
|
|
@@ -58,67 +62,42 @@ class QuickBrickViewController: UIViewController, UILayerViewControllerProtocol
|
|
|
58
62
|
return interfaceOrientation
|
|
59
63
|
}
|
|
60
64
|
|
|
61
|
-
|
|
62
|
-
let interfaceOrientation = getUIOrientation()
|
|
63
|
-
|
|
64
|
-
switch interfaceOrientation {
|
|
65
|
-
case .landscapeLeft:
|
|
66
|
-
return .landscapeLeft
|
|
67
|
-
case .landscapeRight:
|
|
68
|
-
return .landscapeRight
|
|
69
|
-
case .portrait:
|
|
70
|
-
return .portrait
|
|
71
|
-
case .portraitUpsideDown:
|
|
72
|
-
return .portraitUpsideDown
|
|
73
|
-
default:
|
|
74
|
-
return .unknown
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
65
|
+
var currentDeviceOrientation: UIDeviceOrientation = .unknown
|
|
78
66
|
func getDeviceOrientation() -> UIDeviceOrientation {
|
|
79
|
-
|
|
80
|
-
if deviceOrientation == .landscapeLeft {
|
|
81
|
-
return .landscapeRight
|
|
82
|
-
} else if deviceOrientation == .landscapeRight {
|
|
83
|
-
return .landscapeLeft
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return deviceOrientation
|
|
67
|
+
UIDevice.current.orientation
|
|
87
68
|
}
|
|
88
69
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/// - orientation: int value representing
|
|
93
|
-
/// JS_PORTAIT = 1
|
|
94
|
-
/// JS_LANDSCAPE = 1
|
|
95
|
-
/// JS_LANDSCAPE_REVERSED = 4
|
|
96
|
-
/// JS_PORTAIT_REVERSED = 8
|
|
97
|
-
/// JS_LANDSCAPE_SENSOR = JS_LANDSCAPE | JS_LANDSCAPE_REVERSED
|
|
98
|
-
/// JS_PORTAIT_SENSOR = JS_PORTAIT | JS_PORTAIT_REVERSED
|
|
99
|
-
/// JS_FULL_SENSOR = JS_LANDSCAPE_SENSOR | JS_PORTAIT_SENSOR
|
|
100
|
-
/// JS_SENSOR = JS_LANDSCAPE_SENSOR | JS_PORTAIT
|
|
101
|
-
public func allowOrientationForScreen(_ orientation: Int) {
|
|
102
|
-
orientationMask = mapOrientation(orientation)
|
|
70
|
+
public func allowOrientationForScreen(_ orientation: ReactNativeOrientation) {
|
|
71
|
+
orientationMask = orientation.toInterfaceOrientationMask()
|
|
72
|
+
// TODO: Remove orientation stack
|
|
103
73
|
orientationStack.append(orientationMask)
|
|
104
|
-
|
|
74
|
+
forceOrientationWithMaskIfNeeded(orientationMask)
|
|
105
75
|
}
|
|
106
76
|
|
|
107
77
|
/// Release Orientation for specific screen to previous state
|
|
108
78
|
public func releaseOrientationForScreen() {
|
|
109
79
|
if orientationStack.count > 1 {
|
|
110
80
|
_ = orientationStack.dropLast()
|
|
111
|
-
|
|
81
|
+
forceOrientationWithMaskIfNeeded(orientationStack.last ?? UIInterfaceOrientationMask.all)
|
|
112
82
|
}
|
|
113
83
|
}
|
|
114
84
|
|
|
115
|
-
override func viewWillTransition(to
|
|
116
|
-
with
|
|
117
|
-
|
|
85
|
+
override func viewWillTransition(to size: CGSize,
|
|
86
|
+
with coordinator: UIViewControllerTransitionCoordinator) {
|
|
87
|
+
super.viewWillTransition(to: size, with: coordinator)
|
|
88
|
+
let isLandscape = size.width > size.height
|
|
89
|
+
let interfaceOrientation = isLandscape ?
|
|
90
|
+
UIInterfaceOrientation.landscapeLeft :
|
|
91
|
+
UIInterfaceOrientation.portrait
|
|
118
92
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
93
|
+
let reactNativeToOrientation = ReactNativeOrientation.fromInterfaceOrientation(orientation: interfaceOrientation)
|
|
94
|
+
let reactNativefromOrientation = ReactNativeOrientation.fromInterfaceOrientation(orientation: currentInterfaceOrientation)
|
|
95
|
+
currentInterfaceOrientation = interfaceOrientation
|
|
96
|
+
|
|
97
|
+
ReactNativeEventEmitter.orientationChange(toOrientation: reactNativeToOrientation,
|
|
98
|
+
fromOrientation: reactNativefromOrientation)
|
|
99
|
+
|
|
100
|
+
logger?.debugLog(message: "viewWillTransition: interface orientation was changed to: \(interfaceOrientation.toString())",
|
|
122
101
|
category: QuickBrickViewControllerLogs.forceOrientation.category)
|
|
123
102
|
}
|
|
124
103
|
|
|
@@ -129,9 +108,13 @@ class QuickBrickViewController: UIViewController, UILayerViewControllerProtocol
|
|
|
129
108
|
selector: #selector(deviceDidRotate(notification:)),
|
|
130
109
|
name: UIDevice.orientationDidChangeNotification,
|
|
131
110
|
object: nil)
|
|
111
|
+
}
|
|
132
112
|
|
|
113
|
+
override func viewDidAppear(_ animated: Bool) {
|
|
114
|
+
super.viewDidAppear(animated)
|
|
133
115
|
// Initial device orientation
|
|
134
|
-
|
|
116
|
+
currentDeviceOrientation = getDeviceOrientation()
|
|
117
|
+
currentInterfaceOrientation = getUIOrientation()
|
|
135
118
|
}
|
|
136
119
|
|
|
137
120
|
override func viewWillDisappear(_ animated: Bool) {
|
|
@@ -152,112 +135,65 @@ class QuickBrickViewController: UIViewController, UILayerViewControllerProtocol
|
|
|
152
135
|
return
|
|
153
136
|
}
|
|
154
137
|
|
|
155
|
-
|
|
156
|
-
|
|
138
|
+
let reactNativeToOrientation = ReactNativeOrientation.fromDeviceOrientation(orientation: deviceOrientation)
|
|
139
|
+
let reactNativeFromOrientation = ReactNativeOrientation.fromDeviceOrientation(orientation: currentDeviceOrientation)
|
|
140
|
+
currentDeviceOrientation = deviceOrientation
|
|
141
|
+
|
|
142
|
+
ReactNativeEventEmitter.orientationChange(toOrientation: reactNativeToOrientation,
|
|
143
|
+
fromOrientation: reactNativeFromOrientation,
|
|
157
144
|
physicalChange: true)
|
|
158
|
-
logger?.debugLog(message: "deviceDidRotate: UI oritation changed to: \(getUIOrientation().toString())",
|
|
159
|
-
category: QuickBrickViewControllerLogs.forceOrientation.category)
|
|
160
145
|
|
|
161
|
-
|
|
146
|
+
logger?.debugLog(message: "deviceDidRotate: device oritation changed to: \(deviceOrientation.toString())",
|
|
147
|
+
category: QuickBrickViewControllerLogs.forceOrientation.category)
|
|
162
148
|
}
|
|
163
149
|
|
|
164
|
-
private func
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
switch orientation {
|
|
175
|
-
case JS_PORTAIT:
|
|
176
|
-
return UIInterfaceOrientationMask.portrait
|
|
177
|
-
case JS_LANDSCAPE:
|
|
178
|
-
return UIInterfaceOrientationMask.landscapeRight
|
|
179
|
-
case JS_LANDSCAPE_REVERSED:
|
|
180
|
-
return UIInterfaceOrientationMask.landscapeLeft
|
|
181
|
-
case JS_LANDSCAPE_SENSOR:
|
|
182
|
-
return UIInterfaceOrientationMask.landscape
|
|
183
|
-
case JS_PORTAIT_REVERSED:
|
|
184
|
-
return UIInterfaceOrientationMask.portraitUpsideDown
|
|
185
|
-
case JS_PORTAIT_SENSOR:
|
|
186
|
-
return UIInterfaceOrientationMask.portrait
|
|
187
|
-
case JS_FULL_SENSOR:
|
|
188
|
-
return UIInterfaceOrientationMask.all
|
|
189
|
-
case JS_SENSOR:
|
|
190
|
-
return UIInterfaceOrientationMask.allButUpsideDown
|
|
191
|
-
default:
|
|
192
|
-
return UIInterfaceOrientationMask.all
|
|
150
|
+
private func forceOrientationWithMaskIfNeeded(_ orientationMask: UIInterfaceOrientationMask) {
|
|
151
|
+
if #available(iOS 16.0, *) {
|
|
152
|
+
logger?.debugLog(message: "\(QuickBrickViewControllerLogs.forceOrientation.message) UI orientation to: \(orientationMask.toString())",
|
|
153
|
+
category: QuickBrickViewControllerLogs.forceOrientation.category)
|
|
154
|
+
|
|
155
|
+
let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
|
|
156
|
+
windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: orientationMask))
|
|
157
|
+
UIViewController.attemptRotationToDeviceOrientation()
|
|
158
|
+
return
|
|
193
159
|
}
|
|
194
|
-
}
|
|
195
160
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return UIInterfaceOrientation.portrait
|
|
200
|
-
case UIInterfaceOrientationMask.landscape:
|
|
201
|
-
return UIInterfaceOrientation.landscapeRight
|
|
202
|
-
case UIInterfaceOrientationMask.landscapeRight:
|
|
203
|
-
return UIInterfaceOrientation.landscapeRight
|
|
204
|
-
case UIInterfaceOrientationMask.landscapeLeft:
|
|
205
|
-
return UIInterfaceOrientation.landscapeLeft
|
|
206
|
-
case UIInterfaceOrientationMask.all:
|
|
207
|
-
return UIInterfaceOrientation.portrait
|
|
208
|
-
case UIInterfaceOrientationMask.allButUpsideDown:
|
|
209
|
-
return UIInterfaceOrientation.portrait
|
|
210
|
-
case UIInterfaceOrientationMask.portraitUpsideDown:
|
|
211
|
-
return UIInterfaceOrientation.portraitUpsideDown
|
|
212
|
-
default:
|
|
213
|
-
return UIInterfaceOrientation.portrait
|
|
161
|
+
if isSupportOrientation(mask: orientationMask,
|
|
162
|
+
interfaceOrientation: currentInterfaceOrientation) {
|
|
163
|
+
return
|
|
214
164
|
}
|
|
165
|
+
|
|
166
|
+
logger?.debugLog(message: "\(QuickBrickViewControllerLogs.forceOrientation.message) UI orientation to: \(orientationMask.toString())",
|
|
167
|
+
category: QuickBrickViewControllerLogs.forceOrientation.category)
|
|
168
|
+
|
|
169
|
+
changeOrienation(orientationMask: orientationMask)
|
|
215
170
|
}
|
|
216
171
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
case UIInterfaceOrientationMask.landscape:
|
|
172
|
+
func changeOrienation(orientationMask: UIInterfaceOrientationMask) {
|
|
173
|
+
func setDeviceOrientation(_ orientaion: UIDeviceOrientation) {
|
|
174
|
+
UIDevice.current.setValue(orientaion.rawValue,
|
|
175
|
+
forKey: "orientation")
|
|
176
|
+
}
|
|
223
177
|
|
|
224
|
-
|
|
225
|
-
|
|
178
|
+
if orientationMask == .landscapeRight {
|
|
179
|
+
setDeviceOrientation(UIDeviceOrientation.landscapeLeft)
|
|
180
|
+
} else if orientationMask == .landscapeLeft {
|
|
181
|
+
setDeviceOrientation(UIDeviceOrientation.landscapeRight)
|
|
182
|
+
} else if orientationMask == .landscape {
|
|
183
|
+
if currentDeviceOrientation == .landscapeLeft || currentDeviceOrientation == .landscapeRight {
|
|
184
|
+
setDeviceOrientation(currentDeviceOrientation)
|
|
226
185
|
} else {
|
|
227
|
-
|
|
186
|
+
setDeviceOrientation(UIDeviceOrientation.landscapeRight)
|
|
228
187
|
}
|
|
229
188
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
case UIInterfaceOrientationMask.landscapeLeft:
|
|
234
|
-
forceOrientation(UIInterfaceOrientation.landscapeLeft)
|
|
235
|
-
|
|
236
|
-
case UIInterfaceOrientationMask.all:
|
|
237
|
-
break
|
|
238
|
-
case UIInterfaceOrientationMask.allButUpsideDown:
|
|
239
|
-
forceOrientation(UIInterfaceOrientation.portrait)
|
|
240
|
-
|
|
241
|
-
case UIInterfaceOrientationMask.portraitUpsideDown:
|
|
242
|
-
forceOrientation(UIInterfaceOrientation.portraitUpsideDown)
|
|
243
|
-
default:
|
|
244
|
-
break
|
|
189
|
+
} else if orientationMask == .portrait {
|
|
190
|
+
setDeviceOrientation(UIDeviceOrientation.portrait)
|
|
245
191
|
}
|
|
246
|
-
}
|
|
247
192
|
|
|
248
|
-
|
|
249
|
-
if let newOrientation = UIDeviceOrientation(rawValue: orientation.rawValue) {
|
|
250
|
-
logger?.debugLog(message: "\(QuickBrickViewControllerLogs.forceOrientation.message) UI oritation to: \(orientation.toString())",
|
|
251
|
-
category: QuickBrickViewControllerLogs.forceOrientation.category,
|
|
252
|
-
data: ["newDeviceOrientation": newOrientation.toString(),
|
|
253
|
-
"newInterfaceOrientation": orientation.toString()])
|
|
254
|
-
UIDevice.current.setValue(newOrientation,
|
|
255
|
-
forKey: "orientation")
|
|
256
|
-
UIViewController.attemptRotationToDeviceOrientation()
|
|
257
|
-
}
|
|
193
|
+
UIViewController.attemptRotationToDeviceOrientation()
|
|
258
194
|
}
|
|
259
195
|
|
|
260
|
-
|
|
261
|
-
|
|
196
|
+
func isSupportOrientation(mask: UIInterfaceOrientationMask, interfaceOrientation: UIInterfaceOrientation) -> Bool {
|
|
197
|
+
(mask.rawValue & (1 << interfaceOrientation.rawValue)) != 0
|
|
262
198
|
}
|
|
263
199
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// ReactNativeEventEmitter.swift
|
|
3
3
|
// QuickBrickApple
|
|
4
4
|
//
|
|
5
|
-
// Created by
|
|
5
|
+
// Created by Anton Kononenko on 10/11/2022.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
import Foundation
|
|
@@ -12,12 +12,12 @@ import React
|
|
|
12
12
|
open class ReactNativeEventEmitter: RCTEventEmitter {
|
|
13
13
|
public static var emitter: RCTEventEmitter!
|
|
14
14
|
|
|
15
|
-
public static func orientationChange(toOrientation:
|
|
16
|
-
fromOrientation:
|
|
15
|
+
public static func orientationChange(toOrientation: ReactNativeOrientation,
|
|
16
|
+
fromOrientation: ReactNativeOrientation,
|
|
17
17
|
physicalChange: Bool = false) {
|
|
18
18
|
if toOrientation.rawValue > 0 {
|
|
19
|
-
emitter?.sendEvent(withName: "orientationChange", body: ["toOrientation": toOrientation.
|
|
20
|
-
"fromOrientation": fromOrientation.
|
|
19
|
+
emitter?.sendEvent(withName: "orientationChange", body: ["toOrientation": toOrientation.rawValue,
|
|
20
|
+
"fromOrientation": fromOrientation.rawValue,
|
|
21
21
|
"physicalChange": physicalChange])
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
// ReactNativeOrientation.swift
|
|
3
|
+
// QuickBrickApple
|
|
4
|
+
//
|
|
5
|
+
// Created by Anna Bauza on 03/02/2020.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import UIKit
|
|
9
|
+
import ZappCore
|
|
10
|
+
|
|
11
|
+
public enum ReactNativeOrientation: Int {
|
|
12
|
+
case unknown = 0
|
|
13
|
+
case portrait = 1
|
|
14
|
+
case landscapeRight = 2
|
|
15
|
+
case landscapeLeft = 4
|
|
16
|
+
case portraitUpsideDown = 8
|
|
17
|
+
case landscape = 6
|
|
18
|
+
case all = 15
|
|
19
|
+
case allButUpsideDown = 7
|
|
20
|
+
}
|
|
@@ -200,8 +200,10 @@ extension ReactNativeManager: QuickBrickManagerDelegate {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
public func allowOrientationForScreen(_ payload: [String: Any]) {
|
|
203
|
-
if let qbViewController = reactNativeViewController() as? QuickBrickViewController,
|
|
204
|
-
|
|
203
|
+
if let qbViewController = reactNativeViewController() as? QuickBrickViewController,
|
|
204
|
+
let orientation = payload["orientation"] as? Int,
|
|
205
|
+
let reactNativeOrientation = ReactNativeOrientation(rawValue: orientation) {
|
|
206
|
+
qbViewController.allowOrientationForScreen(reactNativeOrientation)
|
|
205
207
|
}
|
|
206
208
|
}
|
|
207
209
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-native-apple",
|
|
3
|
-
"version": "5.20.
|
|
3
|
+
"version": "5.20.7",
|
|
4
4
|
"description": "iOS and tvOS native code for QuickBrick applications. This package is used to provide native logic for QuickBrick",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// UIDeviceOrientation+Extension.swift
|
|
3
|
-
// QuickBrickApple
|
|
4
|
-
//
|
|
5
|
-
// Created by Anton Kononenko on 8/30/21.
|
|
6
|
-
// Copyright © 2021 Anton Kononenko. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
import Foundation
|
|
10
|
-
import React
|
|
11
|
-
|
|
12
|
-
extension UIDeviceOrientation {
|
|
13
|
-
func mapOrientation() -> Int {
|
|
14
|
-
var orientation = 0
|
|
15
|
-
|
|
16
|
-
switch self {
|
|
17
|
-
case .portrait:
|
|
18
|
-
orientation = 1
|
|
19
|
-
case .landscapeRight:
|
|
20
|
-
orientation = 2
|
|
21
|
-
case .landscapeLeft:
|
|
22
|
-
orientation = 4
|
|
23
|
-
case .portraitUpsideDown:
|
|
24
|
-
orientation = 8
|
|
25
|
-
default:
|
|
26
|
-
orientation = 0
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return orientation
|
|
30
|
-
}
|
|
31
|
-
}
|