shiftPlacement method

Placement shiftPlacement(
  1. bool outTop,
  2. bool outBottom,
  3. bool outLeft,
  4. bool outRight,
)

Implementation

Placement shiftPlacement(
  bool outTop,
  bool outBottom,
  bool outLeft,
  bool outRight,
) {
  Placement effectPlacement = placement;

  Placement shiftToVertical() {
    if (outTop) return Placement.bottom;
    return Placement.top;
  }

  if (outLeft && outRight) {
    return shiftToVertical();
  }

  /// TODO: ::边界响应策略:: 可以将转换策略作为函数参数,使用者来自定义。
  // if(placement.isHorizontal&&(outTop||outBottom)){
  //   return shiftToVertical();
  // }
  switch (placement) {
    case Placement.left:
      if (outLeft) return Placement.right;
      if (outBottom) return Placement.leftEnd;
      if (outTop) return Placement.leftStart;
      break;
    case Placement.leftStart:
      if (outBottom) return Placement.leftEnd;
      if (outLeft) return Placement.rightStart;
      break;
    case Placement.leftEnd:
      if (outTop) return Placement.leftStart;
      if (outLeft) return Placement.rightEnd;
      break;
    case Placement.right:
      if (outRight) return Placement.left;
      if (outBottom) return Placement.rightEnd;
      if (outTop) return Placement.rightStart;

      break;
    case Placement.rightStart:
      if (outBottom) return Placement.rightEnd;
      if (outRight) return Placement.leftStart;
      break;
    case Placement.rightEnd:
      if (outTop) return Placement.rightStart;
      if (outRight) return Placement.leftEnd;
      break;
    default:
      if (outBottom && placement.isBottom || outTop && placement.isTop) {
        return placement.shift;
      }
  }
  return effectPlacement;
}