| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- import 'package:flutter/material.dart';
- import '../../core/theme/app_colors.dart';
- /// Pencil Component/ActionBar — 底部操作栏
- ///
- /// 水平排列三个按钮:重置(可选)、存草稿、提交。
- /// 所有按钮圆角22,总高度72,padding 16,gap 12,背景bgCard。
- class ActionBar extends StatelessWidget {
- final String? leftLabel;
- final String centerLabel;
- final String rightLabel;
- final VoidCallback? onLeftTap;
- final VoidCallback? onCenterTap;
- final VoidCallback? onRightTap;
- final bool showLeft;
- const ActionBar({
- super.key,
- this.leftLabel,
- required this.centerLabel,
- required this.rightLabel,
- this.onLeftTap,
- this.onCenterTap,
- this.onRightTap,
- this.showLeft = true,
- });
- @override
- Widget build(BuildContext context) {
- return Container(
- height: 72,
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
- decoration: const BoxDecoration(
- color: AppColors.bgCard,
- ),
- child: Row(
- children: [
- // 左侧重置按钮(可选显示)
- if (showLeft && leftLabel != null) ...[
- Expanded(
- child: _ActionButton(
- label: leftLabel!,
- backgroundColor: AppColors.bgCard,
- textColor: AppColors.textSecondary,
- onTap: onLeftTap,
- ),
- ),
- const SizedBox(width: 12),
- ],
- // 中间存草稿按钮
- Expanded(
- child: _ActionButton(
- label: centerLabel,
- backgroundColor: AppColors.primaryLight,
- textColor: AppColors.primary,
- onTap: onCenterTap,
- ),
- ),
- const SizedBox(width: 12),
- // 右侧提交按钮
- Expanded(
- child: _ActionButton(
- label: rightLabel,
- backgroundColor: AppColors.primary,
- textColor: AppColors.bgCard,
- onTap: onRightTap,
- ),
- ),
- ],
- ),
- );
- }
- }
- class _ActionButton extends StatelessWidget {
- final String label;
- final Color backgroundColor;
- final Color textColor;
- final VoidCallback? onTap;
- const _ActionButton({
- required this.label,
- required this.backgroundColor,
- required this.textColor,
- this.onTap,
- });
- @override
- Widget build(BuildContext context) {
- return SizedBox(
- height: 40,
- child: Material(
- color: backgroundColor,
- borderRadius: BorderRadius.circular(22),
- child: InkWell(
- onTap: onTap,
- borderRadius: BorderRadius.circular(22),
- child: Center(
- child: Text(
- label,
- style: TextStyle(
- fontSize: AppFontSizes.body,
- fontWeight: FontWeight.w500,
- color: textColor,
- ),
- ),
- ),
- ),
- ),
- );
- }
- }
|