Skip to content

Commit 4754b12

Browse files
author
Alexander Vakrilov
authored
Merge pull request #37 from NativeScript/tns30
Update to NativeScript 3.0
2 parents acef3c8 + b058c1c commit 4754b12

26 files changed

+418
-191
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
logs
33
*.log
44
npm-debug.log*
5+
.DS_Store
56

67
# Runtime data
78
pids
@@ -40,6 +41,7 @@ jspm_packages
4041
#Exclude all javascript (js) and (js.map) files from source code
4142
**/*.js
4243
**/*.map
44+
!examples/CameraTestAngular/webpack.*.js
4345

4446
# Dist directory where create script produces plugin installation files
4547
dist

README.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
# nativescript-camera
22
NativeScript plugin to empower using device camera.
33

4-
Steps to create redistributable package.
5-
6-
1. cd to root folder of the plugin.
7-
2. npm install
8-
3. ./create.sh
4+
## Build
95

6+
Run the create script in the root of the repo:
7+
```
8+
./create.sh
9+
```
1010
This will create a `nativescript-camera-*.tgz` file (* stands for version) within ./dist folder.
11-
12-
Prerequisites:
13-
14-
1. tns-core-modules >= 2.4.0
15-
2. tns-core-modules-widgets >= 2.4.0
16-
3. tns-platform-declarations@next
17-
18-
> Note: On Android 6.0 and above it is neccessary to request permissions for camera (to be able to take picture) and access for Photos (to be able to share the image via Google Photos app).
19-
NativeScript-camera plug-in has a dedicated method called `requestPermissions()` which can be used in that case.

compile.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
#!/bin/bash
2+
set -x
23

34
SOURCE_DIR=src;
45
PACK_DIR=dist/package/;
56
DIST_DIR=dist;
67

8+
cd $SOURCE_DIR
9+
npm install
10+
cd ..
11+
712
copy_package_files() {
813
cp "$SOURCE_DIR"/package.json $PACK_DIR
914
cp "$SOURCE_DIR"/*.md $PACK_DIR
@@ -18,5 +23,5 @@ rm -rf $DIST_DIR
1823
mkdir -p $PACK_DIR
1924

2025
#compile package and copy file required by npm
21-
node_modules/.bin/tsc -p $SOURCE_DIR --outDir $PACK_DIR
26+
$SOURCE_DIR/node_modules/.bin/tsc -p $SOURCE_DIR --outDir $PACK_DIR
2227
copy_package_files

examples/CameraTest/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
"nativescript": {
77
"id": "org.nativescript.CameraTest",
88
"tns-ios": {
9-
"version": "2.5.0"
9+
"version": "3.0.0-rc.1"
1010
},
1111
"tns-android": {
12-
"version": "2.5.0"
12+
"version": "3.0.0-rc.1"
1313
}
1414
},
1515
"dependencies": {
16-
"nativescript-camera": "0.0.6",
17-
"tns-core-modules": "^2.5.1"
16+
"nativescript-camera": "*",
17+
"tns-core-modules": "^3.0.0 || ^3.0.0-rc.1"
1818
},
1919
"devDependencies": {
2020
"babel-traverse": "6.15.0",
2121
"babel-types": "6.15.0",
2222
"babylon": "6.9.1",
2323
"lazy": "1.0.11",
24-
"nativescript-dev-typescript": "^0.3.0",
25-
"typescript": "2.0.3"
24+
"nativescript-dev-typescript": "^0.4.2",
25+
"typescript": "^2.2.2"
2626
}
2727
}

examples/CameraTest/references.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/// <reference path="./node_modules/tns-core-modules/tns-core-modules.d.ts" />
1+
/// <reference path="./node_modules/tns-core-modules/tns-core-modules.d.ts" /> Needed for autocompletion and compilation.

examples/CameraTest/tsconfig.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,22 @@
55
"experimentalDecorators": true,
66
"emitDecoratorMetadata": true,
77
"noEmitHelpers": true,
8-
"noEmitOnError": true
8+
"noEmitOnError": true,
9+
"lib": [
10+
"es6",
11+
"dom"
12+
],
13+
"baseUrl": ".",
14+
"paths": {
15+
"*": [
16+
"./node_modules/tns-core-modules/*",
17+
"./node_modules/*"
18+
]
19+
}
920
},
1021
"exclude": [
1122
"node_modules",
12-
"platforms"
23+
"platforms",
24+
"**/*.aot.ts"
1325
]
1426
}

examples/CameraTestAngular/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Label text="saveToGallery"></Label>
44
<Switch [(ngModel)]="saveToGallery"></Switch>
55
</StackLayout>
6-
<Image row="1" [src]="cameraImage" id="image" stretch="aspectFit" margin="10"></Image>
6+
<Image row="1" [src]="cameraImage" stretch="aspectFit" margin="10"></Image>
77
<StackLayout orientation="horizontal" row="2" padding="10">
88
<Button text="Take Picture" (tap)='onTakePictureTap($event)'></Button>
99
<Button text="Request Permissions" (tap)='onRequestPermissionsTap()'></Button>

examples/CameraTestAngular/app/app.component.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
import { Component } from '@angular/core';
22
import { takePicture, requestPermissions } from 'nativescript-camera';
3-
import * as imageSourceModule from 'image-source';
3+
import { ImageSource } from 'tns-core-modules/image-source';
4+
import { ImageAsset } from 'tns-core-modules/image-asset';
45

56
@Component({
6-
selector: 'my-app',
7-
templateUrl: './app.component.html'
7+
selector: 'my-app',
8+
templateUrl: './app.component.html'
89
})
910
export class AppComponent {
10-
public saveToGallery: boolean = false;
11-
12-
/**
13-
*
14-
*/
15-
constructor() {
16-
this.saveToGallery = true;
17-
}
11+
public saveToGallery: boolean = true;
12+
public cameraImage: ImageAsset;
1813

1914
onTakePictureTap(args) {
20-
let imageView = args.object.page.getViewById("image");
21-
takePicture({width: 180, height: 180, keepAspectRatio: false, saveToGallery: this.saveToGallery}).then((imageAsset) => {
22-
let source = new imageSourceModule.ImageSource();
15+
takePicture({ width: 180, height: 180, keepAspectRatio: false, saveToGallery: this.saveToGallery })
16+
.then((imageAsset) => {
17+
let source = new ImageSource();
2318
source.fromAsset(imageAsset).then((source) => {
2419
console.log(`Size: ${source.width}x${source.height}`);
25-
});
26-
imageView.src = imageAsset;
20+
})
21+
this.cameraImage = imageAsset;
22+
}, (error) => {
23+
console.log("Error: " + error)
2724
});
2825
}
2926

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
2+
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
3+
import { NativeScriptFormsModule } from "nativescript-angular/forms";
4+
import { AppComponent } from "./app.component";
5+
6+
@NgModule({
7+
bootstrap: [
8+
AppComponent
9+
],
10+
imports: [
11+
NativeScriptModule,
12+
NativeScriptFormsModule
13+
],
14+
declarations: [
15+
AppComponent,
16+
],
17+
schemas: [
18+
NO_ERRORS_SCHEMA
19+
]
20+
})
21+
export class AppModule { }
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// this import should be first in order to load some required settings (like globals and reflect-metadata)
2+
import { platformNativeScript } from "nativescript-angular/platform-static";
3+
4+
import { AppModuleNgFactory } from "./app.module.ngfactory";
5+
6+
platformNativeScript().bootstrapModuleFactory(AppModuleNgFactory);
Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
// this import should be first in order to load some required settings (like globals and reflect-metadata)
2-
import { platformNativeScriptDynamic, NativeScriptModule } from "nativescript-angular/platform";
3-
import { NativeScriptFormsModule } from "nativescript-angular/forms";
4-
import { NgModule } from "@angular/core";
5-
import { AppComponent } from "./app.component";
2+
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
63

7-
@NgModule({
8-
declarations: [AppComponent],
9-
bootstrap: [AppComponent],
10-
imports: [NativeScriptModule, NativeScriptFormsModule],
11-
})
12-
class AppComponentModule {}
4+
import { AppModule } from "./app.module";
135

14-
platformNativeScriptDynamic().bootstrapModule(AppComponentModule);
6+
platformNativeScriptDynamic().bootstrapModule(AppModule);

examples/CameraTestAngular/app/vendor-platform.android.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
//Resolve JavaScript classes that extend a Java class, and need to resolve
2-
//their JavaScript module from a bundled script. For example:
3-
//NativeScriptApplication, NativeScriptActivity, etc.
1+
// Resolve JavaScript classes that extend a Java class, and need to resolve
2+
// their JavaScript module from a bundled script. For example:
3+
// NativeScriptApplication, NativeScriptActivity, etc.
44
//
5-
//This module gets bundled together with the rest of the app code and the
6-
//`require` calls get resolved to the correct bundling import call.
5+
// This module gets bundled together with the rest of the app code and the
6+
// `require` calls get resolved to the correct bundling import call.
77
//
8-
//At runtime the module gets loaded *before* the rest of the app code, so code
9-
//placed here needs to be careful about its dependencies.
8+
// At runtime the module gets loaded *before* the rest of the app code, so code
9+
// placed here needs to be careful about its dependencies.
1010

1111
require("application");
1212
require("ui/frame");
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
require("./vendor-platform");
22

3-
require('reflect-metadata');
4-
require('@angular/platform-browser');
5-
require('@angular/platform-browser-dynamic');
6-
require('@angular/core');
7-
require('@angular/common');
8-
require('@angular/forms');
9-
require('@angular/http');
10-
require('@angular/router');
3+
require("reflect-metadata");
4+
require("@angular/platform-browser");
5+
require("@angular/core");
6+
require("@angular/common");
7+
require("@angular/forms");
8+
require("@angular/http");
9+
require("@angular/router");
1110

12-
require('nativescript-angular/platform');
13-
require('nativescript-angular/forms');
14-
require('nativescript-angular/router');
11+
require("nativescript-angular/platform-static");
12+
require("nativescript-angular/forms");
13+
require("nativescript-angular/router");

examples/CameraTestAngular/package.json

Lines changed: 38 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,67 +5,55 @@
55
"repository": "<fill-your-repository-here>",
66
"nativescript": {
77
"id": "org.nativescript.CameraTestAngular",
8+
"tns-ios": {
9+
"version": "3.0.0-rc.1"
10+
},
811
"tns-android": {
9-
"version": "2.5.0"
12+
"version": "3.0.0-rc.1"
1013
}
1114
},
1215
"dependencies": {
13-
"@angular/common": "2.1.1",
14-
"@angular/compiler": "2.1.1",
15-
"@angular/core": "2.1.1",
16-
"@angular/forms": "2.1.1",
17-
"@angular/http": "2.1.1",
18-
"@angular/platform-browser": "2.1.1",
19-
"@angular/platform-browser-dynamic": "2.1.1",
20-
"@angular/router": "3.1.1",
21-
"nativescript-angular": "1.1.1",
22-
"nativescript-camera": "0.0.7",
16+
"@angular/animations": "~4.0.0",
17+
"@angular/common": "~4.0.0",
18+
"@angular/compiler": "~4.0.0",
19+
"@angular/core": "~4.0.0",
20+
"@angular/forms": "~4.0.0",
21+
"@angular/http": "~4.0.0",
22+
"@angular/platform-browser": "~4.0.0",
23+
"@angular/platform-browser-dynamic": "~4.0.0",
24+
"@angular/router": "~4.0.0",
25+
"nativescript-angular": "rc",
26+
"nativescript-camera": "*",
27+
"nativescript-theme-core": "~1.0.2",
2328
"reflect-metadata": "~0.1.8",
24-
"tns-core-modules": "^2.5.2"
29+
"rxjs": "~5.2.0",
30+
"tns-core-modules": "^3.0.0 || ^3.0.0-rc.1",
31+
"zone.js": "~0.8.2"
2532
},
2633
"devDependencies": {
27-
"awesome-typescript-loader": "~2.2.4",
28-
"babel-traverse": "6.18.0",
29-
"babel-types": "6.18.0",
30-
"babylon": "6.13.0",
31-
"copy-webpack-plugin": "~3.0.1",
32-
"html-loader": "~0.4.3",
34+
"@angular/compiler-cli": "~4.0.0",
35+
"@ngtools/webpack": "1.2.13",
36+
"babel-traverse": "6.23.1",
37+
"babel-types": "6.23.0",
38+
"babylon": "6.16.1",
39+
"copy-webpack-plugin": "^3.0.1",
40+
"extract-text-webpack-plugin": "~2.0.0-beta.4",
3341
"lazy": "1.0.11",
34-
"nativescript-dev-typescript": "0.3.2",
35-
"nativescript-dev-webpack": "^0.2.0",
36-
"typescript": "2.1.5",
37-
"webpack": "~2.1.0-beta.25",
38-
"webpack-sources": "~0.1.2",
39-
"zone.js": "~0.6.21",
42+
"nativescript-css-loader": "~0.26.0",
43+
"nativescript-dev-android-snapshot": "^0.*.*",
44+
"nativescript-dev-typescript": "~0.4.0",
45+
"nativescript-dev-webpack": "^0.3.7",
4046
"raw-loader": "~0.5.1",
41-
"css-loader": "~0.26.0",
4247
"resolve-url-loader": "~1.6.0",
43-
"extract-text-webpack-plugin": "~2.0.0-beta.4",
44-
"@angular/compiler-cli": "2.2.1",
45-
"@ngtools/webpack": "1.1.6"
48+
"typescript": "~2.2.1",
49+
"webpack": "2.2.0",
50+
"webpack-sources": "~0.1.3"
4651
},
4752
"scripts": {
48-
"clean-android": "tns clean-app android",
49-
"clean-ios": "tns clean-app ios",
50-
"prewebpack-android": "npm run clean-android",
51-
"prewebpack-ios": "npm run clean-ios",
52-
"webpack-android": "npm run clean-android && webpack --config=webpack.android.js",
53-
"webpack-ios": "npm run clean-ios && webpack --config=webpack.ios.js",
54-
"prestart-android": "npm run webpack-android",
55-
"prestart-ios": "npm run webpack-ios",
56-
"start-android": "tns run android --bundle --disable-npm-install",
57-
"start-ios": "tns run ios --bundle --disable-npm-install",
58-
"prebuild-android": "npm run webpack-android",
59-
"prebuild-ios": "npm run webpack-ios",
60-
"build-android": "tns build android --bundle --disable-npm-install",
61-
"build-ios": "tns build ios --bundle --disable-npm-install",
62-
"prestart-android-bundle": "npm run webpack-android",
63-
"prestart-ios-bundle": "npm run webpack-ios",
64-
"start-android-bundle": "tns run android --bundle --disable-npm-install",
65-
"start-ios-bundle": "tns run ios --bundle --disable-npm-install",
66-
"prebuild-android-bundle": "npm run webpack-android",
67-
"prebuild-ios-bundle": "npm run webpack-ios",
68-
"build-android-bundle": "tns build android --bundle --disable-npm-install",
69-
"build-ios-bundle": "tns build ios --bundle --disable-npm-install"
53+
"ns-bundle": "ns-bundle",
54+
"start-android-bundle": "npm run ns-bundle --android --start-app",
55+
"start-ios-bundle": "npm run ns-bundle --ios --start-app",
56+
"build-android-bundle": "npm run ns-bundle --android --build-app",
57+
"build-ios-bundle": "npm run ns-bundle --ios --build-app"
7058
}
7159
}

examples/CameraTestAngular/references.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)