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

63 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-12-02 21:21:00 +05:00
import React, { Fragment } from 'react';
2021-11-23 15:06:35 +05:00
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) {
2021-11-23 15:26:06 +05:00
if (!platforms) return true;
2021-11-23 15:06:35 +05:00
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,
2021-12-02 21:21:00 +05:00
text:Body,
2021-11-23 15:06:35 +05:00
image: Photo,
list: List,
subheading: SubHeading,
features: Features,
callToActions: Cta
};
2021-11-23 19:24:53 +05:00
export const renderItem = ({item, index, color,inline}) => {
2021-12-02 21:21:00 +05:00
const Item = renderItems[item.type] || Fragment
2021-11-23 15:06:35 +05:00
2021-11-23 19:24:53 +05:00
return <Item key={item.text || item.src || item.type} {...item} index={index} color={color} inline={inline} />;
2021-11-23 15:06:35 +05:00
};