-
-
Notifications
You must be signed in to change notification settings - Fork 643
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate langauge to another page in settings screen (#944)
- Loading branch information
1 parent
24db5bf
commit bb1fcad
Showing
6 changed files
with
113 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* @flow */ | ||
import React, { PureComponent } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { StyleSheet, View } from 'react-native'; | ||
|
||
import { Actions } from '../types'; | ||
import { Screen } from '../common'; | ||
import LanguagePicker from './LanguagePicker'; | ||
import boundActions from '../boundActions'; | ||
import { getAuth } from '../selectors'; | ||
|
||
const styles = StyleSheet.create({ | ||
optionWrapper: { | ||
flex: 1, | ||
}, | ||
optionRow: { | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
padding: 8, | ||
}, | ||
optionTitle: { | ||
padding: 8, | ||
fontWeight: 'bold', | ||
}, | ||
optionList: { | ||
flex: 1, | ||
}, | ||
}); | ||
|
||
class SettingsDetailScreen extends PureComponent { | ||
props: { | ||
actions: Actions, | ||
locale: string, | ||
navigation: { | ||
state: { | ||
params: { | ||
setting: string, | ||
title: string, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
handleLocaleChange = (value: string) => { | ||
this.props.actions.settingsChange('locale', value); | ||
}; | ||
|
||
renderSettings = (setting: string) => { | ||
const { locale } = this.props; | ||
switch (setting) { | ||
case 'language': { | ||
return <LanguagePicker value={locale} onValueChange={this.handleLocaleChange} />; | ||
} | ||
default: | ||
return null; | ||
} | ||
}; | ||
|
||
render() { | ||
const { title, setting } = this.props.navigation.state.params; | ||
return ( | ||
<Screen title={title}> | ||
<View style={styles.optionWrapper}> | ||
{this.renderSettings(setting)} | ||
</View> | ||
</Screen> | ||
); | ||
} | ||
} | ||
|
||
export default connect( | ||
state => ({ | ||
offlineNotification: state.settings.offlineNotification, | ||
onlineNotification: state.settings.onlineNotification, | ||
locale: state.settings.locale, | ||
theme: state.settings.theme, | ||
auth: getAuth(state), | ||
}), | ||
boundActions, | ||
)(SettingsDetailScreen); |