mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-12 08:54:00 +02:00
34 lines
1018 B
JavaScript
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;
|
|
};
|