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

// iOS Button
// --------------------------------------------------

$button-ios-margin:                   .4rem .2rem !default;
$button-ios-padding:                  0 1em !default;
$button-ios-font-size:                1.6rem !default;
$button-ios-height:                   2.8em !default;
$button-ios-color:                    color($colors-ios, primary) !default;
$button-ios-color-activated:          color-shade($button-ios-color) !default;
$button-ios-text-color:               color-contrast($colors-ios, $button-ios-color) !default;
$button-ios-hover-opacity:            .8 !default;
$button-ios-border-radius:            4px !default;

$button-ios-large-font-size:          2rem !default;
$button-ios-large-height:             2.8em !default;
$button-ios-large-padding:            1em !default;
$button-ios-small-font-size:          1.3rem !default;
$button-ios-small-height:             2.1em !default;
$button-ios-small-padding:            .9em !default;
$button-ios-small-icon-font-size:     1.3em !default;


// iOS Default Button
// --------------------------------------------------

.button {
  margin: $button-ios-margin;
  padding: $button-ios-padding;

  height: $button-ios-height;

  border-radius: $button-ios-border-radius;
  font-size: $button-ios-font-size;

  color: $button-ios-text-color;
  background-color: $button-ios-color;

  &:hover:not(.disable-hover) {
    text-decoration: none;
    opacity: $button-ios-hover-opacity;
  }

  &.activated {
    background-color: $button-ios-color-activated;
    opacity: 1;
  }
}


// iOS Default Button Color Mixin
// --------------------------------------------------

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

  .button-#{$color-name} {
    $background-color: $color-base;
    $background-color-activated: color-shade($background-color);
    $fg-color: $color-contrast;

    color: $fg-color;
    background-color: $background-color;

    &.activated {
      background-color: $background-color-activated;
    }
  }

}


// iOS Button Sizes
// --------------------------------------------------

.button-large {
  padding: 0 $button-ios-large-padding;

  height: $button-ios-large-height;

  font-size: $button-ios-large-font-size;
}

.button-small {
  padding: 0 $button-ios-small-padding;

  height: $button-ios-small-height;

  font-size: $button-ios-small-font-size;

  &.button-icon-only ion-icon {
    font-size: $button-ios-small-icon-font-size;
  }
}

// iOS Block Button
// --------------------------------------------------

.button-block {
  margin-right: 0;
  margin-left: 0;
}

// iOS Full Button
// --------------------------------------------------

.button-full {
  margin-right: 0;
  margin-left: 0;

  border-right-width: 0;
  border-left-width: 0;
  border-radius: 0;
}

// iOS Outline Button
// --------------------------------------------------

.button-outline {
  border-width: 1px;
  border-style: solid;
  border-radius: 4px;
  border-color: $button-ios-color;
  color: $button-ios-color;
  background-color: transparent;

  &.activated {
    color: color-contrast($colors-ios, $button-ios-color);
    background-color: $button-ios-color;
    opacity: 1;
  }
}

&.hairlines .button-outline {
  border-width: $hairlines-width;
}

// iOS Outline Button Color Mixin
// --------------------------------------------------

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

  .button-outline-#{$color-name} {
    border-color: $color-base;
    color: $color-base;
    background-color: transparent;

    &.activated {
      color: $color-contrast;
      background-color: $color-base;
    }
  }

}


// iOS Clear Button
// --------------------------------------------------

.button-clear {
  border-color: transparent;
  color: $button-ios-color;
  background-color: transparent;

  &.activated {
    background-color: transparent;
    opacity: .4;
  }

  &:hover:not(.disable-hover) {
    color: $button-ios-color;
    opacity: .6;
  }
}


// iOS Clear Button Color Mixin
// --------------------------------------------------

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

  .button-clear-#{$color-name} {
    $fg-color: $color-base;
    border-color: transparent;
    color: $fg-color;
    background-color: transparent;

    &.activated {
      opacity: .4;
    }

    &:hover:not(.disable-hover) {
      color: $fg-color;
    }
  }

}

// iOS Round Button
// --------------------------------------------------

.button-round {
  padding: $button-round-padding;

  border-radius: $button-round-border-radius;
}


ion-button-effect {
  // iOS does not use the button effect
  display: none;
}


// Generate iOS Button Colors
// --------------------------------------------------

@each $color-name, $color-base, $color-contrast in get-colors($colors-ios) {
  @include ios-button-default($color-name, $color-base, $color-contrast);
  @include ios-button-outline($color-name, $color-base, $color-contrast);
  @include ios-button-clear($color-name, $color-base, $color-contrast);
}


// Core Button Overrides
// --------------------------------------------------

@import "./button-fab";
@import "./button-icon";
