Files
notesnook/apps/mobile/src/components/Announcements/functions.js

61 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-11-23 15:06:35 +05:00
import React from 'react';
import {View} from 'react-native';
import {allowedPlatforms} from '../../provider/stores';
import {ProFeatures} from '../ResultDialog/pro-features';
import {Body} from './body';
import {Cta} from './cta';
import {Description} from './description';
import {List} from './list';
import {Photo} from './photo';
import {SubHeading} from './subheading';
import {Title} from './title';
export function allowedOnPlatform(platforms) {
return platforms.some(platform => allowedPlatforms.indexOf(platform) > -1);
}
2021-11-22 15:12:26 +05:00
export const margins = {
0: 0,
1: 12,
2: 20
};
export const getStyle = style => {
if (!style) return {};
return {
marginTop: margins[style.marginTop] || 0,
marginBottom: margins[style.marginBottom] || 0,
textAlign: style.textAlign || 'left'
};
};
2021-11-23 15:06:35 +05:00
const Features = () => {
return (
<View
style={{
paddingHorizontal: 12,
alignItems: 'center',
width: '100%'
}}>
<ProFeatures />
</View>
);
};
const renderItems = {
title: Title,
description: Description,
body: Body,
image: Photo,
list: List,
subheading: SubHeading,
features: Features,
callToActions: Cta
};
export const renderItem = ({item, index, color}) => {
const Item = renderItems[item.type];
2021-11-23 15:11:17 +05:00
return <Item key={item.text || item.src || item.type} {...item} index={index} color={color} />;
2021-11-23 15:06:35 +05:00
};