Skip to content

Commit 56ac48e

Browse files
committed
finishing android
1 parent 4056f17 commit 56ac48e

12 files changed

+313
-5
lines changed

demo/app/app.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.title {
2+
font-size: 16;
3+
horizontal-align: center;
4+
margin: 20;
5+
}
6+
7+
button {
8+
font-size: 42;
9+
horizontal-align: center;
10+
}
11+
12+
.message {
13+
font-size: 20;
14+
color: #284848;
15+
horizontal-align: center;
16+
}

demo/app/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
var application = require("application");
2+
application.mainModule = "main-page";
3+
application.cssFile = "./app.css";
4+
application.start();

demo/app/main-page.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var observable = require("data/observable").Observable;
2+
var app = require("application");
3+
var color = require("color");
4+
5+
var data = new observable({});
6+
7+
function pageLoaded(args) {
8+
var page = args.object;
9+
page.bindingContext = data;
10+
}
11+
exports.pageLoaded = pageLoaded;
12+
13+
14+
function getDrawing(args) {
15+
console.log(args.object);
16+
}
17+
exports.getDrawing = getDrawing;

demo/app/main-page.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Page xmlns="http://schemas.nativescript.org/tns.xsd"
2+
xmlns:SignaturePad="nativescript-signaturepad">
3+
<ScrollView>
4+
<StackLayout>
5+
<label text="&lt;SignaturePad:SignaturePad id='sketchPad' &gt;" class="title" textWrap="true" />
6+
7+
<SignaturePad:SignaturePad id="drawingPad" penColor="#3489db" penWidth="5" />
8+
<Button text="Get Drawing" />
9+
10+
11+
</StackLayout>
12+
</ScrollView>
13+
</Page>

demo/app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"tns-template-hello-world","main":"app.js","version":"1.5.1","author":{"name":"Telerik","email":"[email protected]"},"description":"Nativescript hello-world project template","license":"Apache-2.0","keywords":["telerik","mobile","nativescript","{N}","tns","appbuilder","template"],"repository":{"type":"git","url":"git://github.com/NativeScript/template-hello-world.git"},"bugs":{"url":"https://github.com/NativeScript/template-hello-world/issues"},"homepage":"https://github.com/NativeScript/template-hello-world","android":{"v8Flags":"--expose_gc"},"readme":"ERROR: No README data found!","_id":"[email protected]","_from":"[email protected]"}

demo/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"nativescript": {
3+
"id": "org.nativescript.signaturepad",
4+
"tns-android": {
5+
"version": "1.5.1"
6+
},
7+
"tns-ios": {
8+
"version": "1.5.2"
9+
}
10+
},
11+
"dependencies": {
12+
"nativescript-signaturepad": "file:..",
13+
"tns-core-modules": "latest"
14+
}
15+
}

package.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "nativescript-signaturepad",
3+
"version": "0.1.0",
4+
"main": "signaturepad.js",
5+
"description": "A NativeScript plugin to provide a way to capture signatures (and any other drawing) from the device screen.",
6+
"nativescript": {
7+
"platforms": {
8+
"android": "1.5.0",
9+
"ios": "1.5.2"
10+
}
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/bradmartin/nativescript-signaturepad.git"
15+
},
16+
"keywords": [
17+
"NativeScript",
18+
"native",
19+
"script",
20+
"signature",
21+
"drawing",
22+
"drawing pad",
23+
"bradmartin",
24+
"Thorum"
25+
],
26+
"author": {
27+
"name": "Brad Martin",
28+
"email": "[email protected]",
29+
"url": "https://github.com/bradmartin"
30+
},
31+
"license": "Apache-2.0",
32+
"bugs": {
33+
"url": "https://github.com/bradmartin/nativescript-signaturepad/issues"
34+
},
35+
"homepage": "https://github.com/bradmartin/nativescript-signaturepad"
36+
}

signaturepad-common.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,40 @@
1-
// WIP
1+
var __extends = (this && this.__extends) || function (d, b) {
2+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
3+
function __() { this.constructor = d; }
4+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5+
};
6+
var view = require("ui/view");
7+
var proxy_1 = require("ui/core/proxy");
8+
var dependency_observable_1 = require("ui/core/dependency-observable");
9+
var penColorProperty = new dependency_observable_1.Property("penColor", "SignaturePad", new proxy_1.PropertyMetadata(undefined, dependency_observable_1.PropertyMetadataSettings.None));
10+
var penWidthProperty = new dependency_observable_1.Property("penWidth", "SignaturePad", new proxy_1.PropertyMetadata(undefined, dependency_observable_1.PropertyMetadataSettings.None));
11+
var SignaturePad = (function (_super) {
12+
__extends(SignaturePad, _super);
13+
function SignaturePad() {
14+
_super.call(this);
15+
}
16+
Object.defineProperty(SignaturePad.prototype, "penColor", {
17+
get: function () {
18+
return this._getValue(SignaturePad.penColorProperty);
19+
},
20+
set: function (value) {
21+
this._setValue(SignaturePad.penColorProperty, value);
22+
},
23+
enumerable: true,
24+
configurable: true
25+
});
26+
Object.defineProperty(SignaturePad.prototype, "penWidth", {
27+
get: function () {
28+
return this._getValue(SignaturePad.penWidthProperty);
29+
},
30+
set: function (value) {
31+
this._setValue(SignaturePad.penWidthProperty, value);
32+
},
33+
enumerable: true,
34+
configurable: true
35+
});
36+
SignaturePad.penColorProperty = penColorProperty;
37+
SignaturePad.penWidthProperty = penWidthProperty;
38+
return SignaturePad;
39+
})(view.View);
40+
exports.SignaturePad = SignaturePad;

signaturepad-common.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,41 @@
1-
// WIP
1+
import definition = require("signaturepad");
2+
import view = require("ui/view");
3+
import {PropertyMetadata} from "ui/core/proxy";
4+
import {Property, PropertyMetadataSettings} from "ui/core/dependency-observable";
5+
6+
var penColorProperty = new Property(
7+
"penColor",
8+
"SignaturePad",
9+
new PropertyMetadata(undefined, PropertyMetadataSettings.None)
10+
);
11+
12+
var penWidthProperty = new Property(
13+
"penWidth",
14+
"SignaturePad",
15+
new PropertyMetadata(undefined, PropertyMetadataSettings.None)
16+
);
17+
18+
export class SignaturePad extends view.View implements definition.SignaturePad {
19+
20+
public static penColorProperty = penColorProperty;
21+
public static penWidthProperty = penWidthProperty;
22+
23+
constructor() {
24+
super();
25+
}
26+
27+
get penColor(): number {
28+
return this._getValue(SignaturePad.penColorProperty);
29+
}
30+
set penColor(value: number) {
31+
this._setValue(SignaturePad.penColorProperty, value);
32+
}
33+
34+
get penWidth(): number {
35+
return this._getValue(SignaturePad.penWidthProperty);
36+
}
37+
set penWidth(value: number) {
38+
this._setValue(SignaturePad.penWidthProperty, value);
39+
}
40+
41+
}

signaturepad.android.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,40 @@
1-
// WIP
1+
var __extends = (this && this.__extends) || function (d, b) {
2+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
3+
function __() { this.constructor = d; }
4+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5+
};
6+
var common = require("./signaturepad-common");
7+
global.moduleMerge(common, exports);
8+
var CardView = (function (_super) {
9+
__extends(CardView, _super);
10+
function CardView() {
11+
_super.call(this);
12+
}
13+
Object.defineProperty(CardView.prototype, "android", {
14+
get: function () {
15+
return this._android;
16+
},
17+
enumerable: true,
18+
configurable: true
19+
});
20+
Object.defineProperty(CardView.prototype, "_nativeView", {
21+
get: function () {
22+
return this._android;
23+
},
24+
enumerable: true,
25+
configurable: true
26+
});
27+
CardView.prototype._createUI = function () {
28+
this._android = new com.github.gcacace.signaturepad.views.SignaturePad(this._context, null);
29+
if (!this._androidViewId) {
30+
this._androidViewId = android.view.View.generateViewId();
31+
}
32+
this._android.setId(this._androidViewId);
33+
if (this.penColor)
34+
this._android.setPenColor(this.penColor.android);
35+
if (this.penWidth)
36+
this._android.setMinWidth(this.penWidth);
37+
};
38+
return CardView;
39+
})(common.SignaturePad);
40+
exports.CardView = CardView;

0 commit comments

Comments
 (0)