Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into main
  • Loading branch information
rainyuxuan committed Nov 8, 2020
2 parents 7763adc + 1a44982 commit 23aa86c
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 23 deletions.
23 changes: 0 additions & 23 deletions Flourish/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,26 +184,3 @@ export default function App() {
);
}

// import { StatusBar } from 'expo-status-bar';
// import React from 'react';
// import { StyleSheet, Text, View } from 'react-native';
// import TabNavigation from './TabNavigation'
//
// export default function App() {
// return (
// <View style={styles.container}>
// <Text>Open up App.js to start working on your app!</Text>
// <StatusBar style="auto" />
// <TabNavigation />
// </View>
// );
// }
//
// const styles = StyleSheet.create({
// container: {
// flex: 1,
// backgroundColor: '#fff',
// alignItems: 'center',
// justifyContent: 'center',
// },
// });
57 changes: 57 additions & 0 deletions Flourish/Gateways/StorageAccess.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { AsyncStorage } from 'react-native';

const STORAGE_KEY_PLANTS = '@plants'
const STORAGE_KEY_REMINDERS = '@reminders'

export default class StorageAccess extends React.Component {
state = {
plants: [],
reminders: []
}

savePlants = async () => {
try {
await AsyncStorage.setItem(STORAGE_KEY_PLANTS, this.state.plants)
alert('Data successfully saved')
} catch (e) {
alert('Failed to save the data to the storage')
}
}

saveReminders = async () => {
try {
await AsyncStorage.setItem(STORAGE_KEY_REMINDERS, this.state.reminders)
alert('Data successfully saved')
} catch (e) {
alert('Failed to save the data to the storage')
}
}

readPlants = async () => {
try {
const plants = await AsyncStorage.getItem(STORAGE_KEY_PLANTS)

if (plants !== null) {
this.setState({
plants: plants
})
}
} catch (e) {
alert('Failed to fetch the data from storage')
}
}

readReminders = async () => {
try {
const reminders = await AsyncStorage.getItem(STORAGE_KEY_REMINDERS)

if (reminders !== null) {
this.setState({
reminders: reminders
})
}
} catch (e) {
alert('Failed to fetch the data from storage')
}
}
}
1 change: 1 addition & 0 deletions Flourish/Tabs/FlourishingTabScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default class FlourishingTabScreen extends React.Component{
componentDidMount() {
this.setState({
plants: this.props.plants

})
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions Flourish/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Flourish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@react-native-community/image-picker-ios": "^1.0.1",
"@react-navigation/bottom-tabs": "^5.10.6",
"@react-navigation/stack": "^5.12.3",
"axios": "^0.21.0",
"expo": "~39.0.2",
"expo-camera": "~9.0.0",
"expo-image-picker": "~9.1.1",
Expand All @@ -28,6 +29,7 @@
"react-native-screens": "^2.13.0",
"react-native-svg": "12.1.0",
"react-native-web": "~0.13.12",
"react-native-web-webview": "^1.0.2",
"react-native-webview": "^10.10.2",
"react-navigation": "^4.4.3"
},
Expand Down
38 changes: 38 additions & 0 deletions Plant-ID/Identifier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

import Reach from 'react';
import axios from 'axios';


// export default class Indentification extends React.Component {
// state = {
// files: [],
// }

// componentDidMount()
// }

const axios = require('axios')
var fs = require('fs');

const files = [];

const base64files = files.map(file => fs.readFileSync(file, 'base64'));

const data = {
api_key: "ftgMU1minamhEWUAjMdlh2VVWMTYPGSkT5BioLhADeQNkqDBrN",
images: base64files,
modifiers: ["crops_fast", "similar_images"],
plant_language: "en",
plant_details: ["common_names",
"url",
"name_authority",
"wiki_description",
"taxonomy",
"synonyms"]
};

axios.post('https://api.plant.id/v2/identify', data).then(res => {
console.log('Success:', res.data);
}).catch(error => {
console.error('Error: ', error)
})

0 comments on commit 23aa86c

Please sign in to comment.