-
Notifications
You must be signed in to change notification settings - Fork 775
refactor(ui): update language selectionscreen #703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
housseindjirdeh
merged 8 commits into
gitpoint:master
from
Arjun-sna:language_selection
Jan 28, 2018
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6301fea
refactor(ui): update user settings page
Arjun-sna 7c5233c
docs(update contributors): update contributors
Arjun-sna be84064
refactor(ui): make ui consistent
Arjun-sna 09ac717
refactor(ui): make language settings screen consistent
Arjun-sna 8c19749
refactor(ui): refoctor code in launguage selection file
Arjun-sna 6d42d74
Merge branch 'master' into language_selection
machour 3cdfab1
refactor(ui): use Styled components in language settings screen
Arjun-sna 970f02d
fix(ui): fix lint errors
Arjun-sna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,113 @@ | ||
| /* eslint-disable no-shadow */ | ||
| import React, { Component } from 'react'; | ||
| import { FlatList } from 'react-native'; | ||
| import styled from 'styled-components/native'; | ||
| import { connect } from 'react-redux'; | ||
| import { ListItem } from 'react-native-elements'; | ||
| import { colors, fonts } from 'config'; | ||
| import { changeLocale } from 'auth'; | ||
| import { bindActionCreators } from 'redux'; | ||
| import { emojifyText, translate } from 'utils'; | ||
| import { NavigationActions } from 'react-navigation'; | ||
| import { ViewContainer } from 'components'; | ||
| import languages from './language-settings'; | ||
|
|
||
| const ListTitle = styled.Text` | ||
| color: ${colors.black}; | ||
| ${fonts.fontPrimary}; | ||
| `; | ||
|
|
||
| const Language = styled.View` | ||
| flex-direction: row; | ||
| `; | ||
|
|
||
| const Flag = styled.Text` | ||
| padding-right: 7; | ||
| color: ${colors.black}; // random any color for the correct display emoji | ||
| `; | ||
|
|
||
| const StyledListItem = styled(ListItem).attrs({ | ||
| containerStyle: { | ||
| borderBottomColor: colors.greyLight, | ||
| borderBottomWidth: 1, | ||
| height: 50, | ||
| justifyContent: 'center', | ||
| }, | ||
| titleStyle: props => ({ | ||
| color: props.signOut ? colors.red : colors.black, | ||
| ...fonts.fontPrimary, | ||
| }), | ||
| underlayColor: colors.greyLight, | ||
| hideChevron: props => props.hideChevron, | ||
| })``; | ||
|
|
||
| class LanguageSettings extends Component { | ||
| props: { | ||
| locale: string, | ||
| changeLocale: () => void, | ||
| }; | ||
|
|
||
| componentWillReceiveProps(nextState) { | ||
| if (nextState.locale !== this.props.locale) { | ||
| const navigationParams = NavigationActions.setParams({ | ||
| params: { | ||
| title: translate('auth.userOptions.language', nextState.locale), | ||
| }, | ||
| key: nextState.navigation.state.key, | ||
| }); | ||
|
|
||
| nextState.navigation.dispatch(navigationParams); | ||
| } | ||
| } | ||
|
|
||
| renderListItem = ({ item }) => { | ||
| const { locale, changeLocale } = this.props; | ||
|
|
||
| return ( | ||
| <StyledListItem | ||
| title={ | ||
| <Language> | ||
| <Flag>{emojifyText(item.emojiCode)}</Flag> | ||
| <ListTitle>{item.name}</ListTitle> | ||
| </Language> | ||
| } | ||
| hideChevron={locale !== item.code} | ||
| rightIcon={{ name: 'check' }} | ||
| onPress={() => changeLocale(item.code)} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| render() { | ||
| const { locale } = this.props; | ||
|
|
||
| return ( | ||
| <ViewContainer> | ||
| <FlatList | ||
| data={languages} | ||
| renderItem={this.renderListItem} | ||
| keyExtractor={(item, index) => index} | ||
| extraData={locale} | ||
| /> | ||
| </ViewContainer> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| const mapStateToProps = state => ({ | ||
| locale: state.auth.locale, | ||
| user: state.auth.user, | ||
| }); | ||
|
|
||
| const mapDispatchToProps = dispatch => | ||
| bindActionCreators( | ||
| { | ||
| changeLocale, | ||
| }, | ||
| dispatch | ||
| ); | ||
|
|
||
| export const LanguageSettingsScreen = connect( | ||
| mapStateToProps, | ||
| mapDispatchToProps | ||
| )(LanguageSettings); |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉