import '../../core/theme/app_colors.dart'; import 'package:flutter/material.dart'; import '../../core/theme/app_colors_extension.dart'; /// 表单字段行,左侧标签 + 右侧值 + 可选箭头。 /// /// [required] 为 true 时标签前显示红色星号。 class FormFieldRow extends StatelessWidget { final String label; final String? value; final String? hint; final bool showArrow; final bool readOnly; final bool required; final VoidCallback? onTap; const FormFieldRow({ super.key, required this.label, this.value, this.hint, this.showArrow = true, this.readOnly = false, this.required = false, this.onTap, }); @override Widget build(BuildContext context) { final colors = Theme.of(context).extension()!; final hasValue = value != null && value!.isNotEmpty; return GestureDetector( onTap: onTap, behavior: HitTestBehavior.opaque, child: Container( padding: EdgeInsets.zero, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text.rich( TextSpan( children: [ TextSpan( text: label, style: TextStyle( fontSize: AppFontSizes.subtitle, color: colors.textSecondary, ), ), if (required) TextSpan( text: ' *', style: TextStyle( fontSize: AppFontSizes.subtitle, color: colors.danger, ), ), ], ), ), Row( mainAxisSize: MainAxisSize.min, children: [ Text( hasValue ? value! : (hint ?? '请选择或填写'), style: TextStyle( fontSize: AppFontSizes.subtitle, color: hasValue ? (readOnly ? colors.textPrimary : colors.textPrimary) : colors.textPlaceholder, ), ), if (showArrow && !readOnly) ...[ const SizedBox(width: 4), Icon( Icons.chevron_right, size: 14, color: colors.textPlaceholder, ), ], ], ), ], ), ), ); } }