mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat(platforms): Android and iOS Specific Styles and Transitions
This commit is contained in:
@@ -92,7 +92,8 @@ describe('bar directives', function() {
|
||||
function setup(attrs) {
|
||||
var el;
|
||||
ionic.views.HeaderBar = function(opts) {
|
||||
this.opts = opts;
|
||||
this.alignTitle = opts.alignTitle;
|
||||
this.el = opts.el;
|
||||
this.align = jasmine.createSpy('align');
|
||||
};
|
||||
inject(function($compile, $rootScope) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
describe('ionNavBackButton directive', function() {
|
||||
beforeEach(module('ionic'));
|
||||
|
||||
@@ -76,4 +77,29 @@ describe('ionNavBackButton directive', function() {
|
||||
expect(el.scope().$navBack).not.toHaveBeenCalled();
|
||||
expect(el.scope().doSomething).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
describe('ionNavBackButton directive: Platforms', function() {
|
||||
describe('ionNavBackButton directive: iOS Platform', function() {
|
||||
beforeEach(function($provide) {
|
||||
TestUtil.setPlatform('ios');
|
||||
});
|
||||
|
||||
it('Should set default back button icon from ionicNavBarConfig ', inject(function($ionicNavBarConfig) {
|
||||
var el = setup();
|
||||
expect(el.hasClass('ion-ios7-arrow-back')).toBe(true);
|
||||
}));
|
||||
});
|
||||
|
||||
describe('ionNavBackButton directive: Android Platform', function() {
|
||||
beforeEach(function($provide) {
|
||||
TestUtil.setPlatform('android');
|
||||
});
|
||||
|
||||
it('Should set default back button icon from ionicNavBarConfig ', inject(function($ionicNavBarConfig) {
|
||||
var el = setup();
|
||||
expect(el.hasClass('ion-android-arrow-back')).toBe(true);
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -294,4 +294,60 @@ describe('ionNavBar', function() {
|
||||
expect(el.hasClass('reverse')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('platforms', function() {
|
||||
function setup(attrs, content) {
|
||||
var el;
|
||||
inject(function($compile, $rootScope) {
|
||||
el = $compile('<ion-nav-bar '+(attrs||'')+'>'+(content||'')+'</ion-nav-bar>')($rootScope.$new());
|
||||
$rootScope.$apply();
|
||||
});
|
||||
return el;
|
||||
}
|
||||
|
||||
describe('iOS', function() {
|
||||
beforeEach(module('ionic', function($provide) {
|
||||
TestUtil.setPlatform('ios');
|
||||
$provide.constant('$ionicNavBarConfig', {
|
||||
alignTitle: 'center',
|
||||
transition: 'nav-title-slide-ios7',
|
||||
backButtonIcon: 'ion-ios7-arrow-back'
|
||||
});
|
||||
}));
|
||||
|
||||
it('should have correct title align', function() {
|
||||
var el = setup();
|
||||
var controller = el.controller('ionNavBar');
|
||||
expect(controller._headerBarView.alignTitle).toBe('center');
|
||||
});
|
||||
|
||||
it('Should have correct transition', function() {
|
||||
var el = setup();
|
||||
expect(el.hasClass('nav-title-slide-ios7')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Android', function() {
|
||||
beforeEach(module('ionic', function($provide) {
|
||||
TestUtil.setPlatform('android');
|
||||
$provide.constant('$ionicNavBarConfig', {
|
||||
alignTitle: 'left',
|
||||
transition: 'no-animation',
|
||||
backButtonIcon: 'ion-android-back'
|
||||
});
|
||||
}));
|
||||
|
||||
it('should have correct title align', function() {
|
||||
var el = setup();
|
||||
var controller = el.controller('ionNavBar');
|
||||
expect(controller._headerBarView.alignTitle).toBe('left');
|
||||
});
|
||||
|
||||
it('Should have correct transition', function() {
|
||||
var el = setup();
|
||||
// Nav bar titles don't animation by default on Android
|
||||
expect(el.hasClass('no-animation')).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -260,6 +260,35 @@ describe('tabs', function() {
|
||||
var el = setup('', '<div class="content"></div>');
|
||||
expect(el[0].querySelector('.tabs .content')).toBeTruthy();
|
||||
});
|
||||
|
||||
describe('platform Styles', function() {
|
||||
describe('iOS', function() {
|
||||
beforeEach(module('ionic', function($provide) {
|
||||
TestUtil.setPlatform('ios');
|
||||
$provide.constant('$ionicTabsConfig', {
|
||||
type: ''
|
||||
});
|
||||
}));
|
||||
|
||||
it('should set iOS style', function() {
|
||||
var el = setup();
|
||||
expect(el.hasClass('tabs-striped')).not.toBe(true);
|
||||
});
|
||||
});
|
||||
describe('android', function() {
|
||||
beforeEach(module('ionic', function($provide) {
|
||||
TestUtil.setPlatform('android');
|
||||
$provide.constant('$ionicTabsConfig', {
|
||||
type: 'tabs-striped'
|
||||
});
|
||||
}));
|
||||
|
||||
it('should set Android style', function() {
|
||||
var el = setup();
|
||||
expect(el.hasClass('tabs-striped')).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('ionicTab controller', function() {
|
||||
|
||||
Reference in New Issue
Block a user