WebController.js 4.96 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/utils";

const defaultIcon = require("../img/defaultIcon.png");
// 可供外界调用的类
export default class WebController extends Component {
    constructor(props) {
        super(props);
    }
    
    static navigationOptions = ({ navigation, screenProps }) => ({
                                                                 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() {
        return (
                <View style={{flex:1}}>
                    <ScrollView  style= {{width:'100%',flex:1,backgroundColor:'#fff'}}>
                        <MyWebView
                            style= {{width:'100%',flex:1}}
                            source={{uri: this.props.navigation.state.params.url}}
                            startInLoadingState={true}
                        />
                    </ScrollView>

                </View>
                );
    }
}