Extract large methods from _BoxingPageState into 6 part files: - boxing_scan_part.dart: scan handling and auto-scan processing - boxing_submit_part.dart: submit/update/delete API calls - boxing_box_mutation_part.dart: box item mutations - boxing_single_ops_part.dart: single-code boxing operations - boxing_multi_ops_part.dart: multi-code boxing operations - boxing_status_part.dart: status bar management Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
87 lines
2.4 KiB
Dart
87 lines
2.4 KiB
Dart
// ignore_for_file: invalid_use_of_protected_member, unnecessary_this
|
|
|
|
part of '../../boxing_page.dart';
|
|
|
|
extension _BoxingStatusPart on _BoxingPageState {
|
|
StatusDotColor _dotForActionError(BoxingActionErrorKind? kind) {
|
|
return switch (kind) {
|
|
BoxingActionErrorKind.network => StatusDotColor.yellow,
|
|
BoxingActionErrorKind.duplicate => StatusDotColor.amber,
|
|
_ => StatusDotColor.red,
|
|
};
|
|
}
|
|
|
|
void _showActionError<T>(
|
|
BoxingActionResult<T> action, {
|
|
required String fallback,
|
|
}) {
|
|
_feedbackService.trigger(switch (action.errorKind) {
|
|
BoxingActionErrorKind.network => FeedbackEvent.networkError,
|
|
BoxingActionErrorKind.duplicate => FeedbackEvent.duplicateBoxNo,
|
|
_ => FeedbackEvent.submitFailure,
|
|
});
|
|
this._showStatusOverride(
|
|
action.errorMessage ?? fallback,
|
|
this._dotForActionError(action.errorKind),
|
|
const Duration(seconds: 2),
|
|
);
|
|
}
|
|
|
|
void _showStatusOverride(String text, StatusDotColor dot, Duration duration) {
|
|
setState(() {
|
|
_statusOverrideText = text;
|
|
_statusOverrideDot = dot;
|
|
});
|
|
Future.delayed(duration, () {
|
|
if (mounted) {
|
|
setState(() {
|
|
_statusOverrideText = null;
|
|
_statusOverrideDot = null;
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
void _jumpToCompletedBox() {
|
|
final boxNo = _completedJumpBoxNo;
|
|
if (boxNo == null) return;
|
|
setState(() {
|
|
_boxNoController.text = boxNo.toString();
|
|
_completedJumpBoxNo = null;
|
|
_statusOverrideText = null;
|
|
_statusOverrideDot = null;
|
|
});
|
|
}
|
|
|
|
void _openDetail() {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (_) => BoxingDetailPage(
|
|
paichanNo: _paichanNo ?? '',
|
|
existingBoxes: _existingBoxes,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
void _updateBaseStatus() {
|
|
final status = boxingStatusFor(
|
|
isAutoProcessing: _isAutoProcessing,
|
|
isSubmitting: _isSubmitting,
|
|
isDuplicateBoxNo: _isDuplicateBoxNo,
|
|
quantityTooHigh: _quantityTooHigh,
|
|
isEditingAssigned: _editingAssignedItemId != null,
|
|
isDeletingAssigned: _deletingAssignedItemId != null,
|
|
hasPaichanSwitchNotice: _paichanSwitchNotice != null,
|
|
phase: _phase,
|
|
isMultiCode: _mode == BoxingMode.multiCode,
|
|
hasVisibleManyToOneItems: _visibleManyToOnePackedItems.isNotEmpty,
|
|
remainingQuantity: _remainingQuantity,
|
|
boxNoText: _boxNoController.text,
|
|
);
|
|
_statusDot = status.dot;
|
|
_statusText = status.text;
|
|
}
|
|
}
|