diff --git a/client/Nightr/package-lock.json b/client/Nightr/package-lock.json index 04b5e41..1469775 100644 --- a/client/Nightr/package-lock.json +++ b/client/Nightr/package-lock.json @@ -3776,6 +3776,14 @@ "reflect-metadata": "^0.1.8" } }, + "nativescript-camera": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/nativescript-camera/-/nativescript-camera-4.4.0.tgz", + "integrity": "sha512-9Snw/IGjw8cVN1nOwkhQko/x/D2thcd6FZT98k9bstvCHwdBBdmLtGGcHCm4SN0k3MSgvbghs8iaARniZCKO0Q==", + "requires": { + "nativescript-permissions": "^1.2.3" + } + }, "nativescript-dev-typescript": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/nativescript-dev-typescript/-/nativescript-dev-typescript-0.9.0.tgz", diff --git a/client/Nightr/package.json b/client/Nightr/package.json index ddcc97a..36bf9c5 100644 --- a/client/Nightr/package.json +++ b/client/Nightr/package.json @@ -22,6 +22,7 @@ "@angular/platform-browser-dynamic": "~7.2.0", "@angular/router": "~7.2.0", "nativescript-angular": "~7.2.0", + "nativescript-camera": "^4.4.0", "nativescript-geolocation": "^5.0.0", "nativescript-theme-core": "~1.0.4", "reflect-metadata": "~0.1.12", diff --git a/client/Nightr/src/app/app.component.html b/client/Nightr/src/app/app.component.html index 97b4fff..8de10bd 100644 --- a/client/Nightr/src/app/app.component.html +++ b/client/Nightr/src/app/app.component.html @@ -4,8 +4,9 @@ - + - + + diff --git a/client/Nightr/src/app/app.module.ts b/client/Nightr/src/app/app.module.ts index aefc8e2..04ef01a 100644 --- a/client/Nightr/src/app/app.module.ts +++ b/client/Nightr/src/app/app.module.ts @@ -5,6 +5,7 @@ import { AppComponent } from "./app.component"; import { MyButtonComponent } from './component/my-button/my-button.component'; import { NativeScriptHttpClientModule } from "nativescript-angular/http-client"; import { MyLocationButtonComponent } from './component/locationButton/locationButton.component'; +import { CameraButtonComponent } from './component/camera-button/camera-button.component'; // Uncomment and add to NgModule imports if you need to use two-way binding // import { NativeScriptFormsModule } from "nativescript-angular/forms"; @@ -24,6 +25,7 @@ import { MyLocationButtonComponent } from './component/locationButton/locationBu AppComponent, MyLocationButtonComponent, MyButtonComponent, + CameraButtonComponent, ], providers: [], schemas: [ diff --git a/client/Nightr/src/app/component/camera-button/camera-button.component.css b/client/Nightr/src/app/component/camera-button/camera-button.component.css new file mode 100644 index 0000000..bcd4764 --- /dev/null +++ b/client/Nightr/src/app/component/camera-button/camera-button.component.css @@ -0,0 +1 @@ +/* Add mobile styles for the component here. */ diff --git a/client/Nightr/src/app/component/camera-button/camera-button.component.html b/client/Nightr/src/app/component/camera-button/camera-button.component.html new file mode 100644 index 0000000..4fe4caf --- /dev/null +++ b/client/Nightr/src/app/component/camera-button/camera-button.component.html @@ -0,0 +1 @@ + diff --git a/client/Nightr/src/app/component/camera-button/camera-button.component.ts b/client/Nightr/src/app/component/camera-button/camera-button.component.ts new file mode 100644 index 0000000..bd916ef --- /dev/null +++ b/client/Nightr/src/app/component/camera-button/camera-button.component.ts @@ -0,0 +1,25 @@ +import { Component, OnInit } from '@angular/core'; +import { MyCameraService } from '../../services/my-camera-service'; +import { Image } from 'tns-core-modules/ui/image' + +@Component({ + selector: 'ns-camera-button', + templateUrl: './camera-button.component.html', + styleUrls: ['./camera-button.component.css'], + moduleId: module.id, +}) +export class CameraButtonComponent implements OnInit { + + camera:MyCameraService = new MyCameraService(); + constructor() { } + + ngOnInit() { + } + + onTap() { + this.camera.takePicture().then( + (res) => {console.log(res)}, () => {} + ); +} + +} diff --git a/client/Nightr/src/app/services/my-camera-service.ts b/client/Nightr/src/app/services/my-camera-service.ts new file mode 100644 index 0000000..a6a4f14 --- /dev/null +++ b/client/Nightr/src/app/services/my-camera-service.ts @@ -0,0 +1,35 @@ +import { Injectable } from '@angular/core'; +import * as camera from 'nativescript-camera'; +import { ImageSource } from 'tns-core-modules/image-source/image-source'; + +@Injectable({ + providedIn: 'root' +}) +export class MyCameraService { + + constructor() { } + + takePicture(): Promise { + var result = new Promise((resolve, reject) => { + camera.requestPermissions(). + then( + () => { + camera.takePicture().then( + (imageAsset) => { + var src = new ImageSource(); + src.fromAsset(imageAsset).then( + (source) => { + resolve(source.toBase64String("png", 75)); + alert("Image uploaded"); + } + ); + } + ).catch((error) => alert(error.message)); + }, () => { + alert("Request rejected"); + } + ).catch(); + }); + return result; + } +} diff --git a/client/Nightr/src/app/services/my-geo-location.service.ts b/client/Nightr/src/app/services/my-geo-location.service.ts index 4de390a..fa658b8 100644 --- a/client/Nightr/src/app/services/my-geo-location.service.ts +++ b/client/Nightr/src/app/services/my-geo-location.service.ts @@ -1,6 +1,5 @@ import { Injectable } from '@angular/core'; import { isEnabled, enableLocationRequest, getCurrentLocation, watchLocation, distance, clearWatch, Location } from "nativescript-geolocation"; -import { stringify } from '@angular/core/src/render3/util'; @Injectable({ providedIn: 'root' diff --git a/client/Nightr/src/main.js b/client/Nightr/src/main.js index faf70ce..d07591d 100644 --- a/client/Nightr/src/main.js +++ b/client/Nightr/src/main.js @@ -11,4 +11,4 @@ var app_module_1 = require("./app/app.module"); // so we provide a wrapper platform object, platformNativeScriptDynamic, // that sets up a NativeScript application and can bootstrap the Angular framework. platform_1.platformNativeScriptDynamic().bootstrapModule(app_module_1.AppModule); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIm1haW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwwR0FBMEc7QUFDMUcsMERBQTRFO0FBRTVFLCtDQUE2QztBQUU3QyxnRkFBZ0Y7QUFDaEYsMEVBQTBFO0FBQzFFLHNFQUFzRTtBQUN0RSx5REFBeUQ7QUFDekQseUVBQXlFO0FBQ3pFLHdFQUF3RTtBQUN4RSxtRkFBbUY7QUFDbkYsc0NBQTJCLEVBQUUsQ0FBQyxlQUFlLENBQUMsc0JBQVMsQ0FBQyxDQUFDIiwic291cmNlc0NvbnRlbn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