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

Complete delivery #199

Merged
merged 10 commits into from
May 27, 2019
2 changes: 1 addition & 1 deletion .expo/packager-info.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
2 changes: 1 addition & 1 deletion .expo/settings.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
92 changes: 58 additions & 34 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { StyleSheet, Text, View, Image, YellowBox, Dimensions} from 'react-native';
import { StyleSheet, Text, View, Image, YellowBox, Dimensions } from 'react-native';
import firebase from 'firebase';
import config from './services/firebase-config';
import FontLoad from './components/FontLoad';
import { createBottomTabNavigator, createAppContainer, createStackNavigator} from 'react-navigation';
import { createBottomTabNavigator, createAppContainer, createStackNavigator } from 'react-navigation';
import AccountProfile from './screens/AccountProfile';
import AvailablePackages from './screens/AvailablePackages';
import Checkout from './screens/Checkout';
Expand All @@ -24,8 +24,19 @@ import YourCart from './screens/YourCart';
import YourResults from './screens/YourResults';
import Payment from './screens/Payment';
import LoadingScreen from './screens/LoadingScreen';
import { createStore, applyMiddleware } from 'redux';
import { Provider, connect } from 'react-redux';
import axios from 'axios';
import axiosMiddleware from 'redux-axios-middleware';
import completedReducer from './reducers/completedReducer';


const client = axios.create({
baseURL: 'https://api.github.com',
responseType: 'json'
});

const store = createStore(completedReducer, applyMiddleware(axiosMiddleware(client)));

YellowBox.ignoreWarnings([
'Require cycle:',
Expand Down Expand Up @@ -80,6 +91,9 @@ const driverStackNavigator = createStackNavigator({
RequestStatus: {
screen: RequestStatus
},
Payment: {
screen: Payment
},
AccountProfile: {
screen: AccountProfile
},
Expand All @@ -92,38 +106,48 @@ const TabNavigator = createBottomTabNavigator({
ShopSearch: shopStackNavigator,
DriverSearch: driverStackNavigator,
},
{
defaultNavigationOptions: ({ navigation }) => ({
tabBarIcon: ({ focused }) => {
const { routeName } = navigation.state;
let imageName;
if (routeName === 'ShopSearch') {
imageName = require('./assets/images/blue-nav-cart.png');
if (focused) {
imageName = require('./assets/images/filled_cart.png');
}
} else if (routeName === 'Notifications') {
imageName = require('./assets/images/home_icon.png');
if (focused) {
imageName = require('./assets/images/filled_house.png');
}
} else if (routeName === 'DriverSearch') {
imageName = require('./assets/images/blue_person_w_bag.png');
if (focused) {
imageName = require('./assets/images/blue_filled_person.png');
{
defaultNavigationOptions: ({ navigation }) => ({
tabBarIcon: ({ focused }) => {
const { routeName } = navigation.state;
let imageName;
if (routeName === 'ShopSearch') {
imageName = require('./assets/images/blue-nav-cart.png');
if (focused) {
imageName = require('./assets/images/filled_cart.png');
}
} else if (routeName === 'Notifications') {
imageName = require('./assets/images/home_icon.png');
if (focused) {
imageName = require('./assets/images/filled_house.png');
}
} else if (routeName === 'DriverSearch') {
imageName = require('./assets/images/blue_person_w_bag.png');
if (focused) {
imageName = require('./assets/images/blue_filled_person.png');
}
}
return <Image source={imageName} style={{ width: Dimensions.get("screen").width * .1, height: Dimensions.get("screen").height * .05, marginTop: Dimensions.get("screen").height * .005, resizeMode: 'contain' }} />;
},
}),
tabBarOptions: {
showLabel: false,
style: {
height: Dimensions.get("screen").height * .08

}
}
return <Image source={imageName} style={{width: Dimensions.get("screen").width*.1, height: Dimensions.get("screen").height*.05, marginTop: Dimensions.get("screen").height*.005, resizeMode: 'contain'}} />;
},
}),
tabBarOptions: {
showLabel: false,
style: {
height: Dimensions.get("screen").height*.08

}
},
}
},
}
);

export default createAppContainer(TabNavigator);
const JuicedAppContainer = createAppContainer(TabNavigator);

const App = () => {
return (
<Provider store={store}>
<JuicedAppContainer/>
</Provider>
)
}

export default App;
30 changes: 24 additions & 6 deletions components/PackagesBox.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React from 'react';
import { StyleSheet, View, Dimensions, LayoutAnimation, TouchableOpacity, Text} from 'react-native';
import PrimaryButton from './../components/PrimaryButton';
import firebase from 'firebase';
import { connect } from 'react-redux';
import { currentDelivery } from '../reducers/completedReducer';

var CustomLayoutAnimation = {
duration: 50,
Expand All @@ -13,8 +16,9 @@ var CustomLayoutAnimation = {
},
};

const database = firebase.database();

export default class PackagesBox extends React.Component {
class PackagesBox extends React.Component {
static navigationOptions = {
header: null,
};
Expand All @@ -30,12 +34,14 @@ export default class PackagesBox extends React.Component {
this.setState (
{expandBox: !this.state.expandBox}
)

this.props.currentDelivery(this.props.item.id)
}
onPress = (item) => {

onPress = () => {
database.ref(`deliveries/delivery${this.props.currentId}/accepted`).set(true)
this.props.navigation.navigate('RequestStatus', {
confirm: item.confirmedEmail,
item: item,
confirm: this.props.item.confirmedEmail,
item: this.props.item,
});
}

Expand All @@ -62,7 +68,7 @@ export default class PackagesBox extends React.Component {
</View>
<Text style = {styles.packageSize}>{this.props.packageSize}</Text>
<View style={styles.buttonContainer}>
<PrimaryButton onPress={this.onPress.bind(this, this.props.item)} title={'Accept'} backgroundColor={ '#19C6D1'} height={Dimensions.get('screen').height*.05} fontSize={25}/>
<PrimaryButton onPress={this.onPress} title={'Accept'} backgroundColor={ '#19C6D1'} height={Dimensions.get('screen').height*.05} fontSize={25}/>
</View>
</View>
</TouchableOpacity>
Expand Down Expand Up @@ -144,3 +150,15 @@ const styles = StyleSheet.create({
marginTop: Dimensions.get('screen').height*.018
},
});

const mapStateToProps = state => {
return {
currentId: state.id
}
}

const mapDispatchToProps = {
currentDelivery
}

export default connect(mapStateToProps, mapDispatchToProps)(PackagesBox);
39 changes: 37 additions & 2 deletions components/StatusUpdateModal.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
import React from 'react';
import { StyleSheet, Text, View, Dimensions, Image, TouchableOpacity } from 'react-native';
import { SMS } from 'expo';
import firebase from 'firebase';
import { connect } from 'react-redux';
import { currentDelivery } from '../reducers/completedReducer';

export default class StatusUpdateModal extends React.Component {

const database = firebase.database();

class StatusUpdateModal extends React.Component {

constructor(props) {
super(props);
this.state = {
userArray: {

},
phone: null,
};
};

componentWillMount = () => {
if (this.checkingDevice()) {
console.log('Available');
} else {
console.log('Unavailable');
}
console.log("Current Id", this.props.currentId) //Current Delivery Key
}

checkingDevice = async() => {
Expand All @@ -22,7 +38,14 @@ export default class StatusUpdateModal extends React.Component {
const { result }= await SMS.sendSMSAsync(this.props.phone, text);
}

sendAndComplete = async(text) => {
const { result }= await SMS.sendSMSAsync(this.props.phone, text);
database.ref(`deliveries/delivery${this.props.currentId}`).remove() //deleting object
this.props.currentDelivery('') //currentId becomes empty string, delivery object key gone
}

render() {

return (
<View style={styles.container}>
<View style = {styles.whiteBox}>
Expand Down Expand Up @@ -57,7 +80,7 @@ export default class StatusUpdateModal extends React.Component {
<View style = {styles.blueRectangles}>
</View>
</TouchableOpacity>
<TouchableOpacity onPress={this.sendText.bind(this, 'Your deliverer has delivered your mail!')}>
<TouchableOpacity onPress={this.sendAndComplete.bind(this, 'Your deliverer has delivered your mail!')}>
<View style = {styles.rectangles}>
<View style={{flex: 1, flexDirection: 'row', alignItems: 'center'}}>
<Text style={styles.rectangleText}>Delivered</Text>
Expand Down Expand Up @@ -140,3 +163,15 @@ const styles = StyleSheet.create({
height: Dimensions.get("screen").height*.01,
},
});

const mapStateToProps = state => {
return {
currentId: state.id
}
}

const mapDispatchToProps = {
currentDelivery
}

export default connect(mapStateToProps, mapDispatchToProps)(StatusUpdateModal);
81 changes: 81 additions & 0 deletions package-lock.json

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

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@
"eject": "expo eject"
},
"dependencies": {
"axios": "^0.18.0",
"expo": "^31.0.6",
"expo-sms": "^4.0.0",
"firebase": "^5.9.0",
"moment": "^2.24.0",
"react": "16.5.0",
"react-native": "https:/expo/react-native/archive/sdk-31.0.0.tar.gz",
"react-native-gesture-handler": "^1.0.15",
"react-navigation": "^3.3.0"
"react-navigation": "^3.3.0",
"react-redux": "^6.0.1",
"redux": "^4.0.1",
"redux-axios-middleware": "^4.0.0"
},
"devDependencies": {
"babel-preset-expo": "^5.0.0",
Expand Down
Loading