Skip to content

Commit

Permalink
Fixed documentation and changed return on value
Browse files Browse the repository at this point in the history
  • Loading branch information
Robson authored and Robson committed May 28, 2019
1 parent 76d8d6b commit 61f0bab
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Swift original measure project: https://github.com/levantAJ/Measure

## Supported Platforms

- iOS
- iOS (Requires ARKit support iOS 11.3+)

## Installation
cordova plugin add https://github.com/robsonala/cordova-plugin-measure
Expand Down Expand Up @@ -40,9 +40,9 @@ cordova.plugins.measure.start({allowMultiplePoints: true});
Set listener for event from measures

```js
cordova.plugins.arkit.onMeasureUpdate((data) => {});
cordova.plugins.measure.onMeasureUpdate((data) => {});

// Example: {"data": "10.00cm"}
// Example: data = {"10.00cm"}
```

----
Expand All @@ -52,16 +52,16 @@ cordova.plugins.arkit.onMeasureUpdate((data) => {});
Set listener when the view is dismissed

```js
cordova.plugins.arkit.onFinish((data) => {});
cordova.plugins.measure.onFinish((data) => {});

/*
Examples:
IF allowMultiplePoints == FALSE:
["10.00cm"]
data = "10.00cm"
IF allowMultiplePoints == TRUE:
["10.00cm", "20.14cm", ...]
data = ["10.00cm", "20.14cm", ...]
*/
```

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-measure",
"version": "1.0.0",
"version": "1.1.0",
"description": "Cordova plugin using ARKit(iOS) to calculate distance of real world objects",
"cordova": {
"id": "cordova-plugin-measure",
Expand All @@ -16,6 +16,6 @@
"arcore"
],
"author": "Robson Alviani <robsonala@gmail.com>",
"license": "ISC"
"license": "MIT"
}

2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-plugin-measure" version="1.0.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<plugin id="cordova-plugin-measure" version="1.1.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>cordova-plugin-measure</name>

<js-module name="cordova-plugin-measure" src="www/cordova-plugin-measure.js">
Expand Down
16 changes: 10 additions & 6 deletions src/ios/MeasurePlugin+ViewControllerDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@ extension MeasurePlugin: ViewControllerDelegate {

func closeView() {
let data = myViewController.getMeasures();

var result: CDVPluginResult
if (!allowMultiple() && data.count > 0) {
result = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: data[0])
} else {
result = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: data)
}

myViewController.view.removeFromSuperview()
self.myViewController = nil

guard let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: data) else { return }

result.setKeepCallbackAs(true)
commandDelegate!.send(result, callbackId: finishListenerCallbackId)
}

func onUpdateMeasure(nodeName: String) {
let data = ["data": nodeName];
guard let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: data) else { return }
guard let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: nodeName) else { return }
result.setKeepCallbackAs(true)
commandDelegate!.send(result, callbackId: measureListenerCallbackId)
}
Expand All @@ -30,4 +34,4 @@ extension MeasurePlugin: ViewControllerDelegate {
finishListenerCallbackId = command.callbackId
}

}
}
4 changes: 2 additions & 2 deletions www/cordova-plugin-measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ var pluginName = 'MeasurePlugin';
/**
* Callback listener for Measure changes
*/
exports.onMeasureUpdate = function (success, error) {
exports.onMeasureUpdate = function (success = function(){}, error = function(){}) {
exec(success, error, pluginName, 'setMeasureListener');
};

/**
* Callback when the view is dismissed
*/
exports.onFinish = function (success, error) {
exports.onFinish = function (success = function(){}, error = function(){}) {
exec(success, error, pluginName, 'setFinishListener');
};

Expand Down

0 comments on commit 61f0bab

Please sign in to comment.