Skip to content

Commit

Permalink
Add external links from the Settings scene
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarty committed Jan 11, 2017
1 parent 0f1a748 commit 43b478d
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 9 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
'quotes': ['error', 'single', { 'allowTemplateLiterals': true }],
'semi': ['error', 'always'],
'comma-dangle': ['error', 'always-multiline'],
'arrow-parens': ['error', 'always'],
'no-console': 0,
},
};
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ android/app/libs
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots

TODO.md
23 changes: 19 additions & 4 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
export default {
'theme': {
'colorBackground': '#f2f2f2',
},
export const theme = {
'colorBackground': '#f2f2f2',
};

export const settings = {
'links': [
{
'label': 'About Project Magnet',
'url': 'https://trymagnet.org',
},
{
'label': 'Privacy Policy',
'url': 'https://trymagnet.org/privacy',
},
{
'label': 'Feedback',
'url': 'https://trymagnet.org/#contact',
},
],
};
2 changes: 1 addition & 1 deletion index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
AppRegistry,
View,
} from 'react-native';
import theme from './config';
import { theme } from './config';
import AppProvider from './js/AppProvider';

export default class MagnetJourney extends Component {
Expand Down
2 changes: 1 addition & 1 deletion index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
AppRegistry,
View,
} from 'react-native';
import theme from './config';
import { theme } from './config';
import AppProvider from './js/AppProvider';

export default class MagnetJourney extends Component {
Expand Down
37 changes: 34 additions & 3 deletions js/scenes/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import React, { Component } from 'react';
import {
View,
Text,
TouchableHighlight,
TouchableOpacity,
Linking,
StyleSheet,
} from 'react-native';

import { settings } from '../../config';

export default class Settings extends Component {
constructor(props) {
super(props);
Expand All @@ -17,14 +21,34 @@ export default class Settings extends Component {
this.navigator.pop();
}

onItemPress(url) {
if (!url) {
return;
}
Linking.openURL(url).catch((err) => {
console.info(`Could not open url ${url} `, err);
});
}

render() {
return (
<View>
<Text>Settings scene</Text>
<TouchableHighlight

{settings.links.map((link, id) => (
<View key={id}>
<View style={styles.separator}/>
<TouchableOpacity
onPress={this.onItemPress.bind(this, link.url)}>
<Text>{link.label}</Text>
</TouchableOpacity>
</View>
))}

<TouchableOpacity
onPress={this.onBackPress}>
<Text>Back</Text>
</TouchableHighlight>
</TouchableOpacity>
</View>
);
}
Expand All @@ -33,3 +57,10 @@ export default class Settings extends Component {
Settings.propTypes = {
navigator: React.PropTypes.object,
};

const styles = StyleSheet.create({
separator: {
height: 1,
backgroundColor: '#eee',
},
});

0 comments on commit 43b478d

Please sign in to comment.