myPublish.js 6.83 KB
/**
 * Created by Cassie on 2018/05/14
 * 我发布的通知
 */
import React, { Component } from 'react';
import {
    StyleSheet,
    View,
    Image,
    ScrollView,
    Text,
    TextInput,
    TouchableOpacity,
    InteractionManager
} from 'react-native';
import {StackNavigator} from 'react-navigation';

import {width,height,zoomW,zoomH} from '../../utils/getSize';
import {xnToast} from '../../utils/utils';
const back = require('../../img/returnB.png');
const search = require('../../img/search.png');
const allDel = require('../../img/allDel.png');
const bread = require('../../img/bread.png');
const avatar = require('../../img/avatar.png');
const addTarget = require('../../img/addTarget.png');
const withdraw = require('../../img/withdraw.png');


export default class MyPublish extends Component {
    static navigationOptions = ({ navigation, screenProps }) => ({
        title: "我发布的通知",
        headerLeft:(<View style={{display:'flex',flexDirection:'row'}} >
            <TouchableOpacity style={styles.topIcon} onPress={navigation.state.params?navigation.state.params.back:null}>
                <Image source={back} style={{width:(16/zoomH),height:(16/zoomH)}} resizeMode="contain" />
            </TouchableOpacity>
        </View>),
        headerRight:(
            <View style={{display:'flex',flexDirection:'row',paddingRight:(5/zoomW)}}>
                <TouchableOpacity style={styles.topIcon} onPress = {navigation.state.params?navigation.state.params.addNotice:null} >
                    <Image source={addTarget} style={{width:(26/zoomH),height:(26/zoomH)}} resizeMode="contain" />
                </TouchableOpacity>
            </View>)
    });

    constructor(props) {
        super(props);
        this.state = {
            sheetList: [1, 2, 3],
        };

    }

    componentDidMount(){
        this.props.navigation.setParams({
            addNotice:() => {
                InteractionManager.runAfterInteractions(() => {this.props.navigation.navigate('AddNotice');})
            },
            back:()=>{
                this.props.navigation.goBack();
            }
        });
    };
    /*显示确认人员页面*/
    toNotificationPage() {
        this.props.navigation.navigate('Notifications');
    }
    renderItem(item,index){
        return(
            <TouchableOpacity key = {index} style={styles.listItem} onPress = {()=>{this.toNotificationPage()}}>
                <View style = {{flex:1,flexDirection:'row',display:'flex',alignItems:'center',width:'100%'}}>
                    <Image source={avatar} style={{width:(52/zoomH),height:(52/zoomH),borderRadius:(26/zoomH)}} resizeMode="contain" />
                    <View style = {{flex:1,paddingLeft:(10/zoomW)}} >
                        <Text style = {{fontSize:18,color:'#000000'}}>部门月度总结大会</Text>
                        <View style = {{flex:1,display:'flex',flexDirection:'row',justifyContent:'space-between'}}>
                            <Text style = {{fontSize :12,color:'#999999'}}>Alice  423  13:45</Text>
                            <Text style ={{fontSize :12,color:'#999999'}}>3人未确认 </Text>
                        </View>
                    </View>
                </View>
                <View style = {{flex:1}}>
                    <Text style = {{fontSize :14,color:'#666666',paddingLeft :(62/zoomH),paddingTop:(17/zoomH)}}>很多人都会犯的错误,只强调做了很多很多事或者学习到很多很多知识,但是却没有阐述做了这些事</Text>
                    <Image source={withdraw} style={{width:(70/zoomH),height:(70/zoomH),borderRadius:(26/zoomH),position:'absolute',right:10,alignItems:'center'}} resizeMode="contain" />
                </View>

            </TouchableOpacity>
        );
    }

    render(){
        return(
            <View style={styles.background}>
                <ScrollView style={{width:'100%'}}>
                    <View style = {{width:'100%',backgroundColor:'#ffffff',alignItems:'center'}}>
                        <View style={styles.searchBox}>
                            <Image source={search} style={{width:(13/zoomH),height:(13/zoomH)}} resizeMode="contain" />
                            <TextInput returnKeyType="search" placeholder='搜索' placeholderTextColor='#8e8e93' style={styles.searchText}
                                       underlineColorAndroid="transparent" clearButtonMode="while-editing"/>
                            <TouchableOpacity style={{height:'100%',position:'absolute',right:0,display:'flex',justifyContent:'center'}}>
                                <Image source={allDel} style={{width:(16/zoomH),height:(48/zoomH),marginLeft:(10/zoomW),marginRight:(10/zoomW)}} resizeMode="center" />
                            </TouchableOpacity>
                        </View>
                    </View>

                    {this.state.sheetList && this.state.sheetList.map((item,index) => this.renderItem(item,index))}
                </ScrollView>
            </View>
        );
    }


}

const styles = StyleSheet.create({
   topIcon:{
     paddingLeft:(10/zoomW),
                paddingRight:(10/zoomW),
                height:'100%',
                display:'flex',
                alignItems:'center'
    },

    background:{
        flex:1,
        backgroundColor:'#ececf1',
        display:'flex',
        alignItems:'center'
    },
    itemBackground:{
        flex:1,
        backgroundColor:'#ffffff',
        display:'flex',
        alignItems:'center'
    },

    targetItem:{
        flex:1,
        display:'flex',
        flexDirection:'row',
        alignItems:'center',
        borderStyle:'solid',
        borderBottomColor:'#eee',
        paddingLeft:(15/zoomW),
        paddingRight:(15/zoomW),
        paddingTop:(10/zoomH),
        paddingBottom:(10/zoomH),
        backgroundColor:'#fff'
    },
    searchBox:{
        width:(345/zoomW),
        height:(34/zoomH),
        backgroundColor:'#eeeff3',
        borderRadius:3,
        display:'flex',
        flexDirection:'row',
        alignItems:'center',
        paddingLeft:(12.5/zoomW),
        paddingRight:(12.5/zoomW),
        marginBottom:(12.5/zoomW)
    },
    searchText:{
        flex:1,
        fontSize:14,
        color:'#000',
        padding:0,
        paddingLeft:(8/zoomW)
    },
    myPublish:{
        width :'100%',
        backgroundColor:'#ffffff',
        paddingLeft:(15/zoomW),
        paddingRight:(15/zoomW),
        paddingTop:(6.5/zoomW),
        paddingBottom:(19/zoomW),
        justifyContent:'space-between',
        flex :1,
        display:'flex',
        flexDirection: 'row'
    },

    listItem:{
       flex:1,
       display:'flex',
       borderStyle:'solid',
       backgroundColor:'#ffffff',
       borderBottomColor:'#eee',
       borderBottomWidth:StyleSheet.hairlineWidth,
       paddingTop:(10/zoomH),
       paddingLeft:(15/zoomW),
       paddingRight:(15/zoomW),
       paddingBottom:(10/zoomH)
    }
})