@applicaster/quick-brick-native-apple 5.14.2-alpha.2 → 5.15.0-alpha.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "QuickBrickApple",
3
- "version": "5.14.2-alpha.2",
3
+ "version": "5.15.0-alpha.0",
4
4
  "platforms": {
5
5
  "ios": "12.0",
6
6
  "tvos": "12.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.14.2-alpha.2"
19
+ "tag": "@@applicaster/quick-brick-native-apple/5.15.0-alpha.0"
20
20
  },
21
21
  "requires_arc": true,
22
22
  "source_files": "universal/**/*.{m,swift}",
@@ -9,6 +9,7 @@
9
9
  import Foundation
10
10
  import os.log
11
11
  import React
12
+ import ZappCore
12
13
 
13
14
  let kQuickBrickCommunicationModule = "QuickBrickCommunicationModule"
14
15
 
@@ -16,6 +17,16 @@ let kQuickBrickCommunicationModule = "QuickBrickCommunicationModule"
16
17
  Events Supported by the QuickBrickManager native module
17
18
  In order to add events, add a case, and add the invoke the appropriate handler in the invokeHandler method
18
19
  */
20
+
21
+ struct ReactNativeCommunicationModuleError {
22
+ public static let errorCode = "ReactNativeCommunicationModuleError"
23
+ public static let languageIsUndefined = "Language value is undefined"
24
+ public static let languageIsEmpty = "Language value is empty"
25
+ public static let localStorageNotAccessible = "Can not access Local Storage"
26
+ public static let unableToSaveToLocalStorage = "Unable to save value to Local Storage"
27
+ public static let unableToUseDelegateManager = "Unable to use delegate manager"
28
+ }
29
+
19
30
  enum Events: String {
20
31
  case quickBrickReady
21
32
  case moveAppToBackground
@@ -45,7 +56,7 @@ enum Events: String {
45
56
  case .forceAppReload:
46
57
  manager.forceAppReload()
47
58
  case .setPrefersHomeIndicatorAutoHidden:
48
- manager.setPrefersHomeIndicatorAutoHidden(payload)
59
+ manager.setPrefersHomeIndicatorAutoHidden(payload)
49
60
  }
50
61
  }
51
62
  }
@@ -123,4 +134,49 @@ class ReactNativeCommunicationModule: NSObject, RCTBridgeModule {
123
134
 
124
135
  event?.invokeHandler(manager: delegateManager, payload: payload ?? [:])
125
136
  }
137
+
138
+ @objc func setAppLanguage(_ language: String?,
139
+ resolver: @escaping RCTPromiseResolveBlock,
140
+ rejecter: @escaping RCTPromiseRejectBlock) {
141
+ let storageKey = "forcedLanguageCode"
142
+
143
+ guard let language = language else {
144
+ rejecter(ReactNativeCommunicationModuleError.errorCode,
145
+ ReactNativeCommunicationModuleError.languageIsUndefined,
146
+ nil)
147
+ return
148
+ }
149
+
150
+ guard !language.isEmpty else {
151
+ rejecter(ReactNativeCommunicationModuleError.errorCode,
152
+ ReactNativeCommunicationModuleError.languageIsEmpty,
153
+ nil)
154
+ return
155
+ }
156
+
157
+ guard let delegateManager = self.delegateManager else {
158
+ rejecter(ReactNativeCommunicationModuleError.errorCode,
159
+ ReactNativeCommunicationModuleError.unableToUseDelegateManager, nil)
160
+ return
161
+ }
162
+
163
+ DispatchQueue.main.async {
164
+ guard let storage = FacadeConnector.connector?.storage else {
165
+ rejecter(ReactNativeCommunicationModuleError.errorCode,
166
+ ReactNativeCommunicationModuleError.localStorageNotAccessible, nil)
167
+ return
168
+ }
169
+
170
+ if storage.localStorageSetValue(for: storageKey,
171
+ value: language,
172
+ namespace: nil) == true {
173
+ resolver(true)
174
+ } else {
175
+ rejecter(ReactNativeCommunicationModuleError.errorCode,
176
+ ReactNativeCommunicationModuleError.unableToSaveToLocalStorage, nil)
177
+ }
178
+
179
+ delegateManager.forceAppReload()
180
+ }
181
+ }
126
182
  }
@@ -14,7 +14,6 @@ import ZappCore
14
14
 
15
15
  public let kQBModuleName = "QuickBrickApp"
16
16
  public let suspendApp = "suspend"
17
- public let kQBLoadingTimeout: TimeInterval = 20
18
17
 
19
18
  /// React Native Manager class for Quick Brick
20
19
  open class ReactNativeManager: NSObject, UserInterfaceLayerProtocol, UserInterfaceLayerDelegate {
@@ -24,7 +23,7 @@ open class ReactNativeManager: NSObject, UserInterfaceLayerProtocol, UserInterfa
24
23
 
25
24
  var launchOptions: [UIApplication.LaunchOptionsKey: Any]?
26
25
  var reactNativePackagerRoot: String?
27
- var timeoutTimer: Timer?
26
+
28
27
  var completion: ((_ viewController: UIViewController?, _ error: Error?) -> Void)?
29
28
 
30
29
  /// url of the react server
@@ -89,12 +88,6 @@ open class ReactNativeManager: NSObject, UserInterfaceLayerProtocol, UserInterfa
89
88
 
90
89
  public func prepareLayerForUse(completion: @escaping (_ viewController: UIViewController?, _ error: Error?) -> Void) {
91
90
  setRightToLeftFlag {
92
- self.timeoutTimer = Timer.scheduledTimer(withTimeInterval: kQBLoadingTimeout,
93
- repeats: false,
94
- block: { _ in
95
- EventsBus.post(EventsBus.Event(type: EventsBusType(.userInterfaceLayerLoadingDelayed),
96
- data: self.launchOptions ?? [:]))
97
- })
98
91
  self.mountReactApp(self.launchOptions)
99
92
  self.completion = completion
100
93
  }
@@ -190,7 +183,6 @@ extension ReactNativeManager: RCTBridgeDelegate {
190
183
 
191
184
  extension ReactNativeManager: QuickBrickManagerDelegate {
192
185
  public func setQuickBrickReady() {
193
- timeoutTimer?.invalidate()
194
186
  completion?(reactNativeViewController(), nil)
195
187
  completion = nil
196
188
  }
@@ -234,4 +226,4 @@ extension ReactNativeManager: QuickBrickManagerDelegate {
234
226
  public func forceAppReload() {
235
227
  EventsBus.post(EventsBus.Event(type: EventsBusType(.forceAppReload)))
236
228
  }
237
- }
229
+ }
@@ -13,6 +13,9 @@
13
13
  RCT_EXTERN_METHOD(quickBrickEvent:(NSString *)eventName
14
14
  payload:(NSDictionary *)payload);
15
15
 
16
+ RCT_EXTERN_METHOD(setAppLanguage:(NSString *)language
17
+ resolver:(RCTPromiseResolveBlock)resolver
18
+ rejecter:(RCTPromiseRejectBlock)rejecter);
16
19
  @end
17
20
 
18
21
  @interface RCT_EXTERN_MODULE (AnalyticsBridge, NSObject)
@@ -123,5 +126,5 @@ RCT_EXTERN_METHOD(delete:(NSString *)path
123
126
  rejecter:(RCTPromiseRejectBlock)reject);
124
127
 
125
128
  RCT_EXTERN_METHOD(getFilesDirectory:(RCTPromiseResolveBlock)resolve
126
- rejecter:(RCTPromiseRejectBlock)reject);
129
+ rejecter:(RCTPromiseRejectBlock)reject);
127
130
  @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-native-apple",
3
- "version": "5.14.2-alpha.2",
3
+ "version": "5.15.0-alpha.0",
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"