Skip to content

Commit

Permalink
add eslint and format files
Browse files Browse the repository at this point in the history
  • Loading branch information
httnn committed Jun 4, 2018
1 parent c008505 commit 9f80513
Show file tree
Hide file tree
Showing 7 changed files with 13,402 additions and 86 deletions.
21 changes: 21 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"parserOptions": {
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"react-native/react-native": true
},
"extends": "eslint:recommended",
"rules": {
"semi": 2,
"quotes": [2, "single", { "avoidEscape": true }],
"react/jsx-uses-vars": 2,
"react/react-in-jsx-scope": 2,
"react/jsx-uses-react": 2
},
"parser": "babel-eslint",
"plugins": ["react", "react-native"]
}
76 changes: 37 additions & 39 deletions example/App.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,55 @@
import React from 'react';
import {Text, TouchableOpacity, View} from 'react-native';
import { Text, TouchableOpacity, View } from 'react-native';
import Modal from 'react-native-simple-modal';

export default class App extends React.Component {
state = {open: false};
state = { open: false };

modalDidOpen = () => console.log('Modal did open.')
modalDidOpen = () => console.log('Modal did open.');

modalDidClose = () => {
this.setState({open: false});
this.setState({ open: false });
console.log('Modal did close.');
}
};

moveUp = () => this.setState({offset: -100})
moveUp = () => this.setState({ offset: -100 });

resetPosition = () => this.setState({offset: 0})
resetPosition = () => this.setState({ offset: 0 });

openModal = () => this.setState({open: true})
openModal = () => this.setState({ open: true });

closeModal = () => this.setState({open: false})
closeModal = () => this.setState({ open: false });

render() {
return (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<TouchableOpacity onPress={this.openModal}>
<Text>Open modal</Text>
</TouchableOpacity>
<Modal
offset={this.state.offset}
open={this.state.open}
modalDidOpen={this.modalDidOpen}
modalDidClose={this.modalDidClose}
style={{alignItems: 'center'}}>
<View style={{alignItems: 'center'}}>
<Text style={{fontSize: 20, marginBottom: 10}}>Hello world!</Text>
<TouchableOpacity
style={{margin: 5}}
onPress={this.moveUp}>
<Text>Move modal up</Text>
</TouchableOpacity>
<TouchableOpacity
style={{margin: 5}}
onPress={this.resetPosition}>
<Text>Reset modal position</Text>
</TouchableOpacity>
<TouchableOpacity
style={{margin: 5}}
onPress={this.closeModal}>
<Text>Close modal</Text>
</TouchableOpacity>
</View>
</Modal>
</View>
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<TouchableOpacity onPress={this.openModal}>
<Text>Open modal</Text>
</TouchableOpacity>
<Modal
offset={this.state.offset}
open={this.state.open}
modalDidOpen={this.modalDidOpen}
modalDidClose={this.modalDidClose}
style={{ alignItems: 'center' }}
>
<View style={{ alignItems: 'center' }}>
<Text style={{ fontSize: 20, marginBottom: 10 }}>Hello world!</Text>
<TouchableOpacity style={{ margin: 5 }} onPress={this.moveUp}>
<Text>Move modal up</Text>
</TouchableOpacity>
<TouchableOpacity
style={{ margin: 5 }}
onPress={this.resetPosition}
>
<Text>Reset modal position</Text>
</TouchableOpacity>
<TouchableOpacity style={{ margin: 5 }} onPress={this.closeModal}>
<Text>Close modal</Text>
</TouchableOpacity>
</View>
</Modal>
</View>
);
}
}
Loading

0 comments on commit 9f80513

Please sign in to comment.