From 33189804053f0f82120905a42c637d3cb056be13 Mon Sep 17 00:00:00 2001 From: Youngchan Je Date: Wed, 16 Nov 2016 15:19:43 +0900 Subject: [PATCH 1/7] added location service dialog box for Android (#115) * added location service dialog box for Android * deleted map test due to having trouble on using jest --- __tests__/map-test.js | 18 -------------- android/app/build.gradle | 1 + .../main/java/com/goober/MainApplication.java | 2 ++ android/settings.gradle | 2 ++ package.json | 1 + shared/components/map.js | 24 +++++++++++++++---- 6 files changed, 25 insertions(+), 23 deletions(-) delete mode 100644 __tests__/map-test.js diff --git a/__tests__/map-test.js b/__tests__/map-test.js deleted file mode 100644 index 8668b33..0000000 --- a/__tests__/map-test.js +++ /dev/null @@ -1,18 +0,0 @@ -import 'react-native'; -import React from 'react'; -import Map from '../shared/components/map'; - -// Note: test renderer must be required after react-native. -import renderer from 'react-test-renderer'; - -it('renders correctly', () => { - const tree = renderer.create( - {}} - selectedItem={{}} - getZoomLevel={()=>{}}/> - ).toJSON(); - expect(tree).toMatchSnapshot(); -}); diff --git a/android/app/build.gradle b/android/app/build.gradle index 499c3ea..6180ccb 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -126,6 +126,7 @@ android { } dependencies { + compile project(':react-native-android-location-services-dialog-box') compile project(':react-native-facebook-login') compile project(':react-native-image-to-base64') compile project(':react-native-camera') diff --git a/android/app/src/main/java/com/goober/MainApplication.java b/android/app/src/main/java/com/goober/MainApplication.java index 70b0701..3efa2e2 100644 --- a/android/app/src/main/java/com/goober/MainApplication.java +++ b/android/app/src/main/java/com/goober/MainApplication.java @@ -5,6 +5,7 @@ import com.airbnb.android.react.maps.MapsPackage; import com.facebook.react.ReactApplication; +import com.showlocationservicesdialogbox.LocationServicesDialogBoxPackage; import com.magus.fblogin.FacebookLoginPackage; import com.github.xfumihiro.react_native_image_to_base64.ImageToBase64Package; import com.lwansbrough.RCTCamera.RCTCameraPackage; @@ -29,6 +30,7 @@ protected boolean getUseDeveloperSupport() { protected List getPackages() { return Arrays.asList( new MainReactPackage(), + new LocationServicesDialogBoxPackage(), new FacebookLoginPackage(), new ImageToBase64Package(), new RCTCameraPackage(), diff --git a/android/settings.gradle b/android/settings.gradle index f8e0b0b..c3099cf 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,6 +1,8 @@ rootProject.name = 'Goober' include ':app' +include ':react-native-android-location-services-dialog-box' +project(':react-native-android-location-services-dialog-box').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-location-services-dialog-box/android') include ':react-native-facebook-login' project(':react-native-facebook-login').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-facebook-login/android') include ':react-native-image-to-base64' diff --git a/package.json b/package.json index e23685a..b2f0261 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "react-addons-shallow-compare": "^15.3.2", "react-addons-update": "^15.3.2", "react-native": "0.35.0", + "react-native-android-location-services-dialog-box": "^1.1.7", "react-native-asset-library-to-base64": "^1.0.1", "react-native-camera": "git+https://github.com/lwansbrough/react-native-camera.git", "react-native-datepicker": "^1.3.2", diff --git a/shared/components/map.js b/shared/components/map.js index fece950..b75386a 100644 --- a/shared/components/map.js +++ b/shared/components/map.js @@ -11,6 +11,7 @@ import eventClickPng from '../resources/marker/event_big.png'; import facilityClickPng from '../resources/marker/facility_big.png'; import warningClickPng from '../resources/marker/warning_big.png'; import {API_GEODATA, API_KEY} from '../utils'; +import LocationServicesDialogBox from 'react-native-android-location-services-dialog-box'; const styles = StyleSheet.create({ container: { @@ -61,11 +62,24 @@ export default class Map extends Component { } componentWillMount() { - this.setCurrentPosition(); - this.props.getZoomLevel(this.props.currentLocation.latitudeDelta); - this.props.getMapItems(this.props.zoomLevel, - this.props.currentLocation.latitude, - this.props.currentLocation.longitude); + LocationServicesDialogBox.checkLocationServicesIsEnabled({ + message: "

Use Location ?

" + + "This app wants to change your device settings:

" + + "Use GPS, Wi-Fi, and cell network for location

", + ok: 'YES', + cancel: 'NO' + }) + .then((success) => { + console.log(success); + this.setCurrentPosition(); + this.props.getZoomLevel(this.props.currentLocation.latitudeDelta); + this.props.getMapItems(this.props.zoomLevel, + this.props.currentLocation.latitude, + this.props.currentLocation.longitude); + }) + .catch((error) => { + console.log(error.message); + }); } // todo: this is duplicate from Create.js. refactoring required From 89e806dc5eb5e3acdf3a87a1ff68cd03c5990378 Mon Sep 17 00:00:00 2001 From: yuda1124 Date: Wed, 16 Nov 2016 15:20:29 +0900 Subject: [PATCH 2/7] warning fix (#116) --- shared/components/Card.js | 8 +++++--- shared/components/detailHeader.js | 6 +++--- shared/components/detailView.js | 7 ++++--- shared/components/map.js | 4 +++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/shared/components/Card.js b/shared/components/Card.js index b99940f..fef5821 100644 --- a/shared/components/Card.js +++ b/shared/components/Card.js @@ -200,11 +200,13 @@ Card.propTypes = { endTime: PropTypes.string, title: PropTypes.string, address: PropTypes.string, - imageUrls: PropTypes.array + imageUrls: PropTypes.array, + key: PropTypes.any })), - getDetailImage: PropTypes.function, + key: PropTypes.string, + getDetailImage: PropTypes.func, currentScene: PropTypes.string, - setCurrentScene: PropTypes.function + setCurrentScene: PropTypes.func }; export default Card; diff --git a/shared/components/detailHeader.js b/shared/components/detailHeader.js index eb18ba3..4e6bd32 100644 --- a/shared/components/detailHeader.js +++ b/shared/components/detailHeader.js @@ -94,8 +94,8 @@ export default class DetailHeader extends Component { DetailHeader.propTypes = { title: PropTypes.string, date: PropTypes.string, - setCurrentScene: PropTypes.function, + setCurrentScene: PropTypes.func, lastScene: PropTypes.string, - messageUnvisible: PropTypes.function, - setModalVisible: PropTypes.function + messageUnvisible: PropTypes.func, + setModalVisible: PropTypes.func }; diff --git a/shared/components/detailView.js b/shared/components/detailView.js index 82b08ee..5e9a80c 100644 --- a/shared/components/detailView.js +++ b/shared/components/detailView.js @@ -255,7 +255,6 @@ export default class DetailView extends Component { } render() { - console.log(JSON.stringify(this.props)); let currentLocation = { latitude: this.props.lat, longitude: this.props.lng, @@ -286,7 +285,8 @@ export default class DetailView extends Component { {this.state.data.map((value, i)=>{ if (i === 0) { return ( - + @@ -327,7 +327,8 @@ export default class DetailView extends Component { ); } return ( - + { (this.state.isClicked) ? : diff --git a/shared/components/map.js b/shared/components/map.js index b75386a..1a62ace 100644 --- a/shared/components/map.js +++ b/shared/components/map.js @@ -206,6 +206,7 @@ export default class Map extends Component { > {this.props.items.map(item => ( Date: Wed, 16 Nov 2016 16:10:25 +0900 Subject: [PATCH 3/7] selecting on existing location highlights the button (#114) --- shared/components/Create.js | 56 +++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/shared/components/Create.js b/shared/components/Create.js index edacee0..42c4ca7 100644 --- a/shared/components/Create.js +++ b/shared/components/Create.js @@ -157,6 +157,7 @@ class Create extends Component { this.state = { addingNewLocation: false, + addingExistingLocation: false, category: { colorEvent: 'white', colorFacility: 'white', @@ -179,7 +180,9 @@ class Create extends Component { onFocusTitle: false, onFocusDateStart: false, onFocusDateEnd: false, - busyPosting: false + busyPosting: false, + selectItemKey: '', + selectUserKey: '' }; this.getAddressData(); @@ -268,7 +271,9 @@ class Create extends Component { handleAddNewLocation() { this.setState({ - addingNewLocation: true + addingNewLocation: true, + addingExistingLocation: false, + selectItemKey: '' }); } @@ -476,19 +481,22 @@ class Create extends Component { Location - + {this.state.streetNumber} {this.state.streetName} - - {(this.state.Done === true) ? this.state.inputTextTitle : 'Add New Location'} + + {(this.state.Done === true && !this.state.addingExistingLocation) ? this.state.inputTextTitle : 'Add New Location'} - {(this.state.Done === true) ? + {(this.state.Done === true && !this.state.addingExistingLocation) ? : 0 km } @@ -513,24 +521,41 @@ class Create extends Component { return (R * c).toFixed(2); } + handleDoneOnAddingExistingLocation() { + this.handleAddExistingLocation(this.state.key, this.state.userKey, this.state.inputTextCaption, this.state.img); + } + // todo: should limit item.title length if it is too long renderAroundLocations() { return ( this.props.dataSource.map(item => ( { - this.handleAddExistingLocation(item.key, item.userKey, this.state.inputTextCaption, this.state.img); + this.setState({ + Done: true, + addingExistingLocation: true, + selectItemKey: item.key, + selectUserKey: item.userKey + }); }}> - {item.address.substring(0, 18)} - {item.title} + {item.address.substring(0, 18)} + {item.title} - - {this.getDistanceFromLatLonInKm(item.lat, item.lng)} km - + {this.state.selectItemKey === item.key ? + + : + + {this.getDistanceFromLatLonInKm(item.lat, item.lng)} km + + } @@ -661,7 +686,8 @@ class Create extends Component { addingNewLocation={this.state.addingNewLocation} Done={this.state.Done} handleBtnLeft={this.handleBefore.bind(this)} - handleBtnRight={this.handleDone.bind(this)} + handleBtnRight={(this.state.addingExistingLocation === true) ? + this.handleDoneOnAddingExistingLocation.bind(this) : this.handleDone.bind(this)} btnRight={ Done } From 3c95050d537c2b0d23c000735b22f810b79e15a8 Mon Sep 17 00:00:00 2001 From: Youngchan Je Date: Thu, 17 Nov 2016 00:50:08 +0900 Subject: [PATCH 4/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 894d826..254de04 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# goober-mobile +# goober-mobile [![Build Status](https://travis-ci.org/sv-bootcamp/goober-mobile.svg?branch=master)](https://travis-ci.org/sv-bootcamp/goober-mobile) Mobile application From 9ab206b19d40ef84affa4b9b6236bc799bd07d9c Mon Sep 17 00:00:00 2001 From: Patrick Shim Date: Thu, 17 Nov 2016 11:34:54 +0900 Subject: [PATCH 5/7] update jest config --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index b2f0261..bf7bc6b 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "test": "eslint shared/**/*.js && eslint __tests__/**/*.js && jest" }, "jest": { - "preset": "jest-react-native" + "preset": "jest-react-native", + "setupFiles": ["./node_modules/react-native/jestSupport/env.js"] }, "dependencies": { "buffer": "^5.0.0", From df99af0d6224666abb3491488d3c7baaa0d814c9 Mon Sep 17 00:00:00 2001 From: Youngchan Je Date: Thu, 17 Nov 2016 13:41:24 +0900 Subject: [PATCH 6/7] add babel plugin module resolver --- .babelrc | 12 +++++++++++- package.json | 7 +++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.babelrc b/.babelrc index a9ce136..b7a9bdb 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,13 @@ { - "presets": ["react-native"] + "presets": ["react-native"], + "plugins": [ + "transform-object-rest-spread", + ["module-resolver", { + "root": ["./"], + "alias": { + "src": "./src", + "config": "./config" + } + }] + ] } diff --git a/package.json b/package.json index bf7bc6b..cb193e5 100644 --- a/package.json +++ b/package.json @@ -10,12 +10,14 @@ }, "jest": { "preset": "jest-react-native", - "setupFiles": ["./node_modules/react-native/jestSupport/env.js"] + "setupFiles": [ + "./node_modules/react-native/jestSupport/env.js" + ] }, "dependencies": { "buffer": "^5.0.0", "moment": "^2.15.2", - "react": "^15.3.2", + "react": "~15.3.2", "react-addons-shallow-compare": "^15.3.2", "react-addons-update": "^15.3.2", "react-native": "0.35.0", @@ -37,6 +39,7 @@ }, "devDependencies": { "babel-jest": "^15.0.0", + "babel-plugin-module-resolver": "^2.3.0", "babel-preset-react-native": "^1.9.0", "eslint": "^3.6.1", "eslint-config-airbnb": "^12.0.0", From 573408cbe6c23f937b0d415f09856cebdc1a8599 Mon Sep 17 00:00:00 2001 From: Youngchan Je Date: Thu, 17 Nov 2016 13:49:17 +0900 Subject: [PATCH 7/7] add negotiator with latest version in order to avoid node security fail --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index cb193e5..c4f6105 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "dependencies": { "buffer": "^5.0.0", "moment": "^2.15.2", + "negotiator": "^0.6.1", "react": "~15.3.2", "react-addons-shallow-compare": "^15.3.2", "react-addons-update": "^15.3.2",