-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
SheetMeta.js
96 lines (88 loc) · 3.27 KB
/
SheetMeta.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import React from 'react';
import {
Text,
TouchableOpacity,
View,
ScrollView,
Image,
} from 'react-native';
import {
CategoryColorLine,
TwoBox,
LanguageToggleButton,
ContentTextWithFallback,
} from './Misc.js';
import styles from './Styles.js';
import strings from "./LocalizedStrings";
import {CloseButton, HebrewInEnglishText} from "./Misc";
import { Topic } from './Topic';
import { useGlobalState } from './Hooks';
var moment = require("moment");
const SheetMeta = ({ sheet, close, openTopic }) => {
const { interfaceLanguage, menuLanguage, theme } = useGlobalState();
const langStyle = interfaceLanguage === "hebrew" ? styles.heInt : styles.enInt;
const topics = Object.values(sheet.topics.reduce((obj, curr) => {
obj[`${curr.slug}|${curr.asTyped}`] = curr;
return obj;
}, {})) || [];
const sheetTopics = topics.map((topic, i) => (
<TouchableOpacity style={[styles.textBlockLink,theme.textBlockLink]} onPress={()=> openTopic(new Topic({slug:topic.slug}))} key={i}>
<ContentTextWithFallback
{...topic}
extraStyles={[{marginBottom: -10}, theme.text]}
lang={menuLanguage}
/>
</TouchableOpacity>
));
return (
<View style={[styles.menu, theme.menu]}>
<CategoryColorLine category="Sheets"/>
<View style={[styles.header, theme.header]}>
<CloseButton onPress={close} />
<Text style={[langStyle, styles.textTocHeaderTitle, styles.textCenter, theme.text]}>
{strings.tableOfContents}
</Text>
<LanguageToggleButton />
</View>
<ScrollView style={styles.menuContent} contentContainerStyle={{paddingTop: 20, paddingBottom: 40}}>
<View style={[styles.textTocTopBox, theme.bordered]}>
<View>
<Text style={[styles.en, styles.textTocTitle, theme.text]}>
<HebrewInEnglishText text={sheet.title} stylesHe={[styles.heInEn]} stylesEn={[]}/>
</Text>
</View>
<View style={styles.textTocCategoryBox}>
{interfaceLanguage == "hebrew" ?
<Text style={[styles.he, styles.textTocCategory, theme.secondaryText]}>דף</Text> :
<Text style={[styles.en, styles.textTocCategory, theme.secondaryText]}>Sheet</Text>
}
</View>
<View style={{flexDirection: "row", flex: 1}}>
<Image
style={[styles.userAvatarMini]}
source={{uri: sheet.ownerImageUrl}}
/>
<Text style={[{alignSelf: "flex-start", color: "#999"}, styles.enInt]}>
by {sheet.ownerName}
</Text>
</View>
<View style={{flexDirection: "row", flex: 1}}>
<Text style={[{alignSelf: "flex-end",color: "#999", margin: 5}, styles.enInt]}>
{sheet.views} Views
</Text>
<Text style={[{alignSelf: "flex-end", color: "#999", margin: 5}, styles.enInt]}>
Created {moment(sheet.dateCreated, "YYYY-MM-DDTHH:mm:ss.SSS").fromNow()}
</Text>
</View>
<Text style={[{alignSelf: "flex-end", color: "#999"}, styles.en]}>
{sheet.summary}
</Text>
</View>
<TwoBox language={menuLanguage}>
{ sheetTopics }
</TwoBox>
</ScrollView>
</View>
);
}
export default SheetMeta;