@import "../../globals.ios";
@import "./tabs";

// iOS Tabs
// --------------------------------------------------

$tabbar-ios-background:               $toolbar-ios-background !default;
$tabbar-ios-item-padding:             0 10px !default;
$tabbar-ios-item-font-size:           10px !default;
$tabbar-ios-item-icon-size:           30px !default;
$tabbar-ios-height:                   49px !default;

$tab-button-ios-max-width:            240px !default;
$tab-button-ios-active-color:         $toolbar-ios-active-color !default;
$tab-button-ios-inactive-color:       $toolbar-ios-inactive-color !default;


tabbar {
  border-top: 1px solid $toolbar-ios-border-color;
  background: $tabbar-ios-background;
}

ion-tabs[tabbarPlacement=top] tabbar {
  border-top: 0;
  border-bottom: 1px solid $toolbar-ios-border-color;
}

.tab-button {
  padding: $tabbar-ios-item-padding;

  max-width: $tab-button-ios-max-width;
  min-height: $tabbar-ios-height;

  color: $tab-button-ios-inactive-color;
}

.tab-button:hover:not(.disable-hover),
.tab-button[aria-selected=true] {
  color: $tab-button-ios-active-color;
}

.tab-button-text {
  margin-top: 0;
  margin-bottom: 0;

  min-height: $tabbar-ios-item-font-size + 1;

  font-size: $tabbar-ios-item-font-size;
}

.has-title-only .tab-button-text {
  font-size: $tabbar-ios-item-font-size + 2;
}

.tab-button-icon {
  min-width: $tabbar-ios-item-icon-size + 5;
  height: $tabbar-ios-item-icon-size;

  font-size: $tabbar-ios-item-icon-size;

  &::before {
    vertical-align: top;
  }
}

[tabbarLayout=icon-right] .tab-button,
[tabbarLayout=icon-left] .tab-button {

  .tab-button-text {
    font-size: 1.4rem;
    line-height: 1.1;
  }

  ion-icon {
    min-width: 24px;
    height: 26px;

    font-size: 24px;
  }
}

[tabbarLayout=icon-hide] .tab-button,
.tab-button.has-title-only {
  min-height: $tabbar-ios-height - 8;

  .tab-button-text {
    margin: 2px 0;

    font-size: 1.4rem;
    line-height: 1.1;
  }
}

[tabbarLayout=title-hide] .tab-button,
.tab-button.icon-only {
  min-height: $tabbar-ios-height - 8;
}

&.hairlines ion-tabs {

  tabbar {
    border-top-width: $hairlines-width;
  }

  &[tabbarPlacement="top"] tabbar {
    border-bottom-width: $hairlines-width;
  }

}


// iOS Tabbar Color Mixin
// --------------------------------------------------

@mixin tabbar-ios($color-name, $color-base, $color-contrast) {

  ion-tabs[#{$color-name}] tabbar {
    border-color: darken($color-base, 10%);
    background-color: $color-base;

    .tab-button {
      color: $color-contrast;
    }

    .tab-button:hover:not(.disable-hover),
    .tab-button[aria-selected=true] {
      color: $color-contrast;
    }
  }

}


// iOS Tabbar Color Generation
// --------------------------------------------------

@each $color-name, $color-base, $color-contrast in get-colors($colors-ios) {

  @include tabbar-ios($color-name, $color-base, $color-contrast);
}
