/**
 * Created by irmo on 16/10/11.
 */

'use strict';

import React, {Component, PropTypes} from 'react';
import {
  StyleSheet,
  Image,
  Text,
  TextInput,
  TouchableHighlight,
  TouchableOpacity,
  View
} from 'react-native';

import Photo from '../component/Photo';
import GeolocationExample from '../component/Location';

import Reflux from 'reflux';
import diaryStore from './../component/Storage';
import DiaryActions from './../actions';


export default class TodayScene extends Component {
  mixins =  [Reflux.connect(diaryStore, 'store')];

  static propTypes = {
    navigator: PropTypes.object.isRequired
  };

  constructor(props, context) {
    super(props, context);
    this.state = {
      text: 'Default Text',
      location: 'unknown',
      imageUrl: null
    }
  }

  _getImageUrl(url) {
    this.setState({imageUrl: url});
  }

  render() {
    return (
      <View style={styles.container}>
        <TouchableHighlight onPress={() => this.props.navigator.pop()}>
          <Text style={styles.backButtonText}>Back</Text>
        </TouchableHighlight>
        <TextInput
          style={styles.input}
          onChangeText={(text) => this.setState({text})}
          value={this.state.text}
          onSubmitEditing={(event) => {DiaryActions.createDiary('100', this.state.text)} }
        />
        <GeolocationExample />
        <Photo storeSource={null} getImageUrlBack={(url) => this._getImageUrl(url)}/>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    padding: 10,
    flex: 1,
    backgroundColor: 'black'
  },
  backButtonText: {
    color: '#FFFFFF',
    fontSize: 50
  },
  commonText: {
    padding: 5,
    paddingBottom: 3,
    color: '#AFAFAF'
  },
  input: {
    height: 100,
    borderColor: 'white',
    borderWidth: 1,
    color: '#AFAFAF',
    fontSize: 15,
    alignItems: 'flex-start'
  },
});

@@ -715,20 +715,8 @@
 t: '
-Default Text
 ',%0A 
@@ -773,16 +773,114 @@
  %7D%0A  %7D%0A%0A
+  submit() %7B%0A    let date = new Date();%0A    DiaryActions.createDiary(date, this.state.text);%0A  %7D%0A%0A
   _getIm
@@ -1313,215 +1313,440 @@
     
-onSubmitEditing=%7B(event) =%3E %7BDiaryActions.createDiary('100', this.state.text)%7D %7D%0A        /%3E%0A        %3CGeolocationExample /%3E%0A        %3CPhoto storeSource=%7Bnull%7D getImageUrlBack=%7B(url) =%3E this._getImageUrl(url)%7D/
+multiline=%7Btrue%7D%0A          placeholder=%7B'Say something...'%7D%0A          placeholderTextColor=%7B'#CFCFCF'%7D%0A          keyboardType=%7B'default'%7D%0A          maxLength=%7B70%7D%0A        /%3E%0A        %3CGeolocationExample /%3E%0A        %3CPhoto storeSource=%7Bnull%7D getImageUrlBack=%7B(url) =%3E this._getImageUrl(url)%7D/%3E%0A        %3CTouchableHighlight%3E%0A          %3CText style=%7Bstyles.commonText%7D onPress=%7B()=%3Ethis.submit()%7D%3ESubmit%3C/Text%3E%0A        %3C/TouchableHighlight
 %3E%0A  

fix merge confict