-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
ReaderControls.js
111 lines (106 loc) · 3.74 KB
/
ReaderControls.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
'use strict';
import PropTypes from 'prop-types';
import React, { useContext, useReducer } from 'react';
import {
Text,
TouchableOpacity,
View,
Image,
Platform,
} from 'react-native';
import ReaderDisplayOptionsMenu from './ReaderDisplayOptionsMenu';
import styles from './Styles.js';
import {
MenuButton,
DirectedButton,
DisplaySettingsButton,
CategoryAttribution,
SText,
HebrewInEnglishText,
SaveButton,
} from './Misc.js';
import { GlobalStateContext, getTheme } from './StateManager';
import { iconData } from "./IconData";
import Sefaria from "./sefaria";
const ReaderControls = ({
enRef,
heRef,
categories,
openTextToc,
openSheetMeta,
goBack,
toggleReaderDisplayOptionsMenu,
openUri,
sheet,
getHistoryObject,
showToast,
}) => {
const { themeStr, textLanguage, interfaceLanguage } = useContext(GlobalStateContext);
const theme = getTheme(themeStr);
const historyItem = getHistoryObject();
const isHeb = Sefaria.util.get_menu_language(interfaceLanguage, textLanguage) == "hebrew";
var langStyle = isHeb ? [styles.he] : [styles.en, sheet ? {lineHeight: 28} : {marginBottom: -5.3}];
var titleTextStyle = [langStyle, styles.headerTextTitleText, theme.text];
const leftMenuButton = (
<DirectedButton
onPress={goBack}
imageStyle={[styles.menuButton, styles.directedButton]}
language="english"
direction="back"
/>
);
var textTitle = isHeb ? heRef : enRef;
if (sheet) {
textTitle = Sefaria.util.stripHtml(sheet.title);
}
return (
<View style={[styles.header, theme.header]}>
{leftMenuButton}
<View style={styles.readerNavSectionMoreInvisible}>
<Image
style={styles.starIcon}
source={iconData.get('bookmark-unfilled', 'white')}
resizeMode={'contain'}
/>
</View>
<TouchableOpacity style={styles.headerTextTitle} onPress={sheet ? openSheetMeta : openTextToc }>
<View style={styles.headerTextTitleInner}>
<Image source={iconData.get('caret', themeStr)}
style={[styles.downCaret, isHeb ? null: {opacity: 0}]}
resizeMode={'contain'} />
{sheet ?
<Text lang={textLanguage} style={titleTextStyle} numberOfLines={1} ellipsizeMode={"middle"}><HebrewInEnglishText text={sheet.title} stylesHe={[styles.heInEn]} stylesEn={[]}/></Text> :
<SText lang={textLanguage} style={titleTextStyle} numberOfLines={1} ellipsizeMode={"middle"} lineMultiplier={Platform.OS == 'ios' ? 1.5 : 1}>{textTitle}</SText>
}
<Image source={iconData.get('caret', themeStr)}
style={[styles.downCaret, isHeb ? {opacity: 0} : null]}
resizeMode={'contain'} />
</View>
<CategoryAttribution
categories={categories}
context={"header"}
linked={false}
openUri={openUri}
/>
</TouchableOpacity>
<SaveButton
historyItem={historyItem}
showToast={showToast}
/>
<DisplaySettingsButton onPress={toggleReaderDisplayOptionsMenu} />
</View>
);
}
ReaderControls.propTypes = {
enRef: PropTypes.string,
heRef: PropTypes.string,
categories: PropTypes.array,
openTextToc: PropTypes.func,
goBack: PropTypes.func,
toggleReaderDisplayOptionsMenu: PropTypes.func,
openUri: PropTypes.func.isRequired,
getHistoryObject: PropTypes.func.isRequired,
showToast: PropTypes.func.isRequired,
};
ReaderControls.whyDidYouRender = true;
export default ReaderControls;