| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import '../../core/theme/app_colors.dart';
- import 'package:flutter/material.dart';
- import '../../core/theme/app_colors_extension.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 colors = Theme.of(context).extension<AppColorsExtension>()!;
- 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: TextStyle(
- fontSize: AppFontSizes.body,
- color: colors.textSecondary,
- ),
- ),
- Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- hasValue ? value! : (hint ?? '请选择或填写'),
- style: TextStyle(
- fontSize: AppFontSizes.body,
- 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,
- ),
- ],
- ],
- ),
- ],
- ),
- ),
- );
- }
- }
|