initRect method

void initRect(
  1. Size size
)

Implementation

void initRect(Size size) {
  double volHeight = volHidden != true ? mDisplayHeight * 0.2 : 0;
  double secondaryHeight =
      secondaryState != SecondaryState.NONE ? mDisplayHeight * 0.2 : 0;

  double mainHeight = mDisplayHeight;
  mainHeight -= volHeight;
  mainHeight -= secondaryHeight;

  mMainRect = Rect.fromLTRB(0, mTopPadding, mWidth, mTopPadding + mainHeight);

  if (volHidden != true) {
    mVolRect = Rect.fromLTRB(0, mMainRect.bottom + mChildPadding, mWidth,
        mMainRect.bottom + volHeight);
  }

  //secondaryState == SecondaryState.NONE隐藏副视图
  if (secondaryState != SecondaryState.NONE) {
    mSecondaryRect = Rect.fromLTRB(
        0,
        mMainRect.bottom + volHeight + mChildPadding,
        mWidth,
        mMainRect.bottom + volHeight + secondaryHeight);
  }
}