This repository was archived by the owner on Jun 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 372
Expand file tree
/
Copy pathindex.js
More file actions
87 lines (76 loc) · 2.43 KB
/
index.js
File metadata and controls
87 lines (76 loc) · 2.43 KB
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
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import * as OptionsActions from 'redux/actions/options.js';
import { connect } from 'react-redux';
import Menu from 'quran-components/lib/Menu';
import { load } from 'redux/actions/verses.js';
import * as customPropTypes from 'customPropTypes';
import LocaleSwitcher from 'components/LocaleSwitcher';
import FontSizeOptions from './FontSizeOptions';
import ReadingModeToggle from './ReadingModeToggle';
import NightModeToggle from './NightModeToggle';
import ChapterInfoToggle from './ChapterInfoToggle';
import ReciterDropdown from './ReciterDropdown';
import TranslationsDropdown from './TranslationsDropdown';
import TooltipOptions from './TooltipOptions';
class Settings extends Component {
handleOptionChange = (payload) => {
const { chapter, setOption, options, versesIds } = this.props;
setOption(payload);
if (chapter) {
const from = [...versesIds][0];
const to = [...versesIds][[...versesIds].length - 1];
const paging = { offset: from - 1, limit: to - from + 1 };
this.props.load(chapter.chapterNumber, paging, {
...options,
...payload
});
}
};
render() {
const { setOption, options } = this.props;
return (
<Menu>
<ChapterInfoToggle
onToggle={setOption}
isToggled={options.isShowingSurahInfo}
/>
<ReadingModeToggle
isToggled={options.isReadingMode}
onToggle={setOption}
/>
<NightModeToggle
isNightMode={options.isNightMode}
onToggle={setOption}
/>
<hr />
<ReciterDropdown onOptionChange={this.handleOptionChange} />
<TranslationsDropdown onOptionChange={this.handleOptionChange} />
<TooltipOptions tooltip={options.tooltip} onOptionChange={setOption} />
<hr />
<FontSizeOptions
fontSize={options.fontSize}
onOptionChange={setOption}
/>
<hr />
<LocaleSwitcher renderAs="menu" />
</Menu>
);
}
}
Settings.propTypes = {
setOption: PropTypes.func.isRequired,
load: PropTypes.func.isRequired,
chapter: customPropTypes.surahType.isRequired,
options: customPropTypes.optionsType.isRequired,
versesIds: PropTypes.instanceOf(Set)
};
function mapStateToProps(state) {
return {
options: state.options
};
}
export default connect(mapStateToProps, {
...OptionsActions,
load
})(Settings);