|
@@ -1,12 +1,12 @@
|
|
-import React, { Component } from 'react';
|
|
+import React, { Component } from "react";
|
|
-import { View, Text, StyleSheet, Platform } from 'react-native';
|
|
+import { View, Text, StyleSheet, Platform } from "react-native";
|
|
-import Header from './header';
|
|
+import Header from "./header";
|
|
-import Footer from './footer';
|
|
+import Footer from "./footer";
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
container: {
|
|
flex: 1,
|
|
flex: 1,
|
|
- backgroundColor: "#FF6633",
|
|
+ backgroundColor: "#F5F5F5",
|
|
...Platform.select({
|
|
...Platform.select({
|
|
ios: {
|
|
ios: {
|
|
paddingTop: 30
|
|
paddingTop: 30
|
|
@@ -19,13 +19,43 @@ const styles = StyleSheet.create({
|
|
});
|
|
});
|
|
|
|
|
|
class App extends Component {
|
|
class App extends Component {
|
|
|
|
+ constructor(props) {
|
|
|
|
+ super(props);
|
|
|
|
+ this.state = {
|
|
|
|
+ value: "",
|
|
|
|
+ items: []
|
|
|
|
+ };
|
|
|
|
+ this.handleAddItem = this.handleAddItem.bind(this);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ handleAddItem() {
|
|
|
|
+ if (!this.state.value) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ const newItems = [
|
|
|
|
+ ...this.state.items,
|
|
|
|
+ {
|
|
|
|
+ key: Date.now(),
|
|
|
|
+ text: this.state.value,
|
|
|
|
+ complete: false
|
|
|
|
+ }
|
|
|
|
+ ];
|
|
|
|
+ this.setState({
|
|
|
|
+ items: newItems,
|
|
|
|
+ value: ""
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
render() {
|
|
render() {
|
|
|
|
+ console.log(this.state);
|
|
return (
|
|
return (
|
|
<View style={styles.container}>
|
|
<View style={styles.container}>
|
|
- <Header />
|
|
+ <Header
|
|
- <View style={styles.content}>
|
|
+ onAddItem={this.handleAddItem}
|
|
- <Text>Some other text</Text>
|
|
+ onChange={(value) => this.setState({ value })}
|
|
- </View>
|
|
+ value={this.state.value}
|
|
|
|
+ />
|
|
|
|
+ <View style={styles.content} />
|
|
<Footer />
|
|
<Footer />
|
|
</View>
|
|
</View>
|
|
);
|
|
);
|