294fc4a781
用户实测已因日期选择器误录:Flutter 原生日历只给年份网格、月份必须靠 < > 逐月点,从 9 月回 4 月要点 5 次,他把当月(2026-09)的就医记录记成了 2026-04-09,进而误判「本月花费 ¥0」是聚合坏了。 新增 lib/core/widgets/app_date_picker.dart,全仓 7 处裸 showDatePicker 收口 (改造后 lib/ 下 showDatePicker 只出现在该文件内部一次): - pickAppDate(...):calendar 首屏 + 保留头部铅笔切手输;initialDate 自动夹进 [firstDate, lastDate] 防原生越界断言(调用方常传「当前值 ?? 今天」,而 「到期日期」的 firstDate 就是今天,历史值可能已越界);返回值统一抹时分秒; 中文文案一律交给 zh-CN 本地化,不硬编码,避免两处文案漂移。 - AppDateFieldTrailing(...):7 处日期行统一「今天 + 日历图标」。今天越界自动 隐藏按钮、提交中禁用、触控 44×44、primaryStrong 白底 4.49:1。 入口模式取舍:不用 calendarOnly——它恰好会砍掉手输按钮,把「录一个已知日期」 这条唯一快路堵死;也不用 input 首屏——「记今天」这类高频场景敲 8 个数字更慢。 两条路都留着最省事。 「今天」为何放表单行而非弹窗内:原生 showDatePicker 无法注入自定义动作 (builder 只能包裹整个 Dialog,拿不到内部选中态;塞进 Column 还会因 Dialog 在无界高度下贪心布局而溢出)。放表单行反而更快——一键落值连弹窗都不用开, 把容易走错的月份导航整段绕开,且一次实现 7 处形态完全一致。 各调用点原有的 firstDate/lastDate 业务约束原样传入、一字未改(健康事件 不许未来、到期日不许补记过去、疫苗 allowFuture 双态、生日不许未来), 并由 widget 测试直接断言 DatePickerDialog.firstDate/lastDate 防后续悄悄放宽。 顺带修配色:此前从未定制 datePickerTheme,选中日直接吃 ColorScheme.fromSeed 由珊瑚橙派生的暗红棕,与品牌脱节。新增 _datePickerTheme 只复用 05 号规范 (iteration-2/05、iteration-3/05)已审计的色对,不新造色值:头部 surfaceTint + primaryDark 7.98:1(选中 chip 同款)、选中日/年 primaryStrong 实底白字 4.49:1、今日 primaryStrong 1.5px 描边、星期表头 inkSoft 6.59:1、 越界日 muted(DEBT-2 允许的禁用态用途)。headerHeadlineStyle 取 22px (默认 32):中文「9月10日周四」在横屏侧栏头部 26px 起就折行。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
606 lines
20 KiB
Dart
606 lines
20 KiB
Dart
import 'package:flutter/material.dart';
|
||
import 'package:patbond_flutter/analytics/analytics_page_name.dart';
|
||
import 'package:patbond_flutter/core/navigation/fade_route.dart';
|
||
import 'package:patbond_flutter/core/network/api_exception.dart';
|
||
import 'package:patbond_flutter/core/theme/app_theme.dart';
|
||
import 'package:patbond_flutter/core/widgets/app_date_picker.dart';
|
||
import 'package:patbond_flutter/core/widgets/app_text_field.dart';
|
||
import 'package:patbond_flutter/core/widgets/empty_state_illustration.dart';
|
||
import 'package:patbond_flutter/core/widgets/inline_error_banner.dart';
|
||
import 'package:patbond_flutter/core/widgets/record_type_dot.dart';
|
||
import 'package:patbond_flutter/features/pets/health_record_analytics.dart';
|
||
import 'package:patbond_flutter/features/pets/health_record_display.dart';
|
||
import 'package:patbond_flutter/features/pets/pet_display.dart';
|
||
import 'package:patbond_flutter/features/pets/pet_exceptions.dart';
|
||
import 'package:patbond_flutter/features/pets/pet_models.dart';
|
||
import 'package:patbond_flutter/features/pets/pets_repository.dart';
|
||
import 'package:patbond_flutter/features/pets/vaccination_form_page.dart';
|
||
import 'package:patbond_flutter/widgets/common.dart';
|
||
|
||
enum _ListPhase { loading, ready, error }
|
||
|
||
/// 疫苗记录列表页(T2-13):契约不分页,服务端按
|
||
/// `series_key, dose_no, created_at, id` 排序,客户端按系列直接分组;
|
||
/// 含 cancelled 行原样展示(取消后同剂次可重新登记的事实留痕)。
|
||
/// 四态齐备;登记经 [VaccinationFormPage]。
|
||
///
|
||
/// T2-14 收尾(25 号报告 §7 遗留①②):scheduled 行支持「标记完成 /
|
||
/// 取消登记」PATCH 流转;完成时可补录厂商/批号(契约可选字段);
|
||
/// 挂 `health_record_edit_succeeded/failed`(recordType=vaccine)。
|
||
///
|
||
/// 曝光埋点:每次进入首个成功加载上报一次
|
||
/// `health_record_viewed(recordType=vaccine, source=pet_detail)`。
|
||
class VaccinationRecordsPage extends StatefulWidget {
|
||
const VaccinationRecordsPage({
|
||
required this.repository,
|
||
required this.petId,
|
||
required this.petSpecies,
|
||
required this.canWrite,
|
||
super.key,
|
||
this.analytics,
|
||
});
|
||
|
||
final PetsRepository repository;
|
||
final String petId;
|
||
|
||
/// 疫苗目录按宠物物种过滤(契约:疫苗 species 须与宠物一致)。
|
||
final PetSpecies petSpecies;
|
||
|
||
/// owner/caregiver 可写;viewer 隐藏登记入口。
|
||
final bool canWrite;
|
||
|
||
final HealthRecordAnalytics? analytics;
|
||
|
||
@override
|
||
State<VaccinationRecordsPage> createState() => _VaccinationRecordsPageState();
|
||
}
|
||
|
||
class _VaccinationRecordsPageState extends State<VaccinationRecordsPage> {
|
||
_ListPhase _phase = _ListPhase.loading;
|
||
List<Vaccination> _records = const [];
|
||
ApiException? _error;
|
||
bool _viewedFired = false;
|
||
bool _mutating = false;
|
||
|
||
@override
|
||
void initState() {
|
||
super.initState();
|
||
_load();
|
||
}
|
||
|
||
Future<void> _load() async {
|
||
setState(() {
|
||
_phase = _ListPhase.loading;
|
||
_error = null;
|
||
});
|
||
try {
|
||
final records = await widget.repository.listVaccinations(widget.petId);
|
||
if (!mounted) return;
|
||
setState(() {
|
||
_records = records;
|
||
_phase = _ListPhase.ready;
|
||
});
|
||
if (!_viewedFired) {
|
||
_viewedFired = true;
|
||
widget.analytics?.viewed(
|
||
recordType: HealthRecordType.vaccine,
|
||
source: HealthRecordViewSource.petDetail,
|
||
);
|
||
}
|
||
} on ApiException catch (error) {
|
||
if (!mounted) return;
|
||
setState(() {
|
||
_error = error;
|
||
_phase = _ListPhase.error;
|
||
});
|
||
}
|
||
}
|
||
|
||
Future<void> _openCreate() async {
|
||
final created = await Navigator.of(context).push<Vaccination>(
|
||
fadePageRoute(
|
||
VaccinationFormPage(
|
||
repository: widget.repository,
|
||
petId: widget.petId,
|
||
petSpecies: widget.petSpecies,
|
||
analytics: widget.analytics,
|
||
),
|
||
settings: RouteSettings(name: AnalyticsPageName.recordForm.pageName),
|
||
),
|
||
);
|
||
if (created != null && mounted) {
|
||
ScaffoldMessenger.of(
|
||
context,
|
||
).showSnackBar(const SnackBar(content: Text('已登记疫苗')));
|
||
// 排序键在服务端(series_key, dose_no),重新拉取而非本地猜位置。
|
||
await _load();
|
||
}
|
||
}
|
||
|
||
void _trackEditFailed(HealthRecordFailureReason reason, [int? errorCode]) {
|
||
widget.analytics?.editFailed(
|
||
recordType: HealthRecordType.vaccine,
|
||
reason: reason,
|
||
errorCode: errorCode,
|
||
);
|
||
}
|
||
|
||
/// 标记完成(25 号报告遗留①②):接种日期必填、下次接种/厂商/批号可选
|
||
/// (厂商/批号为契约可选字段的补录入口)。
|
||
Future<void> _markCompleted(Vaccination record) async {
|
||
final result = await showDialog<_CompleteVaccinationResult>(
|
||
context: context,
|
||
builder: (context) => _CompleteVaccinationDialog(record: record),
|
||
);
|
||
if (result == null || !mounted) return;
|
||
await _mutate(
|
||
record,
|
||
UpdateVaccinationRequest(
|
||
version: record.version,
|
||
status: VaccinationStatus.completed,
|
||
administeredOn: result.administeredOn,
|
||
nextDueOn: result.nextDueOn,
|
||
manufacturer: result.manufacturer,
|
||
batchNo: result.batchNo,
|
||
),
|
||
successText: '已标记完成',
|
||
);
|
||
}
|
||
|
||
Future<void> _cancelRegistration(Vaccination record) async {
|
||
final confirmed = await showDialog<bool>(
|
||
context: context,
|
||
builder: (context) => AlertDialog(
|
||
title: const Text('取消这条登记?'),
|
||
content: Text(
|
||
'「${vaccinationDoseLabel(record)}」将标记为已取消;'
|
||
'取消后同系列同剂次可重新登记。',
|
||
),
|
||
actions: [
|
||
TextButton(
|
||
onPressed: () => Navigator.of(context).pop(false),
|
||
child: const Text('返回'),
|
||
),
|
||
FilledButton(
|
||
onPressed: () => Navigator.of(context).pop(true),
|
||
child: const Text('取消登记'),
|
||
),
|
||
],
|
||
),
|
||
);
|
||
if (confirmed != true || !mounted) return;
|
||
await _mutate(
|
||
record,
|
||
UpdateVaccinationRequest(
|
||
version: record.version,
|
||
status: VaccinationStatus.cancelled,
|
||
),
|
||
successText: '已取消登记',
|
||
);
|
||
}
|
||
|
||
Future<void> _mutate(
|
||
Vaccination record,
|
||
UpdateVaccinationRequest request, {
|
||
required String successText,
|
||
}) async {
|
||
if (_mutating) return;
|
||
setState(() => _mutating = true);
|
||
final messenger = ScaffoldMessenger.of(context);
|
||
try {
|
||
await widget.repository.updateVaccination(record.id, request);
|
||
widget.analytics?.editSucceeded(
|
||
recordType: HealthRecordType.vaccine,
|
||
fieldCount: request.toJson().length - 1,
|
||
);
|
||
if (!mounted) return;
|
||
messenger.showSnackBar(SnackBar(content: Text(successText)));
|
||
await _load();
|
||
} on PetVersionConflictException {
|
||
if (!mounted) return;
|
||
// 40902:并发修改抢先——刷新取新 version 后由用户重试动作。
|
||
messenger.showSnackBar(
|
||
const SnackBar(content: Text('记录已在其他设备被修改,已刷新,请重试')),
|
||
);
|
||
_trackEditFailed(HealthRecordFailureReason.conflict, 40902);
|
||
await _load();
|
||
} on VaccinationRuleException {
|
||
if (!mounted) return;
|
||
// 42201:状态机/状态-日期规则兜底(前端已按规则拦截主路径)。
|
||
messenger.showSnackBar(
|
||
const SnackBar(content: Text('接种状态与日期不符合规则,请核对后重试')),
|
||
);
|
||
_trackEditFailed(HealthRecordFailureReason.validationError, 42201);
|
||
} on PetRecordNotFoundException {
|
||
if (!mounted) return;
|
||
messenger.showSnackBar(const SnackBar(content: Text('记录不存在或已被删除,已刷新')));
|
||
_trackEditFailed(HealthRecordFailureReason.notFound, 40402);
|
||
await _load();
|
||
} on PetAccessDeniedException {
|
||
if (!mounted) return;
|
||
messenger.showSnackBar(const SnackBar(content: Text('你没有权限操作该记录')));
|
||
_trackEditFailed(HealthRecordFailureReason.permissionDenied, 40300);
|
||
} on ApiBusinessException catch (error) {
|
||
if (!mounted) return;
|
||
messenger.showSnackBar(const SnackBar(content: Text('操作失败,请稍后重试')));
|
||
_trackEditFailed(HealthRecordFailureReason.serverError, error.code);
|
||
} on ApiNetworkException {
|
||
if (!mounted) return;
|
||
messenger.showSnackBar(const SnackBar(content: Text('网络异常,请检查网络后重试')));
|
||
_trackEditFailed(HealthRecordFailureReason.networkError);
|
||
} on SessionExpiredException {
|
||
// 会话失效:认证状态机自动回登录页。
|
||
} finally {
|
||
if (mounted) setState(() => _mutating = false);
|
||
}
|
||
}
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Scaffold(
|
||
appBar: AppBar(
|
||
backgroundColor: Colors.transparent,
|
||
elevation: 0,
|
||
foregroundColor: AppColors.ink,
|
||
title: const Text('疫苗记录'),
|
||
centerTitle: true,
|
||
titleTextStyle: const TextStyle(
|
||
color: AppColors.ink,
|
||
fontSize: 16,
|
||
fontWeight: FontWeight.w800,
|
||
),
|
||
actions: [
|
||
if (widget.canWrite && _phase == _ListPhase.ready)
|
||
IconButton(
|
||
tooltip: '登记疫苗',
|
||
onPressed: _openCreate,
|
||
icon: const Icon(Icons.add),
|
||
),
|
||
],
|
||
),
|
||
body: switch (_phase) {
|
||
_ListPhase.loading => const Center(child: CircularProgressIndicator()),
|
||
_ListPhase.error => Center(
|
||
child: Padding(
|
||
padding: const EdgeInsets.all(24),
|
||
child: Column(
|
||
mainAxisAlignment: MainAxisAlignment.center,
|
||
children: [
|
||
InlineErrorBanner(message: petLoadErrorMessage(_error)),
|
||
const SizedBox(height: 16),
|
||
FilledButton(onPressed: _load, child: const Text('重试')),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
_ListPhase.ready when _records.isEmpty => Center(
|
||
child: SingleChildScrollView(
|
||
child: EmptyStateIllustration(
|
||
icon: Icons.vaccines_outlined,
|
||
title: '还没有疫苗记录',
|
||
description: '登记接种计划与完成情况,不错过每一针',
|
||
ctaLabel: widget.canWrite ? '登记第一针' : null,
|
||
onCtaPressed: widget.canWrite ? _openCreate : null,
|
||
),
|
||
),
|
||
),
|
||
_ListPhase.ready => _list(),
|
||
},
|
||
);
|
||
}
|
||
|
||
/// 按系列分组渲染:服务端排序保证同系列相邻,系列变化处插组头
|
||
/// (疫苗名 · 系列键)。
|
||
Widget _list() {
|
||
final children = <Widget>[];
|
||
String? currentSeries;
|
||
for (final record in _records) {
|
||
final seriesId = '${record.vaccineId}/${record.seriesKey}';
|
||
if (seriesId != currentSeries) {
|
||
currentSeries = seriesId;
|
||
children.add(
|
||
Padding(
|
||
padding: EdgeInsets.only(top: children.isEmpty ? 0 : 14, bottom: 8),
|
||
child: Text(
|
||
'${record.vaccineName} · ${record.seriesKey}',
|
||
style: const TextStyle(
|
||
color: AppColors.inkSoft,
|
||
fontSize: 12,
|
||
fontWeight: FontWeight.w700,
|
||
),
|
||
),
|
||
),
|
||
);
|
||
}
|
||
children
|
||
..add(
|
||
_VaccinationTile(
|
||
record: record,
|
||
// 流转动作仅 scheduled 行可用(终态由服务端状态机守卫)。
|
||
onComplete:
|
||
widget.canWrite &&
|
||
record.status == VaccinationStatus.scheduled &&
|
||
!_mutating
|
||
? () => _markCompleted(record)
|
||
: null,
|
||
onCancel:
|
||
widget.canWrite &&
|
||
record.status == VaccinationStatus.scheduled &&
|
||
!_mutating
|
||
? () => _cancelRegistration(record)
|
||
: null,
|
||
),
|
||
)
|
||
..add(const SizedBox(height: 10));
|
||
}
|
||
return RefreshIndicator(
|
||
onRefresh: _load,
|
||
child: ListView(
|
||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 30),
|
||
children: children,
|
||
),
|
||
);
|
||
}
|
||
}
|
||
|
||
/// 疫苗条目:RecordTypeDot(疫苗) + 剂次标题 + 日期副行 + 状态 TagPill
|
||
/// (图标+文字双通道,不单靠颜色区分);scheduled 行附
|
||
/// 「标记完成 / 取消登记」流转动作。
|
||
class _VaccinationTile extends StatelessWidget {
|
||
const _VaccinationTile({
|
||
required this.record,
|
||
this.onComplete,
|
||
this.onCancel,
|
||
});
|
||
|
||
final Vaccination record;
|
||
final VoidCallback? onComplete;
|
||
final VoidCallback? onCancel;
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Card(
|
||
child: Padding(
|
||
padding: const EdgeInsets.all(14),
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Row(
|
||
children: [
|
||
const RecordTypeDot(
|
||
type: RecordType.vaccine,
|
||
size: RecordTypeDotSize.md,
|
||
),
|
||
const SizedBox(width: 12),
|
||
Expanded(
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Text(
|
||
vaccinationDoseLabel(record),
|
||
style: Theme.of(context).textTheme.titleMedium,
|
||
),
|
||
const SizedBox(height: 4),
|
||
Text(
|
||
vaccinationDateLine(record),
|
||
maxLines: 1,
|
||
overflow: TextOverflow.ellipsis,
|
||
style: const TextStyle(
|
||
color: AppColors.inkSoft,
|
||
fontSize: 12,
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
const SizedBox(width: 8),
|
||
TagPill(
|
||
vaccinationStatusLabel(record.status),
|
||
color: vaccinationStatusColor(record.status),
|
||
),
|
||
],
|
||
),
|
||
if (onComplete != null || onCancel != null) ...[
|
||
const SizedBox(height: 6),
|
||
Row(
|
||
mainAxisAlignment: MainAxisAlignment.end,
|
||
children: [
|
||
TextButton.icon(
|
||
onPressed: onCancel,
|
||
icon: const Icon(Icons.close, size: 16),
|
||
style: TextButton.styleFrom(
|
||
foregroundColor: AppColors.inkSoft,
|
||
),
|
||
label: const Text('取消登记'),
|
||
),
|
||
const SizedBox(width: 4),
|
||
TextButton.icon(
|
||
onPressed: onComplete,
|
||
icon: const Icon(Icons.check_circle_outline, size: 16),
|
||
label: const Text('标记完成'),
|
||
),
|
||
],
|
||
),
|
||
],
|
||
],
|
||
),
|
||
),
|
||
);
|
||
}
|
||
}
|
||
|
||
/// 标记完成对话框返回值。
|
||
class _CompleteVaccinationResult {
|
||
const _CompleteVaccinationResult({
|
||
required this.administeredOn,
|
||
this.nextDueOn,
|
||
this.manufacturer,
|
||
this.batchNo,
|
||
});
|
||
|
||
final DateTime administeredOn;
|
||
final DateTime? nextDueOn;
|
||
final String? manufacturer;
|
||
final String? batchNo;
|
||
}
|
||
|
||
/// 标记完成对话框:接种日期必填(默认今天)、下次接种可选;
|
||
/// 厂商/批号补录(契约可选字段,25 号报告遗留②的落地入口)。
|
||
/// 日期规则复用 [vaccinationDateRuleError](42201 前置拦截)。
|
||
class _CompleteVaccinationDialog extends StatefulWidget {
|
||
const _CompleteVaccinationDialog({required this.record});
|
||
|
||
final Vaccination record;
|
||
|
||
@override
|
||
State<_CompleteVaccinationDialog> createState() =>
|
||
_CompleteVaccinationDialogState();
|
||
}
|
||
|
||
class _CompleteVaccinationDialogState
|
||
extends State<_CompleteVaccinationDialog> {
|
||
final _manufacturerCtrl = TextEditingController();
|
||
final _batchNoCtrl = TextEditingController();
|
||
DateTime _administeredOn = DateTime.now();
|
||
DateTime? _nextDueOn;
|
||
String? _dateError;
|
||
|
||
@override
|
||
void initState() {
|
||
super.initState();
|
||
_manufacturerCtrl.text = widget.record.manufacturer ?? '';
|
||
_batchNoCtrl.text = widget.record.batchNo ?? '';
|
||
}
|
||
|
||
@override
|
||
void dispose() {
|
||
_manufacturerCtrl.dispose();
|
||
_batchNoCtrl.dispose();
|
||
super.dispose();
|
||
}
|
||
|
||
void _confirm() {
|
||
final error = vaccinationDateRuleError(
|
||
status: VaccinationStatus.completed,
|
||
administeredOn: _administeredOn,
|
||
nextDueOn: _nextDueOn,
|
||
);
|
||
if (error != null) {
|
||
setState(() => _dateError = error);
|
||
return;
|
||
}
|
||
final manufacturer = _manufacturerCtrl.text.trim();
|
||
final batchNo = _batchNoCtrl.text.trim();
|
||
Navigator.of(context).pop(
|
||
_CompleteVaccinationResult(
|
||
administeredOn: _administeredOn,
|
||
nextDueOn: _nextDueOn,
|
||
manufacturer: manufacturer.isEmpty ? null : manufacturer,
|
||
batchNo: batchNo.isEmpty ? null : batchNo,
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget _dateTile({
|
||
required String label,
|
||
required DateTime? value,
|
||
required bool allowFuture,
|
||
required ValueChanged<DateTime> onPicked,
|
||
}) {
|
||
return ListTile(
|
||
contentPadding: EdgeInsets.zero,
|
||
leading: const Icon(Icons.event_outlined, color: AppColors.muted),
|
||
title: Text(label, style: const TextStyle(fontSize: 14)),
|
||
subtitle: Text(
|
||
value == null ? '未选择' : dateToJson(value),
|
||
style: const TextStyle(color: AppColors.inkSoft, fontSize: 12),
|
||
),
|
||
trailing: AppDateFieldTrailing(
|
||
firstDate: DateTime(1990),
|
||
lastDate: allowFuture
|
||
? DateTime(DateTime.now().year + 5)
|
||
: DateTime.now(),
|
||
onToday: (picked) => setState(() {
|
||
onPicked(picked);
|
||
_dateError = null;
|
||
}),
|
||
),
|
||
onTap: () async {
|
||
final now = DateTime.now();
|
||
final picked = await pickAppDate(
|
||
context: context,
|
||
initialDate: value ?? now,
|
||
firstDate: DateTime(1990),
|
||
lastDate: allowFuture ? DateTime(now.year + 5) : now,
|
||
);
|
||
if (picked != null && mounted) {
|
||
setState(() {
|
||
onPicked(picked);
|
||
_dateError = null;
|
||
});
|
||
}
|
||
},
|
||
);
|
||
}
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return AlertDialog(
|
||
title: const Text('标记完成'),
|
||
content: SingleChildScrollView(
|
||
child: Column(
|
||
mainAxisSize: MainAxisSize.min,
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Text(
|
||
'「${vaccinationDoseLabel(widget.record)}」',
|
||
maxLines: 1,
|
||
overflow: TextOverflow.ellipsis,
|
||
),
|
||
const SizedBox(height: 8),
|
||
_dateTile(
|
||
label: '接种日期',
|
||
value: _administeredOn,
|
||
allowFuture: false,
|
||
onPicked: (value) => _administeredOn = value,
|
||
),
|
||
_dateTile(
|
||
label: '下次接种日期(可选)',
|
||
value: _nextDueOn,
|
||
allowFuture: true,
|
||
onPicked: (value) => _nextDueOn = value,
|
||
),
|
||
if (_dateError != null) ...[
|
||
const SizedBox(height: 4),
|
||
Text(
|
||
_dateError!,
|
||
style: const TextStyle(color: AppColors.error, fontSize: 12),
|
||
),
|
||
],
|
||
const SizedBox(height: 12),
|
||
AppTextField(
|
||
label: '厂商(可选)',
|
||
controller: _manufacturerCtrl,
|
||
textInputAction: TextInputAction.next,
|
||
),
|
||
const SizedBox(height: 12),
|
||
AppTextField(
|
||
label: '批号(可选)',
|
||
controller: _batchNoCtrl,
|
||
textInputAction: TextInputAction.done,
|
||
onSubmitted: (_) => _confirm(),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
actions: [
|
||
TextButton(
|
||
onPressed: () => Navigator.of(context).pop(),
|
||
child: const Text('取消'),
|
||
),
|
||
FilledButton(onPressed: _confirm, child: const Text('确认完成')),
|
||
],
|
||
);
|
||
}
|
||
}
|