text: var dom = require('../doms').ios;
  var View = require('../base_views').IOSBaseView;
  
  class UIView extends View {
    constructor(props, children) {
      super(props, children);
  
      this.setIds([
        'id'
      ]);
    }
  
    getChildWidth (props, parentWidth) {
      if (props.width) {
        props.width  += "";
  
        if (props.width.indexOf("match_parent") > -1){
          let values = props.width.split("/");
          let width = parentWidth;
          let x = (props.x || 0)*1;
          let weight;
  
          if (values.length > 1) {
            weight = values[1]*1;
            width = Math.round(parentWidth/weight);
          }
          
          return width*1 - x;
        }
  
        return props.width;
      }
  
      return props.width;
    }
  
    getChildHeight (props, parentHeight) {
      if (props.height) {
        props.height  += "";
  
        if (props.height.indexOf("match_parent") > -1){
          let values = props.height.split("/");
          let height = parentHeight;
          let y = (props.y || 0)*1;
          let weight;
  
          if (values.length > 1) {
            weight = values[1]*1;
            height = Math.round(parentHeight/weight);
          }
          
          return height*1 - y;  
        }
  
        return props.height;
      }
  
      return props.height;
    }
  
    addDimensionToOrphanNodes() {
      if (window.__CURR_PARENT_INDEX) {
        this.props.width = this.getChildWidth(this.props, window.__IOS_VIEWS[window.__CURR_PARENT_INDEX].width);
        this.props.height = this.getChildHeight(this.props, window.__IOS_VIEWS[window.__CURR_PARENT_INDEX].height);
      }
  
      window.__CURR_PARENT_INDEX = null;
    }
  
    render() {
      var params = this.props;
      var _this = this;
      var debug = params.debug || this.debug;
      var width = this.props.width;
      var height = this.props.height;
  
      params.__filename = params.__source.fileName  + ' :ln ' + params.__source.lineNumber;
      
      if (debug) {
        params.debug = "true";
      }
  
      this.addDimensionToOrphanNodes();
  
      return (
        <uIView
          id={this.props.id?this.props.id:this.idSet.id}  
          params={params}>
  
          {this.children.map(function(child) {
            child.props.width = _this.getChildWidth(child.props, width);
            child.props.height = _this.getChildHeight(child.props, height);
            child.debug = debug?"true":false
            return  child.render()
          })}
        </uIView>
      )
    }
  }
  
  module.exports = UIView;
  