forked from kunall17/react-native-markdown-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderButtons.js
32 lines (28 loc) · 929 Bytes
/
renderButtons.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React from 'react';
import { FlatList, TouchableOpacity, Text } from 'react-native';
import defaultFormats from './defaultFormats';
const FOREGROUND_COLOR = 'rgba(82, 194, 175, 1)';
const defaultStyles = { padding: 8, color: FOREGROUND_COLOR, fontSize: 16 };
const defaultMarkdownButton = ({ item, ...drill }) => {
return (
<TouchableOpacity onPress={() => item.onPress({ item, ...drill })}>
<Text style={[defaultStyles, item.style]}>
{item.title}
</Text>
</TouchableOpacity>
);
};
export const renderFormatButtons = (drill, formats, markdownButton) => {
const list = (
<FlatList
data={formats ? formats : defaultFormats}
keyboardShouldPersistTaps="always"
renderItem={({ item, index }) =>
markdownButton
? markdownButton({ item, ...drill })
: defaultMarkdownButton({ item, ...drill })}
horizontal
/>
);
return list;
};