1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-27 10:32:58 +02:00
joplin/ReactNativeClient/MarkdownEditor/renderButtons.js
2020-06-02 20:13:15 +00:00

34 lines
1018 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>
);
};
// eslint-disable-next-line import/prefer-default-export
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;
};