Commit aa43ddc0 authored by Qiu Xiang's avatar Qiu Xiang

优化示例在 iOS 下的样式

parent dca66e6d
import {Platform} from 'react-native'
import {StackNavigator} from 'react-navigation' import {StackNavigator} from 'react-navigation'
import Examples from './examples' import Examples from './examples'
import MapTypes from './examples/map-types' import MapTypes from './examples/map-types'
...@@ -25,7 +26,14 @@ export default StackNavigator({ ...@@ -25,7 +26,14 @@ export default StackNavigator({
navigationOptions: { navigationOptions: {
headerTintColor: '#212121', headerTintColor: '#212121',
headerStyle: { headerStyle: {
backgroundColor: '#f5f5f5', ...Platform.select({
ios: {
backgroundColor: '#fff',
},
android: {
backgroundColor: '#f5f5f5',
},
})
}, },
}, },
}) })
...@@ -58,7 +58,11 @@ export default class Examples extends Component { ...@@ -58,7 +58,11 @@ export default class Examples extends Component {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
scrollView: { scrollView: {
flex: 1, flex: 1,
backgroundColor: '#f5f5f5', ...Platform.select({
android: {
backgroundColor: '#f5f5f5',
},
})
}, },
group: { group: {
marginTop: 15, marginTop: 15,
...@@ -69,7 +73,6 @@ const styles = StyleSheet.create({ ...@@ -69,7 +73,6 @@ const styles = StyleSheet.create({
}, },
separator: { separator: {
height: StyleSheet.hairlineWidth, height: StyleSheet.hairlineWidth,
backgroundColor: '#e0e0e0',
}, },
itemText: { itemText: {
fontSize: 16, fontSize: 16,
......
import React, {Component} from 'react' import React, {Component} from 'react'
import {StyleSheet, View, Text, Switch} from 'react-native' import {StyleSheet, View, Text, Switch, Platform} from 'react-native'
import MapView from 'react-native-amap3d' import MapView from 'react-native-amap3d'
import styles from '../styles'
export default class Controls extends Component { export default class Controls extends Component {
static navigationOptions = { static navigationOptions = {
...@@ -9,7 +10,7 @@ export default class Controls extends Component { ...@@ -9,7 +10,7 @@ export default class Controls extends Component {
state = { state = {
showsCompass: false, showsCompass: false,
showsScale: false, showsScale: true,
showsZoomControls: true, showsZoomControls: true,
showsLocationButton: false, showsLocationButton: false,
} }
...@@ -56,25 +57,3 @@ export default class Controls extends Component { ...@@ -56,25 +57,3 @@ export default class Controls extends Component {
</View> </View>
} }
} }
const styles = StyleSheet.create({
map: {
flex: 1,
},
controls: {
height: 72,
backgroundColor: '#f5f5f5',
flexDirection: 'row',
justifyContent: 'space-between',
elevation: 4,
paddingLeft: 20,
paddingRight: 20,
},
control: {
alignItems: 'center',
justifyContent: 'center',
},
switch: {
marginTop: 5,
},
})
import React, {Component} from 'react' import React, {Component} from 'react'
import {StyleSheet, View, Text, Switch} from 'react-native' import {StyleSheet, View, Text, Switch} from 'react-native'
import MapView from 'react-native-amap3d' import MapView from 'react-native-amap3d'
import styles from '../styles'
export default class Gestures extends Component { export default class Gestures extends Component {
static navigationOptions = { static navigationOptions = {
...@@ -55,26 +56,3 @@ export default class Gestures extends Component { ...@@ -55,26 +56,3 @@ export default class Gestures extends Component {
</View> </View>
} }
} }
const styles = StyleSheet.create({
map: {
flex: 1,
},
controls: {
height: 72,
backgroundColor: '#f5f5f5',
flexDirection: 'row',
justifyContent: 'space-between',
elevation: 4,
paddingLeft: 20,
paddingRight: 20,
},
control: {
alignItems: 'center',
justifyContent: 'center',
},
switch: {
marginTop: 5,
},
})
...@@ -10,11 +10,12 @@ export default class Indoor extends Component { ...@@ -10,11 +10,12 @@ export default class Indoor extends Component {
render() { render() {
return <MapView return <MapView
coordinate={{ coordinate={{
latitude: 39.91095, latitude: 39.90980,
longitude: 116.37296, longitude: 116.37296,
}} }}
zoomLevel={18} zoomLevel={18}
showsIndoorMap={true} showsIndoorMap={true}
tilt={45}
style={StyleSheet.absoluteFill}/> style={StyleSheet.absoluteFill}/>
} }
} }
import React, {Component} from 'react' import React, {Component} from 'react'
import {StyleSheet, View, Text, Switch} from 'react-native' import {StyleSheet, View, Text, Switch, Platform} from 'react-native'
import MapView from 'react-native-amap3d' import MapView from 'react-native-amap3d'
import commonStyles from '../styles'
export default class Layers extends Component { export default class Layers extends Component {
static navigationOptions = { static navigationOptions = {
...@@ -17,19 +18,19 @@ export default class Layers extends Component { ...@@ -17,19 +18,19 @@ export default class Layers extends Component {
return <View style={StyleSheet.absoluteFill}> return <View style={StyleSheet.absoluteFill}>
<View style={styles.controls}> <View style={styles.controls}>
<View style={styles.control}> <View style={styles.control}>
<Text>建筑</Text> <Text style={styles.label}>建筑</Text>
<Switch <Switch
onValueChange={showsBuildings => this.setState({showsBuildings})} onValueChange={showsBuildings => this.setState({showsBuildings})}
value={this.state.showsBuildings}/> value={this.state.showsBuildings}/>
</View> </View>
<View style={styles.control}> <View style={styles.control}>
<Text>路况</Text> <Text style={styles.label}>路况</Text>
<Switch <Switch
onValueChange={showsTraffic => this.setState({showsTraffic})} onValueChange={showsTraffic => this.setState({showsTraffic})}
value={this.state.showsTraffic}/> value={this.state.showsTraffic}/>
</View> </View>
<View style={styles.control}> <View style={styles.control}>
<Text>标签</Text> <Text style={styles.label}>标签</Text>
<Switch <Switch
onValueChange={showsLabels => this.setState({showsLabels})} onValueChange={showsLabels => this.setState({showsLabels})}
value={this.state.showsLabels}/> value={this.state.showsLabels}/>
...@@ -46,21 +47,22 @@ export default class Layers extends Component { ...@@ -46,21 +47,22 @@ export default class Layers extends Component {
} }
} }
const styles = StyleSheet.create({ const styles = {
map: { ...commonStyles,
flex: 1, map: [commonStyles.map, {
}, ...Platform.select({
controls: { ios: {
marginBottom: 54,
},
}),
}],
controls: [commonStyles.controls, {
height: 54, height: 54,
backgroundColor: '#f5f5f5', }],
flexDirection: 'row', control: [commonStyles.control, {
justifyContent: 'space-between',
elevation: 4,
paddingLeft: 20,
paddingRight: 20,
},
control: {
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', }],
label: {
marginRight: 5,
}, },
}) }
import {StyleSheet, Platform} from 'react-native'
export default StyleSheet.create({
map: {
flex: 1,
...Platform.select({
ios: {
marginBottom: 72,
},
}),
},
controls: {
height: 72,
flexDirection: 'row',
justifyContent: 'space-between',
elevation: 4,
paddingLeft: 20,
paddingRight: 20,
...Platform.select({
android: {
backgroundColor: '#f5f5f5',
},
ios: {
backgroundColor: '#fff',
position: 'absolute',
left: 0,
right: 0,
bottom: 0,
borderTopColor: '#e0e0e0',
borderTopWidth: StyleSheet.hairlineWidth,
zIndex: 1,
},
}),
},
control: {
alignItems: 'center',
justifyContent: 'center',
},
switch: {
marginTop: 5,
},
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment