valueLastClickInfo static method

InfoModal valueLastClickInfo(
  1. BuildContext context,
  2. String keyTitle,
  3. String valueTitle,
  4. String clickValue, {
  5. double? fontSize,
  6. double? itemSpacing,
  7. TextStyle? valueTextStyle,
  8. dynamic clickCallback(
    1. String? clickValue
    )?,
  9. bool isArrow = false,
  10. VoidCallback? valueClickCallback,
  11. Color? linkColor,
  12. PairInfoTableConfig? themeData,
})

-----------以下静态方法为常见显示的快捷构造----------- value的最后一部分带有可点击的超链接

keyTitle 显示的key文案 valueTitle 显示的value文案 clickValue 显示的可点击文案 fontSize 文案的大小 clickCallback 可点击文案点击的回调 isArrow 是否最右侧存在箭头

Implementation

static InfoModal valueLastClickInfo(
  BuildContext context,
  String keyTitle,
  String valueTitle,
  String clickValue, {
  double? fontSize,
  double? itemSpacing,
  TextStyle? valueTextStyle,
  Function(String? clickValue)? clickCallback,
  bool isArrow = false,
  VoidCallback? valueClickCallback,
  Color? linkColor,
  PairInfoTableConfig? themeData,
}) {
  themeData ??= PairInfoTableConfig();
  themeData = BaseThemeConfig.instance
      .getConfig(configId: themeData.configId)
      .pairInfoTableConfig
      .merge(themeData);
  themeData = themeData.merge(PairInfoTableConfig(
      itemSpacing: itemSpacing,
      keyTextStyle: BaseTextStyle(fontSize: fontSize),
      valueTextStyle: BaseTextStyle(fontSize: fontSize)
          .merge(BaseTextStyle.withStyle(valueTextStyle)),
      linkTextStyle: BaseTextStyle(fontSize: fontSize, color: linkColor)
          .merge(BaseTextStyle.withStyle(valueTextStyle))));

  Widget valueWidget;
  if (isArrow) {
    valueWidget = Row(
      mainAxisSize: MainAxisSize.min,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        Flexible(
          child: Text(
            valueTitle,
            overflow: TextOverflow.ellipsis,
            maxLines: 1,
            style: themeData.valueTextStyle.generateTextStyle(),
          ),
        ),
        GestureDetector(
          onTap: () {
            if (clickCallback != null) {
              clickCallback(clickValue);
            }
          },
          child: Text(
            clickValue,
            overflow: TextOverflow.ellipsis,
            maxLines: 1,
            style: themeData.linkTextStyle.generateTextStyle(),
          ),
        )
      ],
    );
  } else {
    valueWidget = RichTextGenerator()
        .addText(
          valueTitle,
          textStyle: themeData.valueTextStyle.generateTextStyle(),
        )
        .addTextWithLink(
          clickValue,
          textStyle: themeData.linkTextStyle.generateTextStyle(),
          richTextLinkClick: (text, url) {
            if (clickCallback != null) {
              clickCallback(text);
            }
          },
        )
        .addIcon(const SizedBox.shrink())
        .build();
  }

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