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
import Constants from '../../global/constants'; | |
import Colors from '../../global/styles/colors'; | |
import Typography from '../../global/styles/typography'; | |
import { StyleSheet } from 'react-native'; | |
export default StyleSheet.create({ | |
titleContainer: { | |
backgroundColor: Colors.green, | |
padding: Constants.GAP | |
}, |
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
import React, { Component } from 'react'; | |
import { Text, View } from 'react-native'; | |
import Styles from './Card.style'; | |
class Card extends Component { | |
render() { | |
return ( | |
<View style={ Styles.container }> | |
<View style={ Styles.titleContainer }> |
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
import Colors from './colors'; | |
export default const Typography = { | |
heading1: { | |
fontSize: 30, | |
fontWeight: 'bold', | |
lineHeight: 32, | |
color: Colors.black | |
}, |
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
export default class AsyncStorageSupplement { | |
static multiGet(keys) { | |
return Promise.all( | |
keys.map(key => AsyncStorage.getItem(key)) | |
) | |
} | |
static multiRemove(keys) { | |
return Promise.all( | |
keys.map(key => AsyncStorage.removeItem(key)) |
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
export default { | |
configSettingExists( config, key ) { | |
// Search the config object for the key value | |
let found = Object.keys( config ).indexOf( key ) | |
return found; | |
}, | |
indexArrayBy(arr, attrName, group=false) { | |
// ... | |
}, |
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
// Old | |
export default { | |
// ... | |
} | |
// New | |
export default class { | |
// ... | |
} |
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
import Utils from 'utils.js'; | |
// Load the config. | |
let config = Utils.initConfig(); | |
// Later, use it | |
if ( ! Utils.configSettingExists( config, 'foo' ) ) { | |
Utils.printConfigFormatInstructions(); | |
} |
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
export default class { | |
initConfig() { | |
this.config = // ... load a json file via AJAX, filesystem, etc. ... | |
return this.config; | |
}, | |
configSettingExists( key ) { | |
// Search the config object for the key value |
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
export default class { | |
// ... | |
static printConfigFormatInstructions() { | |
console.log('Your config file must be in json format, and contain the following keys: foo, bar, baz.'); | |
} | |
} |
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
// Old | |
import Utils from 'utils.js'; | |
// Load the config. | |
let config = Utils.initConfig(); | |
// New | |
import Config from 'config.js'; | |
Config.initConfig(); |