Skip to content

Commit 7f989de

Browse files
authored
Merge pull request #6 from NathanWalker/master
fix(iOS): simplification, clear background w/color, and definition fix
2 parents e7f50a8 + 4ccd790 commit 7f989de

13 files changed

+223
-157
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
*.js
22
*.js.map
33
*.log
4+
*.d.ts
5+
!index.d.ts
6+
lib
47
demo/app/*.js
58
demo/*.d.ts
69
demo/platforms

.npmignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ demo/
77
screens/
88
*.gitattributes
99
*.ts
10-
!index.d.ts
11-
!drawingpad.d.ts
10+
!*.d.ts
1211
tsconfig.json

.vscode/launch.json

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Launch on iOS Device",
6+
"type": "nativescript",
7+
"platform": "ios",
8+
"request": "launch",
9+
"appRoot": "${workspaceRoot}",
10+
"sourceMaps": true,
11+
"diagnosticLogging": false,
12+
"emulator": false
13+
},
14+
{
15+
"name": "Attach on iOS Device",
16+
"type": "nativescript",
17+
"platform": "ios",
18+
"request": "attach",
19+
"appRoot": "${workspaceRoot}",
20+
"sourceMaps": true,
21+
"diagnosticLogging": false,
22+
"emulator": false
23+
},
24+
{
25+
"name": "Launch on iOS Emulator",
26+
"type": "nativescript",
27+
"platform": "ios",
28+
"request": "launch",
29+
"appRoot": "${workspaceRoot}/demo",
30+
"sourceMaps": true,
31+
"diagnosticLogging": false,
32+
"emulator": true
33+
},
34+
{
35+
"name": "Attach on iOS Emulator",
36+
"type": "nativescript",
37+
"platform": "ios",
38+
"request": "attach",
39+
"appRoot": "${workspaceRoot}",
40+
"sourceMaps": true,
41+
"diagnosticLogging": false,
42+
"emulator": true
43+
},
44+
{
45+
"name": "Launch on Android Device",
46+
"type": "nativescript",
47+
"platform": "android",
48+
"request": "launch",
49+
"appRoot": "${workspaceRoot}",
50+
"sourceMaps": true,
51+
"diagnosticLogging": false,
52+
"emulator": false
53+
},
54+
{
55+
"name": "Launch on Android Emulator",
56+
"type": "nativescript",
57+
"platform": "android",
58+
"request": "launch",
59+
"appRoot": "${workspaceRoot}",
60+
"sourceMaps": true,
61+
"diagnosticLogging": false,
62+
"emulator": true
63+
},
64+
{
65+
"name": "Attach on Android Device",
66+
"type": "nativescript",
67+
"platform": "android",
68+
"request": "attach",
69+
"appRoot": "${workspaceRoot}",
70+
"sourceMaps": true,
71+
"diagnosticLogging": false,
72+
"emulator": false
73+
},
74+
{
75+
"name": "Attach on Android Emulator",
76+
"type": "nativescript",
77+
"platform": "android",
78+
"request": "attach",
79+
"appRoot": "${workspaceRoot}",
80+
"sourceMaps": true,
81+
"diagnosticLogging": false,
82+
"emulator": true
83+
}
84+
]
85+
}

demo/app/main-page.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</StackLayout>
1313
<GridLayout padding="10" rows="*, *" columns="*, *">
1414
<Label text="Pen Width:" class="message" textWrap="true" row="0" col="0" />
15-
<Label text="{{ penWidth }}" class="message" textWrap="true" row="0" col="1" />
15+
<Label text="{{ penWidth }}" class="message" textWrap="true" row="0" col="1" />
1616
</GridLayout>
1717
<Slider margin="10" backgroundColor="#ff4801" id="widthSlider" value="{{ penWidth }}" maxValue="20" minValue="1" />
1818
</StackLayout>

demo/app/main-view-model.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,15 @@ import { DrawingPad } from 'nativescript-drawingpad';
99
export class HelloWorldModel extends Observable {
1010
private _myDrawingPad: DrawingPad;
1111
private _widthSlider: Slider;
12+
private _penInput: any;
1213
private _colorPicker: ColorPicker;
1314

14-
public penWidth: string;
15-
public penColor: string;
15+
public penWidth: number = 5;
16+
public penColor: string = '#3489db';
1617

1718
constructor(mainPage: Page) {
1819
super();
1920
this._myDrawingPad = <DrawingPad>mainPage.getViewById('drawingPad');
20-
this._widthSlider = <Slider>mainPage.getViewById('widthSlider');
21-
this._widthSlider.on('propertyChange', (args: PropertyChangeData) => {
22-
this.set('penWidth', args.value);
23-
});
24-
25-
this.penWidth = '5';
26-
this.penColor = '#3489db';
2721
this._colorPicker = new ColorPicker();
2822
}
2923

@@ -42,11 +36,10 @@ export class HelloWorldModel extends Observable {
4236
this.set('penColor', '#ff4801');
4337
}
4438

45-
4639
public openColorPicker() {
47-
this._colorPicker.show('#3489db', 'RGB').then((result) => {
40+
this._colorPicker.show('#3489db', 'HEX').then((result) => {
4841
console.log('color int: ' + result);
49-
this.set('penColor', new Color(result).android);
42+
this.set('penColor', result);
5043
}).catch((err) => {
5144
console.log(err);
5245
})

demo/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"nativescript": {
33
"id": "org.nativescript.demo",
44
"tns-ios": {
5-
"version": "2.0.0"
5+
"version": "2.1.1"
66
},
77
"tns-android": {
88
"version": "2.1.1"
99
}
1010
},
1111
"dependencies": {
12-
"nativescript-color-picker": "^1.1.0",
12+
"nativescript-color-picker": "^1.3.0",
1313
"nativescript-drawingpad": "file:..",
1414
"tns-core-modules": "^2.0.0"
1515
},

drawingpad-common.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/// <reference path="./drawingpad.d.ts" />
2-
import { View } from "ui/core/view";
1+
import { View } from "ui/core/view";
32
import { PropertyMetadata } from "ui/core/proxy";
43
import { Property, PropertyMetadataSettings } from "ui/core/dependency-observable";
54

drawingpad.android.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ function onPenColorPropertyChanged(data: PropertyChangeData) {
2727
global.moduleMerge(common, exports);
2828

2929
declare var com: any;
30+
let SignaturePad: any = com.github.gcacace.signaturepad.views.SignaturePad;
3031

3132
export class DrawingPad extends common.DrawingPad {
32-
private _android: com.github.gcacace.signaturepad.views.SignaturePad;
33+
private _android: any;
3334

3435
get android() {
3536
return this._android;
@@ -41,7 +42,7 @@ export class DrawingPad extends common.DrawingPad {
4142

4243
public _createUI() {
4344

44-
this._android = new com.github.gcacace.signaturepad.views.SignaturePad(this._context, null);
45+
this._android = new SignaturePad(this._context, null);
4546

4647
if (this.penColor) {
4748
this._android.setPenColor(new Color(this.penColor).android);

drawingpad.d.ts

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)