Set home as main component, rename list
This commit is contained in:
@@ -1,60 +1,22 @@
|
||||
import React, { Component } from 'react'
|
||||
import {
|
||||
View,
|
||||
Text,
|
||||
Button,
|
||||
TextInput,
|
||||
FlatList
|
||||
Button
|
||||
} from 'react-native'
|
||||
import * as styles from './styles'
|
||||
import Datastore from 'react-native-local-mongodb'
|
||||
|
||||
const db = new Datastore({ filename: 'asyncStorageKey', autoload: true })
|
||||
|
||||
export default class drip extends Component {
|
||||
export default class home extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
temperatures: []
|
||||
}
|
||||
db.find({ key: { $exists: true } }, (err, persistedTemperatures) => {
|
||||
if (err) throw err
|
||||
this.setState({
|
||||
temperatures: [...persistedTemperatures, ...this.state.temperatures]
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<TextInput
|
||||
placeholder="Enter your temperature"
|
||||
onChangeText={(val) => {
|
||||
this.setState({currentValue: val})
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
onPress={() => {
|
||||
const newTemp = {
|
||||
value: this.state.currentValue,
|
||||
key: Date.now().toString()
|
||||
}
|
||||
this.setState({
|
||||
temperatures: [newTemp, ...this.state.temperatures]
|
||||
})
|
||||
db.insert(newTemp, (err) => {
|
||||
if (err) console.log(err)
|
||||
})
|
||||
}}
|
||||
title="Save"
|
||||
/>
|
||||
<FlatList
|
||||
data = {this.state.temperatures}
|
||||
extraData = {this.state}
|
||||
renderItem={({item}) => <Text>{item.value}</Text>}
|
||||
/>
|
||||
onPress={() => {}}
|
||||
title="Home"></Button>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import React, { Component } from 'react'
|
||||
import {
|
||||
View,
|
||||
Text,
|
||||
Button,
|
||||
TextInput,
|
||||
FlatList
|
||||
} from 'react-native'
|
||||
import * as styles from './styles'
|
||||
import Datastore from 'react-native-local-mongodb'
|
||||
|
||||
const db = new Datastore({ filename: 'asyncStorageKey', autoload: true })
|
||||
|
||||
export default class temp extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
temperatures: []
|
||||
}
|
||||
db.find({ key: { $exists: true } }, (err, persistedTemperatures) => {
|
||||
if (err) throw err
|
||||
this.setState({
|
||||
temperatures: [...persistedTemperatures, ...this.state.temperatures]
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<TextInput
|
||||
placeholder="Enter your temperature"
|
||||
onChangeText={(val) => {
|
||||
this.setState({currentValue: val})
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
onPress={() => {
|
||||
const newTemp = {
|
||||
value: this.state.currentValue,
|
||||
key: Date.now().toString()
|
||||
}
|
||||
this.setState({
|
||||
temperatures: [newTemp, ...this.state.temperatures]
|
||||
})
|
||||
db.insert(newTemp, (err) => {
|
||||
if (err) console.log(err)
|
||||
})
|
||||
}}
|
||||
title="Save"
|
||||
/>
|
||||
<FlatList
|
||||
data = {this.state.temperatures}
|
||||
extraData = {this.state}
|
||||
renderItem={({item}) => <Text>{item.value}</Text>}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,6 @@ public class MainActivity extends ReactActivity {
|
||||
*/
|
||||
@Override
|
||||
protected String getMainComponentName() {
|
||||
return "drip";
|
||||
return "home";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AppRegistry } from 'react-native'
|
||||
import App from './App'
|
||||
import Home from './App'
|
||||
|
||||
AppRegistry.registerComponent('drip', () => App)
|
||||
AppRegistry.registerComponent('home', () => Home)
|
||||
|
||||
Generated
+6
-16
@@ -3207,13 +3207,11 @@
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
"bundled": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
@@ -3226,18 +3224,15 @@
|
||||
},
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
"bundled": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
"bundled": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
"bundled": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@@ -3340,8 +3335,7 @@
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
"bundled": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
@@ -3351,7 +3345,6 @@
|
||||
"is-fullwidth-code-point": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
@@ -3364,7 +3357,6 @@
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
@@ -3464,8 +3456,7 @@
|
||||
},
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
"bundled": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
@@ -3580,7 +3571,6 @@
|
||||
"string-width": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
|
||||
Reference in New Issue
Block a user