@applicaster/quick-brick-native-apple 5.16.0 → 5.18.0
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/LocalNotifications/ReactNativeManager+UNUserNotificationCenterDelegate.swift +7 -5
- package/apple/ios/ReactNative/PushBridge.swift +11 -11
- package/apple/ios/ReactNative/QuickBrickExceptionManager.swift +22 -20
- package/apple/ios/ReactNative/QuickBrickViewController.swift +15 -20
- package/apple/ios/ReactNative/ReactNativeManageriOS+UIApplicationDelegate.swift +15 -18
- package/apple/ios/ReactNativeEventEmitter.swift +19 -21
- package/apple/tvos/Helpers/FocusableGroupManager/FocusableGroupManager.swift +39 -39
- package/apple/tvos/Helpers/FocusableGroupManager/FocusableManagerModule.swift +18 -23
- package/apple/tvos/LocalNotifications/ReactNativeManager+UNUserNotificationCenterDelegate.swift +4 -3
- package/apple/tvos/ReactNative/QuickBrickViewController.swift +3 -3
- package/apple/tvos/Views/FocusableGroupView/FocusableGroupView.swift +118 -114
- package/apple/tvos/Views/FocusableGroupView/FocusableGroupViewConsts.swift +19 -19
- package/apple/tvos/Views/FocusableGroupView/FocusableGroupViewModule.swift +10 -10
- package/apple/tvos/Views/FocusableView/FocusableView+ParallaxViewDelegate.swift +14 -20
- package/apple/tvos/Views/FocusableView/FocusableView.swift +38 -40
- package/apple/tvos/Views/FocusableView/FocusableViewModule.swift +8 -9
- package/apple/tvos/Views/ParallaxView/Extensions/ParallaxableView+Extensions.swift +20 -26
- package/apple/tvos/Views/ParallaxView/Extensions/UIView+ParallaxEffect.swift +26 -28
- package/apple/tvos/Views/ParallaxView/Other/ParallaxEffectOptions.swift +5 -9
- package/apple/tvos/Views/ParallaxView/Other/ParallaxMotionEffect.swift +8 -12
- package/apple/tvos/Views/ParallaxView/Other/ParallaxableView.swift +0 -2
- package/apple/tvos/Views/ParallaxView/ParallaxCollectionViewCell.swift +17 -19
- package/apple/tvos/Views/ParallaxView/ParallaxView.swift +29 -31
- package/apple/tvos/Views/ParallaxView/Protocols/ParallaxViewDelegate.swift +6 -7
- package/apple/universal/ReactNative/AnalyticsBridge.swift +3 -3
- package/apple/universal/ReactNative/LocalNotification/LocalNotificationBridge.swift +8 -6
- package/apple/universal/ReactNative/OfflineAssetsBridge.swift +21 -15
- package/apple/universal/ReactNative/PluginsManagerBridge.swift +20 -15
- package/apple/universal/ReactNative/ReactNativeCommunicationModule.swift +15 -13
- package/apple/universal/ReactNative/ReactNativeManager+UIApplicationDelegate.swift +10 -9
- package/apple/universal/ReactNative/ReactNativeManager.swift +12 -9
- package/apple/universal/Storages/LocalStorage/LocalStorageBridge.swift +35 -20
- package/apple/universal/Storages/SessionStorage/SessionStorageBridge.swift +20 -12
- package/apple/universal/Utils/RTLLocales.swift +5 -5
- package/apple/universal/Utils/XrayLoggerTemplates/QuickBrickViewControllerLogs.swift +0 -2
- package/apple/universal/Utils/XrayLoggerTemplates/ReactNativeManagerLogs.swift +0 -1
- package/package.json +1 -1
package/apple/tvos/LocalNotifications/ReactNativeManager+UNUserNotificationCenterDelegate.swift
CHANGED
|
@@ -10,9 +10,10 @@ import React
|
|
|
10
10
|
import ZappCore
|
|
11
11
|
|
|
12
12
|
extension ReactNativeManager: UNUserNotificationCenterDelegate {
|
|
13
|
-
public func userNotificationCenter(_
|
|
14
|
-
willPresent
|
|
15
|
-
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
|
|
13
|
+
public func userNotificationCenter(_: UNUserNotificationCenter,
|
|
14
|
+
willPresent _: UNNotification,
|
|
15
|
+
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
|
|
16
|
+
{
|
|
16
17
|
completionHandler([.alert, .sound])
|
|
17
18
|
}
|
|
18
19
|
}
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
import UIKit
|
|
9
9
|
|
|
10
10
|
class QuickBrickViewController: UIViewController {
|
|
11
|
-
public func allowOrientationForScreen(_
|
|
12
|
-
//not implemented
|
|
11
|
+
public func allowOrientationForScreen(_: Int) {
|
|
12
|
+
// not implemented
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/// Release Orientation for specific screen to previous state
|
|
16
16
|
public func releaseOrientationForScreen() {
|
|
17
|
-
//not implemented
|
|
17
|
+
// not implemented
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -7,63 +7,64 @@
|
|
|
7
7
|
//
|
|
8
8
|
|
|
9
9
|
import Foundation
|
|
10
|
-
import UIKit
|
|
11
10
|
import React
|
|
11
|
+
import UIKit
|
|
12
12
|
|
|
13
13
|
/// Focusable Group View that implements UIFocusGuide instance that catches focus event
|
|
14
|
-
public class FocusableGroupView:RCTTVView {
|
|
15
|
-
|
|
14
|
+
public class FocusableGroupView: RCTTVView {
|
|
16
15
|
/// Completion that will be used when focus manager forcing to update focusable group
|
|
17
|
-
var didFocusCallBack:(completion:(
|
|
18
|
-
|
|
16
|
+
var didFocusCallBack: (completion: () -> Void, focusableItemId: String)?
|
|
17
|
+
|
|
19
18
|
/// This parameter blocks focus behavior without user interaction, it is used to prevent fast jumps between items
|
|
20
19
|
@objc public var isManuallyBlockingFocusValue: NSNumber?
|
|
21
|
-
|
|
20
|
+
|
|
22
21
|
private var isManuallyBlockingFocus: Bool = false
|
|
23
|
-
|
|
22
|
+
|
|
24
23
|
/// Notify React-Native environment that Focus Did Update
|
|
25
|
-
@objc public var onDidUpdateFocus:RCTBubblingEventBlock?
|
|
26
|
-
|
|
24
|
+
@objc public var onDidUpdateFocus: RCTBubblingEventBlock?
|
|
25
|
+
|
|
27
26
|
/// Notify React-Native environment that Focus Will Update
|
|
28
|
-
@objc public var onWillUpdateFocus:RCTBubblingEventBlock?
|
|
29
|
-
|
|
27
|
+
@objc public var onWillUpdateFocus: RCTBubblingEventBlock?
|
|
28
|
+
|
|
30
29
|
/// Define if focus enabled for current view
|
|
31
|
-
@objc public var isFocusDisabled:Bool = false
|
|
32
|
-
|
|
30
|
+
@objc public var isFocusDisabled: Bool = false
|
|
31
|
+
|
|
33
32
|
/// Current group will try to find initial index id in groups
|
|
34
|
-
@objc public var dependantGroupIds:[String]?
|
|
35
|
-
|
|
33
|
+
@objc public var dependantGroupIds: [String]?
|
|
34
|
+
|
|
36
35
|
/// Check if preferred focus has to be reset to initial value, after group becomes inactive
|
|
37
|
-
@objc public var resetFocusToInitialValue:Bool = false
|
|
38
|
-
|
|
36
|
+
@objc public var resetFocusToInitialValue: Bool = false
|
|
37
|
+
|
|
39
38
|
/// ID of the item that must be focused as init focus
|
|
40
|
-
@objc public var initialItemId:String?
|
|
41
|
-
|
|
39
|
+
@objc public var initialItemId: String?
|
|
40
|
+
|
|
42
41
|
/// ID of the Connected GroupView provided by React-Native env
|
|
43
|
-
@objc public var itemId:String? {
|
|
44
|
-
didSet{
|
|
42
|
+
@objc public var itemId: String? {
|
|
43
|
+
didSet {
|
|
45
44
|
if itemId != oldValue {
|
|
46
45
|
_ = FocusableGroupManager.registerFocusableGroup(group: self)
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
|
-
|
|
49
|
+
|
|
51
50
|
/// ID of the parent group, if relevant
|
|
52
|
-
@objc public var groupId:String?
|
|
53
|
-
|
|
51
|
+
@objc public var groupId: String?
|
|
52
|
+
|
|
54
53
|
/// If this variable not nil it overrides default preffered focus environment
|
|
55
|
-
var customPrefferedFocusEnvironment:[UIFocusEnvironment]? {
|
|
54
|
+
var customPrefferedFocusEnvironment: [UIFocusEnvironment]? {
|
|
56
55
|
didSet {
|
|
57
|
-
var rootView:UIView? = self
|
|
56
|
+
var rootView: UIView? = self
|
|
58
57
|
|
|
59
|
-
while
|
|
58
|
+
while rootView?.superview != nil {
|
|
60
59
|
if let unwrapedRootView = rootView,
|
|
61
|
-
|
|
60
|
+
let superView = unwrapedRootView.superview
|
|
61
|
+
{
|
|
62
62
|
rootView = superView
|
|
63
63
|
if let superFocusGroup = rootView as? FocusableGroupView {
|
|
64
64
|
if let newFocusData = customPrefferedFocusEnvironment as? [FocusableView],
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
let superFocusGroupFocusEnvironment = superFocusGroup.customPrefferedFocusEnvironment as? [FocusableView]
|
|
66
|
+
{
|
|
67
|
+
let groupIdsToStay = newFocusData.map(\.groupId)
|
|
67
68
|
let filteredGroups = superFocusGroupFocusEnvironment.filter { !groupIdsToStay.contains($0.groupId) }
|
|
68
69
|
superFocusGroup.customPrefferedFocusEnvironment = filteredGroups + newFocusData
|
|
69
70
|
} else {
|
|
@@ -72,9 +73,9 @@ public class FocusableGroupView:RCTTVView {
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
|
|
78
79
|
/// Check if group has an initial focus
|
|
79
80
|
/// Note: In case Initial init when app start not calling shouldFocusUpdate
|
|
80
81
|
var isGroupWasFocusedByUser = false
|
|
@@ -82,20 +83,21 @@ public class FocusableGroupView:RCTTVView {
|
|
|
82
83
|
/// View connected to GroupView was updated
|
|
83
84
|
///
|
|
84
85
|
/// - Parameter groupItems: dictionary connected to group view
|
|
85
|
-
public func groupItemsUpdated(groupItems:[String:FocusableView]) {
|
|
86
|
+
public func groupItemsUpdated(groupItems: [String: FocusableView]) {
|
|
86
87
|
guard
|
|
87
|
-
|
|
88
|
+
isGroupWasFocusedByUser == false,
|
|
88
89
|
let initialItemId = initialItemId,
|
|
89
|
-
let initialView = groupItems[initialItemId]
|
|
90
|
-
|
|
90
|
+
let initialView = groupItems[initialItemId]
|
|
91
|
+
else {
|
|
92
|
+
return
|
|
91
93
|
}
|
|
92
|
-
|
|
94
|
+
|
|
93
95
|
let focusedView = customPrefferedFocusEnvironment?.first as? UIView
|
|
94
96
|
if focusedView != initialView || focusedView == nil {
|
|
95
97
|
customPrefferedFocusEnvironment = [initialView]
|
|
96
98
|
}
|
|
97
99
|
}
|
|
98
|
-
|
|
100
|
+
|
|
99
101
|
/// Reset focus to initial state if needed
|
|
100
102
|
///
|
|
101
103
|
/// - Parameter nextFocusedItem: next item that should be focused
|
|
@@ -105,15 +107,17 @@ public class FocusableGroupView:RCTTVView {
|
|
|
105
107
|
guard let nextFocusedItem = nextFocusedItem else {
|
|
106
108
|
return retVal
|
|
107
109
|
}
|
|
108
|
-
|
|
110
|
+
|
|
109
111
|
if focusItemIsDescendant(nextFocuseItem: nextFocusedItem) == false {
|
|
110
112
|
if resetFocusToInitialValue,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
let initialItemId = initialItemId
|
|
114
|
+
{
|
|
115
|
+
if tryTakePrefferedViewFromDependantGroups() == false {
|
|
113
116
|
if let groupId = groupId,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
let initialItemView = FocusableGroupManager.item(byGroupId: groupId,
|
|
118
|
+
andItemId: initialItemId)
|
|
119
|
+
{
|
|
120
|
+
customPrefferedFocusEnvironment = [initialItemView]
|
|
117
121
|
retVal = true
|
|
118
122
|
}
|
|
119
123
|
} else {
|
|
@@ -123,71 +127,71 @@ public class FocusableGroupView:RCTTVView {
|
|
|
123
127
|
}
|
|
124
128
|
return retVal
|
|
125
129
|
}
|
|
126
|
-
|
|
130
|
+
|
|
127
131
|
/// Try to focus on preffered item from another group
|
|
128
132
|
///
|
|
129
133
|
/// - Returns: true if can focus otherwise false
|
|
130
134
|
func tryTakePrefferedViewFromDependantGroups() -> Bool {
|
|
131
135
|
guard let initialItemId = initialItemId,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
let dependantGroupIds = dependantGroupIds,
|
|
137
|
+
|
|
138
|
+
let firstGroupId = dependantGroupIds.first,
|
|
139
|
+
let initialView = FocusableGroupManager.item(byGroupId: firstGroupId,
|
|
140
|
+
andItemId: initialItemId)
|
|
141
|
+
else {
|
|
142
|
+
return false
|
|
138
143
|
}
|
|
139
144
|
|
|
140
145
|
customPrefferedFocusEnvironment = [initialView]
|
|
141
|
-
|
|
146
|
+
|
|
142
147
|
return true
|
|
143
148
|
}
|
|
144
|
-
|
|
149
|
+
|
|
145
150
|
/// Focus guide that will catch the focus of the groups
|
|
146
151
|
var focusGuide = UIFocusGuide()
|
|
147
|
-
|
|
152
|
+
|
|
148
153
|
/// Manager that connects View instance to FocusableGroupViewModule
|
|
149
|
-
var manager:FocusableGroupViewModule?
|
|
150
|
-
|
|
154
|
+
var manager: FocusableGroupViewModule?
|
|
155
|
+
|
|
151
156
|
public required init?(coder aDecoder: NSCoder) {
|
|
152
157
|
super.init(coder: aDecoder)
|
|
153
158
|
setupFocus()
|
|
154
159
|
}
|
|
155
|
-
|
|
156
|
-
public
|
|
160
|
+
|
|
161
|
+
override public init(frame: CGRect) {
|
|
157
162
|
super.init(frame: frame)
|
|
158
163
|
setupFocus()
|
|
159
164
|
}
|
|
160
|
-
|
|
165
|
+
|
|
161
166
|
/// Update customPrefferedFocusEnvironment
|
|
162
167
|
///
|
|
163
168
|
/// - Parameter view: view instance that should be preffered
|
|
164
|
-
func updatePrefferedFocusEnv(with view:FocusableView) {
|
|
169
|
+
func updatePrefferedFocusEnv(with view: FocusableView) {
|
|
165
170
|
customPrefferedFocusEnvironment = [view]
|
|
166
171
|
}
|
|
167
|
-
|
|
172
|
+
|
|
168
173
|
/// Setup Focus Guide for use
|
|
169
174
|
func setupFocus() {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
focusGuide.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
|
|
173
|
-
focusGuide.topAnchor.constraint(equalTo: self.topAnchor).isActive = true
|
|
174
|
-
focusGuide.bottomAnchor.constraint(equalTo: self.bottomAnchor).isActive = true
|
|
175
|
-
focusGuide.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
|
|
175
|
+
addLayoutGuide(focusGuide)
|
|
176
176
|
|
|
177
|
+
focusGuide.leftAnchor.constraint(equalTo: leftAnchor).isActive = true
|
|
178
|
+
focusGuide.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
|
179
|
+
focusGuide.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
|
|
180
|
+
focusGuide.rightAnchor.constraint(equalTo: rightAnchor).isActive = true
|
|
177
181
|
}
|
|
178
|
-
|
|
182
|
+
|
|
179
183
|
/// Send update focus event to Reactnative
|
|
180
184
|
///
|
|
181
185
|
/// - Parameter context: Update UIFocusUpdateContext instance
|
|
182
|
-
func sendUpdateFocusEventToReactNative(bubbleEventBlock:RCTBubblingEventBlock?, context:UIFocusUpdateContext) {
|
|
183
|
-
guard let bubbleEventBlock = bubbleEventBlock
|
|
186
|
+
func sendUpdateFocusEventToReactNative(bubbleEventBlock: RCTBubblingEventBlock?, context: UIFocusUpdateContext) {
|
|
187
|
+
guard let bubbleEventBlock = bubbleEventBlock else {
|
|
184
188
|
return
|
|
185
189
|
}
|
|
186
190
|
let focusHeading = focusHeadingToString(focusHeading: context.focusHeading)
|
|
187
|
-
var params:[String:Any] = [GroupViewUpdateEvents.focusHeading:focusHeading]
|
|
188
|
-
|
|
191
|
+
var params: [String: Any] = [GroupViewUpdateEvents.focusHeading: focusHeading]
|
|
192
|
+
|
|
189
193
|
params[GroupViewUpdateEvents.isFocusingByUser] = focusHeading != FocusHeadingTextValues.manualUpdate
|
|
190
|
-
|
|
194
|
+
|
|
191
195
|
params[GroupViewUpdateEvents.previouslyFocusedItem] = dataForFocusItem(focusItem: context.previouslyFocusedView)
|
|
192
196
|
params[GroupViewUpdateEvents.nextFocusedItem] = dataForFocusItem(focusItem: context.nextFocusedView)
|
|
193
197
|
params[GroupViewUpdateEvents.prefferedFocusEnvironment] = dataForFocusItem(focusItem: customPrefferedFocusEnvironment?.first)
|
|
@@ -196,19 +200,20 @@ public class FocusableGroupView:RCTTVView {
|
|
|
196
200
|
if let focusableView = context.nextFocusedItem as? FocusableView {
|
|
197
201
|
params[GroupViewUpdateEvents.itemId] = focusableView.itemId
|
|
198
202
|
}
|
|
199
|
-
|
|
203
|
+
|
|
200
204
|
if focusItemIsDescendant(nextFocuseItem: context.nextFocusedItem) {
|
|
201
205
|
params[GroupViewUpdateEvents.isActive] = true
|
|
202
|
-
|
|
206
|
+
|
|
203
207
|
} else {
|
|
204
208
|
params[GroupViewUpdateEvents.isActive] = false
|
|
205
209
|
isFocusDisabled = false
|
|
206
210
|
if resetFocusToInitialValue,
|
|
207
|
-
|
|
211
|
+
let initialItemId = initialItemId
|
|
212
|
+
{
|
|
208
213
|
if let groupId = groupId {
|
|
209
214
|
let groupItems = FocusableGroupManager.itemsForGroup(by: groupId)
|
|
210
215
|
if let initialItemView = groupItems[initialItemId] {
|
|
211
|
-
|
|
216
|
+
customPrefferedFocusEnvironment = [initialItemView]
|
|
212
217
|
}
|
|
213
218
|
}
|
|
214
219
|
}
|
|
@@ -217,15 +222,14 @@ public class FocusableGroupView:RCTTVView {
|
|
|
217
222
|
|
|
218
223
|
bubbleEventBlock(params)
|
|
219
224
|
}
|
|
220
|
-
|
|
225
|
+
|
|
221
226
|
/// Data for Focus Item that will be passed to React-Native env
|
|
222
227
|
///
|
|
223
228
|
/// - Parameter focusItem: focu item instance
|
|
224
229
|
/// - Returns: dictionary instance in case data exists, otherwise nil
|
|
225
|
-
func dataForFocusItem(focusItem: Any?) -> [String:Any]? {
|
|
226
|
-
var retVal = [String:Any]()
|
|
230
|
+
func dataForFocusItem(focusItem: Any?) -> [String: Any]? {
|
|
231
|
+
var retVal = [String: Any]()
|
|
227
232
|
if let focusedView = focusItem as? RCTTVView {
|
|
228
|
-
|
|
229
233
|
retVal[FocusItemDataKeys.describingView] = String(describing: focusedView)
|
|
230
234
|
if let reactTag = focusedView.reactTag?.stringValue {
|
|
231
235
|
retVal[FocusItemDataKeys.reactTag] = reactTag
|
|
@@ -234,36 +238,38 @@ public class FocusableGroupView:RCTTVView {
|
|
|
234
238
|
}
|
|
235
239
|
return retVal.keys.count == 0 ? nil : retVal
|
|
236
240
|
}
|
|
237
|
-
|
|
241
|
+
|
|
238
242
|
/// Update preffered Focus View for focuse guide if next focuasable view is part of this focus guide
|
|
239
243
|
///
|
|
240
244
|
/// - Parameter nextFocuseItem: next focus item instance
|
|
241
245
|
func updatePreferredFocusView(nextFocuseItem: Any?) {
|
|
242
246
|
guard let nextFocusView = nextFocuseItem as? UIView,
|
|
243
|
-
|
|
247
|
+
nextFocusView.isDescendant(of: self)
|
|
248
|
+
else {
|
|
244
249
|
return
|
|
245
250
|
}
|
|
246
251
|
|
|
247
252
|
customPrefferedFocusEnvironment = [nextFocusView]
|
|
248
253
|
}
|
|
249
|
-
|
|
254
|
+
|
|
250
255
|
/// Checks if next focus item is part of the current group
|
|
251
256
|
///
|
|
252
257
|
/// - Parameter nextFocuseItem: next item to focus
|
|
253
258
|
/// - Returns: true if next focus item part of this group instance
|
|
254
|
-
func focusItemIsDescendant(nextFocuseItem:Any?) -> Bool {
|
|
259
|
+
func focusItemIsDescendant(nextFocuseItem: Any?) -> Bool {
|
|
255
260
|
guard let nextFocusView = nextFocuseItem as? UIView,
|
|
256
|
-
|
|
257
|
-
|
|
261
|
+
nextFocusView.isDescendant(of: self)
|
|
262
|
+
else {
|
|
263
|
+
return false
|
|
258
264
|
}
|
|
259
265
|
return true
|
|
260
266
|
}
|
|
261
|
-
|
|
267
|
+
|
|
262
268
|
/// Mapping focus enum to readable string
|
|
263
269
|
///
|
|
264
270
|
/// - Parameter focusHeading: UIFocusHeading enum
|
|
265
271
|
/// - Returns: Readable string from enum
|
|
266
|
-
func focusHeadingToString(focusHeading:UIFocusHeading) -> String {
|
|
272
|
+
func focusHeadingToString(focusHeading: UIFocusHeading) -> String {
|
|
267
273
|
switch focusHeading {
|
|
268
274
|
case UIFocusHeading.up:
|
|
269
275
|
return FocusHeadingTextValues.up
|
|
@@ -281,48 +287,47 @@ public class FocusableGroupView:RCTTVView {
|
|
|
281
287
|
return FocusHeadingTextValues.manualUpdate
|
|
282
288
|
}
|
|
283
289
|
}
|
|
284
|
-
|
|
290
|
+
|
|
285
291
|
/// Force manually focus update
|
|
286
292
|
func manuallyBlockFocus() {
|
|
287
293
|
if let isManuallyBlockingFocusValue = isManuallyBlockingFocusValue {
|
|
288
294
|
isManuallyBlockingFocus = true
|
|
289
295
|
let delay = DispatchTime.now() + DispatchTimeInterval.milliseconds(Int(isManuallyBlockingFocusValue.floatValue * 1000))
|
|
290
296
|
|
|
291
|
-
DispatchQueue.main.asyncAfter(deadline: delay)
|
|
297
|
+
DispatchQueue.main.asyncAfter(deadline: delay) { [weak self] in
|
|
292
298
|
self?.isManuallyBlockingFocus = false
|
|
293
299
|
}
|
|
294
300
|
}
|
|
295
301
|
}
|
|
296
|
-
|
|
297
|
-
//MARK: Focus Engine
|
|
298
|
-
|
|
299
|
-
public
|
|
302
|
+
|
|
303
|
+
// MARK: Focus Engine
|
|
304
|
+
|
|
305
|
+
override public var preferredFocusEnvironments: [UIFocusEnvironment] {
|
|
300
306
|
if let customPrefferedFocusEnvironment = customPrefferedFocusEnvironment {
|
|
301
307
|
return customPrefferedFocusEnvironment
|
|
302
308
|
}
|
|
303
309
|
return super.preferredFocusEnvironments
|
|
304
310
|
}
|
|
305
|
-
|
|
306
|
-
public
|
|
311
|
+
|
|
312
|
+
override public func shouldUpdateFocus(in context: UIFocusUpdateContext) -> Bool {
|
|
307
313
|
guard isFocusDisabled == false,
|
|
308
|
-
|
|
309
|
-
|
|
314
|
+
isManuallyBlockingFocus == false
|
|
315
|
+
else {
|
|
310
316
|
// Ignoring focus events that blocks by native side for purpose (maybe changed if future)
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
return false
|
|
317
|
+
if isManuallyBlockingFocus == false {
|
|
318
|
+
sendUpdateFocusEventToReactNative(bubbleEventBlock: onWillUpdateFocus,
|
|
319
|
+
context: context)
|
|
320
|
+
}
|
|
321
|
+
return false
|
|
317
322
|
}
|
|
318
323
|
|
|
319
324
|
isGroupWasFocusedByUser = true
|
|
320
|
-
|
|
325
|
+
|
|
321
326
|
if resetFocusPrefferedEnvironmentIfNeeded(nextFocusedItem: context.nextFocusedItem) == false {
|
|
322
327
|
updatePreferredFocusView(nextFocuseItem: context.nextFocusedItem)
|
|
323
328
|
}
|
|
324
329
|
|
|
325
|
-
sendUpdateFocusEventToReactNative(bubbleEventBlock:onWillUpdateFocus,
|
|
330
|
+
sendUpdateFocusEventToReactNative(bubbleEventBlock: onWillUpdateFocus,
|
|
326
331
|
context: context)
|
|
327
332
|
|
|
328
333
|
if focusItemIsDescendant(nextFocuseItem: context.nextFocusedItem) == false {
|
|
@@ -331,26 +336,25 @@ public class FocusableGroupView:RCTTVView {
|
|
|
331
336
|
return true
|
|
332
337
|
}
|
|
333
338
|
|
|
334
|
-
|
|
335
339
|
override public func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {
|
|
336
340
|
super.didUpdateFocus(in: context, with: coordinator)
|
|
337
341
|
manuallyBlockFocus()
|
|
338
342
|
tryDidFocusCallCallback(context: context)
|
|
339
|
-
sendUpdateFocusEventToReactNative(bubbleEventBlock:onDidUpdateFocus,
|
|
343
|
+
sendUpdateFocusEventToReactNative(bubbleEventBlock: onDidUpdateFocus,
|
|
340
344
|
context: context)
|
|
341
345
|
}
|
|
342
|
-
|
|
343
|
-
|
|
346
|
+
|
|
344
347
|
/// Try to send a callback in case focus manager request callback during force focus update
|
|
345
348
|
///
|
|
346
349
|
/// - Parameter context: An instance of UIFocusUpdateContext containing metadata of the focus related update.
|
|
347
350
|
func tryDidFocusCallCallback(context: UIFocusUpdateContext) {
|
|
348
351
|
guard let callbackData = didFocusCallBack,
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
+
let fousedView = context.nextFocusedView as? FocusableView,
|
|
353
|
+
let itemId = fousedView.itemId
|
|
354
|
+
else {
|
|
355
|
+
return
|
|
352
356
|
}
|
|
353
|
-
|
|
357
|
+
|
|
354
358
|
let completion = callbackData.completion
|
|
355
359
|
let focusableItemId = callbackData.focusableItemId
|
|
356
360
|
if itemId == focusableItemId {
|
|
@@ -7,32 +7,32 @@
|
|
|
7
7
|
//
|
|
8
8
|
|
|
9
9
|
/// Defines Keys that will be passed for focus event heading
|
|
10
|
-
public
|
|
11
|
-
static let up
|
|
12
|
-
static let down
|
|
13
|
-
static let left
|
|
14
|
-
static let right
|
|
15
|
-
static let next
|
|
16
|
-
static let previous
|
|
10
|
+
public enum FocusHeadingTextValues {
|
|
11
|
+
static let up = "Up"
|
|
12
|
+
static let down = "Down"
|
|
13
|
+
static let left = "Left"
|
|
14
|
+
static let right = "Right"
|
|
15
|
+
static let next = "Next"
|
|
16
|
+
static let previous = "Previous"
|
|
17
17
|
static let manualUpdate = "Posible manual update or initial focus by tvOS"
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/// Group view events that will be passed to React-Native env
|
|
21
|
-
public
|
|
22
|
-
static let focusHeading
|
|
23
|
-
static let previouslyFocusedItem
|
|
24
|
-
static let nextFocusedItem
|
|
21
|
+
public enum GroupViewUpdateEvents {
|
|
22
|
+
static let focusHeading = "focusHeading"
|
|
23
|
+
static let previouslyFocusedItem = "previouslyFocusedItem"
|
|
24
|
+
static let nextFocusedItem = "nextFocusedItem"
|
|
25
25
|
static let prefferedFocusEnvironment = "prefferedFocusEnvironment"
|
|
26
|
-
static let groupId
|
|
27
|
-
static let itemId
|
|
28
|
-
static let isActive
|
|
29
|
-
static let isFocusDisabled
|
|
30
|
-
static let isFocusingByUser
|
|
26
|
+
static let groupId = "groupId"
|
|
27
|
+
static let itemId = "itemId"
|
|
28
|
+
static let isActive = "isActive"
|
|
29
|
+
static let isFocusDisabled = "isFocusDisabled"
|
|
30
|
+
static let isFocusingByUser = "isFocusingByUser"
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/// Keys that will be passed to React-Native env for GroupViewUpdateEvents with `previouslyFocusedItem` and `nextFocusedItem`
|
|
34
|
-
public
|
|
34
|
+
public enum FocusItemDataKeys {
|
|
35
35
|
static let describingView = "describingView"
|
|
36
|
-
static let reactTag
|
|
37
|
-
static let isDescendant
|
|
36
|
+
static let reactTag = "reactTag"
|
|
37
|
+
static let isDescendant = "isDescendant"
|
|
38
38
|
}
|
|
@@ -12,29 +12,29 @@ import React
|
|
|
12
12
|
@objc(FocusableGroupViewModule)
|
|
13
13
|
public class FocusableGroupViewModule: RCTViewManager {
|
|
14
14
|
static let focusableGroupViewModuleName = "FocusableGroupViewModule"
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
override public static func moduleName() -> String? {
|
|
17
|
-
|
|
17
|
+
focusableGroupViewModuleName
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
override public class func requiresMainQueueSetup() -> Bool {
|
|
21
|
-
|
|
21
|
+
true
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
override open var methodQueue: DispatchQueue {
|
|
25
|
-
|
|
25
|
+
bridge.uiManager.methodQueue
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
override public func view() -> UIView? {
|
|
29
29
|
let retVal = FocusableGroupView()
|
|
30
30
|
retVal.manager = self
|
|
31
31
|
return retVal
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
public func viewFromReactTag(reactTag:NSNumber?) -> RCTTVView? {
|
|
33
|
+
|
|
34
|
+
public func viewFromReactTag(reactTag: NSNumber?) -> RCTTVView? {
|
|
35
35
|
guard let reactTag = reactTag else {
|
|
36
36
|
return nil
|
|
37
37
|
}
|
|
38
|
-
return
|
|
38
|
+
return bridge.uiManager.view(forReactTag: reactTag) as? RCTTVView
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -8,42 +8,36 @@
|
|
|
8
8
|
|
|
9
9
|
import Foundation
|
|
10
10
|
|
|
11
|
-
extension FocusableView:ParallaxViewDelegate {
|
|
12
|
-
public func parallaxViewWillFocus(_
|
|
11
|
+
extension FocusableView: ParallaxViewDelegate {
|
|
12
|
+
public func parallaxViewWillFocus(_: ParallaxView) {
|
|
13
13
|
guard let onFocus = onViewFocus else {
|
|
14
14
|
return
|
|
15
15
|
}
|
|
16
16
|
onFocus(eventData())
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
public func parallaxViewDidFocus(_ parallaxView: ParallaxView) {
|
|
20
18
|
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public func parallaxViewWillUnfocus(_
|
|
19
|
+
public func parallaxViewDidFocus(_: ParallaxView) {}
|
|
20
|
+
|
|
21
|
+
public func parallaxViewWillUnfocus(_: ParallaxView) {
|
|
24
22
|
guard let onBlur = onViewBlur else {
|
|
25
23
|
return
|
|
26
24
|
}
|
|
27
25
|
onBlur(eventData())
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
public func parallaxViewDidUnfocus(_
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public func
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public func parallaxViewDidSelected(_ parallaxView: ParallaxView) {
|
|
27
|
+
|
|
28
|
+
public func parallaxViewDidUnfocus(_: ParallaxView) {}
|
|
29
|
+
|
|
30
|
+
public func parallaxViewWillSelected(_: ParallaxView) {}
|
|
31
|
+
|
|
32
|
+
public func parallaxViewDidSelected(_: ParallaxView) {
|
|
39
33
|
guard let onPress = onViewPress else {
|
|
40
34
|
return
|
|
41
35
|
}
|
|
42
36
|
onPress(eventData())
|
|
43
37
|
}
|
|
44
|
-
|
|
45
|
-
func eventData() -> [String:Any] {
|
|
46
|
-
var retVal:[String:Any] = [:]
|
|
38
|
+
|
|
39
|
+
func eventData() -> [String: Any] {
|
|
40
|
+
var retVal: [String: Any] = [:]
|
|
47
41
|
retVal["tag"] = reactTag
|
|
48
42
|
retVal["itemID"] = itemId
|
|
49
43
|
return retVal
|