Skip to content

Commit

Permalink
Merge branch 'master' of github.com:STOP2/stop2.0-traveller-client
Browse files Browse the repository at this point in the history
  • Loading branch information
avrj committed Nov 28, 2016
2 parents 2c83a6a + 8448cfd commit ff464a0
Show file tree
Hide file tree
Showing 11 changed files with 213 additions and 199 deletions.
2 changes: 1 addition & 1 deletion app/components/RouteInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class RouteInfo extends Component {
</View>
</View>
<View style={styles.vehicleArrivesInWrapper}>
<DefaultText style={styles.vehicleArrivesInText}>{strings.vehicleArrivesIn}</DefaultText>
<DefaultText style={styles.vehicleArrivesInText}>{this.props.mode == 'stop' ? strings.vehicleStopsIn : strings.vehicleArrivesIn}</DefaultText>
</View>
<View>
<DefaultText style={styles.vehicleMinutesLeft}>{this.props.vehicleMinutesLeft}</DefaultText>
Expand Down
28 changes: 0 additions & 28 deletions app/components/SlideConfirmButton.js

This file was deleted.

19 changes: 0 additions & 19 deletions app/components/__tests__/SlideConfirmButton.snapshot.test.js

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion app/pages/DeparturesListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ class DeparturesListPage extends Component {

return (
<AccessibilityView style={styles.flex1} name={this.sceneName}>
<BoldTitleBar title={strings.chooseVehicle} noBorder={true}/>
<BoldTitleBar title={strings.nearestStops} noBorder={true}/>
{viewElement}
</AccessibilityView>
)
Expand Down
91 changes: 67 additions & 24 deletions app/pages/RouteStopRequestPage.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { View, TouchableOpacity, BackAndroid, Alert } from 'react-native'
import { sendStoprequest } from '../actions/sendStoprequest'
import { cancelStopRequest } from '../actions/cancelStopRequest'
import AwesomeButton from 'react-native-awesome-button'

import { Actions } from 'react-native-router-flux'

import { TitleBar, BoldTitleBar } from '../components/TitleBar'
import { RouteInfoForStop } from '../components/RouteInfo'
import SlideConfirmButton from '../components/SlideConfirmButton'
import AccessibilityView from '../components/AccessibilityView'
import {DefaultText} from '../components/textComponents'

import styles from '../styles/stylesheet'
import strings from '../resources/translations'

import { fetchRouteStops } from '../actions/fetchRouteStops'
import { resetState } from '../actions/resetStateAction'
import { sendStoprequest } from '../actions/sendStoprequest'
import { cancelStopRequest } from '../actions/cancelStopRequest'

const UPDATE_INTERVAL_IN_SECS = 10

Expand Down Expand Up @@ -163,49 +162,96 @@ class RouteStopRequestPage extends Component{

renderSlider = () =>
{
const sendStoprequest = () =>
{
this.props.sendStoprequest(this.props.vehicle, this.props.stop, this.props.fcmToken, true)
}
const sendStopRequest = () =>
{
Alert.alert(
strings.doYouReallyWantToMakeTheStopRequest, '',
[
{text: strings.no, onPress: () => {
}},
{text: strings.yes, onPress: () => {
this.props.sendStoprequest(this.props.vehicle, this.props.stop, this.props.fcmToken, true)
}},
],
{
cancelable: false
}
)
}

if (this.state.renderConfirm)
{
return (<SlideConfirmButton onSlideSuccess={sendStoprequest} text={strings.slide + ' →'} />)
return(<View style={{padding: 10}}><AwesomeButton labelStyle={{fontSize: 20, color: '#ffffff', fontFamily: 'gotham-rounded-medium'}} states={{
default: {
text: strings.stop,
onPress: sendStopRequest,
backgroundColor: '#64BE14'
}
}} /></View>)
/*return (<SlideConfirmButton onSlideSuccess={sendStoprequest} text={strings.slide + ' →'} />)*/
}
else
{
return (
/*return (
<View style={styles.sliderBackgroundGreen}>
<DefaultText style={styles.confirmedText}>{strings.stopsent}</DefaultText>
</View>
)
)*/
}
}

renderButton = () =>
{
const goToStopRequestPage = () =>
{
clearInterval(this.fetchInterval)
BackAndroid.removeEventListener('hardwareBackPress', this.backAndroidHandler)
this.props.resetState()
Actions.start()
const goToFrontPage = () =>
{
Alert.alert(
strings.doYouReallyWantToGoToFrontPage, '',
[
{text: strings.no, onPress: () => {
}},
{text: strings.yes, onPress: () => {
clearInterval(this.fetchInterval)
BackAndroid.removeEventListener('hardwareBackPress', this.backAndroidHandler)
Actions.start()
}},
],
{
cancelable: false
}
)
}

if (this.props.sent)
{
return(<View style={{padding: 10}}><AwesomeButton labelStyle={{fontSize: 20, color: '#ffffff', fontFamily: 'gotham-rounded-medium'}} states={{
default: {
text: strings.goToBackToFrontPage,
onPress: goToFrontPage,
backgroundColor: '#F092CD'
}
}} /></View>)
/*
return (
<TouchableOpacity accessibilityComponentType="button" accessibilityLabel={strings.goToBackToFrontPage} style={styles.goToRouteViewButton} onPress={goToStopRequestPage}>
<DefaultText style={styles.goToRouteViewButtonText}>{strings.goToBackToFrontPage}</DefaultText>
</TouchableOpacity>)
</TouchableOpacity>)*/
}
}

render()
{
return (
<AccessibilityView style={styles.flex1} name="stopRequest">
<BoldTitleBar title={strings.stopRequest}/>
{this.props.successfulStopRequest && <View style={{padding: 10, width: undefined, height: undefined, backgroundColor: '#BEE4F8'}}>
<DefaultText style={{marginBottom: 10, fontWeight: 'bold', fontSize: 20}}>Pysäytyspyyntö lähetetty</DefaultText>
<AwesomeButton labelStyle={{fontSize: 20, color: '#ffffff', fontFamily: 'gotham-rounded-medium'}} states={{
default: {
text: 'Peruuta',
onPress: this.showStopRequestCancelConfirmation,
backgroundColor: '#DC0451'
}
}} />
</View>}
<TitleBar title={this.props.vehicle.line + ' ' + this.props.vehicle.destination} />
<View style={styles.flex3}>
{this.renderRouteInfo()}
Expand All @@ -232,7 +278,8 @@ const mapStateToProps = (state) =>
startStop: state.stopRequestReducer.startStop,
vehicle: state.stopRequestReducer.currentVehicle,
fcmToken: state.fcmReducer.token,
destinationRequestId: state.stopRequestReducer.destinationRequestId
destinationRequestId: state.stopRequestReducer.destinationRequestId,
successfulStopRequest: state.stopRequestReducer.sentStoprequestFromVehicle,
}
}

Expand All @@ -247,10 +294,6 @@ const mapDispatchToProps = (dispatch) =>
{
dispatch(fetchRouteStops(tripId, BusId, current))
},
resetState: () =>
{
dispatch(resetState())
},
cancelStopRequest: (requestId, cancelStopRequestCallback) =>
{
dispatch(cancelStopRequest(requestId, true))
Expand Down
6 changes: 6 additions & 0 deletions app/pages/StartPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import strings from '../resources/translations'
import StartViewButtons from '../components/StartViewButtons'
import AccessibilityView from '../components/AccessibilityView'

import { resetState } from '../actions/resetStateAction'
import BeaconController from '../components/BeaconController'
import { getGpsLocation } from '../actions/gpsLocationActions'

Expand Down Expand Up @@ -47,6 +48,7 @@ class StartView extends Component {

componentWillMount = () =>
{
this.props.resetState()
this.requestLocationPermission()
}

Expand Down Expand Up @@ -82,6 +84,10 @@ const mapDispatchToProps = (dispatch) =>
getGpsLocation: () =>
{
dispatch(getGpsLocation())
},
resetState: () =>
{
dispatch(resetState())
}
}
}
Expand Down
Loading

0 comments on commit ff464a0

Please sign in to comment.