diff --git a/.eslintignore b/.eslintignore index 6942f1a5b..09fc1a1e5 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,5 @@ vendor/ Components/Styles/ -dist/ \ No newline at end of file +dist/ +src/basic/Tabs/ +src/basic/SwipeRow.js \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json index b0ee3ab1c..be814fb57 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,7 +1,18 @@ { + "extends": ["airbnb", "prettier"], "parser": "babel-eslint", "rules": { - "indent": ["warn", 2] + "indent": ["error", 2], + "react/require-extension": "off", + "import/order": ["error", { "newlines-between": "always" }], + "func-names": "off", + "import/prefer-default-export": "off", + "no-prototype-builtins": "off", + "no-nested-ternary": "warn", + "no-underscore-dangle": "off", + "no-unused-expressions": "off", + "react/jsx-filename-extension": "off", + "react/prop-types": "off" }, "plugins": ["react", "jsx-a11y", "import", "react-native"] } diff --git a/package-lock.json b/package-lock.json index 7670bc6d0..80bab1cce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1259,8 +1259,7 @@ "asap": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", - "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=", - "dev": true + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" }, "asn1": { "version": "0.2.4", @@ -2780,7 +2779,6 @@ "version": "15.6.3", "resolved": "https://registry.npmjs.org/create-react-class/-/create-react-class-15.6.3.tgz", "integrity": "sha512-M+/3Q6E6DLO6Yx3OwrWjwHBnvfXXYA7W+dFjt/ZDBemHO1DDZhsalX/NUtnTYclN6GfnBDRh4qRHjcDHmlJBJg==", - "dev": true, "requires": { "fbjs": "^0.8.9", "loose-envify": "^1.3.1", @@ -3070,7 +3068,6 @@ "version": "0.1.12", "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", - "dev": true, "requires": { "iconv-lite": "~0.4.13" } @@ -3348,7 +3345,6 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.0.0.tgz", "integrity": "sha512-vDrcCFE3+2ixNT5H83g28bO/uYAwibJxerXPj+E7op4qzBCsAV36QfvdAyVOoNxKAH2Os/e01T/2x++V0LPukA==", - "dev": true, "requires": { "get-stdin": "^6.0.0" }, @@ -3356,8 +3352,7 @@ "get-stdin": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", - "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", - "dev": true + "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==" } } }, @@ -3419,15 +3414,6 @@ "object-assign": "^4.0.1" } }, - "eslint-plugin-prettier": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.0.tgz", - "integrity": "sha512-XWX2yVuwVNLOUhQijAkXz+rMPPoCr7WFiAl8ig6I7Xn+pPVhDhzg4DxHpmbeb0iqjO9UronEA3Tb09ChnFVHHA==", - "dev": true, - "requires": { - "prettier-linter-helpers": "^1.0.0" - } - }, "eslint-plugin-react": { "version": "6.10.3", "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-6.10.3.tgz", @@ -4141,12 +4127,6 @@ "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", "dev": true }, - "fast-diff": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", - "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", - "dev": true - }, "fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", @@ -4172,7 +4152,6 @@ "version": "0.8.17", "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.17.tgz", "integrity": "sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90=", - "dev": true, "requires": { "core-js": "^1.0.0", "isomorphic-fetch": "^2.1.1", @@ -4186,8 +4165,7 @@ "core-js": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", - "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=", - "dev": true + "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=" } } }, @@ -5420,7 +5398,6 @@ "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dev": true, "requires": { "safer-buffer": ">= 2.1.2 < 3" } @@ -5850,7 +5827,6 @@ "version": "2.2.1", "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", - "dev": true, "requires": { "node-fetch": "^1.0.1", "whatwg-fetch": ">=0.10.0" @@ -7905,7 +7881,6 @@ "version": "1.7.3", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", - "dev": true, "requires": { "encoding": "^0.1.11", "is-stream": "^1.0.1" @@ -8514,15 +8489,6 @@ "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", "dev": true }, - "prettier-linter-helpers": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", - "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", - "dev": true, - "requires": { - "fast-diff": "^1.1.2" - } - }, "pretty-format": { "version": "23.6.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-23.6.0.tgz", @@ -8586,7 +8552,6 @@ "version": "7.3.1", "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", - "dev": true, "requires": { "asap": "~2.0.3" } @@ -9763,8 +9728,7 @@ "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "sane": { "version": "2.5.2", @@ -10170,8 +10134,7 @@ "setimmediate": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", - "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=", - "dev": true + "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" }, "setprototypeof": { "version": "1.1.1", @@ -10948,8 +10911,7 @@ "ua-parser-js": { "version": "0.7.20", "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.20.tgz", - "integrity": "sha512-8OaIKfzL5cpx8eCMAhhvTlft8GYF8b2eQr6JkCyVdrgjcytyOmPCXrqXFcUnhonRpLlh5yxEZVohm6mzaowUOw==", - "dev": true + "integrity": "sha512-8OaIKfzL5cpx8eCMAhhvTlft8GYF8b2eQr6JkCyVdrgjcytyOmPCXrqXFcUnhonRpLlh5yxEZVohm6mzaowUOw==" }, "uglify-js": { "version": "3.6.0", @@ -11242,8 +11204,7 @@ "whatwg-fetch": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", - "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==", - "dev": true + "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" }, "whatwg-mimetype": { "version": "2.3.0", diff --git a/package.json b/package.json index 9877066b2..6f76906f6 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,8 @@ "blueimp-md5": "^2.5.0", "clamp": "^1.0.1", "color": "~1.0.3", + "create-react-class": "^15.6.3", + "eslint-config-prettier": "^6.0.0", "fs-extra": "^2.0.0", "jest-react-native": "^18.0.0", "lodash": "4.17.11", diff --git a/src/basic/Accordion.js b/src/basic/Accordion.js index a43174231..02805dce9 100644 --- a/src/basic/Accordion.js +++ b/src/basic/Accordion.js @@ -1,4 +1,6 @@ -import React, { Component } from 'react'; +/* eslint-disable react/no-multi-comp */ +/* eslint-disable react/prefer-stateless-function */ +import React from 'react'; import { Animated, TouchableWithoutFeedback, @@ -6,9 +8,11 @@ import { StyleSheet, View } from 'react-native'; + +import variable from '../theme/variables/platform'; + import { Text } from './Text'; import { Icon } from './Icon'; -import variable from '../theme/variables/platform'; class DefaultHeader extends React.Component { render() { @@ -18,6 +22,7 @@ class DefaultHeader extends React.Component { return ( {this.props.children} @@ -133,7 +138,13 @@ class AccordionItem extends React.Component { } export class Accordion extends React.Component { - state = { selected: undefined }; + constructor(props) { + super(props); + this.state = { + selected: props.expanded + }; + } + setSelected(index) { if (this.state.selected === index) { this.setState({ selected: undefined }); @@ -142,10 +153,6 @@ export class Accordion extends React.Component { } } - componentDidMount() { - this.setState({ selected: this.props.expanded }); - } - render() { const variables = this.context.theme ? this.context.theme['@@shoutem.theme/themeStyle'].variables @@ -168,7 +175,7 @@ export class Accordion extends React.Component { item={item} expanded={this.state.selected === index} index={index} - setSelected={this.setSelected.bind(this)} + setSelected={i => this.setSelected(i)} headerStyle={this.props.headerStyle} contentStyle={this.props.contentStyle} renderHeader={this.props.renderHeader} diff --git a/src/basic/Actionsheet.js b/src/basic/Actionsheet.js index e8ac49690..695e2645e 100644 --- a/src/basic/Actionsheet.js +++ b/src/basic/Actionsheet.js @@ -1,7 +1,7 @@ +/* eslint-disable radix */ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { - View, Modal, Platform, ActionSheetIOS, @@ -11,17 +11,25 @@ import { Dimensions } from 'react-native'; import { connectStyle } from 'native-base-shoutem-theme'; + +import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; + import { Text } from './Text'; -import { Button } from './Button'; -import { ViewNB } from './View'; import { Icon } from './Icon'; import { Left } from './Left'; import { Right } from './Right'; import { Body } from './Body'; import { ListItem } from './ListItem'; -import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; class ActionSheetContainer extends Component { + static actionsheetInstance; + static show(config, callback) { + this.actionsheetInstance._root.showActionSheet(config, callback); + } + static hide() { + this.actionsheetInstance._root.hideActionSheet(); + } + constructor(props) { super(props); this.state = { @@ -29,22 +37,23 @@ class ActionSheetContainer extends Component { items: [] }; } - static actionsheetInstance; - static show(config, callback) { - this.actionsheetInstance._root.showActionSheet(config, callback); - } - static hide() { - this.actionsheetInstance._root.hideActionSheet(); + + componentDidMount() { + if (!this.props.autoHide && this.props.duration) { + console.warn(`It's not recommended to set autoHide false with duration`); + } } + showActionSheet(config, callback) { if (Platform.OS === 'ios') { - if (typeof config.options[0] == 'object') { - let options = config.options; - let filtered = options.map(item => { + if (typeof config.options[0] === 'object') { + const options = config.options; + const filtered = options.map(item => { return item.text; }); - config.options = filtered; - ActionSheetIOS.showActionSheetWithOptions(config, callback); + + const filteredConfig = { ...config, options: filtered }; + ActionSheetIOS.showActionSheetWithOptions(filteredConfig, callback); } else { ActionSheetIOS.showActionSheetWithOptions(config, callback); } @@ -56,7 +65,7 @@ class ActionSheetContainer extends Component { destructiveButtonIndex: config.destructiveButtonIndex, cancelButtonIndex: config.cancelButtonIndex, modalVisible: true, - callback: callback + callback }); } } @@ -65,16 +74,11 @@ class ActionSheetContainer extends Component { this.setState({ modalVisible: false }); } - componentDidMount() { - if (!this.props.autoHide && this.props.duration) { - console.warn(`It's not recommended to set autoHide false with duration`); - } - } render() { return ( { this.state.callback(this.state.cancelButtonIndex); diff --git a/src/basic/Badge.js b/src/basic/Badge.js index 915fd4cc4..4374c7e7d 100644 --- a/src/basic/Badge.js +++ b/src/basic/Badge.js @@ -1,9 +1,8 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { View, ViewPropTypes } from 'react-native'; - import { connectStyle } from 'native-base-shoutem-theme'; -import variables from '../theme/variables/platform'; + import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; class Badge extends Component { diff --git a/src/basic/Base/NativeBaseComponent.js b/src/basic/Base/NativeBaseComponent.js index a60e589c1..08f1c792b 100644 --- a/src/basic/Base/NativeBaseComponent.js +++ b/src/basic/Base/NativeBaseComponent.js @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import { Component } from 'react'; import PropTypes from 'prop-types'; export default class NativeBaseComponent extends Component { @@ -8,8 +8,8 @@ export default class NativeBaseComponent extends Component { }; static propTypes = { - theme: PropTypes.object, - foregroundColor: PropTypes.string + // eslint-disable-next-line react/forbid-prop-types + theme: PropTypes.object }; static childContextTypes = { diff --git a/src/basic/Body.js b/src/basic/Body.js index cd28aae7b..abbea7430 100644 --- a/src/basic/Body.js +++ b/src/basic/Body.js @@ -1,8 +1,8 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { View, ViewPropTypes } from 'react-native'; - import { connectStyle } from 'native-base-shoutem-theme'; + import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; class Body extends Component { diff --git a/src/basic/Button.js b/src/basic/Button.js index 71ef1a1f1..004af7921 100644 --- a/src/basic/Button.js +++ b/src/basic/Button.js @@ -1,3 +1,4 @@ +/* eslint-disable new-cap */ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { @@ -8,12 +9,13 @@ import { StyleSheet } from 'react-native'; import { connectStyle } from 'native-base-shoutem-theme'; -import variable from './../theme/variables/platform'; -import { Text } from './Text'; -import computeProps from '../utils/computeProps'; +import variable from '../theme/variables/platform'; +import computeProps from '../utils/computeProps'; import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; +import { Text } from './Text'; + class Button extends Component { static contextTypes = { theme: PropTypes.object @@ -33,8 +35,6 @@ class Button extends Component { }; } - _root: React$Element; - prepareRootProps() { const defaultProps = { style: this.getInitialStyle().borderedBtn @@ -72,7 +72,7 @@ class Button extends Component { Platform.OS === 'ios' || Platform.OS === 'web' || variables.androidRipple === false || - Platform['Version'] < 21 + Platform.Version < 21 ) { return ( ); - } else { - if (this.props.rounded) { - let buttonStyle = { ...this.prepareRootProps().style }; - let buttonFlex = - this.props.full || this.props.block - ? variable.buttonDefaultFlex - : buttonStyle.flex; - return ( - - (this._root = c)} - background={TouchableNativeFeedback.Ripple( - this.props.androidRippleColor || variables.androidRippleColor, - true - )} - {...this.prepareRootProps()} - > - - {children} - - - - ); - } else { - return ( + } + if (this.props.rounded) { + const buttonStyle = { ...this.prepareRootProps().style }; + const buttonFlex = + this.props.full || this.props.block + ? variable.buttonDefaultFlex + : buttonStyle.flex; + return ( + (this._root = c)} - onPress={this.props.onPress} - background={ - this.props.transparent - ? TouchableNativeFeedback.Ripple('transparent') - : TouchableNativeFeedback.Ripple( - variables.androidRippleColor, - false - ) - } + background={TouchableNativeFeedback.Ripple( + this.props.androidRippleColor || variables.androidRippleColor, + true + )} {...this.prepareRootProps()} > - {children} + + {children} + - ); - } + + ); } + return ( + (this._root = c)} + onPress={this.props.onPress} + background={ + this.props.transparent + ? TouchableNativeFeedback.Ripple('transparent') + : TouchableNativeFeedback.Ripple( + variables.androidRippleColor, + false + ) + } + {...this.prepareRootProps()} + > + {children} + + ); } } diff --git a/src/basic/Card.js b/src/basic/Card.js index 7c5a4b438..5ce6b95e4 100644 --- a/src/basic/Card.js +++ b/src/basic/Card.js @@ -1,8 +1,8 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { View, ListView, ViewPropTypes } from 'react-native'; - import { connectStyle } from 'native-base-shoutem-theme'; + import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; class Card extends Component { @@ -36,6 +36,7 @@ Card.propTypes = { PropTypes.number, PropTypes.array ]), + // eslint-disable-next-line react/forbid-prop-types dataArray: PropTypes.array, renderRow: PropTypes.func }; diff --git a/src/basic/CardItem.js b/src/basic/CardItem.js index ce0755bd5..d1ef88b08 100644 --- a/src/basic/CardItem.js +++ b/src/basic/CardItem.js @@ -1,8 +1,8 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { TouchableOpacity, View } from 'react-native'; - import { connectStyle } from 'native-base-shoutem-theme'; + import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; class CardItem extends Component { @@ -17,13 +17,12 @@ class CardItem extends Component { {this.props.children} ); - } else { - return ( - (this._root = c)} {...this.props}> - {this.props.children} - - ); } + return ( + (this._root = c)} {...this.props}> + {this.props.children} + + ); } } diff --git a/src/basic/Checkbox.js b/src/basic/Checkbox.js index a7e9e0c89..38efa398b 100644 --- a/src/basic/Checkbox.js +++ b/src/basic/Checkbox.js @@ -1,11 +1,11 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { TouchableOpacity, Platform } from 'react-native'; +import { TouchableOpacity } from 'react-native'; import IconNB from 'react-native-vector-icons/Ionicons'; import { connectStyle } from 'native-base-shoutem-theme'; + import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; import variable from '../theme/variables/platform'; -import _ from 'lodash'; import computeProps from '../utils/computeProps'; class CheckBox extends Component { diff --git a/src/basic/Container.js b/src/basic/Container.js index bf9bab2f3..c4c363da8 100644 --- a/src/basic/Container.js +++ b/src/basic/Container.js @@ -1,13 +1,10 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { View } from 'react-native'; -import { ViewPropTypes } from '../utils'; - import { connectStyle } from 'native-base-shoutem-theme'; + +import { ViewPropTypes } from '../utils'; import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; -import { ToastContainer as Toast } from './ToastContainer'; -import { ActionSheetContainer as ActionSheet } from './Actionsheet'; -import { Text } from './Text'; class Container extends Component { render() { diff --git a/src/basic/Content.js b/src/basic/Content.js index 85d5601ea..e775de4d8 100644 --- a/src/basic/Content.js +++ b/src/basic/Content.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'; import { connectStyle } from 'native-base-shoutem-theme'; + import variable from '../theme/variables/platform'; import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; @@ -16,7 +17,7 @@ class Content extends Component { }; } layoutChange(val) { - let maxComp = Math.max(variable.deviceWidth, variable.deviceHeight); + const maxComp = Math.max(variable.deviceWidth, variable.deviceHeight); if (val.width >= maxComp) this.setState({ orientation: 'landscape' }); else { this.setState({ orientation: 'portrait' }); @@ -163,7 +164,6 @@ Content.propTypes = { ]), padder: PropTypes.bool, disableKBDismissScroll: PropTypes.bool, - enableResetScrollToCoords: PropTypes.bool, keyboardShouldPersistTaps: PropTypes.string }; diff --git a/src/basic/DatePicker.js b/src/basic/DatePicker.js index 1dafef192..c08ba3f75 100644 --- a/src/basic/DatePicker.js +++ b/src/basic/DatePicker.js @@ -6,9 +6,11 @@ import { DatePickerIOS, DatePickerAndroid } from 'react-native'; -import { Text } from './Text'; + import variable from '../theme/variables/platform'; +import { Text } from './Text'; + export class DatePicker extends React.Component { static defaultProps = { disabled: false @@ -32,13 +34,13 @@ export class DatePicker extends React.Component { } } - showDatePicker() { + showDatePicker = () => { if (Platform.OS === 'android') { this.openAndroidDatePicker(); } else { this.setState({ modalVisible: true }); } - } + }; async openAndroidDatePicker() { try { @@ -52,7 +54,7 @@ export class DatePicker extends React.Component { }); const { action, year, month, day } = newDate; if (action === 'dateSetAction') { - let selectedDate = new Date(year, month, day); + const selectedDate = new Date(year, month, day); this.setState({ chosenDate: selectedDate }); this.props.onDateChange(selectedDate); } @@ -76,8 +78,8 @@ export class DatePicker extends React.Component { + !this.props.disabled ? this.showDatePicker() : undefined } style={[ { padding: 10, color: variables.datePickerTextColor }, @@ -96,7 +98,7 @@ export class DatePicker extends React.Component { {}} > @@ -110,7 +112,7 @@ export class DatePicker extends React.Component { ? this.state.chosenDate : this.state.defaultDate } - onDateChange={this.setDate.bind(this)} + onDateChange={date => this.setDate(date)} minimumDate={this.props.minimumDate} maximumDate={this.props.maximumDate} mode="date" diff --git a/src/basic/DeckSwiper.js b/src/basic/DeckSwiper.js index e02cbbad8..375e38d4a 100644 --- a/src/basic/DeckSwiper.js +++ b/src/basic/DeckSwiper.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import { View, Animated, PanResponder, ViewPropTypes } from 'react-native'; import clamp from 'clamp'; import { connectStyle } from 'native-base-shoutem-theme'; + import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; const SWIPE_THRESHOLD = 120; @@ -26,129 +27,13 @@ class DeckSwiper extends Component { }; } - componentWillReceiveProps({ dataSource }) { - if (dataSource.length !== this.props.dataSource.length) { - if (dataSource.length <= 1) { - this.setState({ - ...this.state, - selectedItem: dataSource[0], - selectedItem2: undefined, - disabled: dataSource.length === 0, - lastCard: dataSource.length === 1 - }); - return; - } - - const visibleIndex = dataSource.indexOf(this.state.selectedItem); - const currentIndex = visibleIndex < 0 ? visibleIndex + 1 : visibleIndex; - const nextIndex = - currentIndex + 1 === dataSource.length ? 0 : currentIndex + 1; - - this.setState({ - selectedItem: dataSource[currentIndex], - selectedItem2: dataSource[nextIndex] - }); - } - } - - getInitialStyle() { - return { - topCard: { - position: 'absolute', - top: 0, - right: 0, - left: 0 - } - }; - } - - findNextIndexes(currentIndex) { - const newIdx = currentIndex + 1; - const newIdx2 = currentIndex + 2; - - if ( - newIdx2 > this.props.dataSource.length - 1 && - newIdx === this.props.dataSource.length - 1 - ) { - return [newIdx, 0]; - } else if (newIdx > this.props.dataSource.length - 1) { - return [0, 1]; - } - return [newIdx, newIdx2]; - } - - selectNext() { - const dataSource = this.props.dataSource; - const currentIndex = dataSource.indexOf(this.state.selectedItem); - - // if not looping, check for these conditionals and if true return from selectNext() - if (!this.state.looping) { - // reached end -> only display static renderEmpty() -> no swiping - if (currentIndex === dataSource.length - 1) { - return this.setState({ - disabled: true - }); - } else if (currentIndex === dataSource.length - 2) { - // show last card with renderEmpty() component behind it - return setTimeout(() => { - this.setState({ - selectedItem: dataSource[currentIndex + 1] - }); - setTimeout(() => { - this.setState({ - lastCard: true - }); - }, 350); - }, 50); - } - } - - const nextIndexes = this.findNextIndexes(currentIndex); - setTimeout(() => { - this.setState({ - selectedItem: this.props.dataSource[nextIndexes[0]] - }); - setTimeout(() => { - this.setState({ - selectedItem2: this.props.dataSource[nextIndexes[1]] - }); - }, 350); - }, 50); - } - - swipeRight() { - if (this.props.onSwiping) this.props.onSwiping('right'); - setTimeout(() => { - Animated.timing(this.state.fadeAnim, { toValue: 1 }).start(); - Animated.spring(this.state.enter, { toValue: 1, friction: 7 }).start(); - this.selectNext(); - Animated.decay(this.state.pan, { - velocity: { x: 8, y: 1 }, - deceleration: 0.98 - }).start(this._resetState.bind(this)); - }, 300); - } - - swipeLeft() { - if (this.props.onSwiping) this.props.onSwiping('left'); - setTimeout(() => { - Animated.timing(this.state.fadeAnim, { toValue: 1 }).start(); - Animated.spring(this.state.enter, { toValue: 1, friction: 7 }).start(); - this.selectNext(); - Animated.decay(this.state.pan, { - velocity: { x: -8, y: 1 }, - deceleration: 0.98 - }).start(this._resetState.bind(this)); - }, 300); - } - componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: (evt, gestureState) => Math.abs(gestureState.dx) > 5, - onPanResponderGrant: (e, gestureState) => { + onPanResponderGrant: () => { this.state.pan.setOffset({ x: this.state.pan.x._value, y: this.state.pan.y._value @@ -165,7 +50,6 @@ class DeckSwiper extends Component { this.props.onSwiping('left', gestureState.dx); } let val = Math.abs(gestureState.dx * 0.0013); - const opa = Math.abs(gestureState.dx * 0.0022); if (val > 0.2) { val = 0.2; } @@ -214,19 +98,44 @@ class DeckSwiper extends Component { }); } - _resetState() { - this.state.pan.setValue({ x: 0, y: 0 }); - this.state.enter.setValue(0.8); - this.state.fadeAnim.setValue(0.8); - this.setState({ - card1Top: !this.state.card1Top, - card2Top: !this.state.card2Top - }); - if (this.props.onSwiping) this.props.onSwiping(null); + componentWillReceiveProps({ dataSource }) { + if (dataSource.length !== this.props.dataSource.length) { + if (dataSource.length <= 1) { + this.setState({ + ...this.state, + selectedItem: dataSource[0], + selectedItem2: undefined, + disabled: dataSource.length === 0, + lastCard: dataSource.length === 1 + }); + return; + } + + const visibleIndex = dataSource.indexOf(this.state.selectedItem); + const currentIndex = visibleIndex < 0 ? visibleIndex + 1 : visibleIndex; + const nextIndex = + currentIndex + 1 === dataSource.length ? 0 : currentIndex + 1; + + this.setState({ + selectedItem: dataSource[currentIndex], + selectedItem2: dataSource[nextIndex] + }); + } } + getInitialStyle = () => { + return { + topCard: { + position: 'absolute', + top: 0, + right: 0, + left: 0 + } + }; + }; + getCardStyles() { - const { pan, pan2, enter } = this.state; + const { pan, enter } = this.state; const [translateX, translateY] = [pan.x, pan.y]; // let [translateX, translateY] = [pan2.x, pan2.y]; @@ -251,6 +160,99 @@ class DeckSwiper extends Component { return [animatedCardStyles, animatedCardStyles2]; } + _resetState() { + this.state.pan.setValue({ x: 0, y: 0 }); + this.state.enter.setValue(0.8); + this.state.fadeAnim.setValue(0.8); + this.setState({ + card1Top: !this.state.card1Top, + card2Top: !this.state.card2Top + }); + if (this.props.onSwiping) this.props.onSwiping(null); + } + + swipeRight() { + if (this.props.onSwiping) this.props.onSwiping('right'); + setTimeout(() => { + Animated.timing(this.state.fadeAnim, { toValue: 1 }).start(); + Animated.spring(this.state.enter, { toValue: 1, friction: 7 }).start(); + this.selectNext(); + Animated.decay(this.state.pan, { + velocity: { x: 8, y: 1 }, + deceleration: 0.98 + }).start(this._resetState.bind(this)); + }, 300); + } + + swipeLeft() { + if (this.props.onSwiping) this.props.onSwiping('left'); + setTimeout(() => { + Animated.timing(this.state.fadeAnim, { toValue: 1 }).start(); + Animated.spring(this.state.enter, { toValue: 1, friction: 7 }).start(); + this.selectNext(); + Animated.decay(this.state.pan, { + velocity: { x: -8, y: 1 }, + deceleration: 0.98 + }).start(this._resetState.bind(this)); + }, 300); + } + + selectNext() { + const dataSource = this.props.dataSource; + const currentIndex = dataSource.indexOf(this.state.selectedItem); + + // if not looping, check for these conditionals and if true return from selectNext() + if (!this.state.looping) { + // reached end -> only display static renderEmpty() -> no swiping + if (currentIndex === dataSource.length - 1) { + return this.setState({ + disabled: true + }); + } else if (currentIndex === dataSource.length - 2) { + // show last card with renderEmpty() component behind it + return setTimeout(() => { + this.setState({ + selectedItem: dataSource[currentIndex + 1] + }); + setTimeout(() => { + this.setState({ + lastCard: true + }); + }, 350); + }, 50); + } + } + + const nextIndexes = this.findNextIndexes(currentIndex); + setTimeout(() => { + this.setState({ + selectedItem: this.props.dataSource[nextIndexes[0]] + }); + setTimeout(() => { + this.setState({ + selectedItem2: this.props.dataSource[nextIndexes[1]] + }); + }, 350); + }, 50); + + return null; + } + + findNextIndexes(currentIndex) { + const newIdx = currentIndex + 1; + const newIdx2 = currentIndex + 2; + + if ( + newIdx2 > this.props.dataSource.length - 1 && + newIdx === this.props.dataSource.length - 1 + ) { + return [newIdx, 0]; + } else if (newIdx > this.props.dataSource.length - 1) { + return [0, 1]; + } + return [newIdx, newIdx2]; + } + render() { if (this.state.disabled) { // disable swiping and renderEmpty @@ -331,6 +333,7 @@ DeckSwiper.propTypes = { PropTypes.number, PropTypes.array ]), + // eslint-disable-next-line react/forbid-prop-types dataSource: PropTypes.array }; diff --git a/src/basic/Drawer/index.js b/src/basic/Drawer/index.js index 8d49d5501..f1b22c1c0 100644 --- a/src/basic/Drawer/index.js +++ b/src/basic/Drawer/index.js @@ -1,11 +1,7 @@ import React, { Component } from 'react'; import RNDrawer from 'react-native-drawer'; -import PropTypes from 'prop-types'; export default class Drawer extends Component { - constructor(props) { - super(props); - } render() { return (this._root = c)} {...this.props} />; } diff --git a/src/basic/Fab.js b/src/basic/Fab.js index e842ad63f..fb4339674 100644 --- a/src/basic/Fab.js +++ b/src/basic/Fab.js @@ -1,41 +1,24 @@ import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import computeProps from '../utils/computeProps'; -// import Button from './../Button'; import { Platform, Animated, - Dimensions, TouchableOpacity, TouchableNativeFeedback, View, StyleSheet } from 'react-native'; -import { Icon } from './Icon'; -import { IconNB } from './IconNB'; -import { Button } from './Button'; -import variables from './../theme/variables/platform'; import _ from 'lodash'; -import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; import { connectStyle } from 'native-base-shoutem-theme'; -const { height, width } = Dimensions.get('window'); +import variables from '../theme/variables/platform'; +import computeProps from '../utils/computeProps'; +import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; + +import { Button } from './Button'; const AnimatedFab = Animated.createAnimatedComponent(Button); class Fab extends Component { - props: Animated.props & { - pos?: string, - top?: number, - left?: number, - right?: number, - bottom?: number - }; - - state: { - buttons: void | React$Element ); - } else { - return ( - - ); - } + } + return ( + + ); + }, render() { diff --git a/src/basic/Tabs/SceneComponent.js b/src/basic/Tabs/SceneComponent.js index 43ecaf7c4..cd485e039 100644 --- a/src/basic/Tabs/SceneComponent.js +++ b/src/basic/Tabs/SceneComponent.js @@ -17,4 +17,4 @@ const SceneComponent = Props => { }; module.exports = SceneComponent; -//export default SceneComponent; +// export default SceneComponent; diff --git a/src/basic/Tabs/ScrollableTabBar.js b/src/basic/Tabs/ScrollableTabBar.js index 8899aff0e..5cbe40a51 100644 --- a/src/basic/Tabs/ScrollableTabBar.js +++ b/src/basic/Tabs/ScrollableTabBar.js @@ -193,19 +193,19 @@ const ScrollableTabBar = createReactClass({ ); - } else { - return ( - - ); - } + } + return ( + + ); + }, measureTab(page, event) { @@ -244,10 +244,10 @@ const ScrollableTabBar = createReactClass({ ref={scrollView => { this._scrollView = scrollView; }} - horizontal={true} + horizontal showsHorizontalScrollIndicator={false} showsVerticalScrollIndicator={false} - directionalLockEnabled={true} + directionalLockEnabled onScroll={this.props.onScroll} bounces={false} scrollsToTop={false} diff --git a/src/basic/Tabs/StaticContainer.js b/src/basic/Tabs/StaticContainer.js index ab0860b1f..3c4ff9d5c 100644 --- a/src/basic/Tabs/StaticContainer.js +++ b/src/basic/Tabs/StaticContainer.js @@ -1,4 +1,4 @@ -var React = require('react'); +const React = require('react'); class StaticContainer extends React.Component { shouldComponentUpdate(nextProps: Object): boolean { @@ -6,7 +6,7 @@ class StaticContainer extends React.Component { } render(): ?ReactElement { - var child = this.props.children; + const child = this.props.children; if (child === null || child === false) { return null; } @@ -15,4 +15,4 @@ class StaticContainer extends React.Component { } module.exports = StaticContainer; -//export default StaticContainer; +// export default StaticContainer; diff --git a/src/basic/Tabs/index.js b/src/basic/Tabs/index.js index de7538e01..90964591b 100644 --- a/src/basic/Tabs/index.js +++ b/src/basic/Tabs/index.js @@ -112,9 +112,9 @@ const ScrollableTabView = createReactClass({ return null; } else if (this.props.renderTabBar) { return React.cloneElement(this.props.renderTabBar(props), props); - } else { - return ; - } + } + return ; + }, updateSceneKeys({ @@ -122,7 +122,7 @@ const ScrollableTabView = createReactClass({ children = this.props.children, callback = () => {} }) { - let newKeys = this.newSceneKeys({ + const newKeys = this.newSceneKeys({ previousKeys: this.state.sceneKeys, currentPage: page, children @@ -135,9 +135,9 @@ const ScrollableTabView = createReactClass({ currentPage = 0, children = this.props.children }) { - let newKeys = []; + const newKeys = []; this._children(children).forEach((child, idx) => { - let key = this._makeSceneKey(child, idx); + const key = this._makeSceneKey(child, idx); if ( this._keyExists(previousKeys, key) || this._shouldRenderSceneKey(idx, currentPage) @@ -149,7 +149,7 @@ const ScrollableTabView = createReactClass({ }, _shouldRenderSceneKey(idx, currentPageKey) { - let numOfSibling = this.props.prerenderingSiblingsNumber; + const numOfSibling = this.props.prerenderingSiblingsNumber; return ( idx < currentPageKey + numOfSibling + 1 && idx > currentPageKey - numOfSibling - 1 @@ -161,7 +161,7 @@ const ScrollableTabView = createReactClass({ }, _makeSceneKey(child, idx) { - return child.props.heading + '_' + idx; + return `${child.props.heading }_${ idx}`; }, renderScrollableContent() { @@ -200,7 +200,7 @@ const ScrollableTabView = createReactClass({ _composeScenes() { return this._children().map((child, idx) => { - let key = this._makeSceneKey(child, idx); + const key = this._makeSceneKey(child, idx); return ( child.props.heading), tabStyle: this._children().map(child => child.props.tabStyle), diff --git a/src/basic/Text.js b/src/basic/Text.js index 474ab2791..329ace79f 100644 --- a/src/basic/Text.js +++ b/src/basic/Text.js @@ -2,8 +2,8 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { Text as RNText } from 'react-native'; import _ from 'lodash'; - import { connectStyle } from 'native-base-shoutem-theme'; + import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; class Text extends Component { @@ -15,9 +15,8 @@ class Text extends Component { text = React.Children.map(children, child => { if (_.isString(child)) { return _.toUpper(child); - } else { - return child; } + return child; }); } else { text = children; diff --git a/src/basic/Textarea.js b/src/basic/Textarea.js index b901d4da2..ef297d4cd 100644 --- a/src/basic/Textarea.js +++ b/src/basic/Textarea.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { TextInput } from 'react-native'; import { connectStyle } from 'native-base-shoutem-theme'; + import variables from '../theme/variables/platform'; import computeProps from '../utils/computeProps'; import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; @@ -36,7 +37,7 @@ class Textarea extends Component { : variables.inputColorPlaceholder } underlineColorAndroid="rgba(0,0,0,0)" - editable={this.props.disabled ? false : true} + editable={!this.props.disabled} /> ); } diff --git a/src/basic/Thumbnail.js b/src/basic/Thumbnail.js index 6a3626807..89cc71833 100644 --- a/src/basic/Thumbnail.js +++ b/src/basic/Thumbnail.js @@ -2,7 +2,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { Image } from 'react-native'; import { connectStyle } from 'native-base-shoutem-theme'; -import computeProps from '../utils/computeProps'; + import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; class Thumbnail extends Component { diff --git a/src/basic/Title.js b/src/basic/Title.js index 76b6b5143..76e96035a 100644 --- a/src/basic/Title.js +++ b/src/basic/Title.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { Text } from 'react-native'; import { connectStyle } from 'native-base-shoutem-theme'; + import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; class Title extends Component { diff --git a/src/basic/Toast.js b/src/basic/Toast.js index 3023729da..834dbe777 100644 --- a/src/basic/Toast.js +++ b/src/basic/Toast.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { View, ViewPropTypes } from 'react-native'; import { connectStyle } from 'native-base-shoutem-theme'; + import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; class Toast extends Component { diff --git a/src/basic/ToastContainer.js b/src/basic/ToastContainer.js index b3f1d2efb..5fffc697c 100644 --- a/src/basic/ToastContainer.js +++ b/src/basic/ToastContainer.js @@ -1,21 +1,18 @@ +/* eslint-disable class-methods-use-this */ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { View, Modal, Platform, Animated, ViewPropTypes } from 'react-native'; +import { Platform, Animated, ViewPropTypes } from 'react-native'; import { connectStyle } from 'native-base-shoutem-theme'; + +import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; + import { Text } from './Text'; import { Button } from './Button'; -import { ViewNB } from './View'; import { Toast } from './Toast'; -import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; + class ToastContainer extends Component { - constructor(props) { - super(props); - this.state = { - modalVisible: false, - fadeAnim: new Animated.Value(0) - }; - } + static toastInstance; static show({ ...config }) { this.toastInstance._root.showToast({ config }); @@ -25,6 +22,13 @@ class ToastContainer extends Component { this.toastInstance._root.closeToast('functionCall'); } } + constructor(props) { + super(props); + this.state = { + modalVisible: false, + fadeAnim: new Animated.Value(0) + }; + } getToastStyle() { return { position: 'absolute', @@ -39,15 +43,15 @@ class ToastContainer extends Component { getTop() { if (Platform.OS === 'ios') { return 30; - } else { - return 0; - } + } + return 0; + } getButtonText(buttonText) { if (buttonText) { if (buttonText.trim().length === 0) { return undefined; - } else return buttonText; + } return buttonText; } return undefined; } @@ -108,9 +112,9 @@ class ToastContainer extends Component { {this.state.text} {this.state.buttonText && ( @@ -126,7 +130,7 @@ class ToastContainer extends Component { ); - } else return null; + } return null; } } diff --git a/src/basic/View.js b/src/basic/View.js index 4578d7107..845187366 100644 --- a/src/basic/View.js +++ b/src/basic/View.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { View, ViewPropTypes } from 'react-native'; import { connectStyle } from 'native-base-shoutem-theme'; + import mapPropsToStyleNames from '../utils/mapPropsToStyleNames'; class ViewNB extends Component { diff --git a/src/index.js b/src/index.js index eb38a9d66..da900745b 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ import { StyleProvider, connectStyle } from 'native-base-shoutem-theme'; import { keys } from 'lodash'; import { Col, Row, Grid } from 'react-native-easy-grid'; -// import { Gravatar } from "./basic/Gravatar"; + import setDefaultThemeStyle from './init'; import getTheme from './theme/components'; import variables from './theme/variables/platform'; @@ -57,7 +57,6 @@ import { DefaultTabBar } from './basic/Tabs/DefaultTabBar'; import { ScrollableTab } from './basic/Tabs/ScrollableTabBar'; import { Subtitle } from './basic/Subtitle'; import { Accordion } from './basic/Accordion'; - import VueNativeBase from './vue-native.js'; setDefaultThemeStyle(); diff --git a/src/init.js b/src/init.js index e870047f9..22ed824d2 100644 --- a/src/init.js +++ b/src/init.js @@ -1,4 +1,5 @@ import { Theme } from 'native-base-shoutem-theme'; + import getThemeStyle from './theme/components'; export default function setDefaultThemeStyle() { diff --git a/src/theme/components/Badge.js b/src/theme/components/Badge.js index a76e30323..fb0efa450 100644 --- a/src/theme/components/Badge.js +++ b/src/theme/components/Badge.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const badgeTheme = { '.primary': { backgroundColor: variables.buttonPrimaryBg diff --git a/src/theme/components/Body.js b/src/theme/components/Body.js index c73a2cb52..6de0c888d 100644 --- a/src/theme/components/Body.js +++ b/src/theme/components/Body.js @@ -1,8 +1,6 @@ // @flow -import variable from './../variables/platform'; - -export default (variables /*: * */ = variable) => { +export default () => { const bodyTheme = { flex: 1, alignItems: 'center', diff --git a/src/theme/components/Button.js b/src/theme/components/Button.js index ce5cdbd72..53ee221da 100644 --- a/src/theme/components/Button.js +++ b/src/theme/components/Button.js @@ -3,7 +3,7 @@ import variable from './../variables/platform'; import { PLATFORM } from './../variables/commonColor'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const platformStyle = variables.platformStyle; const platform = variables.platform; const darkCommon = { diff --git a/src/theme/components/Card.js b/src/theme/components/Card.js index 42d9601ab..de4f9f42a 100644 --- a/src/theme/components/Card.js +++ b/src/theme/components/Card.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const cardTheme = { '.transparent': { shadowColor: null, diff --git a/src/theme/components/CardItem.js b/src/theme/components/CardItem.js index 5de92622a..504c03f07 100644 --- a/src/theme/components/CardItem.js +++ b/src/theme/components/CardItem.js @@ -1,9 +1,10 @@ // @flow import { StyleSheet } from 'react-native'; + import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const platform = variables.platform; const transparentBtnCommon = { 'NativeBase.Text': { diff --git a/src/theme/components/CheckBox.js b/src/theme/components/CheckBox.js index a4f74f844..7a858c3c3 100644 --- a/src/theme/components/CheckBox.js +++ b/src/theme/components/CheckBox.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const checkBoxTheme = { '.checked': { 'NativeBase.Icon': { diff --git a/src/theme/components/Container.js b/src/theme/components/Container.js index fd5aefeca..a6fb29eae 100644 --- a/src/theme/components/Container.js +++ b/src/theme/components/Container.js @@ -5,7 +5,7 @@ import { Platform, Dimensions } from 'react-native'; import variable from './../variables/platform'; const deviceHeight = Dimensions.get('window').height; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const theme = { flex: 1, height: Platform.OS === 'ios' ? deviceHeight : deviceHeight - 20, diff --git a/src/theme/components/Content.js b/src/theme/components/Content.js index a96a87d7c..97bd81c6e 100644 --- a/src/theme/components/Content.js +++ b/src/theme/components/Content.js @@ -1,8 +1,6 @@ // @flow -import variable from './../variables/platform'; - -export default (variables /*: * */ = variable) => { +export default () => { const contentTheme = { flex: 1, backgroundColor: 'transparent', diff --git a/src/theme/components/Fab.js b/src/theme/components/Fab.js index 0529d2f6c..4d2b9cbd6 100644 --- a/src/theme/components/Fab.js +++ b/src/theme/components/Fab.js @@ -1,10 +1,6 @@ // @flow -import variable from './../variables/platform'; - -export default (variables /*: * */ = variable) => { - const platform = variables.platform; - +export default () => { const fabTheme = { 'NativeBase.Button': { alignItems: 'center', diff --git a/src/theme/components/Footer.js b/src/theme/components/Footer.js index 370eb8135..167acc660 100644 --- a/src/theme/components/Footer.js +++ b/src/theme/components/Footer.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const platformStyle = variables.platformStyle; const platform = variables.platform; diff --git a/src/theme/components/FooterTab.js b/src/theme/components/FooterTab.js index 82afa0e51..8297e236f 100644 --- a/src/theme/components/FooterTab.js +++ b/src/theme/components/FooterTab.js @@ -4,7 +4,7 @@ import { Platform } from 'react-native'; import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const platform = variables.platform; const footerTabTheme = { diff --git a/src/theme/components/Form.js b/src/theme/components/Form.js index ad36c576c..3040f3003 100644 --- a/src/theme/components/Form.js +++ b/src/theme/components/Form.js @@ -1,10 +1,6 @@ // @flow -import variable from './../variables/platform'; - -export default (variables /*: * */ = variable) => { - const platform = variables.platform; - +export default () => { const theme = { 'NativeBase.Item': { '.fixedLabel': { diff --git a/src/theme/components/H1.js b/src/theme/components/H1.js index a9b3d4336..20aa8db44 100644 --- a/src/theme/components/H1.js +++ b/src/theme/components/H1.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const h1Theme = { color: variables.textColor, fontSize: variables.fontSizeH1, diff --git a/src/theme/components/H2.js b/src/theme/components/H2.js index 418b7f2da..cad4057da 100644 --- a/src/theme/components/H2.js +++ b/src/theme/components/H2.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const h2Theme = { color: variables.textColor, fontSize: variables.fontSizeH2, diff --git a/src/theme/components/H3.js b/src/theme/components/H3.js index edf0c194a..19917f54d 100644 --- a/src/theme/components/H3.js +++ b/src/theme/components/H3.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const h3Theme = { color: variables.textColor, fontSize: variables.fontSizeH3, diff --git a/src/theme/components/Header.js b/src/theme/components/Header.js index 9106b3816..25cafe7f2 100644 --- a/src/theme/components/Header.js +++ b/src/theme/components/Header.js @@ -4,7 +4,7 @@ import { PixelRatio, StatusBar } from 'react-native'; import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const platformStyle = variables.platformStyle; const platform = variables.platform; diff --git a/src/theme/components/Icon.js b/src/theme/components/Icon.js index 6fcc1994a..949307bdf 100644 --- a/src/theme/components/Icon.js +++ b/src/theme/components/Icon.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const iconTheme = { fontSize: variables.iconFontSize, color: '#000' diff --git a/src/theme/components/Input.js b/src/theme/components/Input.js index f5eeee69d..d0dd6af51 100644 --- a/src/theme/components/Input.js +++ b/src/theme/components/Input.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const inputTheme = { '.multiline': { height: null diff --git a/src/theme/components/InputGroup.js b/src/theme/components/InputGroup.js index 2f9f29d3f..7988ca52f 100644 --- a/src/theme/components/InputGroup.js +++ b/src/theme/components/InputGroup.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const inputGroupTheme = { 'NativeBase.Icon': { fontSize: 24, diff --git a/src/theme/components/Item.js b/src/theme/components/Item.js index 8a4cf0291..73c95ff6e 100644 --- a/src/theme/components/Item.js +++ b/src/theme/components/Item.js @@ -4,7 +4,7 @@ import { Platform } from 'react-native'; import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const itemTheme = { '.floatingLabel': { 'NativeBase.Input': { diff --git a/src/theme/components/Label.js b/src/theme/components/Label.js index 576ba48d5..118f648b0 100644 --- a/src/theme/components/Label.js +++ b/src/theme/components/Label.js @@ -1,8 +1,6 @@ // @flow -import variable from './../variables/platform'; - -export default (variables /*: * */ = variable) => { +export default () => { const labelTheme = { '.focused': { width: 0 diff --git a/src/theme/components/Left.js b/src/theme/components/Left.js index 5a9477155..e01d693c8 100644 --- a/src/theme/components/Left.js +++ b/src/theme/components/Left.js @@ -1,8 +1,6 @@ // @flow -import variable from './../variables/platform'; - -export default (variables /*: * */ = variable) => { +export default () => { const leftTheme = { flex: 1, alignSelf: 'center', diff --git a/src/theme/components/ListItem.js b/src/theme/components/ListItem.js index a615ab7d5..68c2c2936 100644 --- a/src/theme/components/ListItem.js +++ b/src/theme/components/ListItem.js @@ -5,7 +5,7 @@ import { Platform, PixelRatio } from 'react-native'; import pickerTheme from './Picker'; import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const platform = variables.platform; const selectedStyle = { 'NativeBase.Text': { diff --git a/src/theme/components/Picker.android.js b/src/theme/components/Picker.android.js index 92b6329c0..300a74356 100644 --- a/src/theme/components/Picker.android.js +++ b/src/theme/components/Picker.android.js @@ -1,8 +1,6 @@ // @flow -import variable from './../variables/platform'; - -export default (variables /*: * */ = variable) => { +export default () => { const pickerTheme = { '.note': { color: '#8F8E95' diff --git a/src/theme/components/Picker.ios.js b/src/theme/components/Picker.ios.js index 6a63c0d6a..b81b0568e 100644 --- a/src/theme/components/Picker.ios.js +++ b/src/theme/components/Picker.ios.js @@ -1,8 +1,6 @@ // @flow -import variable from './../variables/platform'; - -export default (variables /*: * */ = variable) => { +export default () => { const pickerTheme = {}; return pickerTheme; diff --git a/src/theme/components/Picker.js b/src/theme/components/Picker.js index 92b6329c0..300a74356 100644 --- a/src/theme/components/Picker.js +++ b/src/theme/components/Picker.js @@ -1,8 +1,6 @@ // @flow -import variable from './../variables/platform'; - -export default (variables /*: * */ = variable) => { +export default () => { const pickerTheme = { '.note': { color: '#8F8E95' diff --git a/src/theme/components/Radio.js b/src/theme/components/Radio.js index 808687d00..5f16df893 100644 --- a/src/theme/components/Radio.js +++ b/src/theme/components/Radio.js @@ -4,7 +4,7 @@ import { Platform } from 'react-native'; import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const radioTheme = { '.selected': { 'NativeBase.IconNB': { diff --git a/src/theme/components/Right.js b/src/theme/components/Right.js index f356bc4ec..53b33081b 100644 --- a/src/theme/components/Right.js +++ b/src/theme/components/Right.js @@ -1,8 +1,6 @@ // @flow -import variable from './../variables/platform'; - -export default (variables /*: * */ = variable) => { +export default () => { const rightTheme = { 'NativeBase.Button': { alignSelf: null diff --git a/src/theme/components/Segment.js b/src/theme/components/Segment.js index 39344ae1a..b7a69b3cd 100644 --- a/src/theme/components/Segment.js +++ b/src/theme/components/Segment.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const platform = variables.platform; const segmentTheme = { diff --git a/src/theme/components/Separator.js b/src/theme/components/Separator.js index 7eb1416b4..7fdf313cc 100644 --- a/src/theme/components/Separator.js +++ b/src/theme/components/Separator.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const theme = { '.group': { height: 50, diff --git a/src/theme/components/Spinner.js b/src/theme/components/Spinner.js index 49d47be54..a453b3f7e 100644 --- a/src/theme/components/Spinner.js +++ b/src/theme/components/Spinner.js @@ -1,8 +1,6 @@ // @flow -import variable from './../variables/platform'; - -export default (variables /*: * */ = variable) => { +export default () => { const spinnerTheme = { height: 80 }; diff --git a/src/theme/components/Subtitle.js b/src/theme/components/Subtitle.js index 941e05454..981115ae5 100644 --- a/src/theme/components/Subtitle.js +++ b/src/theme/components/Subtitle.js @@ -4,7 +4,7 @@ import { Platform } from 'react-native'; import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const subtitleTheme = { fontSize: variables.subTitleFontSize, fontFamily: variables.titleFontfamily, diff --git a/src/theme/components/SwipeRow.js b/src/theme/components/SwipeRow.js index 75ac2aac5..41d608353 100644 --- a/src/theme/components/SwipeRow.js +++ b/src/theme/components/SwipeRow.js @@ -1,8 +1,6 @@ // @flow -import variable from './../variables/platform'; - -export default (variables /*: * */ = variable) => { +export default () => { const swipeRowTheme = { 'NativeBase.ListItem': { '.list': { diff --git a/src/theme/components/Switch.js b/src/theme/components/Switch.js index 49b75543e..6b667bc07 100644 --- a/src/theme/components/Switch.js +++ b/src/theme/components/Switch.js @@ -1,8 +1,6 @@ // @flow -import variable from './../variables/platform'; - -export default (variables /*: * */ = variable) => { +export default () => { const switchTheme = { marginVertical: -5 }; diff --git a/src/theme/components/Tab.js b/src/theme/components/Tab.js index 7df110259..b2423064e 100644 --- a/src/theme/components/Tab.js +++ b/src/theme/components/Tab.js @@ -1,8 +1,6 @@ // @flow -import variable from './../variables/platform'; - -export default (variables /*: * */ = variable) => { +export default () => { const tabTheme = { flex: 1, backgroundColor: '#FFF' diff --git a/src/theme/components/TabBar.js b/src/theme/components/TabBar.js index bf8c26737..fa1490d45 100644 --- a/src/theme/components/TabBar.js +++ b/src/theme/components/TabBar.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const tabBarTheme = { '.tabIcon': { height: undefined diff --git a/src/theme/components/TabContainer.js b/src/theme/components/TabContainer.js index 56f1c8ee2..2a4cd4953 100644 --- a/src/theme/components/TabContainer.js +++ b/src/theme/components/TabContainer.js @@ -1,11 +1,11 @@ // @flow -import variable from './../variables/platform'; import { Platform } from 'react-native'; -export default (variables /*: * */ = variable) => { +import variable from './../variables/platform'; + +export default (variables /* : * */ = variable) => { const platformStyle = variables.platformStyle; - const platform = variables.platform; const tabContainerTheme = { elevation: 3, diff --git a/src/theme/components/TabHeading.js b/src/theme/components/TabHeading.js index 95aec1ef2..289deb975 100644 --- a/src/theme/components/TabHeading.js +++ b/src/theme/components/TabHeading.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const platform = variables.platform; const tabHeadingTheme = { diff --git a/src/theme/components/Text.js b/src/theme/components/Text.js index 181fe4cf8..8c3fa243f 100644 --- a/src/theme/components/Text.js +++ b/src/theme/components/Text.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const textTheme = { fontSize: variables.DefaultFontSize, fontFamily: variables.fontFamily, diff --git a/src/theme/components/Textarea.js b/src/theme/components/Textarea.js index b7aaede5d..a46d93bc6 100644 --- a/src/theme/components/Textarea.js +++ b/src/theme/components/Textarea.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const textAreaTheme = { '.underline': { borderBottomWidth: variables.borderWidth, diff --git a/src/theme/components/Thumbnail.js b/src/theme/components/Thumbnail.js index 6226b71fe..c6c9f68a6 100644 --- a/src/theme/components/Thumbnail.js +++ b/src/theme/components/Thumbnail.js @@ -1,8 +1,6 @@ // @flow -import variable from './../variables/platform'; - -export default (variables /*: * */ = variable) => { +export default () => { const thumbnailTheme = { '.square': { borderRadius: 0, diff --git a/src/theme/components/Title.js b/src/theme/components/Title.js index d72cb4438..46f28d612 100644 --- a/src/theme/components/Title.js +++ b/src/theme/components/Title.js @@ -4,7 +4,7 @@ import { Platform } from 'react-native'; import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const titleTheme = { fontSize: variables.titleFontSize, fontFamily: variables.titleFontfamily, diff --git a/src/theme/components/Toast.js b/src/theme/components/Toast.js index 58a90b4a3..4e0a9d83b 100644 --- a/src/theme/components/Toast.js +++ b/src/theme/components/Toast.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const platform = variables.platform; const toastTheme = { diff --git a/src/theme/components/View.js b/src/theme/components/View.js index 305f7ec3c..827581e26 100644 --- a/src/theme/components/View.js +++ b/src/theme/components/View.js @@ -2,7 +2,7 @@ import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const viewTheme = { '.padder': { padding: variables.contentPadding diff --git a/src/theme/components/index.js b/src/theme/components/index.js index 102e74172..8b6be3ee6 100644 --- a/src/theme/components/index.js +++ b/src/theme/components/index.js @@ -1,6 +1,8 @@ +/* eslint-disable no-param-reassign */ // @flow import _ from 'lodash'; + import bodyTheme from './Body'; import leftTheme from './Left'; import rightTheme from './Right'; @@ -45,7 +47,7 @@ import separatorTheme from './Separator'; import pickerTheme from './Picker'; import variable from './../variables/platform'; -export default (variables /*: * */ = variable) => { +export default (variables /* : * */ = variable) => { const theme = { variables, 'NativeBase.Left': { diff --git a/src/theme/variables/commonColor.js b/src/theme/variables/commonColor.js index d3327e191..dac12b9ea 100644 --- a/src/theme/variables/commonColor.js +++ b/src/theme/variables/commonColor.js @@ -1,7 +1,6 @@ // @flow import color from 'color'; - import { Platform, Dimensions, PixelRatio } from 'react-native'; export const PLATFORM = { @@ -24,14 +23,14 @@ export default { platformStyle, platform, - //Accordion + // Accordion headerStyle: '#edebed', iconStyle: '#000', contentStyle: '#f5f4f5', expandedIconStyle: '#000', accordionBorderColor: '#d3d3d3', - //Android + // Android androidRipple: true, androidRippleColor: 'rgba(256, 256, 256, 0.3)', androidRippleColorDark: 'rgba(0, 0, 0, 0.15)', @@ -124,10 +123,10 @@ export default { brandDark: '#000', brandLight: '#f4f4f4', - //Container + // Container containerBgColor: '#fff', - //Date Picker + // Date Picker datePickerTextColor: '#000', datePickerBg: 'transparent', @@ -276,7 +275,7 @@ export default { isIphoneX, inputGroupRoundedBorderRadius: 30, - //iPhoneX SafeArea + // iPhoneX SafeArea Inset: { portrait: { topInset: 24, diff --git a/src/theme/variables/material.js b/src/theme/variables/material.js index d8f51a472..84503f71c 100644 --- a/src/theme/variables/material.js +++ b/src/theme/variables/material.js @@ -1,7 +1,6 @@ // @flow import color from 'color'; - import { Platform, Dimensions, PixelRatio } from 'react-native'; import { PLATFORM } from './commonColor'; @@ -21,7 +20,7 @@ export default { platformStyle, platform, - //Accordion + // Accordion headerStyle: '#edebed', iconStyle: '#000', contentStyle: '#f5f4f5', @@ -119,10 +118,10 @@ export default { brandDark: '#000', brandLight: '#f4f4f4', - //Container + // Container containerBgColor: '#fff', - //Date Picker + // Date Picker datePickerTextColor: '#000', datePickerBg: 'transparent', @@ -271,7 +270,7 @@ export default { isIphoneX, inputGroupRoundedBorderRadius: 30, - //iPhoneX SafeArea + // iPhoneX SafeArea Inset: { portrait: { topInset: 24, diff --git a/src/theme/variables/platform.js b/src/theme/variables/platform.js index a932f51b0..6079b8c37 100644 --- a/src/theme/variables/platform.js +++ b/src/theme/variables/platform.js @@ -1,7 +1,6 @@ // @flow import color from 'color'; - import { Platform, Dimensions, PixelRatio } from 'react-native'; import { PLATFORM } from './commonColor'; @@ -21,7 +20,7 @@ export default { platformStyle, platform, - //Accordion + // Accordion headerStyle: '#edebed', iconStyle: '#000', contentStyle: '#f5f4f5', @@ -125,10 +124,10 @@ export default { brandDark: '#000', brandLight: '#f4f4f4', - //Container + // Container containerBgColor: '#fff', - //Date Picker + // Date Picker datePickerTextColor: '#000', datePickerBg: 'transparent', @@ -277,7 +276,7 @@ export default { isIphoneX, inputGroupRoundedBorderRadius: 30, - //iPhoneX SafeArea + // iPhoneX SafeArea Inset: { portrait: { topInset: 24, diff --git a/src/utils/computeProps.js b/src/utils/computeProps.js index 8e80c5e0c..21fc81103 100644 --- a/src/utils/computeProps.js +++ b/src/utils/computeProps.js @@ -6,13 +6,12 @@ module.exports = function(incomingProps, defaultProps) { // External props has a higher precedence let computedProps = {}; - incomingProps = _.clone(incomingProps); - delete incomingProps.children; + const clonedIncomingProps = _.clone(incomingProps); + delete clonedIncomingProps.children; const incomingPropsStyle = incomingProps.style; - delete incomingProps.style; + delete clonedIncomingProps.style; - // console.log(defaultProps, incomingProps); if (incomingProps) { _.assign(computedProps, defaultProps, incomingProps); } else { @@ -38,6 +37,5 @@ module.exports = function(incomingProps, defaultProps) { _.merge(computedProps.style, defaultProps.style, computedPropsStyle); } - // console.log("computedProps ", computedProps); return computedProps; }; diff --git a/src/utils/index.js b/src/utils/index.js index 1588a8e12..0647248b1 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,4 +1,5 @@ import { ViewPropTypes } from 'react-native'; + import InteractionManager from './interactionManager'; export { InteractionManager, ViewPropTypes }; diff --git a/src/utils/interactionManager.js b/src/utils/interactionManager.js index 91eb0d176..857c1d166 100644 --- a/src/utils/interactionManager.js +++ b/src/utils/interactionManager.js @@ -1,9 +1,8 @@ import { InteractionManager } from 'react-native'; + export default { ...InteractionManager, runAfterInteractions: f => { - // ensure f get called, timeout at 10ms - // @gre workaround https://github.com/facebook/react-native/issues/8624 let called = false; const timeout = setTimeout(() => { called = true; diff --git a/src/vue-native.js b/src/vue-native.js index e7fdd1a45..b144655f0 100644 --- a/src/vue-native.js +++ b/src/vue-native.js @@ -1,6 +1,6 @@ import { StyleProvider } from 'native-base-shoutem-theme'; -// import { Gravatar } from "./basic/Gravatar"; import { Col, Row, Grid } from 'react-native-easy-grid'; + import Drawer from './basic/Drawer'; import { SwipeRow } from './basic/SwipeRow'; import { Text } from './basic/Text'; @@ -57,7 +57,7 @@ import { Accordion } from './basic/Accordion'; const VueNativeBasePlugin = { // The install method is all that needs to exist on the plugin object. // It takes the global Vue object as well as user-defined options. - install(Vue, options) { + install(Vue) { Vue.component('nb-drawer', Drawer); Vue.component('nb-row', Row); Vue.component('nb-col', Col);