@applicaster/zapp-react-native-ui-components
Version:
Applicaster Zapp React Native ui components for the Quick Brick App
80 lines (72 loc) • 2.55 kB
text/typescript
import * as R from "ramda";
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
import { PluginConfiguration } from "../index";
export function getCloseButtonProps(config: PluginConfiguration) {
const {
modal_bottom_sheet_close_asset,
modal_bottom_sheet_close_focus_asset,
modal_bottom_sheet_close_height,
modal_bottom_sheet_close_width,
modal_bottom_sheet_close_switch,
modal_bottom_sheet_close_margin_bottom,
modal_bottom_sheet_close_margin_left,
modal_bottom_sheet_close_margin_right,
modal_bottom_sheet_close_margin_top,
} = config;
return {
asset: modal_bottom_sheet_close_asset,
assetFocused: modal_bottom_sheet_close_focus_asset,
enabled: modal_bottom_sheet_close_switch,
width: modal_bottom_sheet_close_width,
height: modal_bottom_sheet_close_height,
marginTop: modal_bottom_sheet_close_margin_top,
marginBottom: modal_bottom_sheet_close_margin_bottom,
marginLeft: modal_bottom_sheet_close_margin_left,
marginRight: modal_bottom_sheet_close_margin_right,
};
}
export function getTextValue(
config: PluginConfiguration,
entry: ZappEntry,
key: string
): string {
const keyValue = config[key];
if (entry) {
const keyPath = R.split(".", keyValue);
return R.path(keyPath, entry);
} else {
return keyValue;
}
}
function getConfigKey(
config: PluginConfiguration,
suffix: string,
key: "title" | "summary"
) {
return config?.[`modal_bottom_sheet_${key}_${suffix}`];
}
export function getTitleProps(
config: PluginConfiguration,
key: "title" | "summary"
) {
return {
enabled: getConfigKey(config, "switch", key),
letterSpacing: platformSelect({
ios: getConfigKey(config, "ios_letter_spacing", key),
android: getConfigKey(config, "android_letter_spacing", key),
}),
fontFamily: platformSelect({
ios: getConfigKey(config, "family_ios_font_selector", key),
android: getConfigKey(config, "family_android_font_selector", key),
}),
lineHeight: getConfigKey(config, "line_height", key),
fontSize: getConfigKey(config, "font_size", key),
color: getConfigKey(config, "font_color", key),
marginTop: getConfigKey(config, "margin_top", key),
marginBottom: getConfigKey(config, "margin_bottom", key),
marginLeft: getConfigKey(config, "margin_left", key),
marginRight: getConfigKey(config, "margin_right", key),
numberOfLines: getConfigKey(config, "number_of_lines", key),
transform: getConfigKey(config, "transform", key),
};
}