valueLastClickInfo static method
RichGridInfo
valueLastClickInfo(
- BuildContext context,
- String keyTitle,
- String valueTitle, {
- dynamic keyQuestionCallback(
- String key
- dynamic valueQuestionCallback(
- String value
- String clickTitle = '',
- Color? clickColor,
- dynamic clickCallback(
- String clickValue
- PairRichInfoGridConfig? themeData,
-----------以下静态方法为常见显示的快捷构造----------- value的最后一部分带有可点击的超链接
keyTitle 显示的key文案 valueTitle 显示的value文案 clickValue 显示的可点击文案 fontSize 文案的大小 clickCallback 可点击文案点击的回调 isArrow 是否最右侧存在箭头
Implementation
static RichGridInfo valueLastClickInfo(
BuildContext context,
String keyTitle,
String valueTitle, {
Function(String key)? keyQuestionCallback,
Function(String value)? valueQuestionCallback,
String clickTitle = '',
Color? clickColor,
Function(String clickValue)? clickCallback,
PairRichInfoGridConfig? themeData,
}) {
themeData ??= PairRichInfoGridConfig();
themeData = BaseThemeConfig.instance
.getConfig(configId: themeData.configId)
.pairRichInfoGridConfig
.merge(themeData);
themeData = themeData.merge(PairRichInfoGridConfig(
linkTextStyle: BaseTextStyle(color: clickColor)));
Widget _getQuestionImage(bool isKey) {
return GestureDetector(
onTap: () {
if (isKey) {
keyQuestionCallback!(keyTitle);
} else {
valueQuestionCallback!(valueTitle);
}
},
child: Padding(
padding: EdgeInsets.only(left: isKey ? 0 : 4),
child: PhoenixTools.getAssetSizeImage(
CardAssets.iconPairInfoQuestion, 14, 14,
package: 'phoenix_card'),
));
}
Widget _getClickValue({required PairRichInfoGridConfig themeData}) {
return GestureDetector(
onTap: () {
if (clickCallback != null) {
clickCallback(clickTitle);
}
},
child: Padding(
padding: const EdgeInsets.only(left: 4),
child: Container(
constraints: const BoxConstraints(maxWidth: 56),
child: Text(clickTitle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: _getClickStyle(clickTitle, clickColor,
themeData: themeData)),
),
),
);
}
bool isShowKeyQuestion = keyQuestionCallback != null;
bool isShowValueQuestion = valueQuestionCallback != null;
bool isShowValueClick = clickTitle.isNotEmpty;
MediaQueryData mediaQuery = MediaQueryData.fromView(View.of(context));
double screen = mediaQuery.size.width;
Widget key = Container(
constraints: BoxConstraints(
maxWidth: screen / 4,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Flexible(
child: Text(
keyTitle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: _getKeyStyle(themeData: themeData),
),
),
isShowKeyQuestion ? _getQuestionImage(true) : const SizedBox.shrink(),
Text(
':',
style: _getKeyStyle(themeData: themeData),
),
],
),
);
Widget value = Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Flexible(
child: Text(
valueTitle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: _getValueStyle(valueTitle, themeData: themeData),
),
),
isShowValueClick
? _getClickValue(themeData: themeData)
: const SizedBox.shrink(),
isShowValueQuestion
? _getQuestionImage(false)
: const SizedBox.shrink(),
],
),
);
return RichGridInfo(key, value);
}