|
@@ -1,114 +1,105 @@
|
|
|
+/**
|
|
|
+ * @param: uri String, username String,flowerNumber String, onPressCallback function
|
|
|
+ *
|
|
|
+ */
|
|
|
+
|
|
|
import React, { Component } from "react";
|
|
|
import {
|
|
|
- Platform,
|
|
|
StyleSheet,
|
|
|
Text,
|
|
|
View,
|
|
|
Image,
|
|
|
TouchableOpacity,
|
|
|
- ImageBackground,
|
|
|
- Button,
|
|
|
- Dimensions,
|
|
|
- DeviceEventEmitter
|
|
|
} from "react-native";
|
|
|
+import Dimensions from '../utils/dimensions'
|
|
|
|
|
|
/** 因没有图,所以Image先用颜色代替,有图可替换 */
|
|
|
-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"
|
|
|
-});
|
|
|
|
|
|
type Props = {};
|
|
|
-var width = Dimensions.get("window").width;
|
|
|
-var height = Dimensions.get("window").height;
|
|
|
+
|
|
|
+const styles = StyleSheet.create({
|
|
|
+ wrapper: {
|
|
|
+ width: Dimensions.width,
|
|
|
+ height: 72,
|
|
|
+ flex: 1,
|
|
|
+ alignItems: "center",
|
|
|
+ backgroundColor: 'red',
|
|
|
+ justifyContent: "center",
|
|
|
+ flexDirection: "row"
|
|
|
+ },
|
|
|
+ avatar: {
|
|
|
+ width: 44,
|
|
|
+ height: 44,
|
|
|
+ borderRadius: 50,
|
|
|
+ marginLeft: 11,
|
|
|
+ marginRight: 11
|
|
|
+ },
|
|
|
+ leftBox:{
|
|
|
+ flex: 1,
|
|
|
+ flexDirection: "column"
|
|
|
+ },
|
|
|
+ userName:{
|
|
|
+ width: 320,
|
|
|
+ fontSize: 18,
|
|
|
+ fontWeight: "bold",
|
|
|
+ textAlign: "left",
|
|
|
+ textAlignVertical: "bottom",
|
|
|
+ color: "#3f3f3f"
|
|
|
+ },
|
|
|
+ leftBottomRow: {
|
|
|
+ flexDirection: "row",
|
|
|
+ alignItems: "center"
|
|
|
+ },
|
|
|
+ flowerIcon:{
|
|
|
+ alignItems: "center",
|
|
|
+ justifyContent: "center",
|
|
|
+ width: 12,
|
|
|
+ height: 12,
|
|
|
+ backgroundColor: "blue"
|
|
|
+ },
|
|
|
+ flowerNumber:{
|
|
|
+ textAlignVertical: "center",
|
|
|
+ marginLeft: 3
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
export default class Header extends Component<Props> {
|
|
|
render() {
|
|
|
return (
|
|
|
<TouchableOpacity activeOpacity={1} onPress={this.props.onPress}>
|
|
|
<View
|
|
|
- style={{
|
|
|
- width: this.props.width,
|
|
|
- height: this.props.height,
|
|
|
- flexDirection: "column"
|
|
|
- }}
|
|
|
+ style={styles.wrapper}
|
|
|
>
|
|
|
- <View style={{ flex: 1 }} />
|
|
|
- <View
|
|
|
- style={{
|
|
|
- flex: 1,
|
|
|
- alignItems: "center",
|
|
|
- justifyContent: "center",
|
|
|
- flexDirection: "row"
|
|
|
+ <Image
|
|
|
+ source={{
|
|
|
+ uri: this.props.uri
|
|
|
}}
|
|
|
+ style={styles.avatar}
|
|
|
+ />
|
|
|
+ <View
|
|
|
+ style={styles.leftBox}
|
|
|
>
|
|
|
- <Image
|
|
|
- source={{
|
|
|
- uri: this.props.uri
|
|
|
- }}
|
|
|
- style={{
|
|
|
- width: 60,
|
|
|
- height: 60,
|
|
|
- borderRadius: 50
|
|
|
- }}
|
|
|
- />
|
|
|
- <View
|
|
|
- style={{
|
|
|
- flex: 0.1
|
|
|
- }}
|
|
|
- />
|
|
|
+ <Text
|
|
|
+ style={styles.userName}
|
|
|
+ >
|
|
|
+ {this.props.username}
|
|
|
+ </Text>
|
|
|
<View
|
|
|
- style={{
|
|
|
- flex: 10,
|
|
|
- width: "100%",
|
|
|
- height: "100%",
|
|
|
- flexDirection: "column"
|
|
|
- }}
|
|
|
+ style={styles.leftBottomRow}
|
|
|
>
|
|
|
+ <Image
|
|
|
+ // source={{
|
|
|
+ // uri: this.props.uri
|
|
|
+ // }}
|
|
|
+ style={styles.flowerIcon}
|
|
|
+ />
|
|
|
<Text
|
|
|
- style={{
|
|
|
- width: "100%",
|
|
|
- height: "50%",
|
|
|
- fontSize: 18,
|
|
|
- fontWeight: "bold",
|
|
|
- textAlign: "left",
|
|
|
- textAlignVertical: "bottom"
|
|
|
- }}
|
|
|
+ style={styles.flowerNumber}
|
|
|
>
|
|
|
- {this.props.username}
|
|
|
+ {this.props.flowerNumber}
|
|
|
</Text>
|
|
|
- <View
|
|
|
- style={{
|
|
|
- flex: 2,
|
|
|
- flexDirection: "row"
|
|
|
- }}
|
|
|
- >
|
|
|
- <Image
|
|
|
- // source={{
|
|
|
- // uri: this.props.uri
|
|
|
- // }}
|
|
|
- style={{
|
|
|
- alignItems: "center",
|
|
|
- justifyContent: "center",
|
|
|
- width: 20,
|
|
|
- height: 20,
|
|
|
- backgroundColor: "blue"
|
|
|
- }}
|
|
|
- />
|
|
|
- <Text
|
|
|
- style={{
|
|
|
- flex: 1,
|
|
|
- textAlignVertical: "center",
|
|
|
- marginLeft: 2
|
|
|
- }}
|
|
|
- >
|
|
|
- {this.props.flowerNumber}
|
|
|
- </Text>
|
|
|
- </View>
|
|
|
</View>
|
|
|
</View>
|
|
|
- <View style={{ flex: 1 }} />
|
|
|
</View>
|
|
|
</TouchableOpacity>
|
|
|
);
|
|
@@ -119,8 +110,6 @@ export default class Header extends Component<Props> {
|
|
|
使用方法
|
|
|
<Header
|
|
|
uri="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1295208965,3056573814&fm=26&gp=0.jpg"
|
|
|
- width={400}
|
|
|
- height={150}
|
|
|
username="卡通笨笨熊"
|
|
|
flowerNumber="123234"
|
|
|
onPress={() => this.toNextPage("MainActivity")}
|