initial repo creation
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { AboutPage } from './about.page';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
IonicModule,
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
RouterModule.forChild([{ path: '', component: AboutPage }])
|
||||
],
|
||||
declarations: [AboutPage]
|
||||
})
|
||||
export class AboutPageModule {}
|
||||
@@ -0,0 +1,16 @@
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>Photo Gallery</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content>
|
||||
<img [src]="currentImage" *ngIf="currentImage">
|
||||
|
||||
<ion-fab vertical="bottom" horizontal="center" slot="fixed">
|
||||
<ion-fab-button (click)="takePicture()">
|
||||
<ion-icon name="camera"></ion-icon>
|
||||
</ion-fab-button>
|
||||
</ion-fab>
|
||||
|
||||
</ion-content>
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AboutPage } from './about.page';
|
||||
|
||||
describe('AboutPage', () => {
|
||||
let component: AboutPage;
|
||||
let fixture: ComponentFixture<AboutPage>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [AboutPage],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(AboutPage);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
|
||||
|
||||
@Component({
|
||||
selector: 'app-about',
|
||||
templateUrl: 'about.page.html',
|
||||
styleUrls: ['about.page.scss']
|
||||
})
|
||||
export class AboutPage {
|
||||
currentImage: any;
|
||||
|
||||
constructor(private camera: Camera) { }
|
||||
|
||||
takePicture() {
|
||||
const options: CameraOptions = {
|
||||
quality: 100,
|
||||
destinationType: this.camera.DestinationType.DATA_URL,
|
||||
encodingType: this.camera.EncodingType.JPEG,
|
||||
mediaType: this.camera.MediaType.PICTURE
|
||||
}
|
||||
|
||||
this.camera.getPicture(options).then((imageData) => {
|
||||
// imageData is either a base64 encoded string or a file URI
|
||||
this.currentImage = 'data:image/jpeg;base64,' + imageData;
|
||||
}, (err) => {
|
||||
// Handle error
|
||||
console.log("Camera issue:" + err);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user