diff --git a/components/ionBody/ionBody.js b/components/ionBody/ionBody.js index 48cc2ac..8abbd74 100644 --- a/components/ionBody/ionBody.js +++ b/components/ionBody/ionBody.js @@ -1,17 +1,21 @@ -isIOS = function () { - return !!navigator.userAgent.match(/iPad/i) || !!navigator.userAgent.match(/iPhone/i) || !!navigator.userAgent.match(/iPod/i); -}; +Platform = { + isIOS: function () { + return (!!navigator.userAgent.match(/iPad/i) || !!navigator.userAgent.match(/iPhone/i) || !!navigator.userAgent.match(/iPod/i)) + || Session.get('platformOverride') === 'iOS'; + }, -isAndroid = function () { - return navigator.userAgent.indexOf('Android') > 0; + isAndroid: function () { + return navigator.userAgent.indexOf('Android') > 0 + || Session.get('platformOverride') === 'Android'; + } }; Template.registerHelper('isIOS', function () { - return isIOS(); + return Platform.isIOS(); }); Template.registerHelper('isAndroid', function () { - return isAndroid(); + return Platform.isAndroid(); }); Template.ionBody.helpers({ @@ -24,10 +28,10 @@ Template.ionBody.helpers({ if (Meteor.isClient) { classes.push('platform-web'); } - if (Meteor.isCordova && isIOS()) { + if ((Meteor.isCordova && Platform.isIOS()) || Session.get('platformOverride') === 'iOS') { classes.push('platform-ios'); } - if (Meteor.isCordova && isAndroid()) { + if ((Meteor.isCordova && Platform.isAndroid()) || Session.get('platformOverride') === 'Android') { classes.push('platform-android'); } diff --git a/components/ionContent/ionContent.js b/components/ionContent/ionContent.js index e597b7f..9642af7 100644 --- a/components/ionContent/ionContent.js +++ b/components/ionContent/ionContent.js @@ -22,6 +22,10 @@ Template.ionContent.helpers({ classes.push('has-tabs'); } + if (Session.get('hasTabsTop')) { + classes.push('has-tabs-top'); + } + if (Session.get('hasFooter')) { classes.push('has-footer'); } diff --git a/components/ionHeaderBar/ionHeaderBar.js b/components/ionHeaderBar/ionHeaderBar.js index 0858ae2..03d5589 100644 --- a/components/ionHeaderBar/ionHeaderBar.js +++ b/components/ionHeaderBar/ionHeaderBar.js @@ -1,16 +1,25 @@ Template.ionHeaderBar.rendered = function () { Session.set('hasHeader', true); - var align = this.alignTitle || 'center'; - var $title = this.$('.title'); + function alignTitle () { + var align = this.alignTitle || 'center'; + var $title = this.$('.title'); - if (align === 'center') { - $title.addClass('title-center'); - } else if (align === 'left') { - $title.addClass('title-left'); - } else if (align === 'right') { - $title.addClass('title-right'); - } + if (align === 'center' && Platform.isAndroid()) { + $title.addClass('title-left'); + return; + } + + if (align === 'center') { + $title.addClass('title-center'); + } else if (align === 'left') { + $title.addClass('title-left'); + } else if (align === 'right') { + $title.addClass('title-right'); + } + }; + + alignTitle.call(this); }; Template.ionHeaderBar.destroyed = function () { diff --git a/components/ionNavBar/ionNavBar.js b/components/ionNavBar/ionNavBar.js index 52a8c2b..8f95ba0 100644 --- a/components/ionNavBar/ionNavBar.js +++ b/components/ionNavBar/ionNavBar.js @@ -1,5 +1,5 @@ Template.ionNavBar.created = function () { - if (isAndroid()) { + if (Platform.isAndroid()) { this.transition = 'android'; } else { this.transition = 'ios'; @@ -20,18 +20,31 @@ Template.ionNavBar.created = function () { Template.ionNavBar.rendered = function () { Session.set('hasHeader', true); - var align = this.alignTitle || 'center'; - var $title = this.$('.title'); + function alignTitle () { + var align = this.alignTitle || 'center'; + var $title = this.$('.title'); - if (align === 'center') { - $title.addClass('title-center'); - } else if (align === 'left') { - $title.addClass('title-left'); - } else if (align === 'right') { - $title.addClass('title-right'); - } + if (align === 'center' && Platform.isAndroid()) { + $title.addClass('title-left'); + return; + } + + if (align === 'center') { + $title.addClass('title-center'); + } else if (align === 'left') { + $title.addClass('title-left'); + } else if (align === 'right') { + $title.addClass('title-right'); + } + }; + + function positionTitle () { + + }; + + alignTitle.call(this); + positionTitle.call(this); - // Animate the title var template = this; this.find('[data-navbar-container]')._uihooks = { insertElement: function(node, next) { @@ -44,6 +57,9 @@ Template.ionNavBar.rendered = function () { if ($node.hasClass('title')) { $node.insertBefore(next).addClass('title-entering title-stage'); + + alignTitle.call(template); + Meteor.setTimeout(function() { $node.removeClass('title-stage').addClass('title-active'); }, 16); diff --git a/components/ionNavView/ionNavView.js b/components/ionNavView/ionNavView.js index a480ed4..38706bb 100644 --- a/components/ionNavView/ionNavView.js +++ b/components/ionNavView/ionNavView.js @@ -1,7 +1,7 @@ Template.ionNavView.created = function () { Session.setDefault('ionNavDirection', 'forward'); - if (isAndroid()) { + if (Platform.isAndroid()) { this.transition = 'android'; } else { this.transition = 'ios'; diff --git a/components/ionTabs/ionTabs.js b/components/ionTabs/ionTabs.js index ccebcbd..e14e4f4 100644 --- a/components/ionTabs/ionTabs.js +++ b/components/ionTabs/ionTabs.js @@ -1,9 +1,17 @@ Template.ionTabs.rendered = function () { - Session.set('hasTabs', true); + if (Platform.isAndroid()) { + Session.set('hasTabsTop', true); + } + if (this.class && this.class === 'tabs-top') { + Session.set('hasTabsTop', true); + } else { + Session.set('hasTabs', true); + } }; Template.ionTabs.destroyed = function () { Session.set('hasTabs', false); + Session.set('hasTabsTop', false); }; Template.ionTabs.helpers({ @@ -12,6 +20,10 @@ Template.ionTabs.helpers({ if (this.class) { classes.push(this.class); + } + + if (Platform.isAndroid()) { + classes.push('tabs-top tabs-striped tabs-icon-left'); } else { classes.push('tabs-icon-top'); } diff --git a/package.js b/package.js index 69b886e..0a51c4b 100644 --- a/package.js +++ b/package.js @@ -1,7 +1,7 @@ Package.describe({ name: "meteoric:ionic", summary: "Ionic components for Meteor. No Angular!", - version: "0.1.4", + version: "0.1.5", git: "https://github.com/meteoric/meteor-ionic.git" }); @@ -94,6 +94,8 @@ Package.onUse(function(api) { "components/ionView/ionView.js" ], "client"); + api.export("Platform"); + api.export("IonActionSheet"); api.export("IonBackdrop"); api.export("IonLoading");