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

// iOS List
// --------------------------------------------------

/// @prop - Margin top of the list
$list-ios-margin-top:                 10px !default;

// deprecated
$list-ios-margin-right:               0 !default;
/// @prop - Margin end of the list
$list-ios-margin-end:                 $list-ios-margin-right !default;

/// @prop - Margin bottom of the list
$list-ios-margin-bottom:              32px !default;

// deprecated
$list-ios-margin-left:                0 !default;
/// @prop - Margin start of the list
$list-ios-margin-start:               $list-ios-margin-left !default;

/// @prop - Margin top of the inset list
$list-inset-ios-margin-top:           16px !default;

// deprecated
$list-inset-ios-margin-right:         16px !default;
/// @prop - Margin end of the inset list
$list-inset-ios-margin-end:           $list-inset-ios-margin-right !default;

/// @prop - Margin bottom of the inset list
$list-inset-ios-margin-bottom:        16px !default;

// deprecated
$list-inset-ios-margin-left:          16px !default;
/// @prop - Margin start of the inset list
$list-inset-ios-margin-start:         $list-inset-ios-margin-left !default;

/// @prop - Border radius of the inset list
$list-inset-ios-border-radius:        4px !default;

// deprecated
$list-ios-header-padding-left:        $item-ios-padding-start !default;
/// @prop - Padding start of the header in a list
$list-ios-header-padding-start:       $list-ios-header-padding-left !default;

/// @prop - Border bottom of the header in a list
$list-ios-header-border-bottom:       $hairlines-width solid $list-ios-border-color !default;

/// @prop - Font size of the header in a list
$list-ios-header-font-size:           1.2rem !default;

/// @prop - Font weight of the header in a list
$list-ios-header-font-weight:         500 !default;

/// @prop - Letter spacing of the header in a list
$list-ios-header-letter-spacing:      .1rem !default;

/// @prop - Text transform of the header in a list
$list-ios-header-text-transform:      uppercase !default;

/// @prop - Text color of the header in a list
$list-ios-header-color:               #333 !default;

/// @prop - Background color of the header in a list
$list-ios-header-background-color:    transparent !default;


// iOS Default List
// --------------------------------------------------

.list-ios {
  @include margin(-1px, $list-ios-margin-end, $list-ios-margin-bottom, $list-ios-margin-start);
}

.list-ios > .item-block:first-child {
  border-top: $hairlines-width solid $list-ios-border-color;
}

.list-ios > .item-block:last-child,
.list-ios > .item-wrapper:last-child .item-block {
  border-bottom: $hairlines-width solid $list-ios-border-color;
}

.list-ios > .item-block:last-child .item-inner,
.list-ios > .item-wrapper:last-child .item-block .item-inner {
  border-bottom: 0;
}

.list-ios .item-block .item-inner {
  border-bottom: $hairlines-width solid $list-ios-border-color;
}

// If the item has the no-lines attribute remove the bottom border from:
// the item itself (for last-child items)
// the item-inner class (if it is not last)
.list-ios .item[no-lines],
.list-ios .item[no-lines] .item-inner {
  border-width: 0;
}

.list-ios ion-item-options {
  border-bottom: $hairlines-width solid $list-ios-border-color;
}

.list-ios ion-item-options .button {
  @include margin(0);
  @include border-radius(0);

  display: inline-flex;

  align-items: center;

  height: 100%;
  min-height: 100%;

  border: 0;

  box-sizing: border-box;
}

.list-ios ion-item-options .button::before {
  @include margin(0, auto);
}

.list-ios:not([inset]) + .list-ios:not([inset]) ion-list-header {
  @include margin(-$list-ios-margin-top, null, null, null);
  @include padding(0, null, null, null);
}


// iOS Inset List
// --------------------------------------------------

.list-ios[inset] {
  @include margin($list-inset-ios-margin-top, $list-inset-ios-margin-end, $list-inset-ios-margin-bottom, $list-inset-ios-margin-start);
  @include border-radius($list-inset-ios-border-radius);
}

.list-ios[inset] ion-list-header {
  background-color: $list-ios-background-color;
}

.list-ios[inset] .item {
  border-bottom: 1px solid $list-ios-border-color;
}

.list-ios[inset] .item-inner {
  border-bottom: 0;
}

.list-ios[inset] > .item:first-child,
.list-ios[inset] > .item-wrapper:first-child .item {
  border-top: 0;
}

.list-ios[inset] > .item:last-child,
.list-ios[inset] > .item-wrapper:last-child .item {
  border-bottom: 0;
}

.list-ios[inset] + ion-list[inset] {
  @include margin(0, null, null, null);
}


// iOS No Lines List
// --------------------------------------------------

.list-ios[no-lines] ion-list-header,
.list-ios[no-lines] ion-item-options,
.list-ios[no-lines] .item,
.list-ios[no-lines] .item .item-inner {
  border-width: 0;
}


// iOS List Header
// --------------------------------------------------

.list-header-ios {
  @include padding-horizontal($list-ios-header-padding-start, null);

  position: relative;

  border-bottom: $list-ios-header-border-bottom;
  font-size: $list-ios-header-font-size;
  font-weight: $list-ios-header-font-weight;
  letter-spacing: $list-ios-header-letter-spacing;
  text-transform: $list-ios-header-text-transform;
  color: $list-ios-header-color;
  background: $list-ios-header-background-color;
}

// Generate iOS List Header Colors
// --------------------------------------------------

@each $color-name, $color-base, $color-contrast in get-colors($colors-ios) {
  .list-header-ios-#{$color-name} {
    color: $color-contrast;
    background-color: $color-base;
  }
}
