Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Styling/form labels #101

Merged
merged 3 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions ApiCalls.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,25 @@ export const deleteFish = async (fishId) => {
console.error(error);
}
};

// Image upload for species identification:
export const uploadPhoto = async (photo) => {
try {
const response = await fetch(
"https://my-fly-box-api.herokuapp.com/api/v1/images",
Comment on lines +141 to +144
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good call to move this to the ApiCalls. This make it the proper formatting for the fetch calls.

{
method: "POST",
headers: {
"Content-Type": "application/json;charset=utf-8",
},
body: JSON.stringify({
base_64: photo,
}),
}
);
const imageResponse = await response.json();
return imageResponse;
} catch (error) {
console.error(error);
}
};
21 changes: 17 additions & 4 deletions components/FlyForm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from "react";
import { StyleSheet, View, TextInput } from "react-native";
import { StyleSheet, View, TextInput, Text } from "react-native";
import { updateFlyEntry, clearFlyEntry } from "../actions";
import { connect } from "react-redux";

Expand All @@ -19,25 +19,28 @@ class FlyForm extends Component {
handleChange = (property, text) => {
this.setState({ property: text });
this.props.updateFlyEntry(property, text);
}
};

render() {
return (
<View style={styles.container}>
<Text style={styles.label}>Fly Name:</Text>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding these labels for these input fields in the fly editing and adding page. This make things more understandable for the user when filling out fly information.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're welcome! Thanks for bringing this to the group's attention!

<TextInput
style={styles.input}
placeholder="Enter Fly Name"
value={this.props.currentFlyEntry.name}
onChangeText={(text) => this.handleChange("name", text)}
/>

<Text style={styles.label}>Fly Color:</Text>
<TextInput
style={styles.input}
placeholder="Enter Fly Color"
value={this.props.currentFlyEntry.color}
onChangeText={(text) => this.handleChange("color", text)}
/>

<Text style={styles.label}>Fly Size:</Text>
<TextInput
style={styles.input}
placeholder="Enter Fly Size"
Expand All @@ -46,13 +49,15 @@ class FlyForm extends Component {
onChangeText={(text) => this.handleChange("size", text)}
/>

<Text style={styles.label}>Type of Fly:</Text>
<TextInput
style={styles.input}
placeholder="Enter Fly Category"
placeholder="Enter Fly Type"
value={this.props.currentFlyEntry.category}
onChangeText={(text) => this.handleChange("category", text)}
/>

<Text style={styles.label}>Quantity:</Text>
<TextInput
style={styles.input}
placeholder="Enter Fly Amount"
Expand All @@ -70,7 +75,15 @@ const styles = StyleSheet.create({
flex: 1,
justifyContent: "center",
alignItems: "center",
paddingTop: 45,
paddingTop: 10,
marginVertical: "10%",
},

label: {
color: "#212326",
fontSize: 14,
fontWeight: "500",
marginBottom: 5,
},

input: {
Expand Down
32 changes: 6 additions & 26 deletions components/PhotoSelector.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import React, { Component } from "react";
import {
Text,
View,
TouchableOpacity,
Platform,
} from "react-native";
import { Text, View, TouchableOpacity, Platform } from "react-native";
import { Camera } from "expo-camera";
import * as Permissions from "expo-permissions";
import { FontAwesome, Ionicons } from "@expo/vector-icons";
import * as ImagePicker from "expo-image-picker";
import * as FileSystem from "expo-file-system";
import { connect } from "react-redux";
import { updateFishEntry } from "../actions";
import { uploadPhoto } from "../ApiCalls";

class PhotoSelector extends Component {
constructor(props) {
Expand Down Expand Up @@ -46,7 +42,8 @@ class PhotoSelector extends Component {
encoding: "base64",
});
await this.props.updateFishEntry("image", base64);
// this.uploadPhoto(base64);
// This is where we would then call the uploadPhoto post request to send the image to identify the species. This is working properly in development, but not on Heroku on a production level. Commenting out the invocation to avoid errors while this error is being researched.
// uploadPhoto(base64);
this.props.navigation.navigate("AddFish");
}
};
Expand All @@ -59,28 +56,11 @@ class PhotoSelector extends Component {
encoding: "base64",
});
await this.props.updateFishEntry("image", base64);
// this.uploadPhoto(base64);
// This is where we would then call the uploadPhoto post request to send the image to identify the species. This is working properly in development, but not on Heroku on a production level. Commenting out the invocation to avoid errors while this error is being researched.
// uploadPhoto(base64);
this.props.navigation.navigate("AddFish");
};

uploadPhoto = async (photo) => {
const response = await fetch(
"https://my-fly-box-api.herokuapp.com/api/v1/images",
{
method: "POST",
headers: {
"Content-Type": "application/json;charset=utf-8",
},
body: JSON.stringify({
base_64: photo,
}),
}
);

const imageResponse = await response.json();
console.log(imageResponse);
};

render() {
const { hasPermission } = this.state;
if (hasPermission === null) {
Expand Down
2 changes: 1 addition & 1 deletion containers/AddFly.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const styles = StyleSheet.create({
fontFamily: "Helvetica Neue",
fontWeight: "bold",
color: "#0b7d83",
marginBottom: 10,
marginBottom: "15%",
},

buttonContainer: {
Expand Down
5 changes: 2 additions & 3 deletions containers/EditFly.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class EditFly extends Component {
render() {
return (
<View style={styles.container}>

<Text style={styles.intro}>Make changes to the selected fly:</Text>

<FlyForm />
Expand Down Expand Up @@ -71,15 +70,15 @@ const styles = StyleSheet.create({
paddingTop: 45,
backgroundColor: "#f8f8ff",
},

intro: {
flex: 0.2,
alignSelf: "center",
fontSize: 20,
fontFamily: "Helvetica Neue",
fontWeight: "bold",
color: "#0b7d83",
marginBottom: 10,
marginBottom: "15%",
},

buttonContainer: {
Expand Down
Loading