Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

Commit

Permalink
Fetch other station locations from map pin
Browse files Browse the repository at this point in the history
  • Loading branch information
ryancoughlin committed Apr 8, 2017
1 parent 462707b commit be2ba3d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 32 deletions.
12 changes: 4 additions & 8 deletions app/components/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default class Map extends Component {

componentDidMount() {
navigator.geolocation.getCurrentPosition((position) => {
console.log(position.coords)
this.setState({
userLocation: {
latitude: position.coords.latitude,
Expand All @@ -35,12 +34,6 @@ export default class Map extends Component {
})
}

pushStationDetail(station) {
Actions.stationDetail({
...station,
})
}

render() {
const { stations, userLocation } = this.state

Expand Down Expand Up @@ -74,7 +67,10 @@ export default class Map extends Component {
height={98}
onPress={() => {
Actions.stationDetail({
...station,
location: {
latitude: station.location[0],
longitude: station.location[1],
},
})
}}
>
Expand Down
27 changes: 9 additions & 18 deletions app/components/station-detail/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ const StationDetail = class extends Component {
constructor(props) {
super(props)

if (props) {
this.state = {
city: props.name,
}
}


this.handleAppStateChange = this.handleAppStateChange.bind(this)

this.state = {
Expand All @@ -35,14 +28,10 @@ const StationDetail = class extends Component {
}

componentDidMount() {
this.findCurrentLocation()
this.requestLoctionInformation()
AppState.addEventListener('change', this.handleAppStateChange)
}

componentWillReceiveProps(nextProps) {
console.log(nextProps)
}

componentWillUnmount() {
AppState.removeEventListener('change', this.handleAppStateChange)
}
Expand All @@ -55,15 +44,17 @@ const StationDetail = class extends Component {
}

if (appState === 'active' && this.state.previousState !== 'active') {
this.findCurrentLocation()
this.requestLoctionInformation()
}
}

findCurrentLocation() {
fetchLocation().then((location) => {
this.props.fetchTideData(location)
this.props.findCityName(location)
})
requestLoctionInformation() {
if (this.props.location) {
this.props.fetchTideData(this.props.location)
this.props.findCityName(this.props.location)
} else {
this.findCurrentLocation()
}
}

render() {
Expand Down
16 changes: 13 additions & 3 deletions index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,24 @@ class Salty extends Component {
initial
key="stationDetail"
component={StationDetail}
rightTitle="Find"
onRight={() => Actions.map()}
type="reset"
/>
<Scene
key="map"
component={Map}
leftTitle="Close"
direction="vertical"
onLeft={() => Actions.pop()}
/>
>
<Scene
titleStyle={BaseStyle.navigationTitle}
key="mapModal"
title="Find a Station"
component={Map}
/>
</Scene>

<Scene
key="tideList"
direction="vertical"
Expand All @@ -62,7 +73,6 @@ class Salty extends Component {
key="tideListModal"
title="Tide Tables"
component={TideList}
direction="vertical"
panHandlers={null}
/>
</Scene>
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"react-native": "^0.42.0",
"react-native-config": "^0.1.2",
"react-native-geocoder": "^0.4.6",
"react-native-maps": "^0.13.0",
"react-native-maps": "^0.14.0",
"react-native-router-flux": "^3.38.0",
"react-native-splash-screen": "^2.0.0",
"react-native-svg": "^4.4.1",
"victory-native": "^0.7.1",
"react-native-svg": "^5.1.5",
"victory-native": "^0.7.2",
"react-redux": "^5.0.3",
"redux": "^3.6.0",
"redux-logger": "^3.0.0",
Expand Down

0 comments on commit be2ba3d

Please sign in to comment.