├── example ├── android │ ├── app │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── values-night │ │ │ │ │ │ └── colors.xml │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ ├── ic_launcher_round.png │ │ │ │ │ │ └── ic_launcher_foreground.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ ├── ic_launcher_round.png │ │ │ │ │ │ └── ic_launcher_foreground.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ ├── ic_launcher_round.png │ │ │ │ │ │ └── ic_launcher_foreground.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ ├── ic_launcher_round.png │ │ │ │ │ │ └── ic_launcher_foreground.png │ │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ ├── ic_launcher_round.png │ │ │ │ │ │ └── ic_launcher_foreground.png │ │ │ │ │ ├── drawable-hdpi │ │ │ │ │ │ └── splashscreen_image.png │ │ │ │ │ ├── drawable-mdpi │ │ │ │ │ │ └── splashscreen_image.png │ │ │ │ │ ├── drawable-xhdpi │ │ │ │ │ │ └── splashscreen_image.png │ │ │ │ │ ├── drawable-xxhdpi │ │ │ │ │ │ └── splashscreen_image.png │ │ │ │ │ ├── drawable-xxxhdpi │ │ │ │ │ │ └── splashscreen_image.png │ │ │ │ │ ├── drawable │ │ │ │ │ │ ├── splashscreen.xml │ │ │ │ │ │ └── rn_edit_text_material.xml │ │ │ │ │ ├── values │ │ │ │ │ │ ├── colors.xml │ │ │ │ │ │ ├── strings.xml │ │ │ │ │ │ └── styles.xml │ │ │ │ │ └── mipmap-anydpi-v26 │ │ │ │ │ │ ├── ic_launcher.xml │ │ │ │ │ │ └── ic_launcher_round.xml │ │ │ │ ├── java │ │ │ │ │ └── expo │ │ │ │ │ │ └── modules │ │ │ │ │ │ └── placepicker │ │ │ │ │ │ └── example │ │ │ │ │ │ ├── MainApplication.kt │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ └── AndroidManifest.xml │ │ │ └── debug │ │ │ │ └── AndroidManifest.xml │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── .gitignore │ ├── react-settings-plugin │ │ ├── src │ │ │ └── main │ │ │ │ └── kotlin │ │ │ │ └── expo │ │ │ │ └── plugins │ │ │ │ └── ReactSettingsPlugin.kt │ │ └── build.gradle.kts │ ├── build.gradle │ ├── gradle.properties │ ├── settings.gradle │ ├── gradlew.bat │ └── gradlew ├── assets │ ├── icon.png │ ├── favicon.png │ ├── splash.png │ └── adaptive-icon.png ├── babel.config.js ├── ios │ ├── reactnativeplacepickerexample │ │ ├── Images.xcassets │ │ │ ├── Contents.json │ │ │ ├── SplashScreen.imageset │ │ │ │ ├── image.png │ │ │ │ └── Contents.json │ │ │ ├── SplashScreenBackground.imageset │ │ │ │ ├── image.png │ │ │ │ └── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ ├── App-Icon-1024x1024@1x.png │ │ │ │ └── Contents.json │ │ ├── noop-file.swift │ │ ├── reactnativeplacepickerexample-Bridging-Header.h │ │ ├── AppDelegate.h │ │ ├── reactnativeplacepickerexample.entitlements │ │ ├── main.m │ │ ├── Supporting │ │ │ └── Expo.plist │ │ ├── PrivacyInfo.xcprivacy │ │ ├── Info.plist │ │ ├── AppDelegate.mm │ │ └── SplashScreen.storyboard │ ├── Podfile.properties.json │ ├── reactnativeplacepickerexample.xcworkspace │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── contents.xcworkspacedata │ ├── .gitignore │ ├── .xcode.env │ ├── Podfile │ └── reactnativeplacepickerexample.xcodeproj │ │ ├── xcshareddata │ │ └── xcschemes │ │ │ └── reactnativeplacepickerexample.xcscheme │ │ └── project.pbxproj ├── tsconfig.json ├── App.tsx ├── .gitignore ├── webpack.config.js ├── Components │ ├── Button.tsx │ └── Row.tsx ├── package.json ├── metro.config.js ├── app.json └── screens │ └── Home.tsx ├── .eslintrc.js ├── android ├── src │ └── main │ │ ├── res │ │ ├── drawable │ │ │ ├── pinshadow.xml │ │ │ ├── ic_baseline_check_24.xml │ │ │ ├── ic_baseline_close_24.xml │ │ │ ├── ic_baseline_location_on_24.xml │ │ │ ├── ic_baseline_search_24.xml │ │ │ └── ic_baseline_my_location_24.xml │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── style.xml │ │ ├── values-night │ │ │ ├── colors.xml │ │ │ └── style.xml │ │ ├── menu │ │ │ └── barbuttonitems.xml │ │ └── layout │ │ │ └── activity_place_picker.xml │ │ ├── java │ │ └── expo │ │ │ └── modules │ │ │ └── placepicker │ │ │ ├── Types │ │ │ ├── PlacePickerPresentationStyle.kt │ │ │ ├── PlacePickerCoordinate.kt │ │ │ ├── PlacePickerAddress.kt │ │ │ ├── PlacePickerResult.kt │ │ │ └── PlacePickerOptions.kt │ │ │ ├── PlacePickerState.kt │ │ │ ├── ReactNativePlacePickerModule.kt │ │ │ └── PlacePickerActivity.kt │ │ └── AndroidManifest.xml └── build.gradle ├── expo-module.config.json ├── tsconfig.json ├── .npmignore ├── src ├── ReactNativePlacePickerModule.ts ├── ReactNativePlacePickerModule.web.ts ├── index.ts └── ReactNativePlacePicker.types.ts ├── ios ├── Types │ ├── PlacePickerPresentationStyle.swift │ ├── PlacePickerCoordinate.swift │ ├── PlacePickerResult.swift │ ├── PlacePickerOptions.swift │ └── PlacePickerAddress.swift ├── Helpers │ ├── CustomSearchComplation.swift │ ├── HighlightedText.swift │ ├── UIColor+Hex.swift │ ├── UIView+AnchorPoint.swift │ ├── DropdownTableViewCell.swift │ └── DropDown.swift ├── ReactNativePlacePicker.podspec └── ReactNativePlacePickerModule.swift ├── .gitignore ├── package.json ├── CONTRIBUTING.md ├── CODE_OF_CONDUCT.md └── README.md /example/android/app/src/main/res/values-night/colors.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/assets/icon.png -------------------------------------------------------------------------------- /example/assets/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/assets/favicon.png -------------------------------------------------------------------------------- /example/assets/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/assets/splash.png -------------------------------------------------------------------------------- /example/assets/adaptive-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/assets/adaptive-icon.png -------------------------------------------------------------------------------- /example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/debug.keystore -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: ['universe/native', 'universe/web'], 4 | ignorePatterns: ['build'], 5 | }; 6 | -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = function (api) { 2 | api.cache(true); 3 | return { 4 | presets: ['babel-preset-expo'], 5 | }; 6 | }; 7 | -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "expo" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample/noop-file.swift: -------------------------------------------------------------------------------- 1 | // 2 | // @generated 3 | // A blank Swift file must be created for native modules with Swift files to work correctly. 4 | // 5 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-hdpi/splashscreen_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/drawable-hdpi/splashscreen_image.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-mdpi/splashscreen_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/drawable-mdpi/splashscreen_image.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-xhdpi/splashscreen_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/drawable-xhdpi/splashscreen_image.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-xxhdpi/splashscreen_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/drawable-xxhdpi/splashscreen_image.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample/reactnativeplacepickerexample-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-xxxhdpi/splashscreen_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/drawable-xxxhdpi/splashscreen_image.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/splashscreen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | @interface AppDelegate : EXAppDelegateWrapper 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Android/IntelliJ 6 | # 7 | build/ 8 | .idea 9 | .gradle 10 | local.properties 11 | *.iml 12 | *.hprof 13 | .cxx/ 14 | 15 | # Bundle artifacts 16 | *.jsbundle 17 | -------------------------------------------------------------------------------- /android/src/main/res/drawable/pinshadow.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample/Images.xcassets/SplashScreen.imageset/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/ios/reactnativeplacepickerexample/Images.xcassets/SplashScreen.imageset/image.png -------------------------------------------------------------------------------- /android/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFFFFF 4 | #DDDDDD 5 | #000000 6 | -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample/Images.xcassets/SplashScreenBackground.imageset/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/ios/reactnativeplacepickerexample/Images.xcassets/SplashScreenBackground.imageset/image.png -------------------------------------------------------------------------------- /expo-module.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "platforms": ["ios", "android"], 3 | "ios": { 4 | "modules": ["ReactNativePlacePickerModule"] 5 | }, 6 | "android": { 7 | "modules": ["expo.modules.placepicker.ReactNativePlacePickerModule"] 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /android/src/main/res/values-night/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #222222 4 | #000000 5 | #FFFFFF 6 | -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample/Images.xcassets/AppIcon.appiconset/App-Icon-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b0iq/react-native-place-picker/HEAD/example/ios/reactnativeplacepickerexample/Images.xcassets/AppIcon.appiconset/App-Icon-1024x1024@1x.png -------------------------------------------------------------------------------- /android/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Cancel 3 | Done 4 | Search... 5 | My Location 6 | 7 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | // @generated by expo-module-scripts 2 | { 3 | "extends": "expo-module-scripts/tsconfig.base", 4 | "compilerOptions": { 5 | "outDir": "./build" 6 | }, 7 | "include": ["./src"], 8 | "exclude": ["**/__mocks__/*", "**/__tests__/*"] 9 | } 10 | -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample/reactnativeplacepickerexample.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "expo/tsconfig.base", 3 | "compilerOptions": { 4 | "strict": true, 5 | "paths": { 6 | "react-native-place-picker": ["../src/index"], 7 | "react-native-place-picker/*": ["../src/*"] 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /example/ios/Podfile.properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "expo.jsEngine": "hermes", 3 | "EX_DEV_CLIENT_NETWORK_INSPECTOR": "true", 4 | "newArchEnabled": "true", 5 | "apple.extraPods": "[]", 6 | "apple.ccacheEnabled": "false", 7 | "apple.privacyManifestAggregationEnabled": "true" 8 | } 9 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | #ffffff 3 | #ffffff 4 | #023c69 5 | #ffffff 6 | -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char * argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Exclude all top-level hidden directories by convention 2 | /.*/ 3 | 4 | # Exclude tarballs generated by `npm pack` 5 | /*.tgz 6 | 7 | __mocks__ 8 | __tests__ 9 | 10 | /babel.config.js 11 | /android/src/androidTest/ 12 | /android/src/test/ 13 | /android/build/ 14 | /example/ 15 | -------------------------------------------------------------------------------- /android/src/main/java/expo/modules/placepicker/Types/PlacePickerPresentationStyle.kt: -------------------------------------------------------------------------------- 1 | package expo.modules.placepicker 2 | 3 | import expo.modules.kotlin.types.Enumerable 4 | 5 | 6 | enum class PlacePickerPresentationStyle(val value: String) : Enumerable { 7 | modal("modal"), 8 | fullscreen("fullscreen") 9 | } -------------------------------------------------------------------------------- /src/ReactNativePlacePickerModule.ts: -------------------------------------------------------------------------------- 1 | import { requireNativeModule } from "expo-modules-core"; 2 | 3 | // It loads the native module object from the JSI or falls back to 4 | // the bridge module (from NativeModulesProxy) if the remote debugger is on. 5 | export default requireNativeModule("ReactNativePlacePicker"); 6 | -------------------------------------------------------------------------------- /ios/Types/PlacePickerPresentationStyle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PlacePickerPresentationStyle.swift 3 | // react-native-place-picker 4 | // 5 | // Created by b0iq on 11/11/2022. 6 | // 7 | 8 | import ExpoModulesCore 9 | 10 | enum PlacePickerPresentationStyle: String, Enumerable { 11 | case modal, fullscreen 12 | } 13 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | react-native-place-picker-example 3 | contain 4 | false 5 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /ios/Helpers/CustomSearchComplation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomSearchComplation.swift 3 | // react-native-place-picker 4 | // 5 | // Created by b0iq on 01/09/2023. 6 | // 7 | 8 | import Foundation 9 | 10 | struct CustomSearchCompletion { 11 | var attrTitle: NSAttributedString? 12 | var attrSubtitle: NSAttributedString? 13 | } 14 | -------------------------------------------------------------------------------- /src/ReactNativePlacePickerModule.web.ts: -------------------------------------------------------------------------------- 1 | import type { 2 | PlacePickerResults, 3 | PlacePickerOptions, 4 | } from "./ReactNativePlacePicker.types"; 5 | 6 | export default { 7 | async pickPlace(_: PlacePickerOptions): Promise { 8 | throw new Error("Method pickPlace is not available on web"); 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /ios/Types/PlacePickerCoordinate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PlacePickerCoordinate.swift 3 | // react-native-place-picker 4 | // 5 | // Created by b0iq on 10/11/2022. 6 | // 7 | 8 | import ExpoModulesCore 9 | 10 | struct PlacePickerCoordinate: Record { 11 | @Field 12 | var latitude: Double 13 | @Field 14 | var longitude: Double 15 | } 16 | -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "filename": "App-Icon-1024x1024@1x.png", 5 | "idiom": "universal", 6 | "platform": "ios", 7 | "size": "1024x1024" 8 | } 9 | ], 10 | "info": { 11 | "version": 1, 12 | "author": "expo" 13 | } 14 | } -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /android/src/main/java/expo/modules/placepicker/Types/PlacePickerCoordinate.kt: -------------------------------------------------------------------------------- 1 | package expo.modules.placepicker 2 | 3 | import expo.modules.kotlin.records.Field 4 | import expo.modules.kotlin.records.Record 5 | 6 | class PlacePickerCoordinate : Record { 7 | @Field 8 | var latitude: Double = 0.0 9 | 10 | @Field 11 | var longitude: Double = 0.0 12 | } 13 | -------------------------------------------------------------------------------- /example/android/react-settings-plugin/src/main/kotlin/expo/plugins/ReactSettingsPlugin.kt: -------------------------------------------------------------------------------- 1 | package expo.plugins 2 | 3 | import org.gradle.api.Plugin 4 | import org.gradle.api.initialization.Settings 5 | 6 | class ReactSettingsPlugin : Plugin { 7 | override fun apply(settings: Settings) { 8 | // Do nothing, just register the plugin. 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /android/src/main/java/expo/modules/placepicker/PlacePickerState.kt: -------------------------------------------------------------------------------- 1 | package expo.modules.placepicker 2 | 3 | import expo.modules.kotlin.Promise 4 | 5 | class PlacePickerState { 6 | companion object { 7 | var globalPromise: Promise? = null 8 | var globalOptions: PlacePickerOptions = PlacePickerOptions() 9 | var globalResult: PlacePickerResult = PlacePickerResult() 10 | } 11 | } -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import type { 2 | PlacePickerOptions, 3 | PlacePickerResults, 4 | } from "./ReactNativePlacePicker.types"; 5 | import ReactNativePlacePickerModule from "./ReactNativePlacePickerModule"; 6 | 7 | export async function pickPlace( 8 | options?: PlacePickerOptions 9 | ): Promise { 10 | return await ReactNativePlacePickerModule.pickPlace(options); 11 | } 12 | 13 | export * from "./ReactNativePlacePicker.types"; 14 | -------------------------------------------------------------------------------- /android/src/main/res/drawable/ic_baseline_check_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample/Supporting/Expo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | EXUpdatesCheckOnLaunch 6 | ALWAYS 7 | EXUpdatesEnabled 8 | 9 | EXUpdatesLaunchWaitMs 10 | 0 11 | 12 | -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample/Images.xcassets/SplashScreen.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "idiom": "universal", 5 | "filename": "image.png", 6 | "scale": "1x" 7 | }, 8 | { 9 | "idiom": "universal", 10 | "scale": "2x" 11 | }, 12 | { 13 | "idiom": "universal", 14 | "scale": "3x" 15 | } 16 | ], 17 | "info": { 18 | "version": 1, 19 | "author": "expo" 20 | } 21 | } -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | .xcode.env.local 25 | 26 | # Bundle artifacts 27 | *.jsbundle 28 | 29 | # CocoaPods 30 | /Pods/ 31 | -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample/Images.xcassets/SplashScreenBackground.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "idiom": "universal", 5 | "filename": "image.png", 6 | "scale": "1x" 7 | }, 8 | { 9 | "idiom": "universal", 10 | "scale": "2x" 11 | }, 12 | { 13 | "idiom": "universal", 14 | "scale": "3x" 15 | } 16 | ], 17 | "info": { 18 | "version": 1, 19 | "author": "expo" 20 | } 21 | } -------------------------------------------------------------------------------- /example/App.tsx: -------------------------------------------------------------------------------- 1 | import { NavigationContainer } from "@react-navigation/native"; 2 | import { createNativeStackNavigator } from "@react-navigation/native-stack"; 3 | 4 | import Home from "./screens/Home"; 5 | 6 | const Stack = createNativeStackNavigator(); 7 | export default function App() { 8 | return ( 9 | 10 | 11 | 12 | 13 | 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /example/android/react-settings-plugin/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 2 | 3 | plugins { 4 | kotlin("jvm") version "1.9.24" 5 | id("java-gradle-plugin") 6 | } 7 | 8 | repositories { 9 | mavenCentral() 10 | } 11 | 12 | gradlePlugin { 13 | plugins { 14 | create("reactSettingsPlugin") { 15 | id = "com.facebook.react.settings" 16 | implementationClass = "expo.plugins.ReactSettingsPlugin" 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /android/src/main/res/drawable/ic_baseline_close_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /example/ios/.xcode.env: -------------------------------------------------------------------------------- 1 | # This `.xcode.env` file is versioned and is used to source the environment 2 | # used when running script phases inside Xcode. 3 | # To customize your local environment, you can create an `.xcode.env.local` 4 | # file that is not versioned. 5 | 6 | # NODE_BINARY variable contains the PATH to the node executable. 7 | # 8 | # Customize the NODE_BINARY variable here. 9 | # For example, to use nvm with brew, add the following line 10 | # . "$(brew --prefix nvm)/nvm.sh" --no-use 11 | export NODE_BINARY=$(command -v node) 12 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files 2 | 3 | # dependencies 4 | node_modules/ 5 | 6 | # Expo 7 | .expo/ 8 | dist/ 9 | web-build/ 10 | 11 | # Native 12 | *.orig.* 13 | *.jks 14 | *.p8 15 | *.p12 16 | *.key 17 | *.mobileprovision 18 | 19 | # Metro 20 | .metro-health-check* 21 | 22 | # debug 23 | npm-debug.* 24 | yarn-debug.* 25 | yarn-error.* 26 | 27 | # macOS 28 | .DS_Store 29 | *.pem 30 | 31 | # local env files 32 | .env*.local 33 | 34 | # typescript 35 | *.tsbuildinfo 36 | -------------------------------------------------------------------------------- /android/src/main/java/expo/modules/placepicker/Types/PlacePickerAddress.kt: -------------------------------------------------------------------------------- 1 | package expo.modules.placepicker 2 | 3 | import expo.modules.kotlin.records.Field 4 | import expo.modules.kotlin.records.Record 5 | 6 | class PlacePickerAddress : Record { 7 | @Field 8 | var name: String = "" 9 | 10 | @Field 11 | var streetName: String = "" 12 | 13 | @Field 14 | var city: String = "" 15 | 16 | @Field 17 | var state: String = "" 18 | 19 | @Field 20 | var zipCode: String = "" 21 | 22 | @Field 23 | var country: String = "" 24 | } 25 | -------------------------------------------------------------------------------- /example/webpack.config.js: -------------------------------------------------------------------------------- 1 | const createConfigAsync = require('@expo/webpack-config'); 2 | const path = require('path'); 3 | 4 | module.exports = async (env, argv) => { 5 | const config = await createConfigAsync( 6 | { 7 | ...env, 8 | babel: { 9 | dangerouslyAddModulePathsToTranspile: ['react-native-place-picker'], 10 | }, 11 | }, 12 | argv 13 | ); 14 | config.resolve.modules = [ 15 | path.resolve(__dirname, './node_modules'), 16 | path.resolve(__dirname, '../node_modules'), 17 | ]; 18 | 19 | return config; 20 | }; 21 | -------------------------------------------------------------------------------- /ios/Helpers/HighlightedText.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HighlightedText.swift 3 | // react-native-place-picker 4 | // 5 | // Created by b0iq on 01/09/2023. 6 | // 7 | 8 | import Foundation 9 | 10 | func highlightedText(_ text: String, inRanges ranges: [NSValue]) -> NSAttributedString { 11 | let attributedText = NSMutableAttributedString(string: text) 12 | for value in ranges { 13 | attributedText.addAttribute(NSAttributedString.Key.backgroundColor, value: UIColor.black.withAlphaComponent(0.25), range: value.rangeValue) 14 | } 15 | return attributedText 16 | } 17 | -------------------------------------------------------------------------------- /android/src/main/res/drawable/ic_baseline_location_on_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # react-native-reanimated 11 | -keep class com.swmansion.reanimated.** { *; } 12 | -keep class com.facebook.react.turbomodule.** { *; } 13 | 14 | # Add any project specific keep options here: 15 | -------------------------------------------------------------------------------- /android/src/main/res/drawable/ic_baseline_search_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /android/src/main/res/drawable/ic_baseline_my_location_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # VSCode 6 | .vscode/ 7 | jsconfig.json 8 | 9 | # Xcode 10 | # 11 | build/ 12 | *.pbxuser 13 | !default.pbxuser 14 | *.mode1v3 15 | !default.mode1v3 16 | *.mode2v3 17 | !default.mode2v3 18 | *.perspectivev3 19 | !default.perspectivev3 20 | xcuserdata 21 | *.xccheckout 22 | *.moved-aside 23 | DerivedData 24 | *.hmap 25 | *.ipa 26 | *.xcuserstate 27 | project.xcworkspace 28 | 29 | # Android/IJ 30 | # 31 | .classpath 32 | .cxx 33 | .gradle 34 | .idea 35 | .project 36 | .settings 37 | local.properties 38 | android.iml 39 | android/app/libs 40 | android/keystores/debug.keystore 41 | 42 | # Cocoapods 43 | # 44 | example/ios/Pods 45 | 46 | # Ruby 47 | example/vendor/ 48 | 49 | # node.js 50 | # 51 | node_modules/ 52 | npm-debug.log 53 | yarn-debug.log 54 | yarn-error.log 55 | 56 | # Expo 57 | .expo/* 58 | -------------------------------------------------------------------------------- /ios/Types/PlacePickerResult.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PlacePickerResult.swift 3 | // react-native-place-picker 4 | // 5 | // Created by b0iq on 11/11/2022. 6 | // 7 | 8 | import ExpoModulesCore 9 | 10 | struct PlacePickerResult: Record { 11 | @Field 12 | var coordinate: PlacePickerCoordinate 13 | @Field 14 | var address: PlacePickerAddress? 15 | @Field 16 | var didCancel: Bool 17 | @Field 18 | var radius: Double? 19 | @Field 20 | var radiusCoordinates: RadiusCoordinates? 21 | } 22 | 23 | struct BoundsCoordinates: Record { 24 | @Field 25 | var northeast: PlacePickerCoordinate 26 | @Field 27 | var southwest: PlacePickerCoordinate 28 | } 29 | 30 | struct RadiusCoordinates: Record { 31 | @Field 32 | var center: PlacePickerCoordinate 33 | @Field 34 | var bounds: BoundsCoordinates 35 | } 36 | -------------------------------------------------------------------------------- /example/Components/Button.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { TouchableOpacity, View, Text, StyleSheet } from 'react-native'; 3 | 4 | export const Button = ({ 5 | label, 6 | red = false, 7 | onPress = () => {}, 8 | }: { 9 | label: string; 10 | red?: boolean; 11 | onPress?: () => void; 12 | }) => ( 13 | 14 | 15 | {label} 16 | 17 | 18 | ); 19 | 20 | const styles = StyleSheet.create({ 21 | button: { 22 | backgroundColor: '#007aff', 23 | padding: 10, 24 | borderRadius: 5, 25 | marginBottom: 5, 26 | }, 27 | buttonLabel: { 28 | color: '#fff', 29 | fontSize: 16, 30 | fontWeight: '600', 31 | textAlign: 'center', 32 | }, 33 | }); 34 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-place-picker-example", 3 | "version": "1.0.1", 4 | "main": "expo/AppEntry.js", 5 | "scripts": { 6 | "start": "expo start", 7 | "android": "expo run:android", 8 | "ios": "expo run:ios", 9 | "web": "expo start --web" 10 | }, 11 | "dependencies": { 12 | "@react-navigation/native": "^6.1.18", 13 | "@react-navigation/native-stack": "^6.11.0", 14 | "expo": "~51.0.28", 15 | "expo-build-properties": "~0.12.5", 16 | "react": "18.2.0", 17 | "react-native": "0.74.5", 18 | "react-native-safe-area-context": "4.10.5", 19 | "react-native-screens": "3.31.1" 20 | }, 21 | "devDependencies": { 22 | "@babel/core": "^7.20.0", 23 | "@types/react": "~18.2.45", 24 | "typescript": "^5.1.3" 25 | }, 26 | "private": true, 27 | "expo": { 28 | "autolinking": { 29 | "nativeModulesDir": ".." 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ios/ReactNativePlacePicker.podspec: -------------------------------------------------------------------------------- 1 | require 'json' 2 | 3 | package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json'))) 4 | 5 | Pod::Spec.new do |s| 6 | s.name = 'ReactNativePlacePicker' 7 | s.version = package['version'] 8 | s.summary = package['description'] 9 | s.description = package['description'] 10 | s.license = package['license'] 11 | s.author = package['author'] 12 | s.homepage = package['homepage'] 13 | s.platforms = { :ios => '13.4', :tvos => '13.4' } 14 | s.swift_version = '5.4' 15 | s.source = { git: 'https://github.com/b0iq/react-native-place-picker' } 16 | 17 | s.dependency 'ExpoModulesCore' 18 | 19 | # Swift/Objective-C compatibility 20 | s.pod_target_xcconfig = { 21 | 'DEFINES_MODULE' => 'YES', 22 | 'SWIFT_COMPILATION_MODE' => 'wholemodule' 23 | } 24 | 25 | s.source_files = "**/*.{h,m,swift}" 26 | end 27 | -------------------------------------------------------------------------------- /ios/Helpers/UIColor+Hex.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+Hex.swift 3 | // react-native-place-picker 4 | // 5 | // Created by b0iq on 10/11/2022. 6 | // 7 | 8 | import Foundation 9 | 10 | extension UIColor { 11 | convenience init(_ hex: String) { 12 | var cString:String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased() 13 | if (cString.hasPrefix("#")) { 14 | cString.remove(at: cString.startIndex) 15 | } 16 | if ((cString.count) != 6) { 17 | self.init(white: 0.5, alpha: 0.5) 18 | } 19 | var rgbValue:UInt64 = 0 20 | Scanner(string: cString).scanHexInt64(&rgbValue) 21 | self.init( 22 | red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0, 23 | green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0, 24 | blue: CGFloat(rgbValue & 0x0000FF) / 255.0, 25 | alpha: CGFloat(1.0) 26 | ) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ios/Helpers/UIView+AnchorPoint.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+AnchorPoint.swift 3 | // react-native-place-picker 4 | // 5 | // Created by b0iq on 11/11/2022. 6 | // 7 | 8 | import Foundation 9 | 10 | extension UIView { 11 | func setAnchorPoint(_ point: CGPoint) { 12 | var newPoint = CGPoint(x: bounds.size.width * point.x, y: bounds.size.height * point.y) 13 | var oldPoint = CGPoint(x: bounds.size.width * layer.anchorPoint.x, y: bounds.size.height * layer.anchorPoint.y); 14 | 15 | newPoint = newPoint.applying(transform) 16 | oldPoint = oldPoint.applying(transform) 17 | 18 | var position = layer.position 19 | 20 | position.x -= oldPoint.x 21 | position.x += newPoint.x 22 | 23 | position.y -= oldPoint.y 24 | position.y += newPoint.y 25 | 26 | layer.position = position 27 | layer.anchorPoint = point 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /android/src/main/java/expo/modules/placepicker/Types/PlacePickerResult.kt: -------------------------------------------------------------------------------- 1 | package expo.modules.placepicker 2 | 3 | import expo.modules.kotlin.records.Field 4 | import expo.modules.kotlin.records.Record 5 | 6 | class PlacePickerResult : Record { 7 | @Field 8 | var coordinate: PlacePickerCoordinate? = null 9 | 10 | @Field 11 | var address: PlacePickerAddress? = null 12 | 13 | @Field 14 | var didCancel: Boolean? = null 15 | 16 | @Field 17 | var radius: Double? = null 18 | 19 | @Field 20 | var radiusCoordinates: RadiusCoordinates? = null 21 | } 22 | 23 | class BoundsCoordinates : Record { 24 | @Field 25 | var northeast: PlacePickerCoordinate? = null 26 | @Field 27 | var southwest: PlacePickerCoordinate? = null 28 | } 29 | 30 | class RadiusCoordinates : Record { 31 | @Field 32 | var center: PlacePickerCoordinate? = null 33 | @Field 34 | var bounds: BoundsCoordinates? = null 35 | } 36 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 14 | 17 | -------------------------------------------------------------------------------- /ios/ReactNativePlacePickerModule.swift: -------------------------------------------------------------------------------- 1 | import ExpoModulesCore 2 | 3 | public class ReactNativePlacePickerModule: Module { 4 | 5 | public func definition() -> ModuleDefinition { 6 | 7 | Name("ReactNativePlacePicker") 8 | 9 | AsyncFunction("pickPlace") { (options: PlacePickerOptions?, promise: Promise) in 10 | let keyWindow = UIApplication.shared.windows.filter {$0.isKeyWindow}.first 11 | if var topController = keyWindow?.rootViewController { 12 | while let presentedViewController = topController.presentedViewController { 13 | topController = presentedViewController 14 | } 15 | let placePickerViewController = UINavigationController(rootViewController: PlacePickerViewController(options ?? PlacePickerOptions(), promise)) 16 | if options?.presentationStyle == .fullscreen { 17 | placePickerViewController.modalPresentationStyle = .fullScreen 18 | } 19 | topController.present(placePickerViewController, animated: true) 20 | } 21 | }.runOnQueue(.main) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /android/src/main/res/menu/barbuttonitems.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 17 | 23 | 29 | 30 | -------------------------------------------------------------------------------- /example/metro.config.js: -------------------------------------------------------------------------------- 1 | // Learn more https://docs.expo.io/guides/customizing-metro 2 | const { getDefaultConfig } = require('expo/metro-config'); 3 | const path = require('path'); 4 | 5 | const config = getDefaultConfig(__dirname); 6 | 7 | // npm v7+ will install ../node_modules/react and ../node_modules/react-native because of peerDependencies. 8 | // To prevent the incompatible react-native between ./node_modules/react-native and ../node_modules/react-native, 9 | // excludes the one from the parent folder when bundling. 10 | config.resolver.blockList = [ 11 | ...Array.from(config.resolver.blockList ?? []), 12 | new RegExp(path.resolve('..', 'node_modules', 'react')), 13 | new RegExp(path.resolve('..', 'node_modules', 'react-native')), 14 | ]; 15 | 16 | config.resolver.nodeModulesPaths = [ 17 | path.resolve(__dirname, './node_modules'), 18 | path.resolve(__dirname, '../node_modules'), 19 | ]; 20 | 21 | config.resolver.extraNodeModules = { 22 | 'react-native-place-picker': '..', 23 | }; 24 | 25 | config.watchFolders = [path.resolve(__dirname, '..')]; 26 | 27 | config.transformer.getTransformOptions = async () => ({ 28 | transform: { 29 | experimentalImportSupport: false, 30 | inlineRequires: true, 31 | }, 32 | }); 33 | 34 | module.exports = config; 35 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "expo": { 3 | "name": "react-native-place-picker-example", 4 | "slug": "react-native-place-picker-example", 5 | "version": "1.0.0", 6 | "orientation": "portrait", 7 | "icon": "./assets/icon.png", 8 | "userInterfaceStyle": "light", 9 | "splash": { 10 | "image": "./assets/splash.png", 11 | "resizeMode": "contain", 12 | "backgroundColor": "#ffffff" 13 | }, 14 | "ios": { 15 | "supportsTablet": true, 16 | "bundleIdentifier": "expo.modules.placepicker.example", 17 | "infoPlist": { 18 | "NSLocationWhenInUseUsageDescription": "This app needs access to location when open.", 19 | "NSLocationUsageDescription": "This app needs access to location." 20 | } 21 | }, 22 | "android": { 23 | "adaptiveIcon": { 24 | "foregroundImage": "./assets/adaptive-icon.png", 25 | "backgroundColor": "#ffffff" 26 | }, 27 | "package": "expo.modules.placepicker.example" 28 | }, 29 | "web": { 30 | "favicon": "./assets/favicon.png" 31 | }, 32 | "plugins": [ 33 | [ 34 | "expo-build-properties", 35 | { 36 | "ios": { 37 | "newArchEnabled": true 38 | }, 39 | "android": { 40 | "newArchEnabled": true 41 | } 42 | } 43 | ] 44 | ] 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ios/Helpers/DropdownTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DropDownCell.swift 3 | // react-native-place-picker 4 | // 5 | // Created by b0iq on 01/09/2023. 6 | // 7 | 8 | import UIKit 9 | 10 | class DropdownTableViewCell: UITableViewCell { 11 | 12 | static let reuseIdentifier = "DropdownTableViewCell" 13 | 14 | let label: UILabel = { 15 | let label = UILabel() 16 | label.textColor = .black 17 | label.translatesAutoresizingMaskIntoConstraints = false 18 | return label 19 | }() 20 | 21 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 22 | super.init(style: style, reuseIdentifier: reuseIdentifier) 23 | setup() 24 | } 25 | 26 | required init?(coder: NSCoder) { 27 | super.init(coder: coder) 28 | setup() 29 | } 30 | 31 | func setup() { 32 | contentView.addSubview(label) 33 | NSLayoutConstraint.activate([ 34 | label.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 8), 35 | label.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -8), 36 | label.topAnchor.constraint(equalTo: contentView.topAnchor), 37 | label.bottomAnchor.constraint(equalTo: contentView.bottomAnchor) 38 | ]) 39 | } 40 | 41 | func set(_ text: String) { 42 | label.text = text 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-place-picker", 3 | "version": "3.1.0", 4 | "description": "Pick place with single click", 5 | "main": "build/index.js", 6 | "types": "build/index.d.ts", 7 | "scripts": { 8 | "build": "expo-module build", 9 | "clean": "expo-module clean", 10 | "lint": "expo-module lint", 11 | "test": "expo-module test", 12 | "prepare": "expo-module prepare", 13 | "prepublishOnly": "expo-module prepublishOnly", 14 | "expo-module": "expo-module", 15 | "open:ios": "xed example/ios", 16 | "open:android": "open -a \"Android Studio\" example/android" 17 | }, 18 | "keywords": [ 19 | "react-native", 20 | "expo", 21 | "react-native-place-picker", 22 | "ReactNativePlacePicker" 23 | ], 24 | "repository": "https://github.com/b0iq/react-native-place-picker", 25 | "bugs": { 26 | "url": "https://github.com/b0iq/react-native-place-picker/issues" 27 | }, 28 | "author": "b0iq (https://github.com/b0iq)", 29 | "license": "MIT", 30 | "homepage": "https://github.com/b0iq/react-native-place-picker#readme", 31 | "dependencies": {}, 32 | "devDependencies": { 33 | "@types/react": "^18.3.7", 34 | "expo-module-scripts": "^3.5.2", 35 | "expo-modules-core": "^1.12.24" 36 | }, 37 | "peerDependencies": { 38 | "expo": "*", 39 | "react": "*", 40 | "react-native": "*" 41 | }, 42 | "packageManager": "yarn@1.22.22" 43 | } -------------------------------------------------------------------------------- /ios/Types/PlacePickerOptions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Options.swift 3 | // react-native-place-picker 4 | // 5 | // Created by b0iq on 10/11/2022. 6 | // 7 | 8 | import ExpoModulesCore 9 | 10 | struct PlacePickerOptions: Record { 11 | @Field 12 | var presentationStyle: PlacePickerPresentationStyle = .fullscreen 13 | @Field 14 | var title: String = "Choose Place" 15 | @Field 16 | var searchPlaceholder: String = "Search..." 17 | @Field 18 | var color: String = "FF0000" 19 | @Field 20 | var contrastColor: String = "FFFFFF" 21 | @Field 22 | var locale: String = "en-US" 23 | @Field 24 | var initialCoordinates: PlacePickerCoordinate = PlacePickerCoordinate(latitude: .init(wrappedValue: 25.2048), longitude: .init(wrappedValue: 55.2708)) 25 | @Field 26 | var enableGeocoding: Bool = true 27 | @Field 28 | var enableSearch: Bool = true 29 | @Field 30 | var enableUserLocation: Bool = true 31 | @Field 32 | var enableLargeTitle: Bool = true 33 | @Field 34 | var rejectOnCancel: Bool = true 35 | @Field 36 | var enableRangeSelection: Bool = false 37 | @Field 38 | var initialRadius: Double = 1000 39 | @Field 40 | var minRadius: Double = 100 41 | @Field 42 | var maxRadius: Double = 10000 43 | @Field 44 | var radiusColor: String = "" 45 | @Field 46 | var radiusStrokeColor: String = "" 47 | @Field 48 | var radiusStrokeWidth: Double = 2 49 | } 50 | -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample/PrivacyInfo.xcprivacy: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSPrivacyAccessedAPITypes 6 | 7 | 8 | NSPrivacyAccessedAPIType 9 | NSPrivacyAccessedAPICategoryUserDefaults 10 | NSPrivacyAccessedAPITypeReasons 11 | 12 | CA92.1 13 | 14 | 15 | 16 | NSPrivacyAccessedAPIType 17 | NSPrivacyAccessedAPICategoryFileTimestamp 18 | NSPrivacyAccessedAPITypeReasons 19 | 20 | 0A2A.1 21 | 3B52.1 22 | C617.1 23 | 24 | 25 | 26 | NSPrivacyAccessedAPIType 27 | NSPrivacyAccessedAPICategoryDiskSpace 28 | NSPrivacyAccessedAPITypeReasons 29 | 30 | E174.1 31 | 85F4.1 32 | 33 | 34 | 35 | NSPrivacyAccessedAPIType 36 | NSPrivacyAccessedAPICategorySystemBootTime 37 | NSPrivacyAccessedAPITypeReasons 38 | 39 | 35F9.1 40 | 41 | 42 | 43 | NSPrivacyCollectedDataTypes 44 | 45 | NSPrivacyTracking 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /android/src/main/java/expo/modules/placepicker/Types/PlacePickerOptions.kt: -------------------------------------------------------------------------------- 1 | package expo.modules.placepicker 2 | 3 | import expo.modules.kotlin.records.Field 4 | import expo.modules.kotlin.records.Record 5 | 6 | class PlacePickerOptions : Record { 7 | @Field 8 | val presentationStyle: PlacePickerPresentationStyle = PlacePickerPresentationStyle.fullscreen 9 | 10 | @Field 11 | val title: String = "Choose Place" 12 | 13 | @Field 14 | val searchPlaceholder: String = "Search..." 15 | 16 | @Field 17 | val color: String = "#FF0000" 18 | 19 | @Field 20 | val contrastColor: String = "#FFFFFF" 21 | 22 | @Field 23 | val locale: String = "en-US" 24 | 25 | @Field 26 | val initialCoordinates: PlacePickerCoordinate? = null 27 | 28 | @Field 29 | val enableGeocoding: Boolean = true 30 | 31 | @Field 32 | val enableSearch: Boolean = true 33 | 34 | @Field 35 | val enableUserLocation: Boolean = true 36 | 37 | @Field 38 | val enableLargeTitle: Boolean = true 39 | 40 | @Field 41 | val rejectOnCancel: Boolean = true 42 | 43 | @Field 44 | val enableRangeSelection: Boolean = false 45 | 46 | @Field 47 | val initialRadius: Double = 1000.0 48 | 49 | @Field 50 | val minRadius: Double = 100.0 51 | 52 | @Field 53 | val maxRadius: Double = 10000.0 54 | 55 | @Field 56 | val radiusColor: String = "" 57 | 58 | @Field 59 | val radiusStrokeColor: String = "" 60 | 61 | @Field 62 | val radiusStrokeWidth: Double = 2.0 63 | } 64 | -------------------------------------------------------------------------------- /ios/Types/PlacePickerAddress.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PlacePickerAddress.swift 3 | // react-native-place-picker 4 | // 5 | // Created by b0iq on 11/11/2022. 6 | // 7 | // :p Copied from https://medium.com/geekculture/working-with-details-of-location-in-swiftui-faf7b139270b 8 | // 9 | 10 | import ExpoModulesCore 11 | import CoreLocation.CLPlacemark 12 | 13 | struct PlacePickerAddress: Record { 14 | init() { 15 | self.name = nil 16 | self.streetName = nil 17 | self.city = nil 18 | self.state = nil 19 | self.zipCode = nil 20 | self.country = nil 21 | } 22 | 23 | @Field 24 | var name: String? = "" 25 | @Field 26 | var streetName: String? = "" 27 | @Field 28 | var city: String? = "" 29 | @Field 30 | var state: String? = "" 31 | @Field 32 | var zipCode: String? = "" 33 | @Field 34 | var country: String? = "" 35 | init(with placemark: CLPlacemark?) { 36 | if let p = placemark { 37 | self.name = p.name ?? "" 38 | self.streetName = p.thoroughfare ?? "" 39 | self.city = p.locality ?? "" 40 | self.state = p.administrativeArea ?? "" 41 | self.zipCode = p.postalCode ?? "" 42 | self.country = p.country ?? "" 43 | } else { 44 | self.name = nil 45 | self.streetName = nil 46 | self.city = nil 47 | self.state = nil 48 | self.zipCode = nil 49 | self.country = nil 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /example/Components/Row.tsx: -------------------------------------------------------------------------------- 1 | /* eslint-disable react-native/no-inline-styles */ 2 | import React from 'react'; 3 | import { TouchableOpacity, View, Text, StyleSheet } from 'react-native'; 4 | 5 | export const Row = ({ 6 | label, 7 | value, 8 | color, 9 | contrast = '#007aff', 10 | onPress, 11 | }: { 12 | label: string; 13 | value?: string; 14 | color?: string; 15 | contrast?: string; 16 | onPress?: () => void; 17 | }) => ( 18 | 19 | 20 | {label} 21 | 33 | {value} 34 | 35 | 36 | 37 | ); 38 | const styles = StyleSheet.create({ 39 | row: { 40 | flexDirection: 'row', 41 | justifyContent: 'space-between', 42 | alignItems: 'center', 43 | paddingHorizontal: 10, 44 | paddingVertical: 5, 45 | backgroundColor: '#F5F5F5', 46 | borderRadius: 5, 47 | marginBottom: 5, 48 | }, 49 | label: { 50 | fontSize: 16, 51 | fontWeight: '600', 52 | }, 53 | value: { 54 | fontSize: 16, 55 | fontWeight: '400', 56 | color: '#007aff', 57 | textAlign: 'right', 58 | padding: 5, 59 | borderWidth: 2, 60 | }, 61 | }); 62 | -------------------------------------------------------------------------------- /android/src/main/res/values-night/style.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 15 | 16 | 20 | 23 | 28 | 29 | -------------------------------------------------------------------------------- /android/src/main/res/values/style.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 15 | 16 | 17 | 21 | 24 | 29 | 30 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = findProperty('android.buildToolsVersion') ?: '34.0.0' 6 | minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23') 7 | compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '34') 8 | targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34') 9 | kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.23' 10 | 11 | ndkVersion = "26.1.10909125" 12 | } 13 | repositories { 14 | google() 15 | mavenCentral() 16 | } 17 | dependencies { 18 | classpath('com.android.tools.build:gradle') 19 | classpath('com.facebook.react:react-native-gradle-plugin') 20 | classpath('org.jetbrains.kotlin:kotlin-gradle-plugin') 21 | } 22 | } 23 | 24 | apply plugin: "com.facebook.react.rootproject" 25 | 26 | allprojects { 27 | repositories { 28 | maven { 29 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 30 | url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android')) 31 | } 32 | maven { 33 | // Android JSC is installed from npm 34 | url(new File(['node', '--print', "require.resolve('jsc-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), '../dist')) 35 | } 36 | 37 | google() 38 | mavenCentral() 39 | maven { url 'https://www.jitpack.io' } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /android/src/main/java/expo/modules/placepicker/ReactNativePlacePickerModule.kt: -------------------------------------------------------------------------------- 1 | package expo.modules.placepicker 2 | 3 | import android.content.Intent 4 | import android.util.Log 5 | import expo.modules.kotlin.Promise 6 | import expo.modules.kotlin.functions.Queues 7 | import expo.modules.kotlin.modules.Module 8 | import expo.modules.kotlin.modules.ModuleDefinition 9 | 10 | const val TAG = "XX_PLACE_PCIKER" 11 | fun lg(string: String?) { 12 | Log.i(TAG, string ?: "Unknown") 13 | } 14 | 15 | class ReactNativePlacePickerModule : Module() { 16 | override fun definition() = ModuleDefinition { 17 | Name(NAME) 18 | AsyncFunction("pickPlace") { options: PlacePickerOptions?, promise: Promise -> 19 | try { 20 | if (options != null) { 21 | PlacePickerState.globalOptions = options 22 | } 23 | PlacePickerState.globalPromise = promise 24 | PlacePickerState.globalResult = PlacePickerResult() 25 | val activity = this@ReactNativePlacePickerModule.appContext.currentActivity 26 | val pickerIntent = Intent(activity, PlacePickerActivity::class.java) 27 | activity?.startActivityForResult(pickerIntent, PLACE_PICKER_REQUEST) 28 | } catch (t: Throwable) { 29 | promise.reject(E_FAILED_TO_SHOW_PICKER, "Unable to launch new activity", t) 30 | PlacePickerState.globalPromise = null 31 | } 32 | }.runOnQueue(Queues.MAIN) 33 | } 34 | 35 | companion object { 36 | const val PLACE_PICKER_REQUEST = 1 37 | const val E_ACTIVITY_DOES_NOT_EXIST = "E_ACTIVITY_DOES_NOT_EXIST" 38 | const val E_FAILED_TO_SHOW_PICKER = "E_FAILED_TO_SHOW_PICKER" 39 | const val NAME = "ReactNativePlacePicker" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/rn_edit_text_material.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 22 | 23 | 24 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | group = 'expo.modules.placepicker' 4 | version = '3.0.8' 5 | 6 | def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle") 7 | apply from: expoModulesCorePlugin 8 | apply plugin: 'org.jetbrains.kotlin.android' 9 | applyKotlinExpoModulesCorePlugin() 10 | useCoreDependencies() 11 | useExpoPublishing() 12 | 13 | // If you want to use the managed Android SDK versions from expo-modules-core, set this to true. 14 | // The Android SDK versions will be bumped from time to time in SDK releases and may introduce breaking changes in your module code. 15 | // Most of the time, you may like to manage the Android SDK versions yourself. 16 | def useManagedAndroidSdkVersions = false 17 | if (useManagedAndroidSdkVersions) { 18 | useDefaultAndroidSdkVersions() 19 | } else { 20 | buildscript { 21 | // Simple helper that allows the root project to override versions declared by this library. 22 | ext.safeExtGet = { prop, fallback -> 23 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback 24 | } 25 | } 26 | project.android { 27 | compileSdkVersion safeExtGet("compileSdkVersion", 34) 28 | defaultConfig { 29 | minSdkVersion safeExtGet("minSdkVersion", 21) 30 | targetSdkVersion safeExtGet("targetSdkVersion", 34) 31 | } 32 | } 33 | } 34 | 35 | android { 36 | namespace "expo.modules.placepicker" 37 | defaultConfig { 38 | versionCode 3000008 39 | versionName "3.0.8" 40 | } 41 | lintOptions { 42 | abortOnError false 43 | } 44 | } 45 | 46 | dependencies { 47 | implementation 'androidx.appcompat:appcompat:1.6.1' 48 | implementation 'com.google.android.material:material:1.10.0' 49 | implementation 'androidx.activity:activity:1.8.0' 50 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' 51 | implementation 'com.google.android.gms:play-services-maps:19.0.0' 52 | implementation 'com.google.android.gms:play-services-location:21.3.0' 53 | } 54 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/expo/modules/placepicker/example/MainApplication.kt: -------------------------------------------------------------------------------- 1 | package expo.modules.placepicker.example 2 | 3 | import android.app.Application 4 | import android.content.res.Configuration 5 | 6 | import com.facebook.react.PackageList 7 | import com.facebook.react.ReactApplication 8 | import com.facebook.react.ReactNativeHost 9 | import com.facebook.react.ReactPackage 10 | import com.facebook.react.ReactHost 11 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load 12 | import com.facebook.react.defaults.DefaultReactNativeHost 13 | import com.facebook.soloader.SoLoader 14 | 15 | import expo.modules.ApplicationLifecycleDispatcher 16 | import expo.modules.ReactNativeHostWrapper 17 | 18 | class MainApplication : Application(), ReactApplication { 19 | 20 | override val reactNativeHost: ReactNativeHost = ReactNativeHostWrapper( 21 | this, 22 | object : DefaultReactNativeHost(this) { 23 | override fun getPackages(): List { 24 | // Packages that cannot be autolinked yet can be added manually here, for example: 25 | // packages.add(new MyReactNativePackage()); 26 | return PackageList(this).packages 27 | } 28 | 29 | override fun getJSMainModuleName(): String = ".expo/.virtual-metro-entry" 30 | 31 | override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG 32 | 33 | override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED 34 | override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED 35 | } 36 | ) 37 | 38 | override val reactHost: ReactHost 39 | get() = ReactNativeHostWrapper.createReactHost(applicationContext, reactNativeHost) 40 | 41 | override fun onCreate() { 42 | super.onCreate() 43 | SoLoader.init(this, false) 44 | if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { 45 | // If you opted-in for the New Architecture, we load the native entry point for this app. 46 | load() 47 | } 48 | ApplicationLifecycleDispatcher.onApplicationCreate(this) 49 | } 50 | 51 | override fun onConfigurationChanged(newConfig: Configuration) { 52 | super.onConfigurationChanged(newConfig) 53 | ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/expo/modules/placepicker/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package expo.modules.placepicker.example 2 | 3 | import android.os.Build 4 | import android.os.Bundle 5 | 6 | import com.facebook.react.ReactActivity 7 | import com.facebook.react.ReactActivityDelegate 8 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled 9 | import com.facebook.react.defaults.DefaultReactActivityDelegate 10 | 11 | import expo.modules.ReactActivityDelegateWrapper 12 | 13 | class MainActivity : ReactActivity() { 14 | override fun onCreate(savedInstanceState: Bundle?) { 15 | // Set the theme to AppTheme BEFORE onCreate to support 16 | // coloring the background, status bar, and navigation bar. 17 | // This is required for expo-splash-screen. 18 | setTheme(R.style.AppTheme); 19 | super.onCreate(null) 20 | } 21 | 22 | /** 23 | * Returns the name of the main component registered from JavaScript. This is used to schedule 24 | * rendering of the component. 25 | */ 26 | override fun getMainComponentName(): String = "main" 27 | 28 | /** 29 | * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate] 30 | * which allows you to enable New Architecture with a single boolean flags [fabricEnabled] 31 | */ 32 | override fun createReactActivityDelegate(): ReactActivityDelegate { 33 | return ReactActivityDelegateWrapper( 34 | this, 35 | BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, 36 | object : DefaultReactActivityDelegate( 37 | this, 38 | mainComponentName, 39 | fabricEnabled 40 | ){}) 41 | } 42 | 43 | /** 44 | * Align the back button behavior with Android S 45 | * where moving root activities to background instead of finishing activities. 46 | * @see onBackPressed 47 | */ 48 | override fun invokeDefaultOnBackPressed() { 49 | if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) { 50 | if (!moveTaskToBack(false)) { 51 | // For non-root activities, use the default implementation to finish them. 52 | super.invokeDefaultOnBackPressed() 53 | } 54 | return 55 | } 56 | 57 | // Use the default back button implementation on Android S 58 | // because it's doing more than [Activity.moveTaskToBack] in fact. 59 | super.invokeDefaultOnBackPressed() 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /android/src/main/res/layout/activity_place_picker.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 22 | 23 | 32 | 33 | 43 | 44 | 53 | 54 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx512m -XX:MaxMetaspaceSize=256m 13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | 25 | # Automatically convert third-party libraries to use AndroidX 26 | android.enableJetifier=true 27 | 28 | # Enable AAPT2 PNG crunching 29 | android.enablePngCrunchInReleaseBuilds=true 30 | 31 | # Use this property to specify which architecture you want to build. 32 | # You can also override it from the CLI using 33 | # ./gradlew -PreactNativeArchitectures=x86_64 34 | reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 35 | 36 | # Use this property to enable support to the new architecture. 37 | # This will allow you to use TurboModules and the Fabric render in 38 | # your application. You should enable this flag either if you want 39 | # to write custom TurboModules/Fabric components OR use libraries that 40 | # are providing them. 41 | newArchEnabled=true 42 | 43 | # Use this property to enable or disable the Hermes JS engine. 44 | # If set to false, you will be using JSC instead. 45 | hermesEnabled=true 46 | 47 | # Enable GIF support in React Native images (~200 B increase) 48 | expo.gif.enabled=true 49 | # Enable webp support in React Native images (~85 KB increase) 50 | expo.webp.enabled=true 51 | # Enable animated webp support (~3.4 MB increase) 52 | # Disabled by default because iOS doesn't support animated webp 53 | expo.webp.animated=false 54 | 55 | # Enable network inspector 56 | EX_DEV_CLIENT_NETWORK_INSPECTOR=true 57 | 58 | # Use legacy packaging to compress native libraries in the resulting APK. 59 | expo.useLegacyPackaging=false 60 | 61 | android.extraMavenRepos=[] -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CADisableMinimumFrameDurationOnPhone 6 | 7 | CFBundleDevelopmentRegion 8 | $(DEVELOPMENT_LANGUAGE) 9 | CFBundleDisplayName 10 | react-native-place-picker-example 11 | CFBundleExecutable 12 | $(EXECUTABLE_NAME) 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | $(PRODUCT_NAME) 19 | CFBundlePackageType 20 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 21 | CFBundleShortVersionString 22 | 1.0.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleURLTypes 26 | 27 | 28 | CFBundleURLSchemes 29 | 30 | expo.modules.placepicker.example 31 | 32 | 33 | 34 | CFBundleVersion 35 | 1 36 | LSRequiresIPhoneOS 37 | 38 | NSAppTransportSecurity 39 | 40 | NSAllowsArbitraryLoads 41 | 42 | NSAllowsLocalNetworking 43 | 44 | 45 | NSLocationUsageDescription 46 | This app needs access to location. 47 | NSLocationWhenInUseUsageDescription 48 | This app needs access to location when open. 49 | UILaunchStoryboardName 50 | SplashScreen 51 | UIRequiredDeviceCapabilities 52 | 53 | arm64 54 | 55 | UIRequiresFullScreen 56 | 57 | UIStatusBarStyle 58 | UIStatusBarStyleDefault 59 | UISupportedInterfaceOrientations 60 | 61 | UIInterfaceOrientationPortrait 62 | UIInterfaceOrientationPortraitUpsideDown 63 | 64 | UISupportedInterfaceOrientations~ipad 65 | 66 | UIInterfaceOrientationPortrait 67 | UIInterfaceOrientationPortraitUpsideDown 68 | UIInterfaceOrientationLandscapeLeft 69 | UIInterfaceOrientationLandscapeRight 70 | 71 | UIUserInterfaceStyle 72 | Light 73 | UIViewControllerBasedStatusBarAppearance 74 | 75 | 76 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def version = providers.exec { 3 | commandLine("node", "-e", "console.log(require('react-native/package.json').version);") 4 | }.standardOutput.asText.get().trim() 5 | def (_, reactNativeMinor, reactNativePatch) = version.split("-")[0].tokenize('.').collect { it.toInteger() } 6 | 7 | includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json')"].execute(null, rootDir).text.trim()).getParentFile().toString()) 8 | if(reactNativeMinor == 74 && reactNativePatch <= 3){ 9 | includeBuild("react-settings-plugin") 10 | } 11 | } 12 | 13 | plugins { id("com.facebook.react.settings") } 14 | 15 | def getRNMinorVersion() { 16 | def version = providers.exec { 17 | commandLine("node", "-e", "console.log(require('react-native/package.json').version);") 18 | }.standardOutput.asText.get().trim() 19 | 20 | def coreVersion = version.split("-")[0] 21 | def (major, minor, patch) = coreVersion.tokenize('.').collect { it.toInteger() } 22 | 23 | return minor 24 | } 25 | 26 | if (getRNMinorVersion() >= 75) { 27 | extensions.configure(com.facebook.react.ReactSettingsExtension) { ex -> 28 | if (System.getenv('EXPO_UNSTABLE_CORE_AUTOLINKING') == '1') { 29 | println('\u001B[32mUsing expo-modules-autolinking as core autolinking source\u001B[0m') 30 | def command = [ 31 | 'node', 32 | '--no-warnings', 33 | '--eval', 34 | 'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))', 35 | 'react-native-config', 36 | '--json', 37 | '--platform', 38 | 'android' 39 | ].toList() 40 | ex.autolinkLibrariesFromCommand(command) 41 | } else { 42 | ex.autolinkLibrariesFromCommand() 43 | } 44 | } 45 | } 46 | 47 | rootProject.name = 'react-native-place-picker-example' 48 | 49 | dependencyResolutionManagement { 50 | versionCatalogs { 51 | reactAndroidLibs { 52 | from(files(new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../gradle/libs.versions.toml"))) 53 | } 54 | } 55 | } 56 | 57 | apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle"); 58 | useExpoModules() 59 | 60 | if (getRNMinorVersion() < 75) { 61 | apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), "../native_modules.gradle"); 62 | applyNativeModulesSettingsGradle(settings) 63 | } 64 | 65 | include ':app' 66 | includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile()) 67 | -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample/AppDelegate.mm: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | #import 4 | #import 5 | 6 | @implementation AppDelegate 7 | 8 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 9 | { 10 | self.moduleName = @"main"; 11 | 12 | // You can add your custom initial props in the dictionary below. 13 | // They will be passed down to the ViewController used by React Native. 14 | self.initialProps = @{}; 15 | 16 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; 17 | } 18 | 19 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 20 | { 21 | return [self bundleURL]; 22 | } 23 | 24 | - (NSURL *)bundleURL 25 | { 26 | #if DEBUG 27 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@".expo/.virtual-metro-entry"]; 28 | #else 29 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 30 | #endif 31 | } 32 | 33 | // Linking API 34 | - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options { 35 | return [super application:application openURL:url options:options] || [RCTLinkingManager application:application openURL:url options:options]; 36 | } 37 | 38 | // Universal Links 39 | - (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray> * _Nullable))restorationHandler { 40 | BOOL result = [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler]; 41 | return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler] || result; 42 | } 43 | 44 | // Explicitly define remote notification delegates to ensure compatibility with some third-party libraries 45 | - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken 46 | { 47 | return [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; 48 | } 49 | 50 | // Explicitly define remote notification delegates to ensure compatibility with some third-party libraries 51 | - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error 52 | { 53 | return [super application:application didFailToRegisterForRemoteNotificationsWithError:error]; 54 | } 55 | 56 | // Explicitly define remote notification delegates to ensure compatibility with some third-party libraries 57 | - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler 58 | { 59 | return [super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 1>&2 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 48 | echo. 1>&2 49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 50 | echo location of your Java installation. 1>&2 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 1>&2 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 62 | echo. 1>&2 63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 64 | echo location of your Java installation. 1>&2 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking") 2 | require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods") 3 | 4 | require 'json' 5 | podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {} 6 | 7 | ENV['RCT_NEW_ARCH_ENABLED'] = podfile_properties['newArchEnabled'] == 'true' ? '1' : '0' 8 | ENV['EX_DEV_CLIENT_NETWORK_INSPECTOR'] = podfile_properties['EX_DEV_CLIENT_NETWORK_INSPECTOR'] 9 | 10 | use_autolinking_method_symbol = ('use' + '_native' + '_modules!').to_sym 11 | origin_autolinking_method = self.method(use_autolinking_method_symbol) 12 | self.define_singleton_method(use_autolinking_method_symbol) do |*args| 13 | if ENV['EXPO_UNSTABLE_CORE_AUTOLINKING'] == '1' 14 | Pod::UI.puts('Using expo-modules-autolinking as core autolinking source'.green) 15 | config_command = [ 16 | 'node', 17 | '--no-warnings', 18 | '--eval', 19 | 'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))', 20 | 'react-native-config', 21 | '--json', 22 | '--platform', 23 | 'ios' 24 | ] 25 | origin_autolinking_method.call(config_command) 26 | else 27 | origin_autolinking_method.call() 28 | end 29 | end 30 | 31 | platform :ios, podfile_properties['ios.deploymentTarget'] || '13.4' 32 | install! 'cocoapods', 33 | :deterministic_uuids => false 34 | 35 | prepare_react_native_project! 36 | 37 | target 'reactnativeplacepickerexample' do 38 | use_expo_modules! 39 | config = use_native_modules! 40 | 41 | use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks'] 42 | use_frameworks! :linkage => ENV['USE_FRAMEWORKS'].to_sym if ENV['USE_FRAMEWORKS'] 43 | 44 | use_react_native!( 45 | :path => config[:reactNativePath], 46 | :hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes', 47 | # An absolute path to your application root. 48 | :app_path => "#{Pod::Config.instance.installation_root}/..", 49 | :privacy_file_aggregation_enabled => podfile_properties['apple.privacyManifestAggregationEnabled'] != 'false', 50 | ) 51 | 52 | post_install do |installer| 53 | react_native_post_install( 54 | installer, 55 | config[:reactNativePath], 56 | :mac_catalyst_enabled => false, 57 | :ccache_enabled => podfile_properties['apple.ccacheEnabled'] == 'true', 58 | ) 59 | 60 | # This is necessary for Xcode 14, because it signs resource bundles by default 61 | # when building for devices. 62 | installer.target_installation_results.pod_target_installation_results 63 | .each do |pod_name, target_installation_result| 64 | target_installation_result.resource_bundle_targets.each do |resource_bundle_target| 65 | resource_bundle_target.build_configurations.each do |config| 66 | config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO' 67 | end 68 | end 69 | end 70 | end 71 | 72 | post_integrate do |installer| 73 | begin 74 | expo_patch_react_imports!(installer) 75 | rescue => e 76 | Pod::UI.warn e 77 | end 78 | end 79 | end 80 | -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample.xcodeproj/xcshareddata/xcschemes/reactnativeplacepickerexample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 55 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /ios/Helpers/DropDown.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DropDown.swift 3 | // react-native-place-picker 4 | // 5 | // Created by b0iq on 01/09/2023. 6 | // 7 | 8 | import UIKit 9 | import MapKit.MKLocalSearchCompleter 10 | 11 | protocol DropDownButtonDelegate: AnyObject { 12 | func didSelect(_ index: Int) 13 | } 14 | 15 | class DropDown: UIView { 16 | 17 | let tableView: UITableView = { 18 | let table: UITableView = UITableView(frame: .zero, style: .plain) 19 | table.translatesAutoresizingMaskIntoConstraints = false 20 | table.isHidden = true 21 | table.backgroundView = UIView() 22 | table.backgroundColor = .none 23 | table.isOpaque = true 24 | table.register(DropdownTableViewCell.self, forCellReuseIdentifier: DropdownTableViewCell.reuseIdentifier) 25 | return table 26 | }() 27 | 28 | var dataSource: [CustomSearchCompletion] = [] { 29 | didSet { 30 | updateTableDataSource() 31 | } 32 | } 33 | 34 | var delegate: DropDownButtonDelegate? 35 | 36 | var tableViewHeight: NSLayoutConstraint? 37 | 38 | var maxVisibleCellsAmount: Int = 10 { 39 | didSet { 40 | updateTableDataSource() 41 | } 42 | } 43 | 44 | init() { 45 | super.init(frame: .zero) 46 | setup() 47 | } 48 | 49 | required init?(coder: NSCoder) { 50 | super.init(coder: coder) 51 | setup() 52 | } 53 | 54 | func setup() { 55 | addSubview(tableView) 56 | 57 | tableView.delegate = self 58 | tableView.dataSource = self 59 | NSLayoutConstraint.activate([ 60 | tableView.topAnchor.constraint(equalTo:topAnchor), 61 | tableView.leadingAnchor.constraint(equalTo: leadingAnchor), 62 | tableView.trailingAnchor.constraint(equalTo: trailingAnchor), 63 | tableView.bottomAnchor.constraint(equalTo: bottomAnchor), 64 | 65 | ]) 66 | tableViewHeight?.isActive = true 67 | tableView.register(SubtitleCell.self, forCellReuseIdentifier: "CELL") 68 | } 69 | 70 | func updateTableDataSource() { 71 | self.tableView.isHidden = dataSource.count < 1 72 | tableView.reloadData() 73 | } 74 | } 75 | 76 | extension DropDown: UITableViewDataSource { 77 | 78 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 79 | dataSource.count 80 | } 81 | 82 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 83 | let cell = tableView.dequeueReusableCell(withIdentifier: "CELL", for: indexPath) 84 | let row = dataSource[indexPath.row] 85 | cell.textLabel?.attributedText = row.attrTitle 86 | cell.detailTextLabel?.attributedText = row.attrSubtitle 87 | return cell 88 | } 89 | 90 | } 91 | 92 | extension DropDown: UITableViewDelegate { 93 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 94 | delegate?.didSelect(indexPath.row) 95 | return 96 | } 97 | 98 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 99 | return tableView.rowHeight 100 | } 101 | } 102 | class SubtitleCell: UITableViewCell { 103 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 104 | super.init(style: .subtitle, reuseIdentifier: reuseIdentifier) 105 | self.isOpaque = true 106 | if #available(iOS 13.0, *) { 107 | self.backgroundColor = .systemBackground.withAlphaComponent(0.8) 108 | } else { 109 | self.backgroundColor = .white.withAlphaComponent(0.8) 110 | } 111 | } 112 | 113 | 114 | required init?(coder: NSCoder) { 115 | fatalError("init(coder:) has not been implemented") 116 | } 117 | } 118 | 119 | -------------------------------------------------------------------------------- /src/ReactNativePlacePicker.types.ts: -------------------------------------------------------------------------------- 1 | export enum PlacePickerPresentationStyle { 2 | modal = "modal", 3 | fullscreen = "fullscreen", 4 | } 5 | export interface PlacePickerAddress { 6 | name: string; 7 | streetName: string; 8 | city: string; 9 | state: string; 10 | zipCode: string; 11 | country: string; 12 | } 13 | export interface PlacePickerCoordinate { 14 | latitude: number; 15 | longitude: number; 16 | } 17 | export interface PlacePickerOptions { 18 | /** 19 | * @description Presentation style of the place picker window on iOS. 20 | * @type PlacePickerPresentationStyle | string 21 | * @platform iOS only 22 | * @default PlacePickerPresentationStyle.fullscreen | 'fullscreen' 23 | */ 24 | presentationStyle?: PlacePickerPresentationStyle | "modal" | "fullscreen"; 25 | /** 26 | * @description The title of the place picker window. 27 | * @type string 28 | * @default 'Choose Place' 29 | */ 30 | title?: string; 31 | /** 32 | * @description If enableSearch is true, the place picker window will have a search bar and you can set the placeholder of the text box. 33 | * @type string 34 | * @default 'Search...' 35 | */ 36 | searchPlaceholder?: string; 37 | /** 38 | * @description Primary color of the theme such as map pin, shadow, etc. 39 | * @type string 40 | * @platform ios, android 41 | * @default '#FF0000' 42 | */ 43 | color?: string; 44 | /** 45 | * @description The contrast color of the primary color. 46 | * @type string 47 | * @default '#FFFFFF' 48 | */ 49 | contrastColor?: string; 50 | /** 51 | * @description The locale of returned address. 52 | * @type string 53 | * @platform ios, android 54 | * @default 'en-US' 55 | */ 56 | locale?: string; 57 | /** 58 | * @description Initial map position. 59 | * @type PlacePickerCoordinate 60 | * @default `{latitude: 25.2048, longitude: 55.2708 }` 61 | */ 62 | initialCoordinates?: PlacePickerCoordinate; 63 | /** 64 | * @description Enable to geocode the address of the selected place. 65 | * @type boolean 66 | * @default true 67 | */ 68 | enableGeocoding?: boolean; 69 | /** 70 | * @description Enable to the search bar to let user search for certain position. 71 | * @type boolean 72 | * @default true 73 | */ 74 | enableSearch?: boolean; 75 | /** 76 | * @description Enable current user position button. 77 | * @WARN You have to setup location privacy note into Info.plist for iOS and AndroidManifest.xml for Android. 78 | * @type boolean 79 | * @default true 80 | */ 81 | enableUserLocation?: boolean; 82 | /** 83 | * @description Enable large navigation bar title of the UIViewController. 84 | * @type boolean 85 | * @platform iOS only 86 | * @default true 87 | */ 88 | enableLargeTitle?: boolean; 89 | /** 90 | * @description Reject and return nothing if user dismiss the window. 91 | * @type boolean 92 | * @default true 93 | */ 94 | rejectOnCancel?: boolean; 95 | /** 96 | * @description Enable draggable radius selection overlay on the map. 97 | * @type boolean 98 | * @default false 99 | */ 100 | enableRangeSelection?: boolean; 101 | /** 102 | * @description Initial radius in meters when range selection is enabled. 103 | * @type number 104 | * @default 1000 105 | */ 106 | initialRadius?: number; 107 | /** 108 | * @description Minimum allowed radius in meters when dragging the handle. 109 | * @type number 110 | * @default 100 111 | */ 112 | minRadius?: number; 113 | /** 114 | * @description Maximum allowed radius in meters when dragging the handle. 115 | * @type number 116 | * @default 10000 117 | */ 118 | maxRadius?: number; 119 | /** 120 | * @description Fill color of radius circle (hex or rgba). Uses `color` with alpha if not provided. 121 | * @type string 122 | */ 123 | radiusColor?: string; 124 | /** 125 | * @description Stroke color of radius circle. 126 | * @type string 127 | */ 128 | radiusStrokeColor?: string; 129 | /** 130 | * @description Stroke width of radius circle in pixels. 131 | * @type number 132 | * @default 2 133 | */ 134 | radiusStrokeWidth?: number; 135 | } 136 | 137 | export interface PlacePickerResults { 138 | /** 139 | * @description Selected coordinate. 140 | */ 141 | coordinate: PlacePickerCoordinate; 142 | /** 143 | * @description Geocoded address for selected location. 144 | * @if `enableGeocoding: true` 145 | */ 146 | address?: PlacePickerAddress; 147 | /** 148 | * @description Did cancel the place picker window without selecting. 149 | */ 150 | didCancel: boolean; 151 | /** 152 | * @description Selected radius in meters if `enableRangeSelection` is true. 153 | */ 154 | radius?: number; 155 | /** 156 | * @description Geometry of the selected radius area. 157 | */ 158 | radiusCoordinates?: { 159 | center: PlacePickerCoordinate; 160 | bounds: { 161 | northeast: PlacePickerCoordinate; 162 | southwest: PlacePickerCoordinate; 163 | }; 164 | }; 165 | } 166 | -------------------------------------------------------------------------------- /example/ios/reactnativeplacepickerexample/SplashScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are always welcome, no matter how large or small! 4 | 5 | We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project. Before contributing, please read the [code of conduct](./CODE_OF_CONDUCT.md). 6 | 7 | ## Development workflow 8 | 9 | To get started with the project, run `yarn` in the root directory to install the required dependencies for each package: 10 | 11 | ```sh 12 | yarn 13 | ``` 14 | 15 | > While it's possible to use [`npm`](https://github.com/npm/cli), the tooling is built around [`yarn`](https://classic.yarnpkg.com/), so you'll have an easier time if you use `yarn` for development. 16 | 17 | While developing, you can run the [example app](/example/) to test your changes. Any changes you make in your library's JavaScript code will be reflected in the example app without a rebuild. If you change any native code, then you'll need to rebuild the example app. 18 | 19 | To start the packager: 20 | 21 | ```sh 22 | yarn example start 23 | ``` 24 | 25 | To run the example app on Android: 26 | 27 | ```sh 28 | yarn example android 29 | ``` 30 | 31 | To run the example app on iOS: 32 | 33 | ```sh 34 | yarn example ios 35 | ``` 36 | 37 | By default, the example is configured to build with the old architecture. To run the example with the new architecture, you can do the following: 38 | 39 | 1. For Android, run: 40 | 41 | ```sh 42 | ORG_GRADLE_PROJECT_newArchEnabled=true yarn example android 43 | ``` 44 | 45 | 2. For iOS, run: 46 | 47 | ```sh 48 | RCT_NEW_ARCH_ENABLED=1 yarn example pods 49 | yarn example ios 50 | ``` 51 | 52 | If you are building for a different architecture than your previous build, make sure to remove the build folders first. You can run the following command to cleanup all build folders: 53 | 54 | ```sh 55 | yarn clean 56 | ``` 57 | 58 | To confirm that the app is running with the new architecture, you can check the Metro logs for a message like this: 59 | 60 | ```sh 61 | Running "PlacePickerExample" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":1} 62 | ``` 63 | 64 | Note the `"fabric":true` and `"concurrentRoot":true` properties. 65 | 66 | Make sure your code passes TypeScript and ESLint. Run the following to verify: 67 | 68 | ```sh 69 | yarn typecheck 70 | yarn lint 71 | ``` 72 | 73 | To fix formatting errors, run the following: 74 | 75 | ```sh 76 | yarn lint --fix 77 | ``` 78 | 79 | Remember to add tests for your change if possible. Run the unit tests by: 80 | 81 | ```sh 82 | yarn test 83 | ``` 84 | 85 | To edit the Objective-C or Swift files, open `example/ios/PlacePickerExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-place-picker`. 86 | 87 | To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `react-native-place-picker` under `Android`. 88 | 89 | 90 | ### Commit message convention 91 | 92 | We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages: 93 | 94 | - `fix`: bug fixes, e.g. fix crash due to deprecated method. 95 | - `feat`: new features, e.g. add new method to the module. 96 | - `refactor`: code refactor, e.g. migrate from class components to hooks. 97 | - `docs`: changes into documentation, e.g. add usage example for the module.. 98 | - `test`: adding or updating tests, e.g. add integration tests using detox. 99 | - `chore`: tooling changes, e.g. change CI config. 100 | 101 | Our pre-commit hooks verify that your commit message matches this format when committing. 102 | 103 | ### Linting and tests 104 | 105 | [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/) 106 | 107 | We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing. 108 | 109 | Our pre-commit hooks verify that the linter and tests pass when committing. 110 | 111 | ### Publishing to npm 112 | 113 | We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc. 114 | 115 | To publish new versions, run the following: 116 | 117 | ```sh 118 | yarn release 119 | ``` 120 | 121 | ### Scripts 122 | 123 | The `package.json` file contains various scripts for common tasks: 124 | 125 | - `yarn bootstrap`: setup project by installing all dependencies and pods. 126 | - `yarn typecheck`: type-check files with TypeScript. 127 | - `yarn lint`: lint files with ESLint. 128 | - `yarn test`: run unit tests with Jest. 129 | - `yarn example start`: start the Metro server for the example app. 130 | - `yarn example android`: run the example app on Android. 131 | - `yarn example ios`: run the example app on iOS. 132 | 133 | ### Sending a pull request 134 | 135 | > **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github). 136 | 137 | When you're sending a pull request: 138 | 139 | - Prefer small pull requests focused on one change. 140 | - Verify that linters and tests are passing. 141 | - Review the documentation to make sure it looks good. 142 | - Follow the pull request template when opening a pull request. 143 | - For pull requests that change the API or implementation, discuss with maintainers first by opening an issue. 144 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 2 | # Contributor Covenant Code of Conduct 3 | 4 | ## Our Pledge 5 | 6 | We as members, contributors, and leaders pledge to make participation in our 7 | community a harassment-free experience for everyone, regardless of age, body 8 | size, visible or invisible disability, ethnicity, sex characteristics, gender 9 | identity and expression, level of experience, education, socio-economic status, 10 | nationality, personal appearance, race, caste, color, religion, or sexual 11 | identity and orientation. 12 | 13 | We pledge to act and interact in ways that contribute to an open, welcoming, 14 | diverse, inclusive, and healthy community. 15 | 16 | ## Our Standards 17 | 18 | Examples of behavior that contributes to a positive environment for our 19 | community include: 20 | 21 | * Demonstrating empathy and kindness toward other people 22 | * Being respectful of differing opinions, viewpoints, and experiences 23 | * Giving and gracefully accepting constructive feedback 24 | * Accepting responsibility and apologizing to those affected by our mistakes, 25 | and learning from the experience 26 | * Focusing on what is best not just for us as individuals, but for the overall 27 | community 28 | 29 | Examples of unacceptable behavior include: 30 | 31 | * The use of sexualized language or imagery, and sexual attention or advances of 32 | any kind 33 | * Trolling, insulting or derogatory comments, and personal or political attacks 34 | * Public or private harassment 35 | * Publishing others' private information, such as a physical or email address, 36 | without their explicit permission 37 | * Other conduct which could reasonably be considered inappropriate in a 38 | professional setting 39 | 40 | ## Enforcement Responsibilities 41 | 42 | Community leaders are responsible for clarifying and enforcing our standards of 43 | acceptable behavior and will take appropriate and fair corrective action in 44 | response to any behavior that they deem inappropriate, threatening, offensive, 45 | or harmful. 46 | 47 | Community leaders have the right and responsibility to remove, edit, or reject 48 | comments, commits, code, wiki edits, issues, and other contributions that are 49 | not aligned to this Code of Conduct, and will communicate reasons for moderation 50 | decisions when appropriate. 51 | 52 | ## Scope 53 | 54 | This Code of Conduct applies within all community spaces, and also applies when 55 | an individual is officially representing the community in public spaces. 56 | Examples of representing our community include using an official e-mail address, 57 | posting via an official social media account, or acting as an appointed 58 | representative at an online or offline event. 59 | 60 | ## Enforcement 61 | 62 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 63 | reported to the community leaders responsible for enforcement at 64 | [INSERT CONTACT METHOD]. 65 | All complaints will be reviewed and investigated promptly and fairly. 66 | 67 | All community leaders are obligated to respect the privacy and security of the 68 | reporter of any incident. 69 | 70 | ## Enforcement Guidelines 71 | 72 | Community leaders will follow these Community Impact Guidelines in determining 73 | the consequences for any action they deem in violation of this Code of Conduct: 74 | 75 | ### 1. Correction 76 | 77 | **Community Impact**: Use of inappropriate language or other behavior deemed 78 | unprofessional or unwelcome in the community. 79 | 80 | **Consequence**: A private, written warning from community leaders, providing 81 | clarity around the nature of the violation and an explanation of why the 82 | behavior was inappropriate. A public apology may be requested. 83 | 84 | ### 2. Warning 85 | 86 | **Community Impact**: A violation through a single incident or series of 87 | actions. 88 | 89 | **Consequence**: A warning with consequences for continued behavior. No 90 | interaction with the people involved, including unsolicited interaction with 91 | those enforcing the Code of Conduct, for a specified period of time. This 92 | includes avoiding interactions in community spaces as well as external channels 93 | like social media. Violating these terms may lead to a temporary or permanent 94 | ban. 95 | 96 | ### 3. Temporary Ban 97 | 98 | **Community Impact**: A serious violation of community standards, including 99 | sustained inappropriate behavior. 100 | 101 | **Consequence**: A temporary ban from any sort of interaction or public 102 | communication with the community for a specified period of time. No public or 103 | private interaction with the people involved, including unsolicited interaction 104 | with those enforcing the Code of Conduct, is allowed during this period. 105 | Violating these terms may lead to a permanent ban. 106 | 107 | ### 4. Permanent Ban 108 | 109 | **Community Impact**: Demonstrating a pattern of violation of community 110 | standards, including sustained inappropriate behavior, harassment of an 111 | individual, or aggression toward or disparagement of classes of individuals. 112 | 113 | **Consequence**: A permanent ban from any sort of public interaction within the 114 | community. 115 | 116 | ## Attribution 117 | 118 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 119 | version 2.1, available at 120 | [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. 121 | 122 | Community Impact Guidelines were inspired by 123 | [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. 124 | 125 | For answers to common questions about this code of conduct, see the FAQ at 126 | [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at 127 | [https://www.contributor-covenant.org/translations][translations]. 128 | 129 | [homepage]: https://www.contributor-covenant.org 130 | [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html 131 | [Mozilla CoC]: https://github.com/mozilla/diversity 132 | [FAQ]: https://www.contributor-covenant.org/faq 133 | [translations]: https://www.contributor-covenant.org/translations 134 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | apply plugin: "org.jetbrains.kotlin.android" 3 | apply plugin: "com.facebook.react" 4 | 5 | def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath() 6 | 7 | static def versionToNumber(major, minor, patch) { 8 | return patch * 100 + minor * 10000 + major * 1000000 9 | } 10 | 11 | def getRNVersion() { 12 | def version = providers.exec { 13 | workingDir(projectDir) 14 | commandLine("node", "-e", "console.log(require('react-native/package.json').version);") 15 | }.standardOutput.asText.get().trim() 16 | 17 | def coreVersion = version.split("-")[0] 18 | def (major, minor, patch) = coreVersion.tokenize('.').collect { it.toInteger() } 19 | 20 | return versionToNumber( 21 | major, 22 | minor, 23 | patch 24 | ) 25 | } 26 | def rnVersion = getRNVersion() 27 | 28 | /** 29 | * This is the configuration block to customize your React Native Android app. 30 | * By default you don't need to apply any configuration, just uncomment the lines you need. 31 | */ 32 | react { 33 | entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android", "absolute"].execute(null, rootDir).text.trim()) 34 | reactNativeDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile() 35 | hermesCommand = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc" 36 | codegenDir = new File(["node", "--print", "require.resolve('@react-native/codegen/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile() 37 | 38 | // Use Expo CLI to bundle the app, this ensures the Metro config 39 | // works correctly with Expo projects. 40 | cliFile = new File(["node", "--print", "require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })"].execute(null, rootDir).text.trim()) 41 | bundleCommand = "export:embed" 42 | 43 | /* Folders */ 44 | // The root of your project, i.e. where "package.json" lives. Default is '..' 45 | // root = file("../") 46 | // The folder where the react-native NPM package is. Default is ../node_modules/react-native 47 | // reactNativeDir = file("../node_modules/react-native") 48 | // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen 49 | // codegenDir = file("../node_modules/@react-native/codegen") 50 | 51 | /* Variants */ 52 | // The list of variants to that are debuggable. For those we're going to 53 | // skip the bundling of the JS bundle and the assets. By default is just 'debug'. 54 | // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. 55 | // debuggableVariants = ["liteDebug", "prodDebug"] 56 | 57 | /* Bundling */ 58 | // A list containing the node command and its flags. Default is just 'node'. 59 | // nodeExecutableAndArgs = ["node"] 60 | 61 | // 62 | // The path to the CLI configuration file. Default is empty. 63 | // bundleConfig = file(../rn-cli.config.js) 64 | // 65 | // The name of the generated asset file containing your JS bundle 66 | // bundleAssetName = "MyApplication.android.bundle" 67 | // 68 | // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' 69 | // entryFile = file("../js/MyApplication.android.js") 70 | // 71 | // A list of extra flags to pass to the 'bundle' commands. 72 | // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle 73 | // extraPackagerArgs = [] 74 | 75 | /* Hermes Commands */ 76 | // The hermes compiler command to run. By default it is 'hermesc' 77 | // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" 78 | // 79 | // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" 80 | // hermesFlags = ["-O", "-output-source-map"] 81 | 82 | if (rnVersion >= versionToNumber(0, 75, 0)) { 83 | /* Autolinking */ 84 | autolinkLibrariesWithApp() 85 | } 86 | } 87 | 88 | /** 89 | * Set this to true to Run Proguard on Release builds to minify the Java bytecode. 90 | */ 91 | def enableProguardInReleaseBuilds = (findProperty('android.enableProguardInReleaseBuilds') ?: false).toBoolean() 92 | 93 | /** 94 | * The preferred build flavor of JavaScriptCore (JSC) 95 | * 96 | * For example, to use the international variant, you can use: 97 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` 98 | * 99 | * The international variant includes ICU i18n library and necessary data 100 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that 101 | * give correct results when using with locales other than en-US. Note that 102 | * this variant is about 6MiB larger per architecture than default. 103 | */ 104 | def jscFlavor = 'org.webkit:android-jsc:+' 105 | 106 | android { 107 | ndkVersion rootProject.ext.ndkVersion 108 | 109 | buildToolsVersion rootProject.ext.buildToolsVersion 110 | compileSdk rootProject.ext.compileSdkVersion 111 | 112 | namespace 'expo.modules.placepicker.example' 113 | defaultConfig { 114 | applicationId 'expo.modules.placepicker.example' 115 | minSdkVersion rootProject.ext.minSdkVersion 116 | targetSdkVersion rootProject.ext.targetSdkVersion 117 | versionCode 1 118 | versionName "1.0.0" 119 | } 120 | signingConfigs { 121 | debug { 122 | storeFile file('debug.keystore') 123 | storePassword 'android' 124 | keyAlias 'androiddebugkey' 125 | keyPassword 'android' 126 | } 127 | } 128 | buildTypes { 129 | debug { 130 | signingConfig signingConfigs.debug 131 | } 132 | release { 133 | // Caution! In production, you need to generate your own keystore file. 134 | // see https://reactnative.dev/docs/signed-apk-android. 135 | signingConfig signingConfigs.debug 136 | shrinkResources (findProperty('android.enableShrinkResourcesInReleaseBuilds')?.toBoolean() ?: false) 137 | minifyEnabled enableProguardInReleaseBuilds 138 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 139 | crunchPngs (findProperty('android.enablePngCrunchInReleaseBuilds')?.toBoolean() ?: true) 140 | } 141 | } 142 | packagingOptions { 143 | jniLibs { 144 | useLegacyPackaging (findProperty('expo.useLegacyPackaging')?.toBoolean() ?: false) 145 | } 146 | } 147 | } 148 | 149 | // Apply static values from `gradle.properties` to the `android.packagingOptions` 150 | // Accepts values in comma delimited lists, example: 151 | // android.packagingOptions.pickFirsts=/LICENSE,**/picasa.ini 152 | ["pickFirsts", "excludes", "merges", "doNotStrip"].each { prop -> 153 | // Split option: 'foo,bar' -> ['foo', 'bar'] 154 | def options = (findProperty("android.packagingOptions.$prop") ?: "").split(","); 155 | // Trim all elements in place. 156 | for (i in 0.. 0) { 161 | println "android.packagingOptions.$prop += $options ($options.length)" 162 | // Ex: android.packagingOptions.pickFirsts += '**/SCCS/**' 163 | options.each { 164 | android.packagingOptions[prop] += it 165 | } 166 | } 167 | } 168 | 169 | dependencies { 170 | // The version of react-native is set by the React Native Gradle Plugin 171 | implementation("com.facebook.react:react-android") 172 | 173 | def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true"; 174 | def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true"; 175 | def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true"; 176 | 177 | if (isGifEnabled) { 178 | // For animated gif support 179 | implementation("com.facebook.fresco:animated-gif:${reactAndroidLibs.versions.fresco.get()}") 180 | } 181 | 182 | if (isWebpEnabled) { 183 | // For webp support 184 | implementation("com.facebook.fresco:webpsupport:${reactAndroidLibs.versions.fresco.get()}") 185 | if (isWebpAnimatedEnabled) { 186 | // Animated webp support 187 | implementation("com.facebook.fresco:animated-webp:${reactAndroidLibs.versions.fresco.get()}") 188 | } 189 | } 190 | 191 | if (hermesEnabled.toBoolean()) { 192 | implementation("com.facebook.react:hermes-android") 193 | } else { 194 | implementation jscFlavor 195 | } 196 | } 197 | 198 | if (rnVersion < versionToNumber(0, 75, 0)) { 199 | apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), "../native_modules.gradle"); 200 | applyNativeModulesAppBuildGradle(project) 201 | } 202 | -------------------------------------------------------------------------------- /example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 87 | APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit 88 | 89 | # Use the maximum available, or set MAX_FD != -1 to use that value. 90 | MAX_FD=maximum 91 | 92 | warn () { 93 | echo "$*" 94 | } >&2 95 | 96 | die () { 97 | echo 98 | echo "$*" 99 | echo 100 | exit 1 101 | } >&2 102 | 103 | # OS specific support (must be 'true' or 'false'). 104 | cygwin=false 105 | msys=false 106 | darwin=false 107 | nonstop=false 108 | case "$( uname )" in #( 109 | CYGWIN* ) cygwin=true ;; #( 110 | Darwin* ) darwin=true ;; #( 111 | MSYS* | MINGW* ) msys=true ;; #( 112 | NONSTOP* ) nonstop=true ;; 113 | esac 114 | 115 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 116 | 117 | 118 | # Determine the Java command to use to start the JVM. 119 | if [ -n "$JAVA_HOME" ] ; then 120 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 121 | # IBM's JDK on AIX uses strange locations for the executables 122 | JAVACMD=$JAVA_HOME/jre/sh/java 123 | else 124 | JAVACMD=$JAVA_HOME/bin/java 125 | fi 126 | if [ ! -x "$JAVACMD" ] ; then 127 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 128 | 129 | Please set the JAVA_HOME variable in your environment to match the 130 | location of your Java installation." 131 | fi 132 | else 133 | JAVACMD=java 134 | if ! command -v java >/dev/null 2>&1 135 | then 136 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | fi 142 | 143 | # Increase the maximum file descriptors if we can. 144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 145 | case $MAX_FD in #( 146 | max*) 147 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 148 | # shellcheck disable=SC2039,SC3045 149 | MAX_FD=$( ulimit -H -n ) || 150 | warn "Could not query maximum file descriptor limit" 151 | esac 152 | case $MAX_FD in #( 153 | '' | soft) :;; #( 154 | *) 155 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 156 | # shellcheck disable=SC2039,SC3045 157 | ulimit -n "$MAX_FD" || 158 | warn "Could not set maximum file descriptor limit to $MAX_FD" 159 | esac 160 | fi 161 | 162 | # Collect all arguments for the java command, stacking in reverse order: 163 | # * args from the command line 164 | # * the main class name 165 | # * -classpath 166 | # * -D...appname settings 167 | # * --module-path (only if needed) 168 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 169 | 170 | # For Cygwin or MSYS, switch paths to Windows format before running java 171 | if "$cygwin" || "$msys" ; then 172 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 173 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 174 | 175 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 176 | 177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 178 | for arg do 179 | if 180 | case $arg in #( 181 | -*) false ;; # don't mess with options #( 182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 183 | [ -e "$t" ] ;; #( 184 | *) false ;; 185 | esac 186 | then 187 | arg=$( cygpath --path --ignore --mixed "$arg" ) 188 | fi 189 | # Roll the args list around exactly as many times as the number of 190 | # args, so each arg winds up back in the position where it started, but 191 | # possibly modified. 192 | # 193 | # NB: a `for` loop captures its iteration list before it begins, so 194 | # changing the positional parameters here affects neither the number of 195 | # iterations, nor the values presented in `arg`. 196 | shift # remove old arg 197 | set -- "$@" "$arg" # push replacement arg 198 | done 199 | fi 200 | 201 | 202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 204 | 205 | # Collect all arguments for the java command: 206 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 207 | # and any embedded shellness will be escaped. 208 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 209 | # treated as '${Hostname}' itself on the command line. 210 | 211 | set -- \ 212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 213 | -classpath "$CLASSPATH" \ 214 | org.gradle.wrapper.GradleWrapperMain \ 215 | "$@" 216 | 217 | # Stop when "xargs" is not available. 218 | if ! command -v xargs >/dev/null 2>&1 219 | then 220 | die "xargs is not available" 221 | fi 222 | 223 | # Use "xargs" to parse quoted args. 224 | # 225 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 226 | # 227 | # In Bash we could simply go: 228 | # 229 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 230 | # set -- "${ARGS[@]}" "$@" 231 | # 232 | # but POSIX shell has neither arrays nor command substitution, so instead we 233 | # post-process each arg (as a line of input to sed) to backslash-escape any 234 | # character that might be a shell metacharacter, then use eval to reverse 235 | # that process (while maintaining the separation between arguments), and wrap 236 | # the whole thing up as a single "set" statement. 237 | # 238 | # This will of course break if any of these variables contains a newline or 239 | # an unmatched quote. 240 | # 241 | 242 | eval "set -- $( 243 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 244 | xargs -n1 | 245 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 246 | tr '\n' ' ' 247 | )" '"$@"' 248 | 249 | exec "$JAVACMD" "$@" 250 | -------------------------------------------------------------------------------- /example/screens/Home.tsx: -------------------------------------------------------------------------------- 1 | import React, { useCallback, useState } from "react"; 2 | import { StyleSheet, Text, ScrollView, Alert } from "react-native"; 3 | // @ts-ignore 4 | import { version as coreVersion } from "react-native/Libraries/Core/ReactNativeVersion"; 5 | import { 6 | pickPlace, 7 | PlacePickerOptions, 8 | PlacePickerResults, 9 | } from "react-native-place-picker"; 10 | 11 | import { Button } from "../Components/Button"; 12 | import { Row } from "../Components/Row"; 13 | function getReactNativeVersion() { 14 | const version = `${coreVersion.major}.${coreVersion.minor}.${coreVersion.patch}`; 15 | return coreVersion.prerelease 16 | ? version + `-${coreVersion.prerelease}` 17 | : version; 18 | } 19 | 20 | function isTMActive() { 21 | // @ts-ignore 22 | return global.__turboModuleProxy != null; 23 | } 24 | 25 | export default function App(props: any) { 26 | const [isFabric, setFabric] = useState(false); 27 | const onLayout = useCallback( 28 | (ev: any) => { 29 | setFabric( 30 | Boolean(ev.currentTarget._internalInstanceHandle?.stateNode?.canonical), 31 | ); 32 | }, 33 | [setFabric], 34 | ); 35 | 36 | const [isTM] = useState(isTMActive()); 37 | 38 | const [results, setResults] = useState(); 39 | const [options, setOptions] = useState({ 40 | presentationStyle: "fullscreen", 41 | contrastColor: "#FFFFFF", 42 | color: "#FF0000", 43 | searchPlaceholder: "Search...", 44 | title: "Choose Place", 45 | enableGeocoding: true, 46 | enableSearch: true, 47 | enableUserLocation: true, 48 | enableLargeTitle: true, 49 | rejectOnCancel: true, 50 | locale: "en-US", 51 | initialCoordinates: { 52 | latitude: 25.2048, 53 | longitude: 55.2708, 54 | }, 55 | }); 56 | const pressHandlerWithOptions = () => { 57 | pickPlace(options) 58 | .then(setResults) 59 | .catch((error) => { 60 | console.log(error); 61 | setResults(undefined); 62 | }); 63 | }; 64 | 65 | const pressHandler = () => { 66 | pickPlace() 67 | .then(setResults) 68 | .catch((error) => { 69 | console.log(error); 70 | setResults(undefined); 71 | }); 72 | }; 73 | 74 | return ( 75 | 81 | Place Picker Playground 82 | (Click to edit) 83 | { 90 | setOptions((prev) => ({ 91 | ...prev, 92 | presentationStyle: 93 | prev.presentationStyle === "modal" ? "fullscreen" : "modal", 94 | })); 95 | }} 96 | /> 97 | { 103 | Alert.prompt( 104 | "Contrast Color", 105 | "Enter color hex value with #", 106 | (text) => { 107 | setOptions((prev) => ({ 108 | ...prev, 109 | contrastColor: text, 110 | })); 111 | }, 112 | "plain-text", 113 | options.contrastColor, 114 | ); 115 | }} 116 | /> 117 | { 123 | Alert.prompt( 124 | "Color", 125 | "Enter color hex value with #", 126 | (text) => { 127 | setOptions((prev) => ({ 128 | ...prev, 129 | color: text, 130 | })); 131 | }, 132 | "plain-text", 133 | options.color, 134 | ); 135 | }} 136 | /> 137 | { 141 | Alert.prompt( 142 | "Title", 143 | "Enter a new title", 144 | (text) => { 145 | setOptions((prev) => ({ 146 | ...prev, 147 | title: text, 148 | })); 149 | }, 150 | "plain-text", 151 | options.title, 152 | ); 153 | }} 154 | /> 155 | { 159 | Alert.prompt( 160 | "Search Placeholder", 161 | "Enter a new search placeholder", 162 | (text) => { 163 | setOptions((prev) => ({ 164 | ...prev, 165 | searchPlaceholder: text, 166 | })); 167 | }, 168 | "plain-text", 169 | options.searchPlaceholder, 170 | ); 171 | }} 172 | /> 173 | { 177 | Alert.prompt( 178 | "Locale", 179 | "Enter a new locale", 180 | (text) => { 181 | setOptions((prev) => ({ 182 | ...prev, 183 | locale: text, 184 | })); 185 | }, 186 | "plain-text", 187 | options.locale, 188 | ); 189 | }} 190 | /> 191 | { 197 | pickPlace({ 198 | presentationStyle: "modal", 199 | searchPlaceholder: "Search...", 200 | title: "Set initial coordinates", 201 | enableLargeTitle: false, 202 | enableSearch: false, 203 | enableGeocoding: false, 204 | }) 205 | .then((r) => { 206 | setOptions((prev) => ({ 207 | ...prev, 208 | initialCoordinates: r.coordinate, 209 | })); 210 | }) 211 | .catch(console.log); 212 | }} 213 | /> 214 | { 218 | setOptions((prev) => ({ 219 | ...prev, 220 | enableGeocoding: !prev.enableGeocoding, 221 | })); 222 | }} 223 | /> 224 | { 228 | setOptions((prev) => ({ 229 | ...prev, 230 | enableSearch: !prev.enableSearch, 231 | })); 232 | }} 233 | /> 234 | { 238 | setOptions((prev) => ({ 239 | ...prev, 240 | enableUserLocation: !prev.enableUserLocation, 241 | })); 242 | }} 243 | /> 244 | { 248 | setOptions((prev) => ({ 249 | ...prev, 250 | enableLargeTitle: !prev.enableLargeTitle, 251 | })); 252 | }} 253 | /> 254 | { 258 | setOptions((prev) => ({ 259 | ...prev, 260 | rejectOnCancel: !prev.rejectOnCancel, 261 | })); 262 | }} 263 | /> 264 |