atlasAdController.js 5.18 KB
//
//  atlasAdController.js
//
//  Created by Cheney Mars on 2018/9/26.
//  Copyright © 2018年 saygoodlolita. All rights reserved.
//

import React, {Component} from 'react';
// 系统组件
import {Image, ScrollView, TouchableOpacity, View} from 'react-native';

import MyWebView from "react-native-webview-autoheight";

import {zoomW} from "../../utils/getSize";

const defaultIcon = require("../../img/defaultIcon.png");
// 可供外界调用的类
export default class atlasAdController extends Component {
    constructor(props) {
        super(props);
    }

    static navigationOptions = ({ navigation, screenProps }) => ({
                                                                 headerTitle: "广告",
                                                                 headerLeft: (
                                                                              <View style={{ flexDirection: "row", flex: 1 }}>
                                                                              <TouchableOpacity
                                                                              style={{
                                                                              flexDirection: "column",
                                                                              justifyContent: "center",
                                                                              paddingRight: 15,
                                                                              paddingLeft: 10
                                                                              }}
                                                                              onPress={
                                                                              navigation.state.params ? navigation.state.params.back : null
                                                                              }
                                                                              >
                                                                              <Image
                                                                              source={require("../../img/loadBack.png")}
                                                                              resizeMode="contain"
                                                                              />
                                                                              </TouchableOpacity>
                                                                              </View>
                                                                              ),
                                                                 headerRight: (
                                                                               <View style={{ flexDirection: "row", flex: 1, justifyContent: "center" }}>
                                                                               <TouchableOpacity
                                                                               style={{
                                                                               flexDirection: "column",
                                                                               justifyContent: "center",
                                                                               paddingRight: 15,
                                                                               paddingLeft: 10
                                                                               }}
                                                                               >
                                                                               <Image
                                                                               style={{ width: 20 / zoomW, height: 20 / zoomW }}
                                                                               resizeMode="contain"
                                                                               />
                                                                               </TouchableOpacity>
                                                                               </View>
                                                                               )
                                                                 });


    componentDidMount() {
        //设置头部
        this.props.navigation.setParams({
                                        back: () => {
                                        this.props.navigation.goBack();
                                        }
                                        });
    }


    render() {
        let url = this.props.navigation.state.params.adLink;
        if(url.indexOf('http://') == -1 && url.indexOf('https://') == -1){
            url = "http://" + url;
        }
        return (
                <View style={{flex:1}}>
                    <ScrollView  style= {{width:'100%',flex:1,backgroundColor:'#fff'}}>
                        <MyWebView
                            style= {{width:'100%',flex:1}}
                            source={{uri: url}}
                            startInLoadingState={true}
                        />
                    </ScrollView>

                </View>
                );
    }
}