mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
derp
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
import {Component} from 'angular2/angular2';
|
||||
import {Control, ControlGroup} from 'angular2/forms';
|
||||
|
||||
import {App, IonicApp, Http} from 'ionic/ionic';
|
||||
|
||||
import {Camera, Geolocation, Vibration, Battery, Device} from 'ionic/ionic';
|
||||
|
||||
import {CameraPage} from 'pages/camera';
|
||||
import {BatteryPage} from 'pages/battery';
|
||||
import {ContactsPage} from 'pages/contacts';
|
||||
import {DevicePage} from 'pages/device';
|
||||
import {DeviceMotionPage} from 'pages/device-motion';
|
||||
import {DeviceOrientationPage} from 'pages/device-orientation';
|
||||
import {GeolocationPage} from 'pages/geolocation';
|
||||
import {VibrationPage} from 'pages/vibration';
|
||||
|
||||
@App({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class MyApp {
|
||||
constructor(app: IonicApp) {
|
||||
this.app = app;
|
||||
|
||||
this.firstPage = CameraPage;
|
||||
console.log('First page', CameraPage);
|
||||
this.plugins = [
|
||||
{title: 'Camera', page: CameraPage},
|
||||
{title: 'Device', page: DevicePage},
|
||||
{title: 'Device Motion', page: DeviceMotionPage},
|
||||
{title: 'Device Orientation', page: DeviceOrientationPage},
|
||||
{title: 'Geolocation', page: GeolocationPage},
|
||||
{title: 'Contacts', page: ContactsPage},
|
||||
{title: 'Battery', page: BatteryPage},
|
||||
{title: 'Vibration', page: VibrationPage},
|
||||
];
|
||||
}
|
||||
|
||||
openPage(aside, plugin) {
|
||||
aside.close();
|
||||
|
||||
let nav = this.app.getComponent('myNav');
|
||||
nav.setItems([plugin.page]);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<ion-aside #aside [content]="content" id="menu">
|
||||
<ion-toolbar><ion-title>Plugins</ion-title></ion-toolbar>
|
||||
<ion-content>
|
||||
<ion-list>
|
||||
<ion-item *ng-for="#p of plugins" (^click)="openPage(aside, p)">
|
||||
<span>{{p.title}}</span>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
</ion-content>
|
||||
</ion-aside>
|
||||
|
||||
<ion-nav id="myNav" #content swipe-back-enabled="false" [root]="firstPage"></ion-nav>
|
||||
@@ -1,47 +0,0 @@
|
||||
import {IonicView, DeviceMotion} from 'ionic/ionic';
|
||||
|
||||
|
||||
@IonicView({
|
||||
template: `
|
||||
<ion-navbar *navbar>
|
||||
<button aside-toggle>
|
||||
<icon menu></icon>
|
||||
</button>
|
||||
<ion-title>Device Motion</ion-title>
|
||||
</ion-navbar>
|
||||
<ion-content class="padding">
|
||||
<button primary outline (click)="doDeviceMotion()">Get Device Motion</button>
|
||||
<div *ng-if="accel">
|
||||
x: <b>{{accel.x}}</b><br>
|
||||
y: <b>{{accel.y}}</b><br>
|
||||
z: <b>{{accel.z}}</b><br>
|
||||
</div>
|
||||
<button primary outline (click)="doDeviceMotionWatch()">Track Device Motion</button>
|
||||
<div *ng-if="accelTrack">
|
||||
x: <b>{{accelTrack.x}}</b><br>
|
||||
y: <b>{{accelTrack.y}}</b><br>
|
||||
z: <b>{{accelTrack.z}}</b><br>
|
||||
</div>
|
||||
</ion-content>
|
||||
`
|
||||
})
|
||||
export class DeviceMotionPage {
|
||||
doDeviceMotion() {
|
||||
let device = DeviceMotion.getCurrentAcceleration().then((resp) => {
|
||||
console.log('Device motion', resp);
|
||||
this.accel = resp.accelerationIncludingGravity;
|
||||
}, (err) => {
|
||||
console.log('Device err', err);
|
||||
});
|
||||
console.log('Got device', device);
|
||||
}
|
||||
doDeviceMotionWatch() {
|
||||
let device = DeviceMotion.watchAcceleration().source.subscribe((resp) => {
|
||||
console.log('Device motion track', resp);
|
||||
this.accelTrack = resp.accelerationIncludingGravity;
|
||||
}, (err) => {
|
||||
console.log('Device err', err);
|
||||
});
|
||||
console.log('Got device', device);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
import {IonicView, DeviceOrientation} from 'ionic/ionic';
|
||||
|
||||
import {CSS} from 'ionic/util/dom';
|
||||
|
||||
import {NgStyle, forwardRef, Host, Component, View, ElementRef} from 'angular2/angular2';
|
||||
|
||||
@IonicView({
|
||||
template: `
|
||||
<ion-navbar *navbar>
|
||||
<button aside-toggle>
|
||||
<icon menu></icon>
|
||||
</button>
|
||||
<ion-title>Device Orientation</ion-title>
|
||||
</ion-navbar>
|
||||
<ion-content class="padding">
|
||||
<div [ng-style]="imageStyle"><img src="http://ionic-io-assets.s3.amazonaws.com/ionitron-love.png" style="max-width: 100%"></div>
|
||||
</ion-content>
|
||||
`
|
||||
})
|
||||
export class DeviceOrientationPage {
|
||||
constructor() {
|
||||
this.imageStyle = {
|
||||
}
|
||||
}
|
||||
onInit() {
|
||||
let device = DeviceOrientation.watchHeading().source.subscribe((resp) => {
|
||||
this.orientation = resp;
|
||||
this.imageStyle['-webkit-transform'] = 'rotate(' + (resp.alpha || 100) + 'deg)';
|
||||
}, (err) => {
|
||||
console.log('Device err', err);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import {IonicView, Device} from 'ionic/ionic';
|
||||
|
||||
|
||||
@IonicView({
|
||||
template: `
|
||||
<ion-navbar *navbar>
|
||||
<button aside-toggle>
|
||||
<icon menu></icon>
|
||||
</button>
|
||||
<ion-title>Vibration</ion-title>
|
||||
</ion-navbar>
|
||||
<ion-content class="padding">
|
||||
<h2>Device</h2>
|
||||
<button primary outline (click)="doDevice()">Get Device</button>
|
||||
<div>
|
||||
</div>
|
||||
</ion-content>
|
||||
`
|
||||
})
|
||||
export class DevicePage {
|
||||
|
||||
doDevice() {
|
||||
let device = Device.getDevice();
|
||||
console.log('Got device', device);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<ion-aside #aside [content]="content" id="mainMenu">
|
||||
<ion-toolbar><ion-title>Ionic 2.0</ion-title></ion-toolbar>
|
||||
<ion-content>
|
||||
<ion-list>
|
||||
<ion-item *ng-for="#c of components" (^click)="openPage(aside, c)">
|
||||
<span>{{c.title}}</span>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
</ion-content>
|
||||
</ion-aside>
|
||||
|
||||
<ion-nav id="myNav" #content swipe-back-enabled="false"></ion-nav>
|
||||
|
||||
<style>
|
||||
my-modal {
|
||||
display: block;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user