@import "../../../themes/ionic.globals.ios";

// iOS Item
// --------------------------------------------------

/// @prop - Font size of the item text
$item-ios-body-text-font-size: 17px !default;

/// @prop - Margin top of the item paragraph
$item-ios-paragraph-margin-top: 0 !default;

/// @prop - Margin end of the item paragraph
$item-ios-paragraph-margin-end: 0 !default;

/// @prop - Margin bottom of the item paragraph
$item-ios-paragraph-margin-bottom: 2px !default;

/// @prop - Margin start of the item paragraph
$item-ios-paragraph-margin-start: $item-ios-paragraph-margin-end !default;

/// @prop - Font size of the item paragraph
$item-ios-paragraph-font-size: 14px !default;

/// @prop - Color of the item paragraph
$item-ios-paragraph-text-color: #8e9093 !default;

/// @prop - Size of the avatar in the item
$item-ios-avatar-size: 36px !default;

/// @prop - Border radius of the avatar in the item
$item-ios-avatar-border-radius: 50% !default;

/// @prop - Size of the thumbnail in the item
$item-ios-thumbnail-size: 56px !default;

/// @prop - Shows the detail arrow icon on an item
$item-ios-detail-push-show: true !default;

/// @prop - Color of the detail arrow icon
$item-ios-detail-push-color: $list-ios-border-color !default;

/// @prop - Icon for the detail arrow
$item-ios-detail-push-svg: "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 20'><path d='M2,20l-2-2l8-8L0,2l2-2l10,10L2,20z' fill='#{$item-ios-detail-push-color}'/></svg>" !default;

/// @prop - Background for the divider
$item-ios-divider-background: #f7f7f7 !default;

/// @prop - Color for the divider
$item-ios-divider-color: #222 !default;

/// @prop - Background for the sliding content
$item-ios-sliding-content-background: $list-ios-background-color !default;

// iOS Item
// --------------------------------------------------

.item-ios {
  position: relative;
  font-size: $item-ios-body-text-font-size;
  color: $list-ios-text-color;
  background-color: $list-ios-background-color;
  transition: background-color 200ms linear;
  
  @include padding-horizontal($item-ios-padding-start, null);
  @include safe-area-padding-horizontal($item-ios-padding-start, null);
  @include border-radius(0);
}

.item-ios[detail-push]:active {
  background-color: $list-ios-activated-background-color;
  transition-duration: 0ms;
}

.item-ios h1 {
  font-size: 24px;
  font-weight: normal;
  
  @include margin(0, 0, 2px);
}

.item-ios h2 {
  font-size: 17px;
  font-weight: normal;
  
  @include margin(0, 0, 2px);
}

.item-ios h3,
.item-ios h4,
.item-ios h5,
.item-ios h6 {
  font-size: 14px;
  font-weight: normal;
  line-height: normal;
  
  @include margin(0, 0, 3px);
}

.item-ios p {
  overflow: inherit;
  font-size: $item-ios-paragraph-font-size;
  line-height: normal;
  color: $item-ios-paragraph-text-color;
  text-overflow: inherit;
  
  @include margin($item-ios-paragraph-margin-top, $item-ios-paragraph-margin-end, $item-ios-paragraph-margin-bottom, $item-ios-paragraph-margin-start);
}

.item-ios h2:last-child,
.item-ios h3:last-child,
.item-ios h4:last-child,
.item-ios h5:last-child,
.item-ios h6:last-child,
.item-ios p:last-child {
  @include margin(null, null, 0, null);
}

.item-ios.item-block .item-inner {
  border-bottom: $hairlines-width solid $list-ios-border-color;
  
  @include padding-horizontal(null, $item-ios-padding-end / 2);
  @include safe-area-padding-horizontal(null, $item-ios-padding-end / 2);
}

// iOS Item Media
// --------------------------------------------------

.item-ios [item-left], // deprecated
.item-ios [item-start] {
  @include margin($item-ios-padding-media-top, $item-ios-padding-start, $item-ios-padding-media-bottom, 0);
}

.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));
}

.item-ios .ion-icon[item-left], // deprecated
.item-ios .ion-icon[item-right], // deprecated
.item-ios .ion-icon[item-start],
.item-ios .ion-icon[item-end] {
  @include margin($item-ios-padding-icon-top, null, $item-ios-padding-icon-bottom, 0);
}

.item-ios .item-button {
  height: 24px;
  font-size: 13px;
  
  @include padding(0, 0.5em);
}

.item-ios .item-button[icon-only] .ion-icon,
.item-ios .item-button[icon-only] {
  @include padding(0, 1px);
}

.item-ios .ion-avatar[item-left], // deprecated
.item-ios .ion-thumbnail[item-left], // deprecated
.item-ios .ion-avatar[item-start],
.item-ios .ion-thumbnail[item-start] {
  @include margin(($item-ios-padding-end / 2), $item-ios-padding-end, ($item-ios-padding-end / 2), 0);
}

.item-ios .ion-avatar[item-right], // deprecated
.item-ios .ion-thumbnail[item-right], // deprecated
.item-ios .ion-avatar[item-end],
.item-ios .ion-thumbnail[item-end] {
  @include margin(($item-ios-padding-end / 2));
}

// iOS Item Avatar
// --------------------------------------------------

.item-ios .ion-avatar {
  min-width: $item-ios-avatar-size;
  min-height: $item-ios-avatar-size;
}

.item-ios .ion-avatar .ion-img,
.item-ios .ion-avatar img {
  width: $item-ios-avatar-size;
  height: $item-ios-avatar-size;
  overflow: hidden;
  
  @include border-radius($item-ios-avatar-border-radius);
}

// iOS Item Thumbnail
// --------------------------------------------------

.item-ios .ion-thumbnail {
  min-width: $item-ios-thumbnail-size;
  min-height: $item-ios-thumbnail-size;
}

.item-ios .ion-thumbnail .ion-img,
.item-ios .ion-thumbnail img {
  width: $item-ios-thumbnail-size;
  height: $item-ios-thumbnail-size;
}

// iOS Item Detail Push
// --------------------------------------------------

// Only show the forward arrow icon if true
@if $item-ios-detail-push-show == true {
  .item-ios[detail-push] .item-inner,
  button.item-ios:not([detail-none]) .item-inner,
  a.item-ios:not([detail-none]) .item-inner {
    background-repeat: no-repeat;
    background-size: 14px 14px;
    $safe-area-position: calc(#{$item-ios-padding-end - 2} + constant(safe-area-inset-right));
    $safe-area-position-env: calc(#{$item-ios-padding-end - 2} + env(safe-area-inset-right));
    
    @include svg-background-image($item-ios-detail-push-svg, true);
    @include padding-horizontal(null, 32px);
    @include background-position(end, $item-ios-padding-end - 2, center);
    @include background-position(end, $safe-area-position, center);
    @include background-position(end, $safe-area-position-env, center);
  }
}

// iOS Item Group
// --------------------------------------------------

.ion-item-group .item-ios:first-child .item-inner {
  border-top-width: 0;
}

.ion-item-group .item-ios:last-child .item-inner,
.ion-item-group .item-wrapper:last-child .item-ios .item-inner {
  border: 0;
}

// iOS Item Divider
// --------------------------------------------------

.item-divider-ios {
  color: $item-ios-divider-color;
  background-color: $item-ios-divider-background;
  
  @include padding-horizontal($item-ios-padding-start, null);
  @include safe-area-padding-horizontal($item-ios-padding-start, null);
}

// Generate iOS Item and Item Divider Colors
// --------------------------------------------------

@each $color-name, $color-base, $color-contrast in get-colors($colors-ios) {
  // If there is text with a color it should use this color
  // and override whatever item sets it to
  .item-ios .text-ios-#{$color-name} {
    color: $color-base;
  }
  
  .item-ios-#{$color-name},
  .item-divider-ios-#{$color-name} {
    color: $color-contrast;
    background-color: $color-base;
    
    p {
      color: $color-contrast;
    }
    
    &:active {
      background-color: color-shade($color-base);
    }
  }
}

// iOS Item Sliding
// --------------------------------------------------

.list-ios .ion-item-sliding {
  background-color: $item-ios-sliding-content-background;
}
