1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00
joplin/ReactNativeClient/MarkdownEditor/renderButtons.js
2020-05-05 19:03:13 +01:00

33 lines
961 B
JavaScript

import React from 'react';
import { FlatList, TouchableOpacity, Text } from 'react-native';
import Formats from './Formats';
const defaultStyles = { padding: 8, fontSize: 16 };
const defaultMarkdownButton = ({ item, getState, setState, color }) => {
return (
<TouchableOpacity onPress={() => item.onPress({ getState, setState, item })}>
<Text style={[defaultStyles, item.style, { color: color }]}>
{item.title}
</Text>
</TouchableOpacity>
);
};
export const renderFormatButtons = ({ getState, setState, color }, formats, markdownButton) => {
const list = (
<FlatList
data={formats ? formats : Formats}
keyboardShouldPersistTaps="always"
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
renderItem={({ item, index }) =>
markdownButton
? markdownButton({ item, getState, setState })
: defaultMarkdownButton({ item, getState, setState, color })}
horizontal
/>
);
return list;
};