@applicaster/zapp-react-native-utils
Version:
Applicaster Zapp React Native utilities package
58 lines (44 loc) • 1.45 kB
text/typescript
import * as R from "ramda";
export const isPlayable = R.anyPass([
R.pathEq(["type", "value"], "video"),
R.pathEq(["type", "value"], "channel"),
R.pathEq(["type", "value"], "audio"),
R.pathEq(["content", "type"], "video/hls"),
]);
const isUiBuilderRiver = R.both(
R.has("ui_components"),
R.compose(R.not, R.has("component_type"))
);
const isNestedRiver = R.has("riverId");
const hasScreenType = R.both(
R.either(
R.compose(R.not, R.isNil, R.prop("screenType")),
R.compose(R.not, R.isNil, R.prop("screen_type"))
),
R.anyPass([R.has("screen_type"), R.has("screenType")])
);
const isLabel = R.propEq("type", "label");
const isTvRightButton = R.propEq("type", "tv_right_button");
const isTvLeftButton = R.propEq("type", "tv_left_button");
const isButton = R.propEq("type", "button");
export const isMenuItem = R.anyPass([
isLabel,
isTvRightButton,
isTvLeftButton,
isButton,
]);
export const isRiver = R.anyPass([
isUiBuilderRiver,
isNestedRiver,
hasScreenType,
]);
// TODO: find a better way to detect river type
export const isV2River = R.allPass([R.has("home"), R.has("hooks")]);
export const isGeneralPlugin = R.propEq("plugin_type", "general");
export const isArticle = R.either(
R.pathEq(["type", "value"], "article"),
R.pathEq(["content", "type"], "html")
);
export const isUrlScheme = R.has("url");
export const isLink = R.pathEq(["type", "value"], "link");
export const isContentScreen = R.T;