import 'package:pad_scanner/pages/boxing/boxing_models.dart'; import 'package:pad_scanner/widgets/status_bar.dart'; class BoxingStatusPresentation { final StatusDotColor dot; final String text; const BoxingStatusPresentation({required this.dot, required this.text}); } BoxingStatusPresentation boxingStatusFor({ required bool isAutoProcessing, required bool isSubmitting, required bool isDuplicateBoxNo, required bool quantityTooHigh, required bool isEditingAssigned, required bool isDeletingAssigned, required bool hasPaichanSwitchNotice, required BoxingPhase phase, required bool isMultiCode, required bool hasVisibleManyToOneItems, required int remainingQuantity, required String boxNoText, }) { if (isAutoProcessing) { return const BoxingStatusPresentation( dot: StatusDotColor.orange, text: '正在同步转运数据...', ); } if (isSubmitting) { return const BoxingStatusPresentation( dot: StatusDotColor.orange, text: '正在提交…', ); } if (isDuplicateBoxNo && phase == BoxingPhase.scanned) { return BoxingStatusPresentation( dot: StatusDotColor.amber, text: '箱号 $boxNoText 已存在,请重新输入', ); } if (quantityTooHigh && phase == BoxingPhase.scanned) { return const BoxingStatusPresentation( dot: StatusDotColor.red, text: '超出可装数量上限', ); } if (isEditingAssigned) { return const BoxingStatusPresentation( dot: StatusDotColor.amber, text: '正在编辑已分配记录', ); } if (isDeletingAssigned) { return const BoxingStatusPresentation( dot: StatusDotColor.red, text: '请确认是否删除该箱记录', ); } if (hasPaichanSwitchNotice) { return const BoxingStatusPresentation( dot: StatusDotColor.blue, text: '排产号已切换,箱号已重置', ); } switch (phase) { case BoxingPhase.waiting: if (isMultiCode && hasVisibleManyToOneItems) { return const BoxingStatusPresentation( dot: StatusDotColor.blue, text: '请继续扫码或完成本箱', ); } return const BoxingStatusPresentation( dot: StatusDotColor.blue, text: '等待扫码', ); case BoxingPhase.scanned: if (remainingQuantity <= 0) { return const BoxingStatusPresentation( dot: StatusDotColor.red, text: '该总排号已全部装箱完毕', ); } return const BoxingStatusPresentation( dot: StatusDotColor.blue, text: '数量已填入,请确认或修改', ); case BoxingPhase.submitted: return BoxingStatusPresentation( dot: StatusDotColor.green, text: isMultiCode ? '请扫描下一个总排号' : '装箱成功,可继续扫码', ); } }