Skip to content

Commit 3a4be60

Browse files
committed
Added contributor, bumped version number
1 parent 196b605 commit 3a4be60

2 files changed

Lines changed: 96 additions & 66 deletions

File tree

demo/app/main-view-model.ts

Lines changed: 91 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,106 @@
1-
import { Observable } from 'tns-core-modules/data/observable';
2-
import { ImageCropper } from 'nativescript-imagecropper';
1+
import { Observable } from "tns-core-modules/data/observable";
2+
import { ImageCropper } from "nativescript-imagecropper";
33
import * as camera from "nativescript-camera";
44
import * as permissions from "nativescript-permissions";
55
import { Image } from "tns-core-modules/ui/image";
66
import * as frameModule from "tns-core-modules/ui/frame";
7-
import * as imageSource from 'tns-core-modules/image-source';
7+
import * as imageSource from "tns-core-modules/image-source";
88

99
declare var android: any;
1010

1111
export class ImageCropperModel extends Observable {
12-
private imageCropper: ImageCropper;
13-
private imageSource: imageSource.ImageSource;
14-
private croppedImage;
12+
private imageCropper: ImageCropper;
13+
private imageSource: imageSource.ImageSource;
14+
private croppedImage;
1515

16-
constructor() {
17-
super();
16+
constructor() {
17+
super();
1818

19-
this.imageCropper = new ImageCropper();
20-
this.croppedImage = frameModule.topmost().getViewById("croppedImage");
21-
}
19+
this.imageCropper = new ImageCropper();
20+
this.croppedImage = frameModule.topmost().getViewById("croppedImage");
21+
}
2222

23-
tapCameraAction = function() {
24-
if (camera.isAvailable()) {
25-
permissions.requestPermission([android.Manifest.permission.CAMERA, android.Manifest.permission.WRITE_EXTERNAL_STORAGE])
26-
.then(() => {
27-
camera.takePicture({width:300,height:300,keepAspectRatio:true})
28-
.then((imageAsset) => {
29-
let source = new imageSource.ImageSource();
30-
source.fromAsset(imageAsset).then((source) => {
31-
this.imageCropper.show(source).then((args) => {
32-
console.dir(args);
33-
if(args.image !== null){
34-
this.croppedImage.imageSource = args.image;
35-
}
36-
})
37-
.catch(function(e){
38-
console.dir(e);
39-
});
23+
tapCameraAction = function() {
24+
if (camera.isAvailable()) {
25+
permissions
26+
.requestPermission([
27+
android.Manifest.permission.CAMERA,
28+
android.Manifest.permission.WRITE_EXTERNAL_STORAGE
29+
])
30+
.then(() => {
31+
camera
32+
.takePicture({
33+
width: 500,
34+
height: 500,
35+
keepAspectRatio: true
36+
})
37+
.then(imageAsset => {
38+
let source = new imageSource.ImageSource();
39+
source.fromAsset(imageAsset).then(source => {
40+
this.imageCropper
41+
.show(source)
42+
.then(args => {
43+
console.dir(args);
44+
if (args.image !== null) {
45+
this.croppedImage.imageSource =
46+
args.image;
47+
}
48+
})
49+
.catch(function(e) {
50+
console.dir(e);
51+
});
52+
});
53+
})
54+
.catch(err => {
55+
console.log("Error -> " + err.message);
56+
});
57+
})
58+
.catch(function() {
59+
// When user denies permission
60+
console.log("User denied permissions");
4061
});
41-
}).catch((err) => {
42-
console.log("Error -> " + err.message);
43-
});
44-
})
45-
.catch(function () {
46-
// When user denies permission
47-
console.log("User denied permissions");
48-
});
49-
}
50-
};
62+
}
63+
};
5164

52-
tapCameraActionResize = function() {
53-
if (camera.isAvailable()) {
54-
permissions.requestPermission([android.Manifest.permission.CAMERA, android.Manifest.permission.WRITE_EXTERNAL_STORAGE])
55-
.then(() => {
56-
camera.takePicture({width:300,height:300,keepAspectRatio:true})
57-
.then((imageAsset) => {
58-
let source = new imageSource.ImageSource();
59-
source.fromAsset(imageAsset).then((source) => {
60-
this.imageCropper.show(source,{width:100,height:100}).then((args) => {
61-
console.dir(args);
62-
if(args.image !== null){
63-
this.croppedImage.imageSource = args.image;
64-
}
65-
})
66-
.catch(function(e){
67-
console.dir(e);
68-
});
65+
tapCameraActionResize = function() {
66+
if (camera.isAvailable()) {
67+
permissions
68+
.requestPermission([
69+
android.Manifest.permission.CAMERA,
70+
android.Manifest.permission.WRITE_EXTERNAL_STORAGE
71+
])
72+
.then(() => {
73+
camera
74+
.takePicture({
75+
width: 300,
76+
height: 300,
77+
keepAspectRatio: true
78+
})
79+
.then(imageAsset => {
80+
let source = new imageSource.ImageSource();
81+
source.fromAsset(imageAsset).then(source => {
82+
this.imageCropper
83+
.show(source, { width: 500, height: 500 })
84+
.then(args => {
85+
console.dir(args);
86+
if (args.image !== null) {
87+
this.croppedImage.imageSource =
88+
args.image;
89+
}
90+
})
91+
.catch(function(e) {
92+
console.dir(e);
93+
});
94+
});
95+
})
96+
.catch(err => {
97+
console.log("Error -> " + err.message);
98+
});
99+
})
100+
.catch(function() {
101+
// When user denies permission
102+
console.log("User denied permissions");
69103
});
70-
}).catch((err) => {
71-
console.log("Error -> " + err.message);
72-
});
73-
})
74-
.catch(function () {
75-
// When user denies permission
76-
console.log("User denied permissions");
77-
});
78-
}
79-
};
104+
}
105+
};
80106
}

src/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-imagecropper",
3-
"version": "0.1.2",
3+
"version": "1.0.0",
44
"description": "NativeScript Image Cropper Plugin",
55
"main": "imagecropper",
66
"typings": "index.d.ts",
@@ -62,6 +62,10 @@
6262
"name": "Brad Martin",
6363
"email": "bmartin@nstudio.io",
6464
"url": "https://github.com/bradmartin"
65+
},
66+
{
67+
"name": "Dick Smith",
68+
"url": "https://github.com/DickSmith"
6569
}
6670
],
6771
"repository": {

0 commit comments

Comments
 (0)