@applicaster/quick-brick-core 12.0.4 → 12.0.5-alpha.1571145715

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,44 @@
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 { useTheme } from "@applicaster/zapp-react-native-utils/theme";
6
+
7
+ import { useLoadingOverlayVisibility } from "./useLoadingOverlayVisibility";
8
+
9
+ export { loadingOverlayManager } from "./LoadingOverlayManager";
10
+
11
+ const styles = StyleSheet.create({
12
+ container: {
13
+ opacity: 0.5,
14
+ alignItems: "center",
15
+ justifyContent: "center",
16
+ zIndex: 100,
17
+ flex: 1,
18
+ },
19
+ });
20
+
21
+ export const LoadingOverlay = () => {
22
+ const visible = useLoadingOverlayVisibility();
23
+ const theme = useTheme();
24
+
25
+ const backgroundColor = React.useMemo(() => {
26
+ return theme?.app_background_color || "black";
27
+ }, [theme?.app_background_color]);
28
+
29
+ React.useEffect(() => {
30
+ if (visible) {
31
+ focusManager.disableFocus();
32
+ } else {
33
+ focusManager.enableFocus();
34
+ }
35
+ }, [visible]);
36
+
37
+ return visible ? (
38
+ <View
39
+ style={[StyleSheet.absoluteFill, styles.container, { backgroundColor }]}
40
+ >
41
+ <Spinner />
42
+ </View>
43
+ ) : null;
44
+ };
@@ -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
+ };
@@ -49,6 +49,7 @@ import { coreAppLogger } from "../logger";
49
49
  import {
50
50
  getPlatform,
51
51
  isTV,
52
+ isVizioPlatform,
52
53
  } from "@applicaster/zapp-react-native-utils/reactUtils";
53
54
  import { useConnectionInfo } from "@applicaster/zapp-react-native-utils/reactHooks/connection";
54
55
  import {
@@ -66,6 +67,9 @@ import { inflateUrl } from "@applicaster/zapp-react-native-ui-components/Compone
66
67
  import { useModalStore } from "@applicaster/zapp-react-native-utils/modalState";
67
68
  import { useSubscriberFor } from "@applicaster/zapp-react-native-utils/reactHooks/useSubscriberFor";
68
69
  import { QBUIComponentEvents } from "@applicaster/zapp-react-native-ui-components/events";
70
+ import { URLSchemeContext } from "../DeepLinking/URLSchemeListener/URLSchemeContextProvider";
71
+
72
+ import { loadingOverlayManager } from "../LoadingOverlay";
69
73
 
70
74
  const logger = coreAppLogger.addSubsystem("Navigator");
71
75
 
@@ -96,6 +100,8 @@ const navigationActions = {
96
100
  const platform = getPlatform();
97
101
 
98
102
  export function NavigationProvider({ children }: Props) {
103
+ const { url: deepLinkURL } = React.useContext(URLSchemeContext);
104
+
99
105
  const {
100
106
  appData: { layoutVersion },
101
107
  rivers,
@@ -394,6 +400,8 @@ export function NavigationProvider({ children }: Props) {
394
400
  } else {
395
401
  dispatch(push(route, { entry: payload, screen: hookPlugin }));
396
402
  }
403
+
404
+ closeLoadingOverlay();
397
405
  };
398
406
 
399
407
  const handleHookError = ({ error, hookPlugin, callback }, dispose) => {
@@ -412,6 +420,8 @@ export function NavigationProvider({ children }: Props) {
412
420
  if (callback && typeof callback === "function") {
413
421
  callback();
414
422
  }
423
+
424
+ closeLoadingOverlay();
415
425
  };
416
426
 
417
427
  const handleHookCancel = ({ hookPlugin, callback }, dispose) => {
@@ -427,6 +437,8 @@ export function NavigationProvider({ children }: Props) {
427
437
  } else {
428
438
  goBack(true, true);
429
439
  }
440
+
441
+ closeLoadingOverlay();
430
442
  };
431
443
 
432
444
  const handleHookSuccess = ({ hookPlugin, callback }) => {
@@ -437,6 +449,10 @@ export function NavigationProvider({ children }: Props) {
437
449
  }
438
450
  };
439
451
 
452
+ const handleBackgroundHook = () => {
453
+ openLoadingOverlay();
454
+ };
455
+
440
456
  const checkStartUpHooks = React.useMemo(() => {
441
457
  if (!pluginConfigurations) return false;
442
458
 
@@ -506,6 +522,8 @@ export function NavigationProvider({ children }: Props) {
506
522
  );
507
523
 
508
524
  callback?.();
525
+
526
+ closeLoadingOverlay();
509
527
  };
510
528
 
511
529
  const offlinePlugin = React.useMemo(() => {
@@ -618,6 +636,7 @@ export function NavigationProvider({ children }: Props) {
618
636
  .on(HOOKS_EVENTS.ERROR, handleHookError)
619
637
  .on(HOOKS_EVENTS.CANCEL, handleHookCancel)
620
638
  .on(HOOKS_EVENTS.SUCCESS, handleHookSuccess)
639
+ .on(HOOKS_EVENTS.START_BACKGROUND_HOOK, handleBackgroundHook)
621
640
  .on(
622
641
  HOOKS_EVENTS.COMPLETE,
623
642
  handleHookComplete(navigationAction, targetRoute, {
@@ -632,6 +651,14 @@ export function NavigationProvider({ children }: Props) {
632
651
  },
633
652
  });
634
653
 
654
+ const openLoadingOverlay = React.useCallback(() => {
655
+ deepLinkURL && isVizioPlatform() && loadingOverlayManager.show();
656
+ }, [deepLinkURL]);
657
+
658
+ const closeLoadingOverlay = React.useCallback(() => {
659
+ loadingOverlayManager.hide();
660
+ }, []);
661
+
635
662
  const openPiP = React.useCallback(() => {
636
663
  dispatch(setVideoPiP());
637
664
  }, []);
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-core",
3
- "version": "12.0.4",
3
+ "version": "12.0.5-alpha.1571145715",
4
4
  "description": "Core package for Applicaster's Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -30,13 +30,13 @@
30
30
  },
31
31
  "homepage": "https://github.com/applicaster/quickbrick#readme",
32
32
  "dependencies": {
33
- "@applicaster/applicaster-types": "12.0.4",
34
- "@applicaster/quick-brick-core-plugins": "12.0.4",
35
- "@applicaster/zapp-pipes-v2-client": "12.0.4",
36
- "@applicaster/zapp-react-native-bridge": "12.0.4",
37
- "@applicaster/zapp-react-native-redux": "12.0.4",
38
- "@applicaster/zapp-react-native-ui-components": "12.0.4",
39
- "@applicaster/zapp-react-native-utils": "12.0.4",
33
+ "@applicaster/applicaster-types": "12.0.5-alpha.1571145715",
34
+ "@applicaster/quick-brick-core-plugins": "12.0.5-alpha.1571145715",
35
+ "@applicaster/zapp-pipes-v2-client": "12.0.5-alpha.1571145715",
36
+ "@applicaster/zapp-react-native-bridge": "12.0.5-alpha.1571145715",
37
+ "@applicaster/zapp-react-native-redux": "12.0.5-alpha.1571145715",
38
+ "@applicaster/zapp-react-native-ui-components": "12.0.5-alpha.1571145715",
39
+ "@applicaster/zapp-react-native-utils": "12.0.5-alpha.1571145715",
40
40
  "atob": "^2.1.2",
41
41
  "axios": "^0.28.0",
42
42
  "btoa": "^1.2.1",