'use strict';

let React = require('react-native');
let {
  Animated,
  ScrollView,
  StyleSheet,
  View,
} = React;

let ExHeader = require('./ExHeader');

const STATUS_BAR_HEIGHT = 20;

class ExScreen extends React.Component {
  constructor(props, context) {
    super(props, context);
    this.state = {
      headerScale: new Animated.Value(1),
      scrollDistance: new Animated.Value(0),
    };
  }

  render() {
    let {
      title,
      headerColor,
      scrollEnabled,
      ...props,
    } = this.props;

    return (
      <View {...props}>
        <ScrollView
          ref={component => { this._scrollView = component; }}
          contentContainerStyle={styles.contentContainer}
          contentInset={{ top: ExHeader.HEIGHT + STATUS_BAR_HEIGHT }}
          scrollEnabled={scrollEnabled}
          showsVerticalScrollIndicator={false}
          scrollEventThrottle={16}
          onScroll={this._handleScroll.bind(this)}>
          {props.children}
        </ScrollView>
        <ExHeader
          title={title}
          scrollDistance={this.state.scrollDistance}
          style={[styles.header, { backgroundColor: headerColor }]}
        />
      </View>
    );
  }

  componentDidMount() {
    this._scrollView.scrollWithoutAnimationTo(-ExHeader.HEIGHT);
  }

  _handleScroll(event) {
    let {
      contentInset: { top: topInset },
      contentOffset: { y: scrollY },
    } = event.nativeEvent;
    let scrollDistance = scrollY + topInset;
    this.state.scrollDistance.setValue(scrollDistance);
  }
}

let styles = StyleSheet.create({
  contentContainer: {
    paddingTop: 10,
  },
  header: {
    position: 'absolute',
    top: 0,
    left: 0,
    right: 0,
  },
});

module.exports = ExScreen;

@@ -694,78 +694,8 @@
 er%7D%0A
-          contentInset=%7B%7B top: ExHeader.HEIGHT + STATUS_BAR_HEIGHT %7D%7D%0A
     
@@ -730,16 +730,16 @@
 nabled%7D%0A
+
         
@@ -864,16 +864,91 @@
 this)%7D%3E%0A
+          %3CView style=%7B%7B height: ExHeader.HEIGHT + STATUS_BAR_HEIGHT %7D%7D /%3E%0A
         
@@ -1192,102 +1192,8 @@
  %7D%0A%0A
-  componentDidMount() %7B%0A    this._scrollView.scrollWithoutAnimationTo(-ExHeader.HEIGHT);%0A  %7D%0A%0A
   _h
@@ -1485,24 +1485,24 @@
 ontainer: %7B%0A
+
     paddingT
@@ -1505,17 +1505,16 @@
 ingTop: 
-1
 0,%0A  %7D,%0A

Update template for android