-
Notifications
You must be signed in to change notification settings - Fork 0
/
Settings.js
65 lines (59 loc) · 2.38 KB
/
Settings.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
import React, { useState } from 'react';
import { View } from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';
import { connect } from 'react-redux';
import { setGeneralSetting, setPersonalSetting } from './actions';
import { ButtonGroup } from 'react-native-elements';
import PersonalSettings from './PersonalSettings';
import { SafeAreaView } from 'react-native-safe-area-context';
import Screen from './Screen';
import GeneralSettings from './GeneralSettings';
import styles from './styles';
const Settings = ({ generalSettings, onSetGeneralSetting, personalSettings, onSetPersonalSetting, navigation }) => {
const buttons = ['General', 'Personal']
const [selectedIndex, setSelectedIndex] = useState(0);
return (
<Screen screenName="Settings" navigation={navigation}>
<ButtonGroup
onPress={(newIndex) => {setSelectedIndex(newIndex)}}
selectedIndex={selectedIndex}
buttons={buttons}
containerStyle={styles.settingsScreen.topButtonBar.containerStyle}
/>
<ScrollView style={{flex: 1}}>
{
buttons[selectedIndex] === 'General' && (
<GeneralSettings
generalSettings={generalSettings}
onSetGeneralSetting={onSetGeneralSetting}
styles={styles}
/>
)
}
{
buttons[selectedIndex] === 'Personal' && (
<View style={{flex: 1}}>
<PersonalSettings
personalSettings={personalSettings}
onSetPersonalSetting={onSetPersonalSetting}
styles={styles}
/>
</View>
)
}
</ScrollView>
</Screen>
)
}
const mapStateToProps = state => ({
generalSettings: state.generalSettings,
personalSettings: state.personalSettings
})
const mapDispatchToProps = dispatch => ({
onSetGeneralSetting: (key, val) => dispatch(setGeneralSetting(key, val)),
onSetPersonalSetting: (key, val) => dispatch(setPersonalSetting(key, val))
})
export default connect(
mapStateToProps,
mapDispatchToProps
)(Settings)