keyOrValueLastQuestionInfo static method

InfoModal keyOrValueLastQuestionInfo(
  1. BuildContext context,
  2. String keyTitle,
  3. String valueTitle, {
  4. bool keyShow = false,
  5. bool valueShow = true,
  6. double? fontSize,
  7. double? itemSpacing,
  8. TextStyle? keyTextStyle,
  9. TextStyle? valueTextStyle,
  10. Function? keyCallback,
  11. Function? valueCallback,
  12. bool isArrow = false,
  13. VoidCallback? valueClickCallback,
  14. PairInfoTableConfig? themeData,
})

key或者value的文本的最后带有问号

keyTitle 显示的key文案 valueTitle 显示的value文案 keyShow 是否可key的最后带有问号 valueShow 是否value的最后带有问号 keyCallback key的小问号点击的回调 valueCallback value的小问号点击的回调 /// isArrow 是否最右侧存在箭头

Implementation

static InfoModal keyOrValueLastQuestionInfo(
  BuildContext context,
  String keyTitle,
  String valueTitle, {
  bool keyShow = false,
  bool valueShow = true,
  double? fontSize,
  double? itemSpacing,
  TextStyle? keyTextStyle,
  TextStyle? valueTextStyle,
  Function? keyCallback,
  Function? valueCallback,
  bool isArrow = false,
  VoidCallback? valueClickCallback,
  PairInfoTableConfig? themeData,
}) {
  themeData ??= PairInfoTableConfig();
  themeData = BaseThemeConfig.instance
      .getConfig(configId: themeData.configId)
      .pairInfoTableConfig
      .merge(themeData);
  themeData = themeData.merge(PairInfoTableConfig(
      itemSpacing: itemSpacing,
      keyTextStyle: BaseTextStyle(fontSize: fontSize)
          .merge(BaseTextStyle.withStyle(keyTextStyle)),
      valueTextStyle: BaseTextStyle(fontSize: fontSize)
          .merge(BaseTextStyle.withStyle(valueTextStyle))));

  dynamic valueWidget;
  dynamic keyWidget;

  if (isArrow) {
    MediaQueryData mediaQuery = MediaQueryData.fromView(View.of(context));
    double screen = mediaQuery.size.width;

    if (keyShow) {
      keyWidget = Container(
        constraints: BoxConstraints(maxWidth: screen / 2),
        child: Row(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Flexible(
              child: Text(
                keyTitle,
                overflow: TextOverflow.ellipsis,
                maxLines: 1,
                style: themeData.keyTextStyle.generateTextStyle(),
              ),
            ),
            GestureDetector(
              onTap: () {
                if (keyCallback != null) {
                  keyCallback();
                }
              },
              child: PhoenixTools.getAssetImage(CardAssets.iconQuestion),
            ),
            Text(
              ':',
              overflow: TextOverflow.ellipsis,
              maxLines: 1,
              style: themeData.valueTextStyle.generateTextStyle(),
            )
          ],
        ),
      );
    } else {
      keyWidget = keyTitle;
    }

    if (valueShow) {
      valueWidget = Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Flexible(
            child: Text(
              valueTitle,
              overflow: TextOverflow.ellipsis,
              maxLines: 1,
              style: themeData.keyTextStyle.generateTextStyle(),
            ),
          ),
          GestureDetector(
            onTap: () {
              if (valueCallback != null) {
                valueCallback();
              }
            },
            child: PhoenixTools.getAssetImage(CardAssets.iconQuestion),
          )
        ],
      );
    } else {
      valueWidget = valueTitle;
    }
  } else {
    RichTextGenerator keyGen = RichTextGenerator();
    keyGen.addText(keyTitle,
        textStyle: themeData.keyTextStyle.generateTextStyle());
    if (keyShow) {
      keyGen.addIcon(GestureDetector(
        onTap: () {
          if (keyCallback != null) {
            keyCallback();
          }
        },
        child: PhoenixTools.getAssetImage(CardAssets.iconQuestion),
      ));
      keyGen.addText(':',
          textStyle: themeData.keyTextStyle.generateTextStyle());
    }
    keyWidget = keyGen.build();

    RichTextGenerator valueGen = RichTextGenerator();
    valueGen.addText(valueTitle,
        textStyle: themeData.valueTextStyle.generateTextStyle());
    if (valueShow) {
      valueGen.addIcon(GestureDetector(
        onTap: () {
          if (valueCallback != null) {
            valueCallback();
          }
        },
        child: PhoenixTools.getAssetImage(CardAssets.iconQuestion),
      ));
    }
    valueWidget = valueGen.build();
  }

  return InfoModal(
    keyPart: keyWidget,
    valuePart: valueWidget,
    isArrow: isArrow,
    valueClickCallback: valueClickCallback,
  );
}