createFromScreenContextPatterns method

List<Widget> createFromScreenContextPatterns({
  1. required BuildContext context,
  2. required String screenContextPattern,
})

Implementation

List<Widget> createFromScreenContextPatterns({ required BuildContext context, required String screenContextPattern }){
  // ketchupDebug('context render invoke(${++renderTimes})');
  testNeedMeasure();
  if(screenContextPattern == PT_FULLSCREEN){
    return [outsideRowExpandedAspectRatio( aspectRatio: screen.fullscreenAspectRatioSize?.aspectRatio,
          child: Column(
            children:[insideColumnExpandedAspectRatio(
              aspectRatio: screen.fullscreenAspectRatioSize?.aspectRatio,
              child: leafContainerWrapping(
                context: context,
                key: screen.gKeys.putIfAbsent(screenContextPattern, ()=>GlobalKey<KetchupUIState>(debugLabel: screenContextPattern)),
                literalAspectRatio: screen.fullscreenAspectRatioSize,
                leafName: screenContextPattern, editModeColor: screen.contextScreenColorMap[screenContextPattern]))]))];
  }else{
    return screenContextPattern.split(',').map<Widget>((String screenPattern){
      var columnCount = 1;
      if(screenPattern.startsWith('(')){
        columnCount = screenPattern.split('-').length;
      }
      /// 计算约束(v0.0.3 新增尾屏比例)
      var widgetSingleAspectRatio = widget.screen.singleAspectRatioSize;
      /// 没有设置单屏比例或者属于尾屏比例范畴 则flex自适配
      Size? calculatedAspectRatio = widgetSingleAspectRatio == null || widget.screen.isTailInclude(screenPattern) ? null:
      /// 不属于尾屏比例并设置了单屏比例则计算总屏幕比例
      Size(widgetSingleAspectRatio.width * columnCount, /// 此处screencount 相当于widget.rowColumn.column
            widgetSingleAspectRatio.height * screenRow);
      return outsideRowExpandedAspectRatio(
          flex: columnCount,
          aspectRatio: calculatedAspectRatio?.aspectRatio,
          child: Column(
            children: [insideColumnExpandedAspectRatio(
                flex: columnCount,
                aspectRatio: calculatedAspectRatio?.aspectRatio,
                child:  leafContainerWrapping(
                  context: context,
                  key: screen.gKeys.putIfAbsent(screenPattern, ()=>GlobalKey<KetchupUIState>(debugLabel: screenPattern)),
                  literalAspectRatio: calculatedAspectRatio,
                  leafName: screenPattern,
                  editModeColor: screen.contextScreenColorMap[screenPattern],
                )///leaf
            )]///inside
          )
        );///outside
      }).toList();
    }
}