import 'package:flutter/material.dart';
import '../../core/theme/app_colors.dart';

/// Pencil Component/FormField — 表单字段行
///
/// 左侧标签(14号/secondary) + 右侧值(14号/可placeholder色) + 可选箭头图标
class FormFieldRow extends StatelessWidget {
  final String label;
  final String? value;
  final String? hint;
  final bool showArrow;
  final bool readOnly;
  final VoidCallback? onTap;

  const FormFieldRow({
    super.key,
    required this.label,
    this.value,
    this.hint,
    this.showArrow = true,
    this.readOnly = false,
    this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    final hasValue = value != null && value!.isNotEmpty;
    return GestureDetector(
      onTap: onTap,
      child: Container(
        height: 44,
        padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Text(
              label,
              style: const TextStyle(
                fontSize: AppFontSizes.body,
                color: AppColors.textSecondary,
              ),
            ),
            Row(
              mainAxisSize: MainAxisSize.min,
              children: [
                Text(
                  hasValue ? value! : (hint ?? '请选择或填写'),
                  style: TextStyle(
                    fontSize: AppFontSizes.body,
                    color: hasValue
                        ? (readOnly ? AppColors.textPrimary : AppColors.textPrimary)
                        : AppColors.textPlaceholder,
                  ),
                ),
                if (showArrow && !readOnly) ...[
                  const SizedBox(width: 4),
                  const Icon(
                    Icons.chevron_right,
                    size: 14,
                    color: AppColors.textPlaceholder,
                  ),
                ],
              ],
            ),
          ],
        ),
      ),
    );
  }
}
