Skip to content
Open
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 .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
repl-temp-*
.pulp*
dist
cabal-dev
.cabal-sandbox
cabal.sandbox.config
*.o
*.hi
*.chi
*.chs.h
*.lksh*
.virthualenv
.psci_modules/
.test_modules/
bower_components/
node_modules
tmp/
.stack-work/
output
examples/docs/docs/
core-tests/full-core-docs.md
.psc-ide-port
26 changes: 26 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "purescript-rnx-google-places",
"description": "Purescript wrapper for react-native-google-places",
"main": "index.js",
"authors": "Sathish Kumar <sathish.s@atomicits.com>",
"license": "MIT",
"keywords": [
"purescript",
"rnx",
"react-native",
"google-places"
],
"homepage": "",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"purescript-rnx" : "^0.1.2-alpha",
"purescript-react": "^2.0.0"
}
}
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "purescript-rnx-google-places",
"version": "1.0.0",
"description": "Purescript wrapper for react-native-google-places",
"main": "index.js",
"repository": "atomicits/purescript-google-places",
"author": "Sathish Kumar <sathish.s@atomicits.com>",
"license": "MIT",
"dependencies": {
"react-native-google-places": "^2.0.9"
}
}
62 changes: 62 additions & 0 deletions src/RNGooglePlaces.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
'use strict';

var rnxGooglePlaces = require("react-native-google-places");

exports._openAutocompleteModal = function(filterOptions){
return function(success_callback){
return function(error_callback){
return function(){
rnxGooglePlaces.openAutocompleteModal(filterOptions).then(function(resData){
success_callback(resData)();
}).catch(function(error){
error_callback(error)();
});
};
};
};
};

exports._openPlacePickerModal = function(boundsOptions){
return function(success_callback){
return function(error_callback){
return function(){
rnxGooglePlaces.openPlacePickerModal(boundsOptions).then(function (resData){
success_callback (resData)();
}).catch(function (error){
error_callback(error)();
});
};
};
};
};


exports._getAutocompletePredictions = function(queryOptions){
return function(success_callback){
return function(error_callback){
return function(){
rnxGooglePlaces.getAutocompletePredictions(queryOptions).then(function (resData){
success_callback (resData)();
}).catch(function (error){
error_callback(error)();
});
};
};
};
};



exports._lookUpPlaceByID = function(placeID){
return function(success_callback){
return function(error_callback){
return function(){
rnxGooglePlaces.lookUpPlaceByID(placeID).then(function (resData){
success_callback(resData)();
}).catch(function(error){
error_callback(error)();
});
};
};
};
};
93 changes: 93 additions & 0 deletions src/RNGooglePlaces.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
module RNGooglePlaces where

import Prelude

import Control.Monad.Aff (Aff, attempt, makeAff)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Exception (Error)
import Data.Either (Either)


type FilterOptions =
{ type :: String
, country :: String
, latitude :: Number
, longitude :: Number
, radius :: Number
, useOverlay :: Number
}

type BoundOptions =
{ latitude :: Number
, longitude :: Number
, radius :: Number
}

type Query =
{ type :: String
, country :: String
, latitude :: Number
, longitude :: Number
, radius :: Number
}

newtype PlaceId = PlaceId String

type ResponseModal =
{ placeID :: String
, website :: String
, phoneNumber :: String
, address :: String
, name :: String
, types :: Array String
, latitude :: Number
, longitude :: Number
}

type AutocompletePredictionsResponseModal = Array APResponseModal

type APResponseModal =
{ primaryText :: String
, placeID :: String
, secondaryText :: String
, fullText :: String
, types :: Array String
}


foreign import _openAutocompleteModal ::
forall e scallback ecallback. FilterOptions
-> scallback
-> ecallback
-> Eff e Unit

foreign import _openPlacePickerModal ::
forall e scallback ecallback. BoundOptions
-> scallback
-> ecallback
-> Eff e Unit

foreign import _getAutocompletePredictions ::
forall e scallback ecallback. Query
-> scallback
-> ecallback
-> Eff e Unit

foreign import _lookUpPlaceByID ::
forall e scallback ecallback. PlaceId
-> scallback
-> ecallback
-> Eff e Unit


openautoCompleteModal :: forall eff. FilterOptions -> Aff eff (Either Error ResponseModal)
openautoCompleteModal opt = attempt $ makeAff (\error success -> _openAutocompleteModal opt success error)

openplacePickerModal :: forall eff. BoundOptions -> Aff eff (Either Error ResponseModal)
openplacePickerModal opt = attempt $ makeAff (\error success -> _openPlacePickerModal opt success error)

getautocompletePredictions :: forall eff. Query -> Aff eff (Either Error AutocompletePredictionsResponseModal)
getautocompletePredictions opt = attempt $ makeAff (\error success -> _getAutocompletePredictions opt success error)

lookUpPlaceByID :: forall eff. PlaceId -> Aff eff (Either Error ResponseModal)
lookUpPlaceByID opt = attempt $ makeAff (\error success -> _lookUpPlaceByID opt success error)
6 changes: 6 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
react-native-google-places@^2.0.9:
version "2.0.9"
resolved "https://registry.yarnpkg.com/react-native-google-places/-/react-native-google-places-2.0.9.tgz#4df2ad5ac930d1f99e3b7ada3a4cd04f1627c143"