buildGalleyUI method

Widget buildGalleyUI()

画廊模式

Implementation

Widget buildGalleyUI() {
  determineBigSmallUser();
  var pageSize = calculatePageSize();
  var curPage = _galleryModePageController!.hasClients
      ? _galleryModePageController!.page!.round()
      : 0;
  if (!_isMinimized &&
      _restoreToPageIndex != null &&
      _galleryModePageController!.hasClients &&
      curPage != _restoreToPageIndex &&
      !WidgetsBinding.instance!.window.physicalSize.isEmpty) {
    assert(() {
      print(
          '$tag, schedule restore pageview index: $_restoreToPageIndex ${_galleryModePageController!.position.viewportDimension}');
      return true;
    }());
    final toPage = _restoreToPageIndex;
    _restoreToPageIndex = null;
    SchedulerBinding.instance!.addPostFrameCallback((_) {
      Timer.run(() {
        setState(() => _galleryModePageController!
            .jumpToPage(min(toPage!.toInt(), pageSize - 1)));
      });
    });
  }
  if (curPage >= pageSize) {
    curPage = pageSize - 1;
    _galleryModePageController!.animateToPage(curPage,
        duration: Duration(milliseconds: 50), curve: Curves.easeInOut);
  }
  return Stack(
    children: <Widget>[
      PageView.builder(
        itemBuilder: (BuildContext context, int index) {
          if (index > 0) {
            return buildGrid(index);
          }
          return isOtherScreenSharing()
              ? buildRemoteScreenShare()
              : buildHostUI();
        },
        physics: PageScrollPhysics(),
        controller: _galleryModePageController,
        allowImplicitScrolling: false,
        itemCount: pageSize,
      ),
      if (pageSize > 1)
        Positioned(
          bottom: bottomBarHeight + 8,
          left: 0,
          right: 0,
          child: SafeArea(
            child: Center(
              child: Container(
                decoration: BoxDecoration(
                  color: UIColors.color_292933,
                  borderRadius: BorderRadius.circular(7),
                  shape: BoxShape.rectangle,
                ),
                padding: EdgeInsets.symmetric(horizontal: 4),
                height: 14,
                child: DotsIndicator(
                  controller: _galleryModePageController!,
                  itemCount: pageSize,
                ),
              ),
            ),
          ),
        ),
      buildSelfVolumeIndicator(),
    ],
  );
}