Browse Source

优化头部组件

wangkang3 5 years ago
parent
commit
cefd566ae4

+ 10 - 3
wechat_demo/app/Details.js

1
import React, { Component } from 'react';
1
import React, { Component } from 'react';
2
import {View,Text,Image,StyleSheet,ScrollView,Platform,Dimensions} from 'react-native'; 
2
import {View,Text,Image,StyleSheet,ScrollView,Platform,Dimensions, TouchableOpacity} from 'react-native'; 
3
import { WebView } from 'react-native-webview';
3
import { WebView } from 'react-native-webview';
4
import Header from './Header'
4
import Header from './Header'
5
var {height,width} =  Dimensions.get('window');
5
var {height,width} =  Dimensions.get('window');
12
    render() {
12
    render() {
13
        return (
13
        return (
14
            <View style={{flex:1}}>
14
            <View style={{flex:1}}>
15
                <Header title='返回' leftEvent={()=>this.back(this)}></Header>
15
                <Header>
16
                    <TouchableOpacity style={{flex: 1, justifyContent: 'center', alignContent: 'center',  flexDirection: 'column', textAlign: 'center',}} onPress={()=>this.back(this)}>
17
                        <Image style={styles.tabImg} source={require('../static/img/back.png')} />
18
                    </TouchableOpacity>
19
                </Header>
16
                {/* <ScrollView style={{height:height-50}}> */}
20
                {/* <ScrollView style={{height:height-50}}> */}
17
                    {/* <View style={{alignItems:'center',height:height-50}}>
21
                    {/* <View style={{alignItems:'center',height:height-50}}>
18
                        <View><Text style={{fontSize:15,marginTop:40}}>3号免手洗</Text></View>
22
                        <View><Text style={{fontSize:15,marginTop:40}}>3号免手洗</Text></View>
32
}
36
}
33
37
34
const styles = StyleSheet.create({
38
const styles = StyleSheet.create({
35
 
39
    tabImg:{
40
        width:30,
41
        height:30
42
    }
36
})
43
})

+ 10 - 2
wechat_demo/app/Header.js

7
 * @lint-ignore-every XPLATJSCOPYRIGHT1
7
 * @lint-ignore-every XPLATJSCOPYRIGHT1
8
 */
8
 */
9
9
10
import React, {Component} from 'react';
10
import React, {Component, Children} from 'react';
11
import {Modal, StyleSheet, Text, View,Image,TouchableOpacity,TouchableHighlight} from 'react-native';
11
import {Modal, StyleSheet, Text, View,Image,TouchableOpacity,TouchableHighlight} from 'react-native';
12
import ModalContent from './ModalContent'
12
import ModalContent from './ModalContent'
13
13
21
        this.setState({ modalVisible: visible });
21
        this.setState({ modalVisible: visible });
22
      }
22
      }
23
    
23
    
24
      renderTitle(){
25
        let {children,title} =  this.props
26
        if(title){
27
          title = <Text style={styles.headerLeftText} numberOfLines={1}>{title}</Text>
28
        }
29
        return title?title:children
30
      }
24
31
25
  render() {
32
  render() {
26
    return (
33
    return (
27
      <View style={{height:50}}>
34
      <View style={{height:50}}>
28
        <View style={styles.headerContainer}>
35
        <View style={styles.headerContainer}>
29
          <View style={styles.headerLeft}>
36
          <View style={styles.headerLeft}>
30
            <Text style={styles.headerLeftText} onPress={()=>{this.props.leftEvent()}}>{this.props.title}</Text>
37
            {this.renderTitle()}
38
            {/* <Text style={styles.headerLeftText} onPress={()=>{this.props.leftEvent()}}>{this.props.title}</Text> */}
31
          </View>
39
          </View>
32
          <View style={styles.headerRight}>
40
          <View style={styles.headerRight}>
33
            <TouchableOpacity style={styles.clickButton,styles.leftButton} onPress={() => {
41
            <TouchableOpacity style={styles.clickButton,styles.leftButton} onPress={() => {

+ 1 - 1
wechat_demo/app/Home.js

247
        console.log(barItems)
247
        console.log(barItems)
248
        return (
248
        return (
249
            <View>
249
            <View>
250
                <Header title="我的二维码" leftEvent={() => { }}></Header>
250
                <Header title="我的二维码"></Header>
251
                <SegmentedBar
251
                <SegmentedBar
252
                    justifyItem={justifyItem}
252
                    justifyItem={justifyItem}
253
                    indicatorType={indicatorType}
253
                    indicatorType={indicatorType}

BIN
wechat_demo/static/img/back.png