@applicaster/quick-brick-core 13.0.0-alpha.4700935119 → 13.0.0-alpha.4936752427

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.
@@ -0,0 +1,27 @@
1
+ import { BehaviorSubject } from "rxjs";
2
+
3
+ class LoadingOverlayManager {
4
+ visibilitySubject: BehaviorSubject<boolean>;
5
+
6
+ constructor() {
7
+ this.visibilitySubject = new BehaviorSubject(false);
8
+ }
9
+
10
+ show() {
11
+ this.visibilitySubject.next(true);
12
+ }
13
+
14
+ hide() {
15
+ this.visibilitySubject.next(false);
16
+ }
17
+
18
+ onVisibilityStateChange(cb: (value: boolean) => void) {
19
+ return this.visibilitySubject.subscribe(cb);
20
+ }
21
+
22
+ get visibility(): boolean {
23
+ return this.visibilitySubject.value;
24
+ }
25
+ }
26
+
27
+ export const loadingOverlayManager = new LoadingOverlayManager();
@@ -0,0 +1,46 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet } from "react-native";
3
+ import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
4
+ import { Spinner } from "@applicaster/zapp-react-native-ui-components/Components/Spinner";
5
+ import { Spinner as CSSSpinner } from "@applicaster/zapp-react-dom-ui-components/Components/Spinner";
6
+ import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
7
+ import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
8
+
9
+ import { useLoadingOverlayVisibility } from "./useLoadingOverlayVisibility";
10
+
11
+ export { loadingOverlayManager } from "./LoadingOverlayManager";
12
+
13
+ const styles = StyleSheet.create({
14
+ container: {
15
+ opacity: 0.5,
16
+ alignItems: "center",
17
+ justifyContent: "center",
18
+ },
19
+ });
20
+
21
+ const SpinnerComponent = isWeb() ? CSSSpinner : Spinner;
22
+
23
+ export const LoadingOverlay = () => {
24
+ const visible = useLoadingOverlayVisibility();
25
+ const theme = useTheme();
26
+
27
+ const backgroundColor = React.useMemo(() => {
28
+ return theme?.app_background_color || "black";
29
+ }, [theme?.app_background_color]);
30
+
31
+ React.useEffect(() => {
32
+ if (visible) {
33
+ focusManager.disableFocus();
34
+ } else {
35
+ focusManager.enableFocus();
36
+ }
37
+ }, [visible]);
38
+
39
+ return visible ? (
40
+ <View
41
+ style={[StyleSheet.absoluteFill, styles.container, { backgroundColor }]}
42
+ >
43
+ <SpinnerComponent />
44
+ </View>
45
+ ) : null;
46
+ };
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+ import { loadingOverlayManager } from "./LoadingOverlayManager";
3
+
4
+ export const useLoadingOverlayVisibility = () => {
5
+ const [visible, setVisible] = React.useState(
6
+ loadingOverlayManager.visibility
7
+ );
8
+
9
+ React.useEffect(() => {
10
+ const listener = loadingOverlayManager.onVisibilityStateChange(setVisible);
11
+
12
+ return () => {
13
+ listener.unsubscribe();
14
+ };
15
+ }, []);
16
+
17
+ return visible;
18
+ };
@@ -68,6 +68,8 @@ import { useSubscriberFor } from "@applicaster/zapp-react-native-utils/reactHook
68
68
  import { QBUIComponentEvents } from "@applicaster/zapp-react-native-ui-components/events";
69
69
  import { Hook } from "@applicaster/zapp-react-native-utils/appUtils/HooksManager/Hook";
70
70
 
71
+ import { loadingOverlayManager } from "../LoadingOverlay";
72
+
71
73
  const logger = coreAppLogger.addSubsystem("Navigator");
72
74
 
73
75
  type Props = {
@@ -393,6 +395,8 @@ export function NavigationProvider({ children }: Props) {
393
395
  } else {
394
396
  dispatch(push(route, { entry: payload, screen: hookPlugin }));
395
397
  }
398
+
399
+ closeLoadingOverlay();
396
400
  };
397
401
 
398
402
  const handleHookError = ({ error, hookPlugin, callback }, dispose) => {
@@ -411,6 +415,8 @@ export function NavigationProvider({ children }: Props) {
411
415
  if (callback && typeof callback === "function") {
412
416
  callback();
413
417
  }
418
+
419
+ closeLoadingOverlay();
414
420
  };
415
421
 
416
422
  const handleHookCancel = ({ hookPlugin, callback }, dispose) => {
@@ -426,6 +432,8 @@ export function NavigationProvider({ children }: Props) {
426
432
  } else {
427
433
  goBack(true, true);
428
434
  }
435
+
436
+ closeLoadingOverlay();
429
437
  };
430
438
 
431
439
  const handleHookSuccess = ({ hookPlugin, callback }) => {
@@ -436,6 +444,10 @@ export function NavigationProvider({ children }: Props) {
436
444
  }
437
445
  };
438
446
 
447
+ const handleBackgroundHook = () => {
448
+ openLoadingOverlay();
449
+ };
450
+
439
451
  const checkStartUpHooks = React.useMemo(() => {
440
452
  if (!pluginConfigurations) return false;
441
453
 
@@ -505,6 +517,8 @@ export function NavigationProvider({ children }: Props) {
505
517
  );
506
518
 
507
519
  callback?.();
520
+
521
+ closeLoadingOverlay();
508
522
  };
509
523
 
510
524
  const offlinePlugin = React.useMemo(() => {
@@ -619,6 +633,7 @@ export function NavigationProvider({ children }: Props) {
619
633
  .on(HOOKS_EVENTS.ERROR, handleHookError)
620
634
  .on(HOOKS_EVENTS.CANCEL, handleHookCancel)
621
635
  .on(HOOKS_EVENTS.SUCCESS, handleHookSuccess)
636
+ .on(HOOKS_EVENTS.START_BACKGROUND_HOOK, handleBackgroundHook)
622
637
  .on(
623
638
  HOOKS_EVENTS.COMPLETE,
624
639
  handleHookComplete(navigationAction, targetRoute, {
@@ -634,6 +649,14 @@ export function NavigationProvider({ children }: Props) {
634
649
  },
635
650
  });
636
651
 
652
+ const openLoadingOverlay = React.useCallback(() => {
653
+ isTV() && loadingOverlayManager.show();
654
+ }, []);
655
+
656
+ const closeLoadingOverlay = React.useCallback(() => {
657
+ loadingOverlayManager.hide();
658
+ }, []);
659
+
637
660
  const openPiP = React.useCallback(() => {
638
661
  dispatch(setVideoPiP());
639
662
  }, []);
@@ -131,9 +131,8 @@ export function appLifeCycleManager(appLoader, QuickBrickManager) {
131
131
  )
132
132
  .map((plugin: any) => plugin.module?.getLoginProtocol?.());
133
133
 
134
- const loginProtocols: LoginProtocol[] = await Promise.all(
135
- promiseProtocols
136
- );
134
+ const loginProtocols: LoginProtocol[] =
135
+ await Promise.all(promiseProtocols);
137
136
 
138
137
  // Await all does not work here
139
138
  for (const protocol of loginProtocols) {
package/App/index.tsx CHANGED
@@ -29,6 +29,7 @@ import { appRemoteDataLoader } from "./appRemoteDataLoader";
29
29
  import { withActionExecutor } from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutorContext";
30
30
  import { withScreenDataContextProvider } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
31
31
  import { LogicAggregatorContainer } from "./LogicAggregatorContainer";
32
+ import { LoadingOverlay } from "./LoadingOverlay";
32
33
 
33
34
  interface AppOptions {
34
35
  Layout: React.ComponentType;
@@ -74,6 +75,7 @@ const App = ({
74
75
  <LogicAggregatorContainer
75
76
  components={[InteractionManager, ApplyScreenHooks]}
76
77
  />
78
+ <LoadingOverlay />
77
79
  </ErrorBoundary>
78
80
  </AppContainer>
79
81
  </SafeAreaProvider>
package/index.d.ts CHANGED
@@ -24,7 +24,7 @@ type AnyValue = void | string | number | boolean | AnyArray | AnyRecord;
24
24
  declare type ReducerAction<
25
25
  T extends string = string,
26
26
  P extends AnyValue = AnyValue,
27
- M extends AnyRecord = AnyRecord
27
+ M extends AnyRecord = AnyRecord,
28
28
  > = {
29
29
  type: T;
30
30
  payload?: P;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-core",
3
- "version": "13.0.0-alpha.4700935119",
3
+ "version": "13.0.0-alpha.4936752427",
4
4
  "description": "Core package for Applicaster's Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -29,13 +29,13 @@
29
29
  },
30
30
  "homepage": "https://github.com/applicaster/quickbrick#readme",
31
31
  "dependencies": {
32
- "@applicaster/applicaster-types": "13.0.0-alpha.4700935119",
33
- "@applicaster/quick-brick-core-plugins": "13.0.0-alpha.4700935119",
34
- "@applicaster/zapp-pipes-v2-client": "13.0.0-alpha.4700935119",
35
- "@applicaster/zapp-react-native-bridge": "13.0.0-alpha.4700935119",
36
- "@applicaster/zapp-react-native-redux": "13.0.0-alpha.4700935119",
37
- "@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.4700935119",
38
- "@applicaster/zapp-react-native-utils": "13.0.0-alpha.4700935119",
32
+ "@applicaster/applicaster-types": "13.0.0-alpha.4936752427",
33
+ "@applicaster/quick-brick-core-plugins": "13.0.0-alpha.4936752427",
34
+ "@applicaster/zapp-pipes-v2-client": "13.0.0-alpha.4936752427",
35
+ "@applicaster/zapp-react-native-bridge": "13.0.0-alpha.4936752427",
36
+ "@applicaster/zapp-react-native-redux": "13.0.0-alpha.4936752427",
37
+ "@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.4936752427",
38
+ "@applicaster/zapp-react-native-utils": "13.0.0-alpha.4936752427",
39
39
  "atob": "^2.1.2",
40
40
  "axios": "^0.28.0",
41
41
  "btoa": "^1.2.1",