| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- import 'package:flutter/material.dart';
- import '../../core/theme/app_colors.dart';
- /// Pencil Component/FormSection — 表单分组卡片
- ///
- /// 标题行(16号/600字重) + 右侧可选操作按钮(带plus图标) + 内容区
- class FormSection extends StatelessWidget {
- final String title;
- final String? actionText;
- final IconData? actionIcon;
- final VoidCallback? onActionTap;
- final bool showAction;
- final List<Widget> children;
- const FormSection({
- super.key,
- required this.title,
- this.actionText,
- this.actionIcon,
- this.onActionTap,
- this.showAction = false,
- required this.children,
- });
- @override
- Widget build(BuildContext context) {
- return Container(
- padding: const EdgeInsets.all(16),
- decoration: BoxDecoration(
- color: AppColors.bgCard,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text(
- title,
- style: const TextStyle(
- fontSize: AppFontSizes.subtitle,
- fontWeight: FontWeight.w600,
- color: AppColors.textPrimary,
- ),
- ),
- if (showAction)
- GestureDetector(
- onTap: onActionTap,
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- actionText ?? '',
- style: const TextStyle(
- fontSize: AppFontSizes.body,
- color: AppColors.primary,
- ),
- ),
- const SizedBox(width: 8),
- Icon(
- actionIcon ?? Icons.add,
- size: 14,
- color: AppColors.primary,
- ),
- ],
- ),
- ),
- ],
- ),
- const SizedBox(height: 16),
- ...children,
- ],
- ),
- );
- }
- }
|