Skip to content

Commit

Permalink
feat(): initial iphoneX support
Browse files Browse the repository at this point in the history
* feat(cordova): add ios11 safeAreaInsets support

* feat(cordova): ios11 padding mixin

* chore(dependencies): go to angular 4.1.3

* chore(build): temporarily disable git pull and status from master as part of build

* fix(sass): add a mixin for the safe-area-padding

* style(sass): fix sass lint errors

* style(): tabs, footer, content changes

* fix(): lint

* style(sass): fix sass linter error

* refactor(footer): use safe area for all modes

* fix(tabs): increase font-weight of tabs for iOS 11

* style(): fix content padding and sizing

* style(sass): fix linter and remove unused vars

* style(): actionsheet, toast, header updates

* fix(): sass lint

* chore(): backout release changes

* chore(): update to lastest master
  • Loading branch information
mhartington committed Sep 26, 2017
1 parent f42e81b commit 112d4f5
Show file tree
Hide file tree
Showing 13 changed files with 199 additions and 21 deletions.
1 change: 1 addition & 0 deletions scripts/gulp/tasks/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ task('release.pullLatest', (done: Function) => {
done();
}
});
done();
});

task('release.prepareChangelog', () => {
Expand Down
4 changes: 4 additions & 0 deletions src/components/action-sheet/action-sheet.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ $action-sheet-ios-button-cancel-font-weight: 600 !default;
@include text-align($action-sheet-ios-text-align);
}

.action-sheet-ios .action-sheet-wrapper {
@include margin(auto, auto, constant(safe-area-inset-bottom), auto);
}

.action-sheet-ios .action-sheet-container {
@include deprecated-variable(padding, $action-sheet-ios-padding) {
@include padding($action-sheet-ios-padding-top, $action-sheet-ios-padding-end, $action-sheet-ios-padding-bottom, $action-sheet-ios-padding-start);
Expand Down
54 changes: 40 additions & 14 deletions src/components/content/content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,40 +91,66 @@ ion-app [no-padding] .scroll-content {
}

@mixin content-padding($mode, $content-padding) {
ion-app.#{$mode} [padding],
ion-app.#{$mode} [padding] .scroll-content {
ion-app.#{$mode} [padding] {
@include padding($content-padding);
}

ion-app.#{$mode} [padding-top],
ion-app.#{$mode} [padding-top] .scroll-content {
ion-app.#{$mode} [padding-top] {
@include padding($content-padding, null, null, null);
}

ion-app.#{$mode} [padding-left],
ion-app.#{$mode} [padding-left] .scroll-content {
ion-app.#{$mode} [padding-left] {
@include padding-horizontal($content-padding, null);
}

ion-app.#{$mode} [padding-right],
ion-app.#{$mode} [padding-right] .scroll-content {
ion-app.#{$mode} [padding-right] {
@include padding-horizontal(null, $content-padding);
}

ion-app.#{$mode} [padding-bottom],
ion-app.#{$mode} [padding-bottom] .scroll-content {
ion-app.#{$mode} [padding-bottom] {
@include padding(null, null, $content-padding, null);
}

ion-app.#{$mode} [padding-vertical],
ion-app.#{$mode} [padding-vertical] .scroll-content {
ion-app.#{$mode} [padding-vertical] {
@include padding($content-padding, null, $content-padding, null);
}

ion-app.#{$mode} [padding-horizontal],
ion-app.#{$mode} [padding-horizontal] .scroll-content {
ion-app.#{$mode} [padding-horizontal] {
@include padding-horizontal($content-padding);
}

// Scroll content should use safe-area-padding
ion-app.#{$mode} [padding] .scroll-content {
@include safe-area-padding($content-padding);
}

ion-app.#{$mode} .scroll-content {
@include safe-area-no-padding($content-padding);
}

ion-app.#{$mode} [padding-top] .scroll-content {
@include safe-area-padding($content-padding, null, null, null);
}

ion-app.#{$mode} [padding-left] .scroll-content {
@include safe-area-padding-horizontal($content-padding, null);
}

ion-app.#{$mode} [padding-right] .scroll-content {
@include safe-area-padding-horizontal(null, $content-padding);
}

ion-app.#{$mode} [padding-bottom] .scroll-content {
@include safe-area-padding(null, null, $content-padding, null);
}

ion-app.#{$mode} [padding-vertical] .scroll-content {
@include safe-area-padding($content-padding, null, $content-padding, null);
}

ion-app.#{$mode} [padding-horizontal] .scroll-content {
@include safe-area-padding-horizontal($content-padding);
}
}


Expand Down
3 changes: 2 additions & 1 deletion src/components/content/content.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Input, NgZone, OnDestroy, Optional, Output, Renderer, ViewChild, ViewEncapsulation } from '@angular/core';
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, EventEmitter, HostListener, Input, NgZone, OnDestroy, Optional, Output, Renderer, ViewChild, ViewEncapsulation } from '@angular/core';

import { App } from '../app/app';
import { Config } from '../../config/config';
Expand Down Expand Up @@ -670,6 +670,7 @@ export class Content extends Ion implements OnDestroy, AfterViewInit, IContent {
* Tell the content to recalculate its dimensions. This should be called
* after dynamically adding/removing headers, footers, or tabs.
*/
@HostListener('window:resize')
resize() {
this._dom.read(this._readDimensions.bind(this));
this._dom.write(this._writeDimensions.bind(this));
Expand Down
4 changes: 3 additions & 1 deletion src/components/item/item.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ $item-ios-sliding-content-background: $list-ios-background-color !default;

.item-ios [item-right], // deprecated
.item-ios [item-end] {
@include margin($item-ios-padding-media-top, ($item-ios-padding-start / 2), $item-ios-padding-media-bottom, ($item-ios-padding-end / 2));
@include margin($item-ios-padding-media-top, null, $item-ios-padding-media-bottom, ($item-ios-padding-end / 2));

@include safe-area-padding-horizontal(null, ($item-ios-padding-start / 4));
}

.item-ios ion-icon[item-left], // deprecated
Expand Down
1 change: 1 addition & 0 deletions src/components/picker/picker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ ion-picker-cmp {
}

.picker-columns {
@include margin(null, null, constant(safe-area-inset-bottom), null);
position: relative;
display: flex;

Expand Down
4 changes: 4 additions & 0 deletions src/components/tabs/tabs.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ $tabs-ios-tab-icon-color-active: $tabs-ios-tab-color-active !default;
/// @prop - Font size of the tab button text
$tabs-ios-tab-font-size: 10px !default;

/// @prop - Font weight of the tab button text
$tabs-ios-tab-font-weight: 500 !default;

/// @prop - Size of the tab button icon
$tabs-ios-tab-icon-size: 30px !default;

Expand All @@ -63,6 +66,7 @@ $tabs-ios-tab-icon-size: 30px !default;
min-height: $tabs-ios-tab-min-height;

font-size: $tabs-ios-tab-font-size;
font-weight: $tabs-ios-tab-font-weight;
color: $tabs-ios-tab-text-color;

@include deprecated-variable(padding, $tabs-ios-tab-padding) {
Expand Down
2 changes: 2 additions & 0 deletions src/components/toast/toast.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ $toast-ios-title-padding-start: $toast-ios-title-padding-end !

.toast-ios .toast-wrapper.toast-top {
@include transform(translate3d(0, -100%, 0));
@include margin(constant(safe-area-inset-top), auto, auto, auto);

top: 0;
}

.toast-ios .toast-wrapper.toast-bottom {
@include transform(translate3d(0, 100%, 0));

@include margin(auto, auto, constant(safe-area-inset-bottom), auto);
bottom: 0;
}

Expand Down
6 changes: 4 additions & 2 deletions src/platform/cordova.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ $cordova-ios-statusbar-padding-modal-max-width: $cordova-statusbar-paddi

// Cordova mixins are in the main cordova file
.ios {
@include statusbar-padding($toolbar-ios-height, $toolbar-ios-padding, $content-ios-padding, $cordova-ios-statusbar-padding, $cordova-ios-statusbar-padding-modal-max-width, true);
}
@include statusbar-padding($toolbar-ios-height, $toolbar-ios-padding, $content-ios-padding, $cordova-ios-statusbar-padding, $cordova-ios-statusbar-padding-modal-max-width, true);

@include footer-safe-area($toolbar-ios-height, $toolbar-ios-padding);
}
2 changes: 2 additions & 0 deletions src/platform/cordova.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ $cordova-md-statusbar-padding-modal-max-width: $cordova-statusbar-paddin
// Cordova mixins are in the main cordova file
.md {
@include statusbar-padding($toolbar-md-height, $toolbar-md-padding, $content-md-padding, $cordova-md-statusbar-padding, $cordova-md-statusbar-padding-modal-max-width);

@include footer-safe-area($toolbar-md-height, $toolbar-md-padding);
}

29 changes: 26 additions & 3 deletions src/platform/cordova.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ $cordova-statusbar-padding-modal-max-width: 767px !default;

ion-nav > .ion-page,
ion-nav > .ion-page > ion-header,
ion-tab > .ion-page,
ion-tab > .ion-page > ion-header,
ion-tabs > .ion-page.tab-subpage > ion-header,
ion-menu > .menu-inner,
Expand All @@ -20,7 +21,7 @@ $cordova-statusbar-padding-modal-max-width: 767px !default;

// If we should style the title elements in the toolbar
@if ($style-title) {
@include toolbar-title-statusbar-padding($toolbar-height, $content-padding, $cordova-statusbar-padding);
@include toolbar-title-statusbar-padding($toolbar-height, $toolbar-padding, $content-padding, $cordova-statusbar-padding);
}
}

Expand All @@ -30,7 +31,7 @@ $cordova-statusbar-padding-modal-max-width: 767px !default;

// If we should style the title elements in the toolbar
@if ($style-title) {
@include toolbar-title-statusbar-padding($toolbar-height, $content-padding, $cordova-statusbar-padding);
@include toolbar-title-statusbar-padding($toolbar-height, $toolbar-padding, $content-padding, $cordova-statusbar-padding);
}
}
}
Expand All @@ -42,19 +43,24 @@ $cordova-statusbar-padding-modal-max-width: 767px !default;

@mixin toolbar-statusbar-padding($toolbar-height, $toolbar-padding, $content-padding, $cordova-statusbar-padding) {


> .toolbar.statusbar-padding:first-child {
@include padding(calc(#{$cordova-statusbar-padding} + #{$toolbar-padding}), null, null, null);
@include padding(calc(constant(safe-area-inset-top) + #{$toolbar-padding}), calc(constant(safe-area-inset-right) + #{$toolbar-padding}), null, calc(constant(safe-area-inset-left) + #{$toolbar-padding}));

min-height: calc(#{$toolbar-height} + #{$cordova-statusbar-padding});
min-height: calc(#{$toolbar-height} + constant(safe-area-inset-top));
}

> ion-content.statusbar-padding:first-child .scroll-content {
@include padding($cordova-statusbar-padding, null, null, null);
@include padding(calc(#{$cordova-statusbar-padding} + constant(safe-area-inset-top)), null, null, null);
}

> ion-content.statusbar-padding:first-child[padding] .scroll-content,
> ion-content.statusbar-padding:first-child[padding-top] .scroll-content {
@include padding(calc(#{$content-padding} + #{$cordova-statusbar-padding}), null, null, null);
@include padding(calc(#{$content-padding} + constant(safe-area-inset-top)), null, null, null);
}

}
Expand All @@ -63,14 +69,31 @@ $cordova-statusbar-padding-modal-max-width: 767px !default;
// iOS is the only mode that uses this mixin and it should be removed with #5036
// --------------------------------------------------------------------------------

@mixin toolbar-title-statusbar-padding($toolbar-height, $content-padding, $cordova-statusbar-padding) {
@mixin toolbar-title-statusbar-padding($toolbar-height, $toolbar-padding, $content-padding, $cordova-statusbar-padding) {

> .toolbar.statusbar-padding:first-child ion-segment,
> .toolbar.statusbar-padding:first-child ion-title {
@include padding($cordova-statusbar-padding, null, null, null);
@include padding(calc(constant(safe-area-inset-top) + #{$toolbar-padding}), null, null, null);

height: calc(#{$toolbar-height} + #{$cordova-statusbar-padding});
height: calc(#{$toolbar-height} + constant(safe-area-inset-top));

min-height: calc(#{$toolbar-height} + #{$cordova-statusbar-padding});
min-height: calc(#{$toolbar-height} + constant(safe-area-inset-top));
}

}


@mixin footer-safe-area($toolbar-height, $toolbar-padding) {
.tabs .tabbar {
@include padding(null, null, constant(safe-area-inset-bottom), null);
}

ion-footer .toolbar:last-child {
@include padding(null, null, calc(constant(safe-area-inset-top) + #{$toolbar-padding}), null);
height: calc(#{$toolbar-height} + constant(safe-area-inset-top));
min-height: calc(#{$toolbar-height} + constant(safe-area-inset-top));
}
}
2 changes: 2 additions & 0 deletions src/platform/cordova.wp.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ $cordova-wp-statusbar-padding-modal-max-width: $cordova-statusbar-paddin
// Cordova mixins are in the main cordova file
.wp {
@include statusbar-padding($toolbar-wp-height, $toolbar-wp-padding, $content-wp-padding, $cordova-wp-statusbar-padding, $cordova-wp-statusbar-padding-modal-max-width);

@include footer-safe-area($toolbar-wp-height, $toolbar-wp-padding);
}
108 changes: 108 additions & 0 deletions src/themes/ionic.mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -538,3 +538,111 @@
}
}
}


// Add safe-area transform for all directions
// Used by item-reorder
// @param {string} $transforms - comma separated list of transforms
@mixin reorder-safe-translate($transforms...) {
$extra: null;

$x: null;
$ltr-translate: null;
$rtl-translate: null;

@each $transform in $transforms {
@if (str-index($transform, translate3d)) {
$transform: str-replace($transform, 'translate3d(');
$transform: str-replace($transform, ')');

$coordinates: str-split($transform, ',');

$x: nth($coordinates, 1);
$y: nth($coordinates, 2);
$z: nth($coordinates, 3);

$ltr-translate: translate3d(calc(-1 * constant(safe-area-inset-right)), 0, 0);
$rtl-translate: translate3d(constant(safe-area-inset-left), $y, $z);
} @else {
@if $extra == null {
$extra: $transform;
} @else {
$extra: $extra $transform;
}
}
}

@if $x == '0' or $x == null {
@include multi-dir() {
transform: $ltr-translate $extra;
}
} @else {
@include ltr() {
transform: $ltr-translate $extra;
}

@include rtl() {
transform: $rtl-translate $extra;
}
}
}

// Add safe-area-padding for all directions
// @param {string} $top
// @param {string} $end
// @param {string} $bottom
// @param {string} $start
// ----------------------------------------------------------
@mixin safe-area-padding($top, $end: $top, $bottom: $top, $start: $end) {
$safe-area-start: null;

@if ($start) {
$safe-area-start: calc(constant(safe-area-inset-left) + #{$start});
}

@include padding($top, $end, $bottom, $start);

@media screen and (orientation: landscape) {
@include padding($top, $end, $bottom, $safe-area-start);
}
}


// Add safe area padding horizontal
// @param {string} $start
// @param {string} $end
// ----------------------------------------------------------
@mixin safe-area-padding-horizontal($start, $end: $start) {
$safe-area-end: null;
$safe-area-start: null;

@if ($end) {
$safe-area-end: calc(constant(safe-area-inset-right) + #{$end});
}
@if ($start) {
$safe-area-start: calc(constant(safe-area-inset-left) + #{$start});
}

@include padding-horizontal($start, $end);

@media screen and (orientation: landscape) {
@include padding-horizontal($safe-area-start, $safe-area-end);
}
}


// Add safe area padding to a screen
// only if it is landscape mode, then only on the left
// @param {string} $start
// ----------------------------------------------------------
@mixin safe-area-no-padding($start) {
$safe-area-start: null;

@if ($start) {
$safe-area-start: calc(constant(safe-area-inset-left) + #{$start});
}

@media screen and (orientation: landscape) {
@include padding-horizontal($safe-area-start, null);
}
}

1 comment on commit 112d4f5

@theHellyar
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove the safe area on the tabs when tabsPlacement="top" ? causing the tabs to be place too high...

Please sign in to comment.