@applicaster/zapp-react-native-utils 12.0.0-rc.1 → 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.
- package/appUtils/orientationHelper.ts +1 -1
- package/package.json +2 -2
- package/reactHooks/device/index.ts +0 -1
- package/reactHooks/device/useIsTablet.tsx +28 -3
- package/reactHooks/device/useMemoizedIsTablet.ts +1 -1
- package/reactHooks/device/useOrientation.tsx +3 -1
- package/reactHooks/layout/index.ts +2 -1
- package/reactHooks/useListenEventBusEvent.ts +30 -0
- package/zappFrameworkUtils/loginPluginUtils.ts +12 -2
- package/reactHooks/device/useIsTablet.android.tsx +0 -14
- package/reactHooks/device/useIsTablet.ios.tsx +0 -7
- package/reactHooks/device/useIsTablet.web.tsx +0 -3
|
@@ -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-rc.
|
|
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-rc.
|
|
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,3 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 "./
|
|
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
|
-
|
|
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
|
-
|
|
7
|
+
|
|
7
8
|
import { isTablet } from "./isTablet";
|
|
8
9
|
|
|
9
10
|
export { isTablet } from "./isTablet";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DeviceEventEmitter, NativeModules, Platform } from "react-native";
|
|
3
|
+
|
|
4
|
+
const { ReactNativeEventBusBridge } = NativeModules;
|
|
5
|
+
|
|
6
|
+
export const useListenEventBusEvent = (
|
|
7
|
+
subscriptionID: string, // subsciption ID to manage it, will be used as a event name for DeviceEventEmitter
|
|
8
|
+
source: string,
|
|
9
|
+
events: string[],
|
|
10
|
+
handler: (event) => void
|
|
11
|
+
) => {
|
|
12
|
+
React.useEffect(() => {
|
|
13
|
+
// TODO: remove after implementing ReactNativeEventBusBridge on iOS
|
|
14
|
+
if (Platform.OS === "android") {
|
|
15
|
+
// subscribe to DeviceEventEmitter using subsciption ID
|
|
16
|
+
const sub = DeviceEventEmitter.addListener(
|
|
17
|
+
subscriptionID,
|
|
18
|
+
handler
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
// ask native to start routing these events to RN
|
|
22
|
+
ReactNativeEventBusBridge.subscribe(subscriptionID, { [source]: events });
|
|
23
|
+
|
|
24
|
+
return () => {
|
|
25
|
+
ReactNativeEventBusBridge.unsubscribe(subscriptionID); // ask EventBus to stop routing these events to RN
|
|
26
|
+
sub.remove(); // stop listening to DeviceEventEmitter
|
|
27
|
+
};
|
|
28
|
+
}
|
|
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,
|
|
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
|
-
};
|