-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathrenderButtons.js
32 lines (28 loc) · 965 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 Formats from './Formats';
const FOREGROUND_COLOR = 'rgba(82, 194, 175, 1)';
const defaultStyles = { padding: 8, color: FOREGROUND_COLOR, fontSize: 16 };
const defaultMarkdownButton = ({ item, getState, setState }) => {
return (
<TouchableOpacity onPress={() => item.onPress({ getState, setState, item })}>
<Text style={[defaultStyles, item.style]}>
{item.title}
</Text>
</TouchableOpacity>
);
};
export const renderFormatButtons = ({ getState, setState }, formats, markdownButton) => {
const list = (
<FlatList
data={formats ? formats : Formats}
keyboardShouldPersistTaps="always"
renderItem={({ item, index }) =>
markdownButton
? markdownButton({ item, getState, setState })
: defaultMarkdownButton({ item, getState, setState })}
horizontal
/>
);
return list;
};