@applicaster/zapp-react-native-utils 12.0.0-alpha.9453522405 → 12.0.0-rc.10

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.
@@ -2,6 +2,7 @@
2
2
  import * as ReactNative from "react-native";
3
3
  import { isTV, platformSelect } from "../reactUtils";
4
4
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
5
+ import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
5
6
 
6
7
  import {
7
8
  QUICK_BRICK_EVENTS,
@@ -9,7 +10,6 @@ import {
9
10
  sendQuickBrickEvent,
10
11
  } from "@applicaster/zapp-react-native-bridge/QuickBrick";
11
12
  import { utilsLogger } from "../logger";
12
- import { useIsTablet } from "../reactHooks/device/useIsTablet";
13
13
 
14
14
  const { DeviceEventEmitter, NativeModules, NativeEventEmitter } = ReactNative;
15
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "12.0.0-alpha.9453522405",
3
+ "version": "12.0.0-rc.10",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "12.0.0-alpha.9453522405",
31
+ "@applicaster/applicaster-types": "12.0.0-rc.10",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",
@@ -1,6 +1,5 @@
1
1
  export { useOrientation } from "./useOrientation";
2
2
 
3
- // @ts-ignore
4
3
  export { useIsTablet } from "./useIsTablet";
5
4
 
6
5
  export { useMemoizedIsTablet } from "./useMemoizedIsTablet";
@@ -1,3 +1,28 @@
1
- // Template function for TS to correctly compile.
2
- // The RN app will use files with platform suffixes
3
- export const useIsTablet = (): boolean => false;
1
+ /* eslint react-native/split-platform-components: off */
2
+
3
+ import { Platform, PlatformIOSStatic, NativeModules } from "react-native";
4
+ import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
5
+ import { F as alwaysFalse } from "ramda";
6
+ import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
7
+
8
+ const useIsTabletIos = (): boolean => {
9
+ const { isPad } = Platform as PlatformIOSStatic;
10
+
11
+ return isPad;
12
+ };
13
+
14
+ const useIsTabletAndroid = (): boolean => {
15
+ const { initialProps } = NativeModules.QuickBrickCommunicationModule;
16
+
17
+ return toBooleanWithDefaultFalse(initialProps?.is_tablet);
18
+ };
19
+
20
+ export const useIsTablet = platformSelect({
21
+ ios: useIsTabletIos,
22
+ android: useIsTabletAndroid,
23
+ lg_tv: alwaysFalse,
24
+ samsung_tv: alwaysFalse,
25
+ android_tv: alwaysFalse,
26
+ tvos: alwaysFalse,
27
+ default: alwaysFalse,
28
+ });
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
3
- import { useIsTablet } from "./index";
3
+ import { useIsTablet } from "./useIsTablet";
4
4
 
5
5
  export const useMemoizedIsTablet = () => {
6
6
  const isTablet = useIsTablet();
@@ -1,6 +1,8 @@
1
1
  import { useWindowDimensions } from "react-native";
2
2
 
3
- export const useOrientation = (): string => {
3
+ type Return = "landscape" | "portrait";
4
+
5
+ export const useOrientation = (): Return => {
4
6
  const { width, height } = useWindowDimensions();
5
7
  const isLandscape = width > height;
6
8
 
@@ -1,9 +1,10 @@
1
1
  import * as R from "ramda";
2
2
  import { StatusBar, Platform } from "react-native";
3
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
3
4
 
4
5
  import { platformSelect, isTV } from "../../reactUtils";
5
6
  import { useIsNavBarVisible } from "../navigation";
6
- import { useSafeAreaInsets } from "react-native-safe-area-context";
7
+
7
8
  import { isTablet } from "./isTablet";
8
9
 
9
10
  export { isTablet } from "./isTablet";
@@ -10,6 +10,7 @@ export const useListenEventBusEvent = (
10
10
  handler: (event) => void
11
11
  ) => {
12
12
  React.useEffect(() => {
13
+ // TODO: remove after implementing ReactNativeEventBusBridge on iOS
13
14
  if (Platform.OS === "android") {
14
15
  // subscribe to DeviceEventEmitter using subsciption ID
15
16
  const sub = DeviceEventEmitter.addListener(
@@ -25,5 +26,5 @@ export const useListenEventBusEvent = (
25
26
  sub.remove(); // stop listening to DeviceEventEmitter
26
27
  };
27
28
  }
28
- }, [subscriptionID, source, events, handler]);
29
+ }, []);
29
30
  };
@@ -2,7 +2,7 @@ import * as R from "ramda";
2
2
  import { createLogger } from "../logger";
3
3
  import { requiresAuthentication } from "../configurationUtils";
4
4
  import { PresentHookPluginOneTime } from "./presentPluginOneTime";
5
- import { skipHook } from "./hooksPresentation";
5
+ import { isPlayerHook, skipHook } from "./hooksPresentation";
6
6
  type LoginPluginUtils = {
7
7
  pluginId: string;
8
8
  };
@@ -36,10 +36,20 @@ const isAuthenticationRequired = ({ payload, logs }) => {
36
36
  return requires_authentication;
37
37
  }
38
38
 
39
+ const isPlayer = isPlayerHook(payload);
40
+
41
+ if (isPlayer) {
42
+ log_info(
43
+ "isAuthenticationRequired: Payload is player screen, authentication not required"
44
+ );
45
+
46
+ return;
47
+ }
48
+
39
49
  const _isPayloadScreen = isPayloadScreen({ payload });
40
50
 
41
51
  log_info(
42
- `isAuthenticationRequired: Payload is screen, authentefication required: ${_isPayloadScreen}`
52
+ `isAuthenticationRequired: Payload is screen, authentication required: ${_isPayloadScreen}`
43
53
  );
44
54
 
45
55
  return _isPayloadScreen;
@@ -1,14 +0,0 @@
1
- import { useWindowDimensions } from "react-native";
2
- import { useOrientation } from "./useOrientation";
3
- import { isTablet } from "../layout";
4
-
5
- /**
6
- * Determines weather the given device is a tablet based on dimensions, orientation, and platform
7
- * @returns {Boolean} isTablet - returns whether the given device is a tablet
8
- */
9
- export const useIsTablet = (): boolean => {
10
- const dimensions = useWindowDimensions();
11
- const orientation = useOrientation();
12
-
13
- return isTablet(dimensions, orientation);
14
- };
@@ -1,7 +0,0 @@
1
- import { Platform, PlatformIOSStatic } from "react-native";
2
-
3
- export const useIsTablet = (): boolean => {
4
- const { isPad } = Platform as PlatformIOSStatic;
5
-
6
- return isPad;
7
- };
@@ -1,3 +0,0 @@
1
- export const useIsTablet = (): boolean => {
2
- return false;
3
- };