defaultImmersionRule top-level property

ImmersionRule defaultImmersionRule
getter/setter pair

默认沉浸规则: 视频显示区域:高度减去状态栏和顶部tab后居中 自适应规则: 可视区域比例>=视频比例时,高度撑满,宽度自适应;反之宽度撑满

Implementation

ImmersionRule defaultImmersionRule = ImmersionRule(
    windowWidthRange: _windowWidthRange,
    windowRatioRange: const MathRange(min: 0),
    getImmersionInfo: (double videoAspectRatio, Size windowSize,
        double bottomTabHeight, double topStatusBarHeight) {
      double videoWidth;
      double videoHeight;
      Offset position;
      double displayHeight =
          windowSize.height - bottomTabHeight - topStatusBarHeight;
      double displayAspectRatio = safeDivide(windowSize.width, displayHeight);
      if (displayAspectRatio >= videoAspectRatio) {
        videoHeight = displayHeight;
        videoWidth = videoHeight * videoAspectRatio;
        position =
            Offset((windowSize.width - videoWidth) / 2, topStatusBarHeight);
      } else {
        videoWidth = windowSize.width;
        videoHeight = videoWidth / videoAspectRatio;
        position = Offset(
            0,
            topStatusBarHeight +
                (windowSize.height -
                        videoHeight -
                        bottomTabHeight -
                        topStatusBarHeight) /
                    2);
      }
      return ImmersionInfo(
          videoSize: Size(videoWidth, videoHeight),
          videoPosition: position,
          immersionSetting: ImmersionSetting(
              isBottomTabImmersive: false, isStatusBarImmersive: false));
    });