diff --git a/.gitignore b/.gitignore index f07f99e..5a683d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,36 +1,22 @@ -# Logs -logs +.vscode +.idea +.DS_Store +*.js +*.js.map *.log - -# Runtime data -pids -*.pid -*.seed - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directory -# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git +logs +!src/scripts/*.js +!seed-tests/*.js +seed-tests/seed-copy/**/*.* +seed-tests/seed-copy-new-git-repo/**/*.* +demo/app/*.js +!demo/karma.conf.js +!demo/app/tests/*.js +demo/*.d.ts +!demo/references.d.ts +demo/lib +demo/platforms +demo/node_modules node_modules - -# Dist directory where grunt script produces plugin installation files -dist - -#Exclude all javascript (js) files from source code -source/**/*.js - -#Exclude visual studio code local folder -.vscode +publish/src +publish/package \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c920821 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,73 @@ +matrix: + include: + - stage: "Lint" + language: node_js + os: linux + node_js: "6" + script: cd src && npm run ci.tslint && cd ../demo && npm run ci.tslint + - stage: "WebPack" + os: osx + env: + - Platform="iOS" + osx_image: xcode8.3 + language: node_js + node_js: "6" + jdk: oraclejdk8 + script: cd demo && npm run build.plugin && npm i && npm run build-ios-bundle + - language: android + os: linux + env: + - Platform="Android" + jdk: oraclejdk8 + before_install: nvm install 6.10.3 + script: cd demo && npm run build.plugin && npm i && npm run build-android-bundle + - stage: "Build and Test" + env: + - BuildAndroid="25" + language: android + os: linux + jdk: oraclejdk8 + before_install: nvm install stable + script: + - cd src && npm i && npm run tsc && cd ../demo && tns build android + - os: osx + env: + - BuildiOS="10.3" + - Xcode="8.3" + osx_image: xcode8.3 + language: node_js + node_js: "6" + jdk: oraclejdk8 + script: + - cd src && npm i && npm run tsc && cd ../demo && tns build ios + - os: linux + language: android + dist: precise + jdk: oraclejdk8 + before_script: + - echo no | android create avd --force -n test -t android-21 -b armeabi-v7a + - emulator -avd test -no-audio -no-window & + - android-wait-for-emulator + before_install: + - nvm install 6 + script: cd src && npm run test.android + - os: osx + language: node_js + node_js: "6" + jdk: oraclejdk8 + osx_image: xcode8.3 + script: cd src && npm run test.ios + +android: + components: + - tools + - platform-tools + - build-tools-25.0.2 + - android-25 + - extra-android-m2repository + - sys-img-armeabi-v7a-android-21 + +install: + - echo no | npm install -g nativescript + - tns usage-reporting disable + - tns error-reporting disable \ No newline at end of file diff --git a/README.md b/README.md index f960b52..932edde 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,90 @@ -# nativescript-geolocation +# NativeScript Geolocation ![apple](https://cdn3.iconfinder.com/data/icons/picons-social/57/16-apple-32.png) ![android](https://cdn4.iconfinder.com/data/icons/logos-3/228/android-32.png) -Steps to compile the plugin. -$ ./create.sh +[![npm](https://img.shields.io/npm/v/nativescript-geolocation.svg)](https://www.npmjs.com/package/nativescript-geolocation) +[![npm](https://img.shields.io/npm/dm/nativescript-geolocation.svg)](https://www.npmjs.com/package/nativescript-geolocation) +[![Build Status](https://travis-ci.org/NativeScript/nativescript-geolocation.svg?branch=master)](https://travis-ci.org/NativeScript/nativescript-geolocation) -This will produce a `dist` folder based on all JavaScript files within `source` folder. Values inside `source/package.json` controls the number of plugin version. +Geolocation plugin to use for getting current location, monitor movement, etc. -Sample application can be found here: -https://github.com/NativeScript/nativescript-geolocation-demo +## Installation + +In Command prompt / Terminal navigate to your application root folder and run: + +``` +tns plugin add nativescript-geolocation +``` + +## Usage + +The best way to explore the usage of the plugin is to inspect the demo app in the plugin's root folder. +In `demo` folder you can find the usage of the plugin for TypeScript non-Angular application. Refer to `demo/app/main-page.ts`. + +In short here are the steps: + +### Import the plugin + +*TypeScript* +``` +import * as geolocation from "nativescript-geolocation"; +import { Accuracy } from "ui/enums"; // used to describe at what accuracy the location should be get +``` + +*Javascript* +``` +var geolocation = require("nativescript-geolocation"); +``` + +### Request permissions + +``` +geolocation.enableLocationRequest(); +``` + +### Call plugin methods + +```` +// Get current location with high accuracy +geolocation.getCurrentLocation({ desiredAccuracy: Accuracy.high, updateDistance: 0.1, maximumAge: 5000, timeout: 20000 }) +```` + +## API + +### Properties + +#### Location + +| Property | Default | Description | +| --- | --- | --- | +| latitude | - | The latitude of the geolocation, in degrees. | +| longitude | - | The longitude of the geolocation, in degrees. | +| altitude | - | The altitude (if available), in meters above sea level. | +| horizontalAccuracy | - | The horizontal accuracy, in meters. | +| verticalAccuracy | - | The vertical accuracy, in meters. | +| speed | - | The speed, in meters/second over ground. | +| timestamp | - | The time at which this location was determined. | + +#### Options + +| Property | Default | Description | +| --- | --- | --- | +| desiredAccuracy? | Accuracy.high | Specifies desired accuracy in meters. | +| updateDistance | iOS - no filter, Android - 0 meters | Update distance filter in meters. Specifies how often to update the location. | +| minimumUpdateTime | - | Minimum time interval between location updates, in milliseconds (ignored on iOS). | +| maximumAge | - | How old locations to receive in ms. | +| timeout | - | How long to wait for a location in ms. | + +### Methods + +| Method | Returns | Description | +| --- | --- | --- | +| getCurrentLocation(options: Options) | Promise | Get current location applying the specified options (if any). | +| watchLocation(successCallback: successCallbackType, errorCallback: errorCallbackType, options: Options) | number | Monitor for location change. | +| clearWatch(watchId: number) | void | Stop monitoring for location change. Parameter expected is the watchId returned from `watchLocation`. | +| enableLocationRequest(always?: boolean) | Promise | Ask for permissions to use location services. The option `always` is application for iOS only. [Read more about its usage](https://developer.apple.com/documentation/corelocation/cllocationmanager/1620551-requestalwaysauthorization) . | +| isEnabled | boolean| Returns `true` if location services are enabled. | +| distance(loc1: Location, loc2: Location) | number | Calculate the distance between two locations. Returns the distance in meters. | + +## License + +Apache License Version 2.0, January 2004 \ No newline at end of file diff --git a/compile.sh b/compile.sh deleted file mode 100755 index 4277aa3..0000000 --- a/compile.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -set -x - -SOURCE_DIR=source; -PACK_DIR=dist/package/; -DIST_DIR=dist; - -cd $SOURCE_DIR -npm install -cd .. - -copy_package_files() { - cp "$SOURCE_DIR"/package.json $PACK_DIR - cp "$SOURCE_DIR"/*.md $PACK_DIR - cp "$SOURCE_DIR"/*.d.ts $PACK_DIR - cp -r "$SOURCE_DIR"/platforms $PACK_DIR -} - -#clean dist folder from previous compilation -rm -rf $DIST_DIR - -#create package folder -mkdir -p $PACK_DIR - -#compile package and copy file required by npm -$SOURCE_DIR/node_modules/.bin/tsc -p $SOURCE_DIR --outDir $PACK_DIR - -#tslint -$SOURCE_DIR/node_modules/.bin/tslint --project $SOURCE_DIR/tsconfig.json --config $SOURCE_DIR/tslint.json - -copy_package_files diff --git a/create.sh b/create.sh deleted file mode 100755 index f33c9c4..0000000 --- a/create.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -x - -DIST_DIR=dist - -pack() { - cd $DIST_DIR - npm pack ./package -} - -./compile.sh && pack diff --git a/demo/app/App_Resources/Android/AndroidManifest.xml b/demo/app/App_Resources/Android/AndroidManifest.xml new file mode 100644 index 0000000..9db8321 --- /dev/null +++ b/demo/app/App_Resources/Android/AndroidManifest.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo/app/App_Resources/Android/app.gradle b/demo/app/App_Resources/Android/app.gradle new file mode 100644 index 0000000..c9d40ec --- /dev/null +++ b/demo/app/App_Resources/Android/app.gradle @@ -0,0 +1,16 @@ +// Add your native dependencies here: + +// Uncomment to add recyclerview-v7 dependency +//dependencies { +// compile 'com.android.support:recyclerview-v7:+' +//} + +android { + defaultConfig { + generatedDensities = [] + applicationId = "org.nativescript.demo" + } + aaptOptions { + additionalParameters "--no-version-vectors" + } +} diff --git a/demo/app/App_Resources/Android/drawable-hdpi/background.png b/demo/app/App_Resources/Android/drawable-hdpi/background.png new file mode 100644 index 0000000..eb381c2 Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-hdpi/background.png differ diff --git a/demo/app/App_Resources/Android/drawable-hdpi/icon.png b/demo/app/App_Resources/Android/drawable-hdpi/icon.png new file mode 100644 index 0000000..1034356 Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-hdpi/icon.png differ diff --git a/demo/app/App_Resources/Android/drawable-hdpi/logo.png b/demo/app/App_Resources/Android/drawable-hdpi/logo.png new file mode 100644 index 0000000..5218f4c Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-hdpi/logo.png differ diff --git a/demo/app/App_Resources/Android/drawable-ldpi/background.png b/demo/app/App_Resources/Android/drawable-ldpi/background.png new file mode 100644 index 0000000..748b2ad Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-ldpi/background.png differ diff --git a/demo/app/App_Resources/Android/drawable-ldpi/icon.png b/demo/app/App_Resources/Android/drawable-ldpi/icon.png new file mode 100644 index 0000000..ddfc17a Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-ldpi/icon.png differ diff --git a/demo/app/App_Resources/Android/drawable-ldpi/logo.png b/demo/app/App_Resources/Android/drawable-ldpi/logo.png new file mode 100644 index 0000000..b9e102a Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-ldpi/logo.png differ diff --git a/demo/app/App_Resources/Android/drawable-mdpi/background.png b/demo/app/App_Resources/Android/drawable-mdpi/background.png new file mode 100644 index 0000000..efeaf29 Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-mdpi/background.png differ diff --git a/demo/app/App_Resources/Android/drawable-mdpi/icon.png b/demo/app/App_Resources/Android/drawable-mdpi/icon.png new file mode 100644 index 0000000..486e410 Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-mdpi/icon.png differ diff --git a/demo/app/App_Resources/Android/drawable-mdpi/logo.png b/demo/app/App_Resources/Android/drawable-mdpi/logo.png new file mode 100644 index 0000000..6263387 Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-mdpi/logo.png differ diff --git a/demo/app/App_Resources/Android/drawable-nodpi/splash_screen.xml b/demo/app/App_Resources/Android/drawable-nodpi/splash_screen.xml new file mode 100644 index 0000000..ada77f9 --- /dev/null +++ b/demo/app/App_Resources/Android/drawable-nodpi/splash_screen.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/demo/app/App_Resources/Android/drawable-xhdpi/background.png b/demo/app/App_Resources/Android/drawable-xhdpi/background.png new file mode 100644 index 0000000..612bbd0 Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-xhdpi/background.png differ diff --git a/demo/app/App_Resources/Android/drawable-xhdpi/icon.png b/demo/app/App_Resources/Android/drawable-xhdpi/icon.png new file mode 100644 index 0000000..f291882 Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-xhdpi/icon.png differ diff --git a/demo/app/App_Resources/Android/drawable-xhdpi/logo.png b/demo/app/App_Resources/Android/drawable-xhdpi/logo.png new file mode 100644 index 0000000..ad8ee2f Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-xhdpi/logo.png differ diff --git a/demo/app/App_Resources/Android/drawable-xxhdpi/background.png b/demo/app/App_Resources/Android/drawable-xxhdpi/background.png new file mode 100644 index 0000000..0fa88e2 Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-xxhdpi/background.png differ diff --git a/demo/app/App_Resources/Android/drawable-xxhdpi/icon.png b/demo/app/App_Resources/Android/drawable-xxhdpi/icon.png new file mode 100644 index 0000000..4f69cb2 Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-xxhdpi/icon.png differ diff --git a/demo/app/App_Resources/Android/drawable-xxhdpi/logo.png b/demo/app/App_Resources/Android/drawable-xxhdpi/logo.png new file mode 100644 index 0000000..6683278 Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-xxhdpi/logo.png differ diff --git a/demo/app/App_Resources/Android/drawable-xxxhdpi/background.png b/demo/app/App_Resources/Android/drawable-xxxhdpi/background.png new file mode 100644 index 0000000..c650f64 Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-xxxhdpi/background.png differ diff --git a/demo/app/App_Resources/Android/drawable-xxxhdpi/icon.png b/demo/app/App_Resources/Android/drawable-xxxhdpi/icon.png new file mode 100644 index 0000000..50887a8 Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-xxxhdpi/icon.png differ diff --git a/demo/app/App_Resources/Android/drawable-xxxhdpi/logo.png b/demo/app/App_Resources/Android/drawable-xxxhdpi/logo.png new file mode 100644 index 0000000..fa6331c Binary files /dev/null and b/demo/app/App_Resources/Android/drawable-xxxhdpi/logo.png differ diff --git a/demo/app/App_Resources/Android/values-v21/colors.xml b/demo/app/App_Resources/Android/values-v21/colors.xml new file mode 100644 index 0000000..a64641a --- /dev/null +++ b/demo/app/App_Resources/Android/values-v21/colors.xml @@ -0,0 +1,4 @@ + + + #3d5afe + \ No newline at end of file diff --git a/demo/app/App_Resources/Android/values-v21/styles.xml b/demo/app/App_Resources/Android/values-v21/styles.xml new file mode 100644 index 0000000..dac8727 --- /dev/null +++ b/demo/app/App_Resources/Android/values-v21/styles.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demo/app/App_Resources/Android/values/colors.xml b/demo/app/App_Resources/Android/values/colors.xml new file mode 100644 index 0000000..74ad882 --- /dev/null +++ b/demo/app/App_Resources/Android/values/colors.xml @@ -0,0 +1,7 @@ + + + #F5F5F5 + #757575 + #33B5E5 + #272734 + \ No newline at end of file diff --git a/demo/app/App_Resources/Android/values/styles.xml b/demo/app/App_Resources/Android/values/styles.xml new file mode 100644 index 0000000..1e8c7f2 --- /dev/null +++ b/demo/app/App_Resources/Android/values/styles.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..5f53593 --- /dev/null +++ b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,128 @@ +{ + "images" : [ + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "icon-29.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "icon-29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "icon-29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "icon-40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "icon-40@3x.png", + "scale" : "3x" + }, + { + "size" : "57x57", + "idiom" : "iphone", + "filename" : "icon-57.png", + "scale" : "1x" + }, + { + "size" : "57x57", + "idiom" : "iphone", + "filename" : "icon-57@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "icon-60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "icon-60@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "icon-29.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "icon-29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "icon-40.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "icon-40@2x.png", + "scale" : "2x" + }, + { + "size" : "50x50", + "idiom" : "ipad", + "filename" : "icon-50.png", + "scale" : "1x" + }, + { + "size" : "50x50", + "idiom" : "ipad", + "filename" : "icon-50@2x.png", + "scale" : "2x" + }, + { + "size" : "72x72", + "idiom" : "ipad", + "filename" : "icon-72.png", + "scale" : "1x" + }, + { + "size" : "72x72", + "idiom" : "ipad", + "filename" : "icon-72@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "icon-76.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "icon-76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "icon-83.5@2x.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png new file mode 100644 index 0000000..9e15af0 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png new file mode 100644 index 0000000..7b9e555 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png new file mode 100644 index 0000000..76f61ec Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png new file mode 100644 index 0000000..15b06db Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png new file mode 100644 index 0000000..585065f Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png new file mode 100644 index 0000000..a450c42 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png new file mode 100644 index 0000000..4a62478 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png new file mode 100644 index 0000000..01ff7c1 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png new file mode 100644 index 0000000..beea819 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png new file mode 100644 index 0000000..c3dc7b0 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png new file mode 100644 index 0000000..457b6d9 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png new file mode 100644 index 0000000..fa5a6ac Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png new file mode 100644 index 0000000..556bdd6 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png new file mode 100644 index 0000000..4f69cb2 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png new file mode 100644 index 0000000..94abcf7 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png new file mode 100644 index 0000000..2e71dd3 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png new file mode 100644 index 0000000..4abc9ec Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/Contents.json b/demo/app/App_Resources/iOS/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/demo/app/App_Resources/iOS/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 0000000..4414bad --- /dev/null +++ b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,158 @@ +{ + "images" : [ + { + "extent" : "full-screen", + "idiom" : "iphone", + "subtype" : "736h", + "filename" : "Default-736h@3x.png", + "minimum-system-version" : "8.0", + "orientation" : "portrait", + "scale" : "3x" + }, + { + "extent" : "full-screen", + "idiom" : "iphone", + "subtype" : "736h", + "filename" : "Default-Landscape@3x.png", + "minimum-system-version" : "8.0", + "orientation" : "landscape", + "scale" : "3x" + }, + { + "extent" : "full-screen", + "idiom" : "iphone", + "subtype" : "667h", + "filename" : "Default-667h@2x.png", + "minimum-system-version" : "8.0", + "orientation" : "portrait", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "filename" : "Default@2x.png", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "extent" : "full-screen", + "idiom" : "iphone", + "subtype" : "retina4", + "filename" : "Default-568h@2x.png", + "minimum-system-version" : "7.0", + "orientation" : "portrait", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "filename" : "Default-Portrait.png", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "filename" : "Default-Landscape.png", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "filename" : "Default-Portrait@2x.png", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "filename" : "Default-Landscape@2x.png", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "filename" : "Default.png", + "extent" : "full-screen", + "scale" : "1x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "filename" : "Default@2x.png", + "extent" : "full-screen", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "filename" : "Default-568h@2x.png", + "extent" : "full-screen", + "subtype" : "retina4", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "to-status-bar", + "scale" : "1x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "filename" : "Default-Portrait.png", + "extent" : "full-screen", + "scale" : "1x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "to-status-bar", + "scale" : "1x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "filename" : "Default-Landscape.png", + "extent" : "full-screen", + "scale" : "1x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "to-status-bar", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "filename" : "Default-Portrait@2x.png", + "extent" : "full-screen", + "scale" : "2x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "to-status-bar", + "scale" : "2x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "filename" : "Default-Landscape@2x.png", + "extent" : "full-screen", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png new file mode 100644 index 0000000..d7f17fc Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png new file mode 100644 index 0000000..b884154 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png new file mode 100644 index 0000000..faab4b6 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png new file mode 100644 index 0000000..3365ba3 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png new file mode 100644 index 0000000..a44945c Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png new file mode 100644 index 0000000..e6dca62 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png new file mode 100644 index 0000000..1a50079 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png new file mode 100644 index 0000000..73d8b92 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png new file mode 100644 index 0000000..9f1f6ce Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png new file mode 100644 index 0000000..514fc5c Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json new file mode 100644 index 0000000..4f4e9c5 --- /dev/null +++ b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchScreen-AspectFill.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchScreen-AspectFill@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png new file mode 100644 index 0000000..c293f9c Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png new file mode 100644 index 0000000..233693a Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json new file mode 100644 index 0000000..23c0ffd --- /dev/null +++ b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchScreen-Center.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchScreen-Center@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png new file mode 100644 index 0000000..a5a775a Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png differ diff --git a/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png new file mode 100644 index 0000000..154c193 Binary files /dev/null and b/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png differ diff --git a/demo/app/App_Resources/iOS/Info.plist b/demo/app/App_Resources/iOS/Info.plist new file mode 100644 index 0000000..ea3e3ea --- /dev/null +++ b/demo/app/App_Resources/iOS/Info.plist @@ -0,0 +1,47 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIRequiresFullScreen + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/demo/app/App_Resources/iOS/LaunchScreen.storyboard b/demo/app/App_Resources/iOS/LaunchScreen.storyboard new file mode 100644 index 0000000..2ad9471 --- /dev/null +++ b/demo/app/App_Resources/iOS/LaunchScreen.storyboard @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo/app/App_Resources/iOS/build.xcconfig b/demo/app/App_Resources/iOS/build.xcconfig new file mode 100644 index 0000000..0562055 --- /dev/null +++ b/demo/app/App_Resources/iOS/build.xcconfig @@ -0,0 +1,5 @@ +// You can add custom settings here +// for example you can uncomment the following line to force distribution code signing +// CODE_SIGN_IDENTITY = iPhone Distribution +ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; +ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; diff --git a/demo/app/app.css b/demo/app/app.css new file mode 100644 index 0000000..634f26a --- /dev/null +++ b/demo/app/app.css @@ -0,0 +1 @@ +@import 'nativescript-theme-core/css/core.light.css'; diff --git a/demo/app/app.ts b/demo/app/app.ts new file mode 100644 index 0000000..8986233 --- /dev/null +++ b/demo/app/app.ts @@ -0,0 +1,3 @@ +import "./bundle-config"; +import * as application from 'tns-core-modules/application'; +application.start({ moduleName: "main-page" }); diff --git a/demo/app/bundle-config.ts b/demo/app/bundle-config.ts new file mode 100644 index 0000000..8e4e338 --- /dev/null +++ b/demo/app/bundle-config.ts @@ -0,0 +1,5 @@ +if ((global).TNS_WEBPACK) { + require("tns-core-modules/bundle-entry-points"); + + global.registerModule("main-page", () => require("./main-page")); +} diff --git a/demo/app/main-page.ts b/demo/app/main-page.ts new file mode 100644 index 0000000..f4ae1a3 --- /dev/null +++ b/demo/app/main-page.ts @@ -0,0 +1,54 @@ +import * as geolocation from "nativescript-geolocation"; +import { Accuracy } from "ui/enums"; +import { EventData } from "data/observable"; +import { Page } from "ui/page"; +import { MainViewModel } from "./main-view-model"; + +let page: Page; +let model = new MainViewModel(); +let watchId; + +export function pageLoaded(args: EventData) { + page = args.object; + page.bindingContext = model; +} + +export function enableLocationTap() { + if (!geolocation.isEnabled()) { + geolocation.enableLocationRequest(); + } +} + +export function buttonGetLocationTap() { + let location = geolocation.getCurrentLocation({ desiredAccuracy: Accuracy.high, updateDistance: 0.1, maximumAge: 5000, timeout: 20000 }) + .then(function(loc) { + if (loc) { + model.locations.push(loc); + } + }, function(e) { + console.log("Error: " + e.message); + }); +} + +export function buttonStartTap() { + watchId = geolocation.watchLocation( + function(loc) { + if (loc) { + model.locations.push(loc); + } + }, + function(e) { + console.log("Error: " + e.message); + }, + { desiredAccuracy: Accuracy.high, updateDistance: 0.1, minimumUpdateTime: 100 }); +} + +export function buttonStopTap() { + if (watchId) { + geolocation.clearWatch(watchId); + } +} + +export function buttonClearTap() { + model.locations.splice(0, model.locations.length); +} diff --git a/demo/app/main-page.xml b/demo/app/main-page.xml new file mode 100644 index 0000000..a4abf9e --- /dev/null +++ b/demo/app/main-page.xml @@ -0,0 +1,16 @@ + + + +