@applicaster/quick-brick-native-apple 6.11.1 → 6.11.2

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "QuickBrickApple",
3
- "version": "6.11.1",
3
+ "version": "6.11.2",
4
4
  "platforms": {
5
5
  "ios": "16.0",
6
6
  "tvos": "16.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/6.11.1"
19
+ "tag": "@@applicaster/quick-brick-native-apple/6.11.2"
20
20
  },
21
21
  "requires_arc": true,
22
22
  "source_files": "universal/**/*.{m,swift}",
@@ -12,7 +12,6 @@ import React
12
12
 
13
13
  protocol FocusableGroupManagerUpdater {
14
14
  var focusableGroupRegistrationUpdates: PassthroughSubject<FocusableGroupView, Never> { get }
15
- var focusableItemsUpdatedAddedToGroupUpdate: PassthroughSubject<FocusableGroupUpdateEvent, Never> { get }
16
15
  var focusableItemDidUpdatePreferredFocus: PassthroughSubject<FocusableView, Never> { get }
17
16
  }
18
17
 
@@ -50,8 +49,6 @@ class FocusableGroupManager {
50
49
  for itemId in items.keys {
51
50
  await itemStorage.unregisterItem(withId: itemId, inGroup: groupId)
52
51
  }
53
-
54
- await notifyGroupView(groupId: groupId)
55
52
  }
56
53
 
57
54
  public func getGroup(by groupID: String) async -> FocusableGroupView? {
@@ -64,7 +61,6 @@ class FocusableGroupManager {
64
61
  let success = await itemStorage.registerItem(item)
65
62
  if success,
66
63
  let groupId = await item.groupId {
67
- await notifyGroupView(groupId: groupId)
68
64
  if let itemGroup = await getGroup(by: groupId) {
69
65
  // Handler in case group was registerd later then items
70
66
  // TODO: Check this it gives a lot of calls, need to be optimized
@@ -76,7 +72,6 @@ class FocusableGroupManager {
76
72
 
77
73
  public func unregisterItem(withId itemId: String, inGroup groupId: String) async {
78
74
  await itemStorage.unregisterItem(withId: itemId, inGroup: groupId)
79
- await notifyGroupView(groupId: groupId)
80
75
  }
81
76
 
82
77
  public func getItems(forGroup groupId: String) async -> [String: FocusableView] {
@@ -87,15 +82,6 @@ class FocusableGroupManager {
87
82
  await itemStorage.item(withId: itemId, inGroup: groupId)
88
83
  }
89
84
 
90
- /// Notify group view that item relevant to it was updated
91
- ///
92
- /// - Parameter groupID: ID of the group
93
- private func notifyGroupView(groupId: String) async {
94
- let groupItems = await getItems(forGroup: groupId)
95
- updateService.sendFocusableItemInGroupUpdate(groupId: groupId,
96
- focusableItems: groupItems)
97
- }
98
-
99
85
  public func notifyFocusableItemDidUpdatePreferredFocus(focusableView: FocusableView) {
100
86
  updateService.sendFocusableItemDidUpdatePreferredFocus(focusableView)
101
87
  }
@@ -174,8 +160,4 @@ extension FocusableGroupManager: FocusableGroupManagerUpdater {
174
160
  var focusableGroupRegistrationUpdates: PassthroughSubject<FocusableGroupView, Never> {
175
161
  updateService.focusableGroupRegistrationUpdates
176
162
  }
177
-
178
- var focusableItemsUpdatedAddedToGroupUpdate: PassthroughSubject<FocusableGroupUpdateEvent, Never> {
179
- updateService.focusableItemsUpdatedAddedToGroupUpdate
180
- }
181
163
  }
@@ -14,20 +14,12 @@ struct FocusableGroupUpdateEvent {
14
14
 
15
15
  class UpdateService {
16
16
  let focusableGroupRegistrationUpdates = PassthroughSubject<FocusableGroupView, Never>()
17
- let focusableItemsUpdatedAddedToGroupUpdate = PassthroughSubject<FocusableGroupUpdateEvent, Never>()
18
17
  let focusableItemDidUpdatePreferredFocus = PassthroughSubject<FocusableView, Never>()
19
18
 
20
19
  public func sendFocusableGroupRegisteredUpdate(_ focusableGroupView: FocusableGroupView) {
21
20
  focusableGroupRegistrationUpdates.send(focusableGroupView)
22
21
  }
23
22
 
24
- public func sendFocusableItemInGroupUpdate(groupId: String,
25
- focusableItems: [String: FocusableView]) {
26
- let event = FocusableGroupUpdateEvent(groupId: groupId,
27
- focusableItems: focusableItems)
28
- focusableItemsUpdatedAddedToGroupUpdate.send(event)
29
- }
30
-
31
23
  public func sendFocusableItemDidUpdatePreferredFocus(_ focusableView: FocusableView) {
32
24
  focusableItemDidUpdatePreferredFocus.send(focusableView)
33
25
  }
@@ -22,8 +22,7 @@ RCT_EXPORT_VIEW_PROPERTY(onGroupFocus, RCTDirectEventBlock)
22
22
  RCT_EXPORT_VIEW_PROPERTY(onGroupBlur, RCTDirectEventBlock)
23
23
  RCT_EXPORT_VIEW_PROPERTY(itemId, NSString);
24
24
  RCT_EXPORT_VIEW_PROPERTY(groupId, NSString);
25
- RCT_EXPORT_VIEW_PROPERTY(initialItemId, NSString);
26
- RCT_EXPORT_VIEW_PROPERTY(isPreferredFocusDisabled, BOOL);
25
+ RCT_EXPORT_VIEW_PROPERTY(isWithMemory, BOOL);
27
26
  RCT_EXPORT_VIEW_PROPERTY(isFocusDisabled, BOOL);
28
27
  @end
29
28
 
@@ -15,7 +15,24 @@ import UIKit
15
15
  ///
16
16
  public class FocusableGroupView: RCTTVView {
17
17
  override public var debugDescription: String {
18
- "GROUP_ID: \(groupId ?? "NONE"), ID: \(itemId ?? "NONE"), \(super.debugDescription)"
18
+ let groupIdDesc = groupId ?? "NO_GROUP"
19
+ let itemIdDesc = itemId ?? "NO_ID"
20
+ let activeStateDesc = activeStateNotifier.isActive ? "ACTIVE" : "inactive"
21
+ let focusDisabledDesc = isFocusDisabled ? "focus-disabled" : "focus-enabled"
22
+ let preferredFocusDisabledDesc = isPreferredFocusDisabled ? "preferred-focus-disabled" : "preferred-focus-enabled"
23
+ let dependentGroupsDesc = dependantGroupIds?.joined(separator: ",") ?? "NO_DEPS"
24
+ let reactTagDesc = reactTag?.stringValue ?? "NO_TAG"
25
+
26
+ return """
27
+ FocusableGroupView[
28
+ ID: \(itemIdDesc)
29
+ GROUP: \(groupIdDesc)
30
+ TAG: \(reactTagDesc)
31
+ STATE: \(activeStateDesc), \(focusDisabledDesc), \(preferredFocusDisabledDesc)
32
+ DEPS: \(dependentGroupsDesc)
33
+ FRAME: \(frame)
34
+ ]
35
+ """
19
36
  }
20
37
 
21
38
  private var cancellables = Set<AnyCancellable>()
@@ -35,13 +52,9 @@ public class FocusableGroupView: RCTTVView {
35
52
  @objc public var dependantGroupIds: [String]?
36
53
 
37
54
  /// Check if preferred focus environment disabled
38
- @objc public var isPreferredFocusDisabled: Bool = false
39
-
40
- /// ID of the item that must be focused as init focus
41
- @objc public var initialItemId: String? {
42
- didSet {
43
- updateInitialItemId()
44
- }
55
+ @objc public var isWithMemory: Bool = true
56
+ var isPreferredFocusDisabled: Bool {
57
+ isWithMemory == false
45
58
  }
46
59
 
47
60
  /// ID of the Connected GroupView provided by React-Native env
@@ -58,15 +71,13 @@ public class FocusableGroupView: RCTTVView {
58
71
  /// ID of the parent group, if relevant
59
72
  @objc public var groupId: String?
60
73
 
61
- private var userPreferredFocusEnvironments: [UIFocusEnvironment]?
74
+ @MainActor private var userPreferredFocusEnvironments: [UIFocusEnvironment]?
75
+ @MainActor private var customPreferredFocusEnvironment: [UIFocusEnvironment]?
62
76
 
63
77
  private var manager: FocusableGroupManager {
64
78
  FocusableGroupManager.shared
65
79
  }
66
80
 
67
- /// If this variable not nil it overrides default preferred focus environment
68
- @MainActor private var customPreferredFocusEnvironment: [UIFocusEnvironment]?
69
-
70
81
  /// Manager that connects View instance to FocusableGroupViewModule
71
82
  private weak var module: FocusableGroupViewModule?
72
83
  public func setModule(_ module: FocusableGroupViewModule) {
@@ -120,13 +131,6 @@ public class FocusableGroupView: RCTTVView {
120
131
  focusGuide.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
121
132
  focusGuide.rightAnchor.constraint(equalTo: rightAnchor).isActive = true
122
133
 
123
- manager.focusableItemsUpdatedAddedToGroupUpdate
124
- .filter { $0.groupId == self.groupId }
125
- .sink { [weak self] _ in
126
- guard let self else { return }
127
- updateInitialItemId()
128
- }.store(in: &cancellables)
129
-
130
134
  manager.focusableItemDidUpdatePreferredFocus
131
135
  .filter { self.groupId != nil && $0.groupId == self.itemId }
132
136
  .sink { [weak self] focusableView in
@@ -143,23 +147,6 @@ public class FocusableGroupView: RCTTVView {
143
147
  }.store(in: &cancellables)
144
148
  }
145
149
 
146
- /// Update initial item id
147
- @MainActor private func updateInitialItemId() {
148
- Task(priority: .userInitiated) { [weak self] in
149
- guard let self else { return }
150
-
151
- guard
152
- let initialItemId,
153
- let groupId,
154
- let initialView = await manager.getItem(withId: initialItemId, inGroup: groupId)
155
- else {
156
- return
157
- }
158
-
159
- updatePreferredFocusEnv(with: initialView)
160
- }
161
- }
162
-
163
150
  private func createFocusEventParams(context: UIFocusUpdateContext, isActive: Bool) -> [String: Any] {
164
151
  var params: [String: Any] = [
165
152
  GroupViewUpdateEvents.focusHeading: focusHeadingToString(focusHeading: context.focusHeading),
@@ -256,7 +243,7 @@ public class FocusableGroupView: RCTTVView {
256
243
  // MARK: Focus Engine
257
244
 
258
245
  override public var preferredFocusEnvironments: [UIFocusEnvironment] {
259
- userPreferredFocusEnvironments ?? customPreferredFocusEnvironment ?? super.preferredFocusEnvironments
246
+ customPreferredFocusEnvironment ?? userPreferredFocusEnvironments ?? super.preferredFocusEnvironments
260
247
  }
261
248
 
262
249
  override public func shouldUpdateFocus(in _: UIFocusUpdateContext) -> Bool {
@@ -14,7 +14,26 @@ import UIKit
14
14
  /// RCTTVView subclass that has api how to conects to FocusableGroup
15
15
  public class FocusableView: ParallaxView {
16
16
  override public var debugDescription: String {
17
- "GROUP_ID: \(groupId ?? "NONE"), ID: \(itemId ?? "NONE"), \(super.debugDescription)"
17
+ let groupIdDesc = groupId ?? "NO_GROUP"
18
+ let itemIdDesc = itemId ?? "NO_ID"
19
+ let focusableDesc = focusable ? "focusable" : "non-focusable"
20
+ let preferredFocusDesc = preferredFocus ? "preferred" : "not-preferred"
21
+ let isRegisteredDesc = isViewRegistered ? "registered" : "unregistered"
22
+ let reactTagDesc = reactTag?.stringValue ?? "NO_TAG"
23
+ let focusStateDesc = isFocused ? "FOCUSED" : "unfocused"
24
+ let parallelDesc = isParallaxDisabled ? "parallax-off" : "parallax-on"
25
+ let pressDesc = isPressDisabled ? "press-disabled" : "press-enabled"
26
+
27
+ return """
28
+ FocusableView[
29
+ ID: \(itemIdDesc)
30
+ GROUP: \(groupIdDesc)
31
+ TAG: \(reactTagDesc)
32
+ STATE: \(focusStateDesc), \(focusableDesc), \(preferredFocusDesc), \(isRegisteredDesc)
33
+ SETTINGS: \(parallelDesc), \(pressDesc)
34
+ FRAME: \(frame)
35
+ ]
36
+ """
18
37
  }
19
38
 
20
39
  private var cancellables = Set<AnyCancellable>()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-native-apple",
3
- "version": "6.11.1",
3
+ "version": "6.11.2",
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"