-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
MySheetResult.js
60 lines (57 loc) · 2.21 KB
/
MySheetResult.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'use strict';
import PropTypes from 'prop-types';
import React, { useContext } from 'react';
import {
Text,
TouchableOpacity,
View,
Image,
} from 'react-native';
import { GlobalStateContext, getTheme } from './StateManager';
import strings from './LocalizedStrings';
import styles from './Styles.js';
const MySheetResult = ({ title, heTitle, onPress, views, topics, created, isPrivate }) => {
const { themeStr, interfaceLanguage } = useContext(GlobalStateContext);
const theme = getTheme(themeStr);
const isHeb = interfaceLanguage === 'hebrew';
title = title.replace(/\s\s+/g, ' ');
const isTitleHeb = Sefaria.hebrew.isHebrew(title);
const locale = isHeb ? 'iw-IL' : 'en-US';
const dateOptions = { year: 'numeric', month: 'short', day: 'numeric' };
const date = (new Date(created)).toLocaleDateString(locale, dateOptions).replace(',', '')
return (
<TouchableOpacity
style={[
styles.textBlockLink,
theme.textBlockLink,
{margin:0, borderBottomWidth: 1, borderBottomColor: "#ccc", paddingVertical: 13, alignItems: isHeb ? 'flex-end' : 'flex-start'}
]}
onPress={onPress}
>
<View style={{flex: 1, flexDirection: (isHeb ? "row-reverse" : "row")}}>
<Text style={[isTitleHeb ? styles.hebrewText : styles.englishText, isTitleHeb ? null : {paddingTop: 6}, styles.mySheetListTitle, theme.text]}>{title}</Text>
{
isPrivate ?
<Image style={{marginTop: 5, marginHorizontal: 8, width:15, height: 15}} source={require('./img/lock.png')}/>
: null
}
</View>
<View style={{flex: 1, flexDirection: (isHeb ? "row-reverse" : "row")}}>
<Text style={[theme.tertiaryText, isHeb ? styles.heInt : styles.enInt, isHeb ? { writingDirection: 'rtl'} : null]}>
{`${views} ${strings.views} • ${date}`}
{ !!topics.length ? ` • ${topics.map(t => t.asTyped).join(', ')}` : null }
</Text>
</View>
</TouchableOpacity>
);
}
MySheetResult.propTypes = {
title: PropTypes.string,
heTitle: PropTypes.string,
onPress: PropTypes.func.isRequired,
views: PropTypes.number,
tags: PropTypes.array,
created: PropTypes.string,
isPrivate:PropTypes.bool,
};
export default MySheetResult;