Skip to content

Commit

Permalink
fix(header): add iOS 8 support to iOS header fix. assumes all iOS wil…
Browse files Browse the repository at this point in the history
…l have 7 style headers. closes #1625
  • Loading branch information
perrygovier committed Jun 18, 2014
1 parent c8ced5a commit 4a2296d
Show file tree
Hide file tree
Showing 4 changed files with 263 additions and 11 deletions.
20 changes: 10 additions & 10 deletions scss/_platform.scss
Original file line number Diff line number Diff line change
Expand Up @@ -96,39 +96,39 @@
*/
//}

.platform-ios7.platform-cordova {
// iOS7 has a status bar which sits on top of the header.
.platform-ios.platform-cordova {
// iOS7/8 has a status bar which sits on top of the header.
// Bump down everything to make room for it. However, if
// if its in Cordova, and set to fullscreen, then disregard the bump.
&:not(.fullscreen) {
.bar-header:not(.bar-subheader) {
height: $bar-height + $ios7-statusbar-height;
height: $bar-height + $ios-statusbar-height;

&.item-input-inset .item-input-wrapper {
margin-top: 19px !important;
}

> * {
margin-top: $ios7-statusbar-height;
margin-top: $ios-statusbar-height;
}
}
.tabs-top > .tabs,
.tabs.tabs-top {
top: $bar-height + $ios7-statusbar-height;
top: $bar-height + $ios-statusbar-height;
}

.has-header,
.bar-subheader {
top: $bar-height + $ios7-statusbar-height;
top: $bar-height + $ios-statusbar-height;
}
.has-subheader {
top: (2 * $bar-height) + $ios7-statusbar-height;
top: (2 * $bar-height) + $ios-statusbar-height;
}
.has-tabs-top {
top: $bar-height + $tabs-height + $ios7-statusbar-height;
top: $bar-height + $tabs-height + $ios-statusbar-height;
}
.has-header.has-subheader.has-tabs-top {
top: 2 * $bar-height + $tabs-height + $ios7-statusbar-height;
top: 2 * $bar-height + $tabs-height + $ios-statusbar-height;
}
}
&.status-bar-hide {
Expand All @@ -138,7 +138,7 @@
}

@media (orientation:landscape) {
.platform-ios7.platform-browser.platform-ipad {
.platform-ios.platform-browser.platform-ipad {
position: fixed; // required for iPad 7 Safari
}
}
Expand Down
2 changes: 1 addition & 1 deletion scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -684,4 +684,4 @@ $z-index-view: 1 !default;
// Platform
// -------------------------------

$ios7-statusbar-height: 20px !default;
$ios-statusbar-height: 20px !default;
106 changes: 106 additions & 0 deletions test/css/headers-ios.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<!DOCTYPE html>
<html ng-app="ionic">
<head>
<script src="../../dist/js/ionic.bundle.js"></script>
<meta charset="utf-8">
<title>Header</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<link href="../../dist/css/ionic.css" rel="stylesheet">
<style>
.bar {
position: relative;
top: 0;
}
</style>
</head>
<body class="platform-ios platform-ios8 platform-cordova">

<content>

<header class="bar bar-header">
<a class="button" href="index.html">Back</a>
<h1 class="title">Really really really really really really really really long title!</h1>
<a class="button icon ion-home"> Home</a>
</header>

<div class="bar bar-header-subheader">
<a class="button icon ion-navicon"> Home</a>
<div class="button-bar">
<a class="button">First</a>
<a class="button">Second</a>
<a class="button">Third</a>
</div>
<a class="button">
Favorites
</a>
</div>

<header class="bar bar-header bar-positive">
<a class="button icon ion-navicon"> Home</a>
<div class="button-bar">
<a class="button button-calm">First</a>
<a class="button">Second</a>
<a class="button">Third</a>
</div>
<a class="button">
<i class="icon ion-star"></i> Favorites
</a>
</header>

<header class="bar bar-header bar-royal">
<a class="button button-clear icon ion-ios7-alarm"> Back</a>
<div class="button-bar">
<a class="button button-calm">First</a>
<a class="button">Second</a>
<a class="button">Third</a>
</div>
<a class="button">
<i class="icon ion-star"></i> Favorites
</a>
</header>

<header class="bar bar-header bar-positive">
<a class="button button-clear icon ion-ios7-arrow-back"> Back</a>
<div class="button-bar">
<a class="button button-calm">First</a>
<a class="button">Second</a>
<a class="button">Third</a>
</div>
<a class="button">
<i class="icon ion-star"></i> Favorites
</a>
</header>

<div class="bar bar-header bar-calm">
<a class="button button-icon icon ion-home"></a>
<div class="button-bar">
<a href="#" class="button button-clear">Edit</a>
<a href="#" class="button button-clear">Teach</a>
<a href="#" class="button button-clear">Delete</a>
</div>
<a class="button button-icon">
<i class="icon ion-home"></i>
</a>
</div>

<header class="bar bar-header bar-dark">
<a class="button icon ion-home"></a>
<div class="button-bar">
<a class="button">First</a>
<a class="button">Second</a>
<a class="button">Third</a>
</div>
<a class="button">
<i class="icon ion-star"></i>
</a>
</header>

<header class="bar bar-header bar-stable">
<button class="button button-clear button-icon ion-ios7-arrow-back"> Back</button>
<h1 class="title">Title here</h1>
</header>

</ion-content>

</body>
</html>
146 changes: 146 additions & 0 deletions test/html/status-bar-toggles.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<!DOCTYPE html>
<html ng-app="ionicApp">
<head>
<meta charset="utf-8">
<title>Status Bar</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<link href="../../dist/css/ionic.css" rel="stylesheet">
<style>
#ios-status-bar {
position: absolute;
width: 100%;
height: 20px;
background: blue;
color: white;
text-align: center;
z-index: 9999;
display: none;
}
.platform-cordova.platform-ios #ios-status-bar {
display: block;
}
</style>
<script src="../../dist/js/ionic.bundle.js"></script>
<script>
angular.module('ionicApp', ['ionic'])

.controller('AppCtrl', function($scope, $timeout){

$scope.fullScreenTrueTrue = function() {
ionic.Platform.fullScreen(true, true);
showBodyClass();
};

$scope.fullScreenFalseTrue = function() {
ionic.Platform.fullScreen(false, true);
showBodyClass();
};

$scope.fullScreenFalseFalse = function() {
ionic.Platform.fullScreen(false, false);
showBodyClass();
};

$scope.fullScreenTrueFalse = function() {
ionic.Platform.fullScreen(true, false);
showBodyClass();
};

$scope.fullScreenDefault = function() {
ionic.Platform.fullScreen();
showBodyClass();
};

$scope.fullScreenTrueDefault = function() {
ionic.Platform.fullScreen(true);
showBodyClass();
};

$scope.fullScreenFalseDefault = function() {
ionic.Platform.fullScreen(false);
showBodyClass();
};

$scope.ios = function() {
document.body.classList.toggle('platform-ios');
showBodyClass();
};

$scope.android = function() {
document.body.classList.toggle('platform-android');
showBodyClass();
};

$scope.cordova = function() {
document.body.classList.toggle('platform-cordova');
showBodyClass();
};

$scope.init = function() {
showBodyClass();
};

function showBodyClass() {
$timeout(function(){
$scope.bodyClass = document.body.className;
$scope.isFullScreen = ionic.Platform.isFullScreen;
$scope._showStatusBar = ionic.Platform._showStatusBar;
}, 50);
}

});

// fake cordova
window.StatusBar = {
show: function() {
console.log('StatusBar show');
document.getElementById('ios-status-bar').style.display = '';
},
hide: function() {
console.log('StatusBar hide');
document.getElementById('ios7-status-bar').style.display = 'none';
}
}

</script>
</head>
<body ng-controller="AppCtrl" ng-init="init()">

<div id="ios-status-bar">Fake iOS Status Bar</div>

<header class="bar bar-header">
<a class="button" href="./">Back</a>
<h1 class="title">Status Bar</h1>
<a class="button icon ion-home" href="./"> Home</a>
</header>

<div class="content padding" style="padding-top: 100px">

<p><code>fullScreen: function(showFullScreen, showStatusBar)</code></p>

<p><code>Body Class: {{ bodyClass }}</code></p>

<p><code>isFullScreen: {{ isFullScreen }}</code></p>

<p><code>_showStatusBar: {{ _showStatusBar }}</code></p>

<p>
<button ng-click="fullScreenDefault()">fullScreen()</button>
<button ng-click="fullScreenTrueDefault()">fullScreen(true)</button>
<button ng-click="fullScreenFalseDefault()">fullScreen(false)</button>
<button ng-click="fullScreenTrueTrue()">fullScreen(true, true)</button>
<button ng-click="fullScreenFalseTrue()">fullScreen(false, true)</button>
<button ng-click="fullScreenFalseFalse()">fullScreen(false, false)</button>
<button ng-click="fullScreenTrueFalse()">fullScreen(true, false)</button>
</p>

<p>
<button ng-click="cordova()">.platform-cordova</button>
<button ng-click="ios()">.platform-ios</button>
<button ng-click="android()">.platform-android</button>
</p>

</div>

</body>
</html>

0 comments on commit 4a2296d

Please sign in to comment.