-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/EdwardHaoranLee/2020NewHacks …
…into main
- Loading branch information
Showing
9 changed files
with
119 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) |