Skip to content

Commit

Permalink
Remove default marginTop on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
anhtuank7c committed Sep 16, 2018
1 parent 777b293 commit 74934b3
Show file tree
Hide file tree
Showing 5 changed files with 400 additions and 45 deletions.
13 changes: 12 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
{
"extends": "rallycoding"
"parser": "babel-eslint",
"plugins": ["react", "react-native"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"modules": true
}
},
"extends": ["eslint:recommended", "plugin:react/recommended", "airbnb-base"],
"rules": {
"arrow-body-style": "warn"
}
}
37 changes: 25 additions & 12 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,39 @@
* @flow
*/

import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View, Image, PixelRatio, Switch } from 'react-native';
import NetworkState, { Settings } from 'react-native-network-state';
import React, { Component } from 'react'
import {
Platform,
StyleSheet,
Text,
View,
Image,
PixelRatio,
Switch
} from 'react-native'
import NetworkState, { Settings } from 'react-native-network-state'

const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
android: 'Double tap R on your keyboard to reload,\n' + 'Shake or press menu button for dev menu'
});
android:
'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu'
})

type Props = {};
type Props = {}
export default class App extends Component<Props> {
state = {
layoutOne: true,
connected: Settings.isConnected
};
}

renderNoInternet() {
return (
<View>
<Image source={require('./unicorn.png')} style={styles.unicorn} />
<Text style={styles.welcome}>No internet available</Text>
</View>
);
)
}

renderNormal() {
Expand All @@ -38,7 +48,7 @@ export default class App extends Component<Props> {
<Text style={styles.instructions}>To get started, edit App.js</Text>
<Text style={styles.instructions}>{instructions}</Text>
</View>
);
)
}

render() {
Expand All @@ -48,17 +58,20 @@ export default class App extends Component<Props> {
<Text>Change style: </Text>
<Switch
value={this.state.layoutOne}
onValueChange={() => this.setState(prev => ({ layoutOne: !prev.layoutOne }))}
onValueChange={() =>
this.setState(prev => ({ layoutOne: !prev.layoutOne }))
}
/>
</View>
{this.state.connected ? this.renderNormal() : this.renderNoInternet()}
<NetworkState
style={{ ...Platform.select({ ios: { marginTop: 20 } }) }}
visible={!this.state.layoutOne}
onDisconnected={() => this.setState({ connected: false })}
onConnected={() => this.setState({ connected: true })}
/>
</View>
);
)
}
}

Expand Down Expand Up @@ -88,4 +101,4 @@ const styles = StyleSheet.create({
justifyContent: 'center',
alignItems: 'center'
}
});
})
7 changes: 1 addition & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,7 @@ const styles = StyleSheet.create({
position: "absolute",
top: 0,
left: 0,
right: 0,
...Platform.select({
ios: {
marginTop: 20
}
})
right: 0
},
txtSuccess: {
paddingVertical: 5,
Expand Down
Loading

0 comments on commit 74934b3

Please sign in to comment.