@import "../themes/ionic.globals";

// Cordova Status Bar Padding iOS Platform
// --------------------------------------------------------------------------------

/// @prop - The breakpoint when a modal becomes inset
$cordova-statusbar-padding-modal-max-width:         767px !default;


@mixin statusbar-padding($toolbar-height, $toolbar-padding, $content-padding, $cordova-statusbar-padding, $modal-max-width, $style-title: false) {

  ion-nav > .ion-page,
  ion-nav > .ion-page > ion-header,
  ion-tab > .ion-page > ion-header,
  ion-tabs > .ion-page.tab-subpage > ion-header,
  ion-menu > .menu-inner,
  ion-menu > .menu-inner > ion-header {

    @include toolbar-statusbar-padding($toolbar-height, $toolbar-padding, $content-padding, $cordova-statusbar-padding);

    // 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);
    }
  }

  @media only screen and (max-width: $modal-max-width) {
    .modal-wrapper > .ion-page > ion-header {
      @include toolbar-statusbar-padding($toolbar-height, $toolbar-padding, $content-padding, $cordova-statusbar-padding);

      // 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);
      }
    }
  }

}

// The first-child should get modified padding-top for the status bar
// --------------------------------------------------------------------------------

@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);

    min-height: calc(#{$toolbar-height} + #{$cordova-statusbar-padding});
  }

  > ion-content.statusbar-padding:first-child .scroll-content {
    @include padding($cordova-statusbar-padding, 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);
  }

}


// 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) {

  > .toolbar.statusbar-padding:first-child ion-segment,
  > .toolbar.statusbar-padding:first-child ion-title {
    @include padding($cordova-statusbar-padding, null, null, null);

    height: calc(#{$toolbar-height} + #{$cordova-statusbar-padding});
    min-height: calc(#{$toolbar-height} + #{$cordova-statusbar-padding});
  }

}
