mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 14:01:20 +08:00
checking in
This commit is contained in:
@ -42,30 +42,30 @@ export class IonicApp {
|
|||||||
return this._ua;
|
return this._ua;
|
||||||
}
|
}
|
||||||
|
|
||||||
matchesQuery(queryKey, queryValue) {
|
matchesQuery(queryValue) {
|
||||||
const val = this.query(queryKey);
|
let val = this.query('ionicplatform');
|
||||||
return !!(val && val == queryValue);
|
if (val) {
|
||||||
|
let valueSplit = val.toLowerCase().split(';');
|
||||||
|
for (let i = 0; i < valueSplit.length; i++) {
|
||||||
|
if (valueSplit[i] == queryValue) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
matchesUserAgent(userAgentExpression) {
|
matchesUserAgent(userAgentExpression) {
|
||||||
const rx = new RegExp(userAgentExpression, 'i');
|
let rx = new RegExp(userAgentExpression, 'i');
|
||||||
return rx.test(this._ua);
|
return rx.test(this._ua);
|
||||||
}
|
}
|
||||||
|
|
||||||
matchesPlatform(platformQueryValue, platformUserAgentExpression) {
|
matchesPlatform(queryValue, userAgentExpression) {
|
||||||
if (!platformUserAgentExpression) {
|
if (!userAgentExpression) {
|
||||||
platformUserAgentExpression = platformQueryValue;
|
userAgentExpression = queryValue;
|
||||||
}
|
}
|
||||||
return this.matchesQuery('ionicplatform', platformQueryValue) ||
|
return this.matchesQuery(queryValue) ||
|
||||||
this.matchesUserAgent(platformUserAgentExpression);
|
this.matchesUserAgent(userAgentExpression);
|
||||||
}
|
|
||||||
|
|
||||||
matchesDevice(deviceQueryValue, deviceUserAgentExpression) {
|
|
||||||
if (!deviceUserAgentExpression) {
|
|
||||||
deviceUserAgentExpression = deviceQueryValue;
|
|
||||||
}
|
|
||||||
return this.matchesQuery('ionicdevice', deviceQueryValue) ||
|
|
||||||
this.matchesUserAgent(deviceUserAgentExpression);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
width(val) {
|
width(val) {
|
||||||
@ -143,7 +143,7 @@ export function ionicBootstrap(ComponentType, config) {
|
|||||||
app.width(window.innerWidth);
|
app.width(window.innerWidth);
|
||||||
app.height(window.innerHeight);
|
app.height(window.innerHeight);
|
||||||
|
|
||||||
let platform = Platform.getActivePlatform(app);
|
let platform = Platform.create(app);
|
||||||
|
|
||||||
config = config || new IonicConfig();
|
config = config || new IonicConfig();
|
||||||
config.platform(platform);
|
config.platform(platform);
|
||||||
@ -159,8 +159,7 @@ export function ionicBootstrap(ComponentType, config) {
|
|||||||
bootstrap(ComponentType, injectableBindings).then(appRef => {
|
bootstrap(ComponentType, injectableBindings).then(appRef => {
|
||||||
app.ref(appRef);
|
app.ref(appRef);
|
||||||
|
|
||||||
let rootPlatform = platform.root();
|
platform.run();
|
||||||
rootPlatform.runAll();
|
|
||||||
|
|
||||||
resolve({
|
resolve({
|
||||||
app,
|
app,
|
||||||
|
@ -155,25 +155,16 @@ export function main(ionicBootstrap) {
|
|||||||
'tabBarPlacement': 'adam'
|
'tabBarPlacement': 'adam'
|
||||||
});
|
});
|
||||||
|
|
||||||
// myConfig.platform('ios', {
|
|
||||||
// 'tabBarPlacement': 'ios'
|
|
||||||
// });
|
|
||||||
|
|
||||||
// myConfig.device('ipad', {
|
|
||||||
// 'tabBarPlacement': 'ipad'
|
|
||||||
// });
|
|
||||||
|
|
||||||
// myConfig.platform('android', {
|
|
||||||
// 'tabBarPlacement': 'android'
|
|
||||||
// });
|
|
||||||
|
|
||||||
ionicBootstrap(MyApp, myConfig).then(root => {
|
ionicBootstrap(MyApp, myConfig).then(root => {
|
||||||
|
|
||||||
console.log('mobile', root.platform.is('mobile'))
|
console.log('mobile', root.platform.is('mobile'))
|
||||||
console.log('ipad', root.platform.is('ipad'))
|
console.log('ipad', root.platform.is('ipad'))
|
||||||
|
console.log('iphone', root.platform.is('iphone'))
|
||||||
|
console.log('phablet', root.platform.is('phablet'))
|
||||||
console.log('tablet', root.platform.is('tablet'))
|
console.log('tablet', root.platform.is('tablet'))
|
||||||
console.log('ios', root.platform.is('ios'))
|
console.log('ios', root.platform.is('ios'))
|
||||||
console.log('android', root.platform.is('android'))
|
console.log('android', root.platform.is('android'))
|
||||||
|
console.log('windows phone', root.platform.is('windowsphone'))
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,7 @@ export * from 'ionic/config/ionic-view'
|
|||||||
export * from 'ionic/components'
|
export * from 'ionic/components'
|
||||||
|
|
||||||
export * from 'ionic/platform/platform'
|
export * from 'ionic/platform/platform'
|
||||||
// export * from 'ionic/platform/core'
|
export * from 'ionic/platform/registry'
|
||||||
// export * from 'ionic/platform/android'
|
|
||||||
// export * from 'ionic/platform/ios'
|
|
||||||
|
|
||||||
export * from 'ionic/routing/router'
|
export * from 'ionic/routing/router'
|
||||||
|
|
||||||
|
@ -1,90 +1,97 @@
|
|||||||
import * as util from '../util/util';
|
import * as util from '../util/util';
|
||||||
import {Tap} from '../util/tap';
|
|
||||||
|
|
||||||
let platformRegistry = {};
|
|
||||||
let defaultPlatform;
|
|
||||||
let activePlatform;
|
|
||||||
|
|
||||||
export class Platform {
|
export class Platform {
|
||||||
|
|
||||||
load(platformName) {
|
constructor() {
|
||||||
this._c = Platform.get(platformName);
|
this._settings = {};
|
||||||
|
this._platforms = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
name() {
|
is(platformName) {
|
||||||
return this._c.name;
|
return (this._platforms.indexOf(platformName) > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
settings() {
|
settings(val) {
|
||||||
return this._c.settings || {};
|
if (arguments.length) {
|
||||||
|
this._settings = val;
|
||||||
}
|
}
|
||||||
|
return this._settings;
|
||||||
subsets() {
|
|
||||||
return this._c.subsets || [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run() {
|
run() {
|
||||||
this._c.run && this._c.run();
|
let config = null;
|
||||||
|
|
||||||
|
for (var i = 0; i < this._platforms.length; i++) {
|
||||||
|
config = Platform.get(this._platforms[i]);
|
||||||
|
config.run && config.run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parent(val) {
|
add(platformName) {
|
||||||
if (arguments.length) {
|
this._platforms.push(platformName);
|
||||||
this._parent = val;
|
|
||||||
}
|
|
||||||
return this._parent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
child(val) {
|
|
||||||
if (arguments.length) {
|
/* Static Methods */
|
||||||
this._child = val;
|
static create(app) {
|
||||||
}
|
let rootNode = null;
|
||||||
return this._child;
|
|
||||||
|
function matchPlatform(platformConfig) {
|
||||||
|
let platformNode = new PlatformNode();
|
||||||
|
platformNode.config(platformConfig);
|
||||||
|
let tmpPlatform = platformNode.getRoot(app, 0);
|
||||||
|
|
||||||
|
if (tmpPlatform) {
|
||||||
|
tmpPlatform.depth = 0;
|
||||||
|
let childPlatform = tmpPlatform.child();
|
||||||
|
while(childPlatform) {
|
||||||
|
tmpPlatform.depth++
|
||||||
|
childPlatform = childPlatform.child();
|
||||||
}
|
}
|
||||||
|
|
||||||
isMatch(app) {
|
if (!rootNode || tmpPlatform.depth > rootNode.depth) {
|
||||||
if (!this._c.isMatch) {
|
rootNode = tmpPlatform;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return this._c.isMatch(app);
|
|
||||||
}
|
|
||||||
|
|
||||||
getRoot(app, childPlatform) {
|
|
||||||
if (this.isMatch(app)) {
|
|
||||||
let parents = Platform.getSubsetParents(this.name());
|
|
||||||
|
|
||||||
if (!parents.length) {
|
|
||||||
platform = new Platform();
|
|
||||||
platform.load(this.name());
|
|
||||||
platform.child(childPlatform);
|
|
||||||
return platform;
|
|
||||||
}
|
|
||||||
|
|
||||||
let platform = null;
|
|
||||||
let rootPlatform = null;
|
|
||||||
|
|
||||||
for (let i = 0; i < parents.length; i++) {
|
|
||||||
platform = new Platform();
|
|
||||||
platform.load(parents[i]);
|
|
||||||
platform.child(this);
|
|
||||||
|
|
||||||
rootPlatform = platform.getRoot(app, this);
|
|
||||||
if (rootPlatform) {
|
|
||||||
this.parent(platform);
|
|
||||||
return rootPlatform;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
function insertSuperset(platformNode) {
|
||||||
|
let supersetPlaformName = platformNode.superset();
|
||||||
|
if (supersetPlaformName) {
|
||||||
|
let supersetPlatform = new PlatformNode();
|
||||||
|
supersetPlatform.load(supersetPlaformName);
|
||||||
|
supersetPlatform.parent(platformNode.parent());
|
||||||
|
supersetPlatform.child(platformNode);
|
||||||
|
supersetPlatform.parent().child(supersetPlatform);
|
||||||
|
platformNode.parent(supersetPlatform);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (let platformName in platformRegistry) {
|
||||||
|
matchPlatform( platformRegistry[platformName] );
|
||||||
|
}
|
||||||
|
|
||||||
static getActivePlatform(app) {
|
|
||||||
let platform = new Platform();
|
let platform = new Platform();
|
||||||
platform.load('tablet');
|
if (rootNode) {
|
||||||
|
let platformNode = rootNode.child();
|
||||||
|
while (platformNode) {
|
||||||
|
insertSuperset(platformNode);
|
||||||
|
platformNode = platformNode.child();
|
||||||
|
}
|
||||||
|
|
||||||
let root = platform.getRoot(app, null);
|
platformNode = rootNode.child();
|
||||||
console.log(root)
|
let settings = {};
|
||||||
|
while (platformNode) {
|
||||||
|
platform.add(platformNode.name());
|
||||||
|
util.extend(settings, platformNode.settings());
|
||||||
|
platformNode = platformNode.child();
|
||||||
|
}
|
||||||
|
|
||||||
|
platform.settings(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
return platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
static register(platform) {
|
static register(platform) {
|
||||||
@ -109,116 +116,93 @@ export class Platform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let rootPlatform = null;
|
|
||||||
|
|
||||||
|
class PlatformNode {
|
||||||
|
|
||||||
Platform.register({
|
load(platformName) {
|
||||||
name: 'core',
|
this._c = Platform.get(platformName);
|
||||||
subsets: [
|
|
||||||
'mobile'
|
|
||||||
],
|
|
||||||
settings: {
|
|
||||||
mode: 'a'
|
|
||||||
},
|
|
||||||
run() {
|
|
||||||
console.log('Core');
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
|
config(val) {
|
||||||
Platform.register({
|
this._c = val;
|
||||||
name: 'mobile',
|
|
||||||
subsets: [
|
|
||||||
'android',
|
|
||||||
'ios'
|
|
||||||
],
|
|
||||||
settings: {
|
|
||||||
mode: 'b'
|
|
||||||
},
|
|
||||||
run() {
|
|
||||||
console.log('Mobile');
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
|
settings() {
|
||||||
|
return this._c.settings || {};
|
||||||
|
}
|
||||||
|
|
||||||
|
name() {
|
||||||
|
return this._c.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
superset() {
|
||||||
|
return this._c.superset;
|
||||||
|
}
|
||||||
|
|
||||||
|
runAll() {
|
||||||
|
let platform = this;
|
||||||
|
while (platform) {
|
||||||
|
platform.run();
|
||||||
|
platform = platform.child();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
parent(val) {
|
||||||
|
if (arguments.length) {
|
||||||
|
this._parent = val;
|
||||||
|
}
|
||||||
|
return this._parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
child(val) {
|
||||||
|
if (arguments.length) {
|
||||||
|
this._child = val;
|
||||||
|
}
|
||||||
|
return this._child;
|
||||||
|
}
|
||||||
|
|
||||||
Platform.register({
|
|
||||||
name: 'android',
|
|
||||||
subsets: [
|
|
||||||
'tablet'
|
|
||||||
],
|
|
||||||
settings: {
|
|
||||||
mode: 'c'
|
|
||||||
},
|
|
||||||
isMatch(app) {
|
isMatch(app) {
|
||||||
return app.matchesPlatform('android');
|
if (typeof this._c._isMatched !== 'boolean') {
|
||||||
},
|
// only do the actual check once
|
||||||
run() {
|
if (!this._c.isMatch) {
|
||||||
console.log('Android');
|
this._c._isMatched = true;
|
||||||
|
} else {
|
||||||
|
this._c._isMatched = this._c.isMatch(app);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
Platform.register({
|
|
||||||
name: 'tablet',
|
|
||||||
settings: {
|
|
||||||
mode: 'd'
|
|
||||||
},
|
|
||||||
isMatch(app) {
|
|
||||||
return app.height() >= 800 || app.width() >= 800;
|
|
||||||
},
|
|
||||||
run() {
|
|
||||||
console.log('Tablet');
|
|
||||||
}
|
}
|
||||||
});
|
return this._c._isMatched;
|
||||||
|
|
||||||
|
|
||||||
Platform.register({
|
|
||||||
name: 'ios',
|
|
||||||
subsets: [
|
|
||||||
'ipad',
|
|
||||||
'iphone'
|
|
||||||
],
|
|
||||||
settings: {
|
|
||||||
mode: 'e'
|
|
||||||
},
|
|
||||||
isMatch(app) {
|
|
||||||
return app.matchesPlatform('ios');
|
|
||||||
},
|
|
||||||
run() {
|
|
||||||
console.log('iOS');
|
|
||||||
Tap.run();
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
|
getRoot(app) {
|
||||||
|
if (this.isMatch(app)) {
|
||||||
|
|
||||||
Platform.register({
|
let parents = Platform.getSubsetParents(this.name());
|
||||||
name: 'ipad',
|
|
||||||
subsets: [
|
if (!parents.length) {
|
||||||
'tablet'
|
return this;
|
||||||
],
|
|
||||||
settings: {
|
|
||||||
mode: 'f'
|
|
||||||
},
|
|
||||||
isMatch(app) {
|
|
||||||
return app.matchesDevice('ipad');
|
|
||||||
},
|
|
||||||
run() {
|
|
||||||
console.log('iPad');
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
|
let platform = null;
|
||||||
|
let rootPlatform = null;
|
||||||
|
|
||||||
Platform.register({
|
for (let i = 0; i < parents.length; i++) {
|
||||||
name: 'iphone',
|
platform = new PlatformNode();
|
||||||
settings: {
|
platform.load(parents[i]);
|
||||||
mode: 'g'
|
platform.child(this);
|
||||||
},
|
|
||||||
isMatch(app) {
|
rootPlatform = platform.getRoot(app);
|
||||||
return app.matchesDevice('iphone');
|
if (rootPlatform) {
|
||||||
},
|
this.parent(platform);
|
||||||
run() {
|
return rootPlatform;
|
||||||
console.log('iPhone');
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
let platformRegistry = {};
|
||||||
|
|
||||||
|
@ -1,155 +0,0 @@
|
|||||||
// import * as util from '../util/util';
|
|
||||||
// import {IonicConfig} from '../config/config';
|
|
||||||
|
|
||||||
|
|
||||||
// let platformRegistry = {};
|
|
||||||
|
|
||||||
// export class Platform extends IonicConfig {
|
|
||||||
|
|
||||||
// constructor(settings={}) {
|
|
||||||
// super(settings);
|
|
||||||
// this._chld = {};
|
|
||||||
// this._parent = null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// parent(val) {
|
|
||||||
// if (arguments.length) {
|
|
||||||
// this._parent = val;
|
|
||||||
// }
|
|
||||||
// return this._parent;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// app(val) {
|
|
||||||
// if (arguments.length) {
|
|
||||||
// this._app = val;
|
|
||||||
// }
|
|
||||||
// return this._app;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// name(val) {
|
|
||||||
// if (arguments.length) {
|
|
||||||
// this._name = val;
|
|
||||||
// }
|
|
||||||
// return this._name;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// is(platformName, climbToRoot) {
|
|
||||||
// if (this._name == platformName) {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// let platform = null;
|
|
||||||
|
|
||||||
// if (climbToRoot !== false) {
|
|
||||||
// platform = this._parent
|
|
||||||
// while (platform) {
|
|
||||||
// if (platform.name() == platformName) {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// platform = platform._parent;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// for (let childPlatform in this._chld) {
|
|
||||||
// platform = this._chld[childPlatform];
|
|
||||||
// platform.app(this._app);
|
|
||||||
// if (platform.is(platformName, false) == platform.isMatch()) {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// matchesQuery(queryKey, queryValue) {
|
|
||||||
// const qs = this._app.query()[queryKey];
|
|
||||||
// return !!(qs && qs == queryValue);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// matchesUserAgent(userAgentExpression) {
|
|
||||||
// const rx = new RegExp(userAgentExpression, 'i');
|
|
||||||
// return rx.test( this._app.userAgent() );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// matchesPlatform(platformQueryValue, platformUserAgentExpression) {
|
|
||||||
// return this.matchesQuery('ionicplatform', platformQueryValue) ||
|
|
||||||
// this.matchesUserAgent(platformUserAgentExpression);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// matchesDevice(deviceQueryValue, deviceUserAgentExpression) {
|
|
||||||
// return this.matchesQuery('ionicdevice', deviceQueryValue) ||
|
|
||||||
// this.matchesUserAgent(deviceUserAgentExpression);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// registerChild(platformName, PlatformClass) {
|
|
||||||
// let platform = new PlatformClass();
|
|
||||||
// platform.name(platformName);
|
|
||||||
// platform.parent(this);
|
|
||||||
// this._chld[platformName] = platform;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// root() {
|
|
||||||
// let rootPlatform = this;
|
|
||||||
// while (rootPlatform._parent) {
|
|
||||||
// rootPlatform = rootPlatform._parent;
|
|
||||||
// }
|
|
||||||
// return rootPlatform;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// runAll() {
|
|
||||||
// let platform = null;
|
|
||||||
|
|
||||||
// if (this.isMatch()) {
|
|
||||||
// this.run();
|
|
||||||
|
|
||||||
// for (let childPlatform in this._chld) {
|
|
||||||
// this._chld[childPlatform].app(this._app);
|
|
||||||
// this._chld[childPlatform].runAll();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// getActive() {
|
|
||||||
// let platform = null;
|
|
||||||
|
|
||||||
// if (this.isMatch()) {
|
|
||||||
// for (let childPlatform in this._chld) {
|
|
||||||
// this._chld[childPlatform].app(this._app);
|
|
||||||
// platform = this._chld[childPlatform].getActive();
|
|
||||||
// if (platform) {
|
|
||||||
// return platform;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return this;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// /* Methods to Override */
|
|
||||||
// isMatch() { return true; }
|
|
||||||
// run() {}
|
|
||||||
|
|
||||||
|
|
||||||
// /* Static Methods */
|
|
||||||
// static register(platformName, PlatformClass) {
|
|
||||||
// basePlatform.registerChild(platformName, PlatformClass);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// static getActivePlatform(app) {
|
|
||||||
// basePlatform.app(app);
|
|
||||||
// return basePlatform.getActive(app);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// static setBase(PlatformClass) {
|
|
||||||
// basePlatform = new PlatformClass();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// let basePlatform = null;
|
|
||||||
|
|
||||||
|
|
||||||
console.log('')
|
|
113
ionic/platform/registry.js
Normal file
113
ionic/platform/registry.js
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
import {Platform} from './platform';
|
||||||
|
import {Tap} from '../util/tap';
|
||||||
|
|
||||||
|
|
||||||
|
Platform.register({
|
||||||
|
name: 'core',
|
||||||
|
subsets: [
|
||||||
|
'android',
|
||||||
|
'ios',
|
||||||
|
'windowsphone'
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Platform.register({
|
||||||
|
name: 'mobile'
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Platform.register({
|
||||||
|
name: 'phablet',
|
||||||
|
isMatch(app) {
|
||||||
|
let smallest = Math.min(app.width(), app.height());
|
||||||
|
let largest = Math.max(app.width(), app.height());
|
||||||
|
// http://www.mydevice.io/devices/
|
||||||
|
return (smallest > 390 && smallest < 520) &&
|
||||||
|
(largest > 620 && largest < 800);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Platform.register({
|
||||||
|
name: 'tablet',
|
||||||
|
isMatch(app) {
|
||||||
|
let smallest = Math.min(app.width(), app.height());
|
||||||
|
let largest = Math.max(app.width(), app.height());
|
||||||
|
// http://www.mydevice.io/devices/
|
||||||
|
return (smallest > 460 && smallest < 820) &&
|
||||||
|
(largest > 780 && largest < 1400);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Platform.register({
|
||||||
|
name: 'android',
|
||||||
|
superset: 'mobile',
|
||||||
|
subsets: [
|
||||||
|
'phablet',
|
||||||
|
'tablet'
|
||||||
|
],
|
||||||
|
settings: {
|
||||||
|
mode: 'md'
|
||||||
|
},
|
||||||
|
isMatch(app) {
|
||||||
|
return app.matchesPlatform('android');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Platform.register({
|
||||||
|
name: 'ios',
|
||||||
|
superset: 'mobile',
|
||||||
|
subsets: [
|
||||||
|
'ipad',
|
||||||
|
'iphone'
|
||||||
|
],
|
||||||
|
settings: {
|
||||||
|
mode: 'ios'
|
||||||
|
},
|
||||||
|
isMatch(app) {
|
||||||
|
return app.matchesPlatform('ios');
|
||||||
|
},
|
||||||
|
run() {
|
||||||
|
Tap.run();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Platform.register({
|
||||||
|
name: 'ipad',
|
||||||
|
superset: 'tablet',
|
||||||
|
isMatch(app) {
|
||||||
|
return app.matchesPlatform('ipad');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Platform.register({
|
||||||
|
name: 'iphone',
|
||||||
|
subsets: [
|
||||||
|
'phablet'
|
||||||
|
],
|
||||||
|
isMatch(app) {
|
||||||
|
return app.matchesPlatform('iphone');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Platform.register({
|
||||||
|
name: 'windowsphone',
|
||||||
|
superset: 'mobile',
|
||||||
|
subsets: [
|
||||||
|
'phablet',
|
||||||
|
'tablet'
|
||||||
|
],
|
||||||
|
settings: {
|
||||||
|
mode: 'wp'
|
||||||
|
},
|
||||||
|
isMatch(app) {
|
||||||
|
return app.matchesPlatform('windowsphone', 'windows phone');
|
||||||
|
}
|
||||||
|
});
|
Reference in New Issue
Block a user