applySecondaryConstraints method

void applySecondaryConstraints()

Applies constraints to the secondaryWidth, secondaryHeight, secondaryLeft and secondaryTop.

Implementation

void applySecondaryConstraints() {
  if (secondaryAlignment.value == Alignment.centerRight ||
      secondaryAlignment.value == Alignment.centerLeft) {
    secondaryLeft.value = size.width / 2;
  } else if (secondaryAlignment.value == Alignment.topCenter ||
      secondaryAlignment.value == Alignment.bottomCenter) {
    secondaryTop.value = size.height / 2;
  }

  secondaryWidth.value = _applySWidth(secondaryWidth.value);
  secondaryHeight.value = _applySHeight(secondaryHeight.value);
  secondaryLeft.value = _applySLeft(secondaryLeft.value);
  secondaryRight.value = _applySRight(secondaryRight.value);
  secondaryTop.value = _applySTop(secondaryTop.value);
  secondaryBottom.value = _applySBottom(secondaryBottom.value);

  // Limit the width and height if docked.
  if (secondaryAlignment.value == Alignment.centerRight ||
      secondaryAlignment.value == Alignment.centerLeft) {
    secondaryWidth.value = min(secondaryWidth.value, size.width / 2);
  } else if (secondaryAlignment.value == Alignment.topCenter ||
      secondaryAlignment.value == Alignment.bottomCenter) {
    secondaryHeight.value = min(secondaryHeight.value, size.height / 2);
  }

  // Determine the [possibleSecondaryAlignment].
  possibleSecondaryAlignment.value = null;
  if (secondaryDragged.value) {
    if (secondaryLeft.value != null) {
      if (secondaryLeft.value! <= 0) {
        possibleSecondaryAlignment.value = Alignment.centerLeft;
      } else if (secondaryLeft.value! >= size.width - secondaryWidth.value) {
        possibleSecondaryAlignment.value = Alignment.centerRight;
      }
    }

    if (secondaryTop.value != null) {
      if (secondaryTop.value! <= 0) {
        possibleSecondaryAlignment.value = Alignment.topCenter;
      } else if (secondaryTop.value! >= size.height - secondaryHeight.value) {
        possibleSecondaryAlignment.value = Alignment.bottomCenter;
      }
    }
  }
}