@applicaster/zapp-react-native-utils 12.0.0-rc.2 → 12.0.0-rc.20
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/cellUtils/index.ts +13 -0
- package/package.json +2 -2
- package/pluginUtils/index.ts +9 -5
- 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 +6 -12
- 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/cellUtils/index.ts
CHANGED
|
@@ -343,6 +343,19 @@ export const ifElseFocused = R.curry(
|
|
|
343
343
|
state === "focused" ? focusedValue : defaultValue
|
|
344
344
|
);
|
|
345
345
|
|
|
346
|
+
export const ifElseSelected = R.curry(
|
|
347
|
+
(state: string, selectedValue, defaultValue) => {
|
|
348
|
+
switch (state) {
|
|
349
|
+
case "selected":
|
|
350
|
+
return selectedValue;
|
|
351
|
+
case "focused_selected":
|
|
352
|
+
return selectedValue;
|
|
353
|
+
default:
|
|
354
|
+
return defaultValue;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
);
|
|
358
|
+
|
|
346
359
|
/**
|
|
347
360
|
* Map textAlign values to their corresponding alignSelf values
|
|
348
361
|
* This is so that we could use the same field for both properties
|
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.20",
|
|
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.20",
|
|
32
32
|
"buffer": "^5.2.1",
|
|
33
33
|
"camelize": "^1.0.0",
|
|
34
34
|
"create-react-context": "^0.2.3",
|
package/pluginUtils/index.ts
CHANGED
|
@@ -68,11 +68,13 @@ export function findComponentByType({
|
|
|
68
68
|
* Returns the plugin for a given identifier, if found
|
|
69
69
|
* @param identifier of the plugin to look for
|
|
70
70
|
* @param plugins map of the available plugins
|
|
71
|
+
* @param doNotWarn if set to true, will not log a warning if plugin is not found
|
|
71
72
|
* @return whole plugin if found, undefined otherwise
|
|
72
73
|
*/
|
|
73
74
|
export function findPluginByIdentifier(
|
|
74
75
|
identifier: string,
|
|
75
|
-
plugins: (QuickBrickPlugin | ZappPlugin | Plugin)[]
|
|
76
|
+
plugins: (QuickBrickPlugin | ZappPlugin | Plugin)[],
|
|
77
|
+
doNotWarn: boolean = false
|
|
76
78
|
): (QuickBrickPlugin | ZappPlugin | Plugin) | undefined {
|
|
77
79
|
if (!identifier) {
|
|
78
80
|
return undefined;
|
|
@@ -84,10 +86,12 @@ export function findPluginByIdentifier(
|
|
|
84
86
|
)(plugins);
|
|
85
87
|
|
|
86
88
|
if (!plugin && identifier !== "river" && identifier !== "hooks") {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
if (!doNotWarn) {
|
|
90
|
+
pluginUtilsLogger.warning({
|
|
91
|
+
message: `Could not find plugin for identifier ${identifier}`,
|
|
92
|
+
data: { identifier },
|
|
93
|
+
});
|
|
94
|
+
}
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
return plugin;
|
|
@@ -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";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { DeviceEventEmitter, NativeModules, Platform } from "react-native";
|
|
3
|
-
import { PushTopicManager } from "@applicaster/zapp-react-native-bridge/PushNotifications/PushTopicManager";
|
|
4
3
|
|
|
5
4
|
const { ReactNativeEventBusBridge } = NativeModules;
|
|
6
5
|
|
|
@@ -11,26 +10,21 @@ export const useListenEventBusEvent = (
|
|
|
11
10
|
handler: (event) => void
|
|
12
11
|
) => {
|
|
13
12
|
React.useEffect(() => {
|
|
14
|
-
let sub;
|
|
15
|
-
|
|
16
13
|
// TODO: remove after implementing ReactNativeEventBusBridge on iOS
|
|
17
14
|
if (Platform.OS === "android") {
|
|
18
15
|
// subscribe to DeviceEventEmitter using subsciption ID
|
|
19
|
-
sub = DeviceEventEmitter.addListener(
|
|
16
|
+
const sub = DeviceEventEmitter.addListener(
|
|
20
17
|
subscriptionID,
|
|
21
18
|
handler
|
|
22
19
|
);
|
|
23
20
|
|
|
24
21
|
// ask native to start routing these events to RN
|
|
25
22
|
ReactNativeEventBusBridge.subscribe(subscriptionID, { [source]: events });
|
|
26
|
-
}
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
sub?.remove?.(); // stop listening to DeviceEventEmitter
|
|
34
|
-
};
|
|
24
|
+
return () => {
|
|
25
|
+
ReactNativeEventBusBridge.unsubscribe(subscriptionID); // ask EventBus to stop routing these events to RN
|
|
26
|
+
sub.remove(); // stop listening to DeviceEventEmitter
|
|
27
|
+
};
|
|
28
|
+
}
|
|
35
29
|
}, []);
|
|
36
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
|
-
};
|