forked from Sefaria/Sefaria-Mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SearchTextResult.js
36 lines (34 loc) · 1.37 KB
/
SearchTextResult.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
33
34
35
36
'use strict';
import PropTypes from 'prop-types';
import React, { useContext } from 'react';
import {
StyleSheet,
Text,
TouchableOpacity,
View
} from 'react-native';
import { SimpleHTMLView } from './Misc';
import { GlobalStateContext, getTheme } from './StateManager';
import styles from './Styles.js';
const SearchTextResult = ({ text, title, heTitle, textType, version, onPress }) => {
const { textLanguage, interfaceLanguage, themeStr } = useContext(GlobalStateContext);
const theme = getTheme(themeStr);
const isHeb = Sefaria.util.get_menu_language(interfaceLanguage, textLanguage) == "hebrew";
const refTitleStyle = isHeb ? styles.he : styles.en;
const refTitle = isHeb ? heTitle : title;
return (
<TouchableOpacity style={[styles.searchTextResult, theme.searchTextResult]} onPress={onPress} delayPressIn={200}>
<Text style={[refTitleStyle, styles.textListCitation, theme.textListCitation]}>{refTitle}</Text>
<SimpleHTMLView text={text} lang={textType} />
{!!version ? <Text style={[styles.enInt, {fontSize: 12, marginTop: 4}, theme.textListCitation]}>{version}</Text> : null}
</TouchableOpacity>
);
}
SearchTextResult.propTypes = {
text: PropTypes.string,
title: PropTypes.string,
heTitle: PropTypes.string,
textType: PropTypes.oneOf(["english","hebrew"]),
onPress: PropTypes.func.isRequired
};
export default SearchTextResult;