|
|
'use strict';
|
|
|
|
|
|
import React, {View, Text, StyleSheet} from "react-native";
|
|
|
import React from "react-native";
|
|
|
import Button from "apsl-react-native-button";
|
|
|
import {Actions} from "react-native-router-flux";
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
container: {
|
|
|
flex: 1,
|
|
|
justifyContent: "center",
|
|
|
alignItems: "center",
|
|
|
backgroundColor: "#F0F0F0",
|
|
|
},
|
|
|
statusBar: {
|
|
|
backgroundColor: '#3E3E3E',
|
|
|
paddingTop: 0,
|
|
|
top: 0,
|
|
|
height: 20,
|
|
|
right: 0,
|
|
|
left: 0,
|
|
|
position: 'absolute',
|
|
|
let {
|
|
|
Component,
|
|
|
View,
|
|
|
Text,
|
|
|
ListView,
|
|
|
StyleSheet,
|
|
|
TouchableHighlight,
|
|
|
Dimensions
|
|
|
} = React;
|
|
|
|
|
|
export default class SideMenu extends React.Component {
|
|
|
|
|
|
static propTypes = {
|
|
|
items: React.PropTypes.arrayOf(
|
|
|
React.PropTypes.shape({
|
|
|
id: React.PropTypes.number,
|
|
|
name: React.PropTypes.string,
|
|
|
})
|
|
|
),
|
|
|
onPressItem: React.PropTypes.func,
|
|
|
};
|
|
|
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
|
|
|
this._renderHeader = this._renderHeader.bind(this);
|
|
|
this._renderSeparator = this._renderSeparator.bind(this);
|
|
|
this._renderRow = this._renderRow.bind(this);
|
|
|
this._pressRow = this._pressRow.bind(this);
|
|
|
|
|
|
this.ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
_pressRow(rowID) {
|
|
|
this.props.onPressItem && this.props.onPressItem(rowID);
|
|
|
}
|
|
|
|
|
|
_renderHeader(sectionData, sectionID) {
|
|
|
return (
|
|
|
<Text style={styles.header}>
|
|
|
店铺切换
|
|
|
</Text>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
_renderSeparator(sectionID, rowID, adjacentRowHighlighted) {
|
|
|
return (
|
|
|
<View style={styles.separator} key={rowID}/>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
_renderRow(rowData, sectionID, rowID) {
|
|
|
return (
|
|
|
<TouchableHighlight onPress={() => this._pressRow(rowID)} underlayColor={'white'} key={rowID}>
|
|
|
<View style={styles.row} >
|
|
|
<Text style={styles.text}>
|
|
|
{rowData.name}
|
|
|
</Text>
|
|
|
</View>
|
|
|
</TouchableHighlight>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
export default class SideMenu extends React.Component {
|
|
|
render(){
|
|
|
var {View, Text} = React;
|
|
|
|
|
|
return (
|
|
|
<View style={[styles.container, this.props.sceneStyle]}>
|
|
|
<View style={[styles.container]}>
|
|
|
<View style={styles.statusBar} />
|
|
|
<Text>Tab {this.props.title}</Text>
|
|
|
|
|
|
<View style={styles.listContainer}>
|
|
|
<ListView
|
|
|
contentContainerStyle={styles.contentContainer}
|
|
|
dataSource={this.ds.cloneWithRows(this.props.items)}
|
|
|
renderHeader={this._renderHeader}
|
|
|
renderSeparator={this._renderSeparator}
|
|
|
renderRow={this._renderRow}
|
|
|
enableEmptySections={true}
|
|
|
/>
|
|
|
</View>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
...
|
...
|
@@ -39,3 +90,51 @@ export default class SideMenu extends React.Component { |
|
|
SideMenu.contextTypes = {
|
|
|
drawer: React.PropTypes.object
|
|
|
};
|
|
|
|
|
|
let {width, height} = Dimensions.get('window');
|
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
container: {
|
|
|
flex: 1,
|
|
|
backgroundColor: "#F0F0F0",
|
|
|
},
|
|
|
statusBar: {
|
|
|
backgroundColor: '#3E3E3E',
|
|
|
paddingTop: 0,
|
|
|
top: 0,
|
|
|
height: 20,
|
|
|
right: 0,
|
|
|
left: 0,
|
|
|
position: 'absolute',
|
|
|
},
|
|
|
listContainer: {
|
|
|
top: 20,
|
|
|
height: height - 20,
|
|
|
},
|
|
|
contentContainer: {
|
|
|
backgroundColor: 'white',
|
|
|
},
|
|
|
header: {
|
|
|
fontSize: 18,
|
|
|
color: '#B0B0B0',
|
|
|
top: 10,
|
|
|
right: 15,
|
|
|
height: 28,
|
|
|
alignSelf: 'flex-end',
|
|
|
},
|
|
|
separator: {
|
|
|
height: 1,
|
|
|
backgroundColor: '#E0E0E0',
|
|
|
},
|
|
|
row: {
|
|
|
height: 65,
|
|
|
justifyContent: 'center',
|
|
|
backgroundColor: 'transparent',
|
|
|
},
|
|
|
text: {
|
|
|
fontSize: 18,
|
|
|
color: '#444444',
|
|
|
fontWeight: 'bold',
|
|
|
left: 14,
|
|
|
},
|
|
|
}); |
...
|
...
|
|