feat: support box-number navigation for completed multi-code boxing & unify key handling
- In multi-code boxing mode, scanning a completed total-row number shows a clickable warning banner; clicking it or pressing P4 navigates to that box number to view boxing details. - Unify key handling across all pages to LogicalKeyboardKey named constants, removing the _androidKeyCodeFromLogicalKey fallback path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -84,9 +84,6 @@ class BoxingPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
|
||||
static const _androidKeyCodeButtonR1 = 103;
|
||||
static const _androidKeyCodeButtonL2 = 104;
|
||||
|
||||
final _scannerService = ScannerService();
|
||||
final _apiService = ApiService();
|
||||
final _feedbackService = FeedbackService();
|
||||
@@ -145,6 +142,9 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
|
||||
bool _isAutoProcessing = false;
|
||||
final _autoWarnings = <String>[];
|
||||
|
||||
// 多码凑箱:已完成装箱时可跳转的箱号
|
||||
int? _completedJumpBoxNo;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -201,28 +201,23 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
|
||||
_finishManyToOneBox();
|
||||
}
|
||||
}
|
||||
if (_completedJumpBoxNo != null && _isJumpToBoxKey(event)) {
|
||||
_jumpToCompletedBox();
|
||||
}
|
||||
}
|
||||
|
||||
bool _isModeSwitchKey(KeyEvent event) {
|
||||
final key = event.logicalKey;
|
||||
return key == LogicalKeyboardKey.select ||
|
||||
key == LogicalKeyboardKey.gameButtonRight1 ||
|
||||
_androidKeyCodeFromLogicalKey(key) == _androidKeyCodeButtonR1;
|
||||
key == LogicalKeyboardKey.gameButtonRight1;
|
||||
}
|
||||
|
||||
bool _isFinishBoxKey(KeyEvent event) {
|
||||
final key = event.logicalKey;
|
||||
return key == LogicalKeyboardKey.gameButtonLeft2 ||
|
||||
_androidKeyCodeFromLogicalKey(key) == _androidKeyCodeButtonL2;
|
||||
return event.logicalKey == LogicalKeyboardKey.gameButtonLeft2;
|
||||
}
|
||||
|
||||
int? _androidKeyCodeFromLogicalKey(LogicalKeyboardKey key) {
|
||||
final keyId = key.keyId;
|
||||
const androidPlane = LogicalKeyboardKey.androidPlane;
|
||||
if (keyId >= androidPlane && keyId < androidPlane + 0x100000000) {
|
||||
return keyId - androidPlane;
|
||||
}
|
||||
return null;
|
||||
bool _isJumpToBoxKey(KeyEvent event) {
|
||||
return event.logicalKey == LogicalKeyboardKey.gameButtonRight2;
|
||||
}
|
||||
|
||||
void _onBoxNoTextChanged() {
|
||||
@@ -372,6 +367,7 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
|
||||
_editingAssignedItemId = null;
|
||||
_editingAssignedQuantity = '';
|
||||
_deletingAssignedItemId = null;
|
||||
_completedJumpBoxNo = null;
|
||||
_statusOverrideText = null;
|
||||
if (_mode == BoxingMode.singleCode) {
|
||||
_paichanSwitchNotice = null;
|
||||
@@ -482,6 +478,10 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
|
||||
final remaining = _remainingQuantity;
|
||||
if (remaining <= 0) {
|
||||
_quantityController.clear();
|
||||
if (_manyToOnePackedItems.isEmpty &&
|
||||
_currentZongpaiBoxes.isNotEmpty) {
|
||||
_completedJumpBoxNo = _currentZongpaiBoxes.first.boxNo;
|
||||
}
|
||||
_statusOverrideText = '该总排号已全部装箱完毕';
|
||||
_statusOverrideDot = StatusDotColor.red;
|
||||
return;
|
||||
@@ -1230,6 +1230,17 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
|
||||
});
|
||||
}
|
||||
|
||||
void _jumpToCompletedBox() {
|
||||
final boxNo = _completedJumpBoxNo;
|
||||
if (boxNo == null) return;
|
||||
setState(() {
|
||||
_boxNoController.text = boxNo.toString();
|
||||
_completedJumpBoxNo = null;
|
||||
_statusOverrideText = null;
|
||||
_statusOverrideDot = null;
|
||||
});
|
||||
}
|
||||
|
||||
// === 导航到详情页 ===
|
||||
|
||||
void _openDetail() {
|
||||
@@ -1430,15 +1441,32 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
|
||||
if (_phase == _Phase.scanned &&
|
||||
_zongpaiNo != null &&
|
||||
_remainingQuantity <= 0) {
|
||||
banners.add(
|
||||
_noticeBanner(
|
||||
icon: Icon(Icons.warning, size: 14, color: Colors.red.shade800),
|
||||
text: '${_zongpaiNo!} 已全部装箱完毕,无需操作',
|
||||
background: Colors.red.shade50,
|
||||
foreground: Colors.red.shade800,
|
||||
border: Colors.red.shade100,
|
||||
),
|
||||
);
|
||||
final jumpBoxNo = _completedJumpBoxNo;
|
||||
if (jumpBoxNo != null) {
|
||||
banners.add(
|
||||
GestureDetector(
|
||||
onTap: _jumpToCompletedBox,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: _noticeBanner(
|
||||
icon: Icon(Icons.warning, size: 14, color: Colors.amber.shade800),
|
||||
text: '${_zongpaiNo!} 已完成装箱。(P4跳转所在箱号)',
|
||||
background: Colors.amber.shade50,
|
||||
foreground: Colors.amber.shade800,
|
||||
border: Colors.amber.shade200,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
banners.add(
|
||||
_noticeBanner(
|
||||
icon: Icon(Icons.warning, size: 14, color: Colors.red.shade800),
|
||||
text: '${_zongpaiNo!} 已全部装箱完毕,无需操作',
|
||||
background: Colors.red.shade50,
|
||||
foreground: Colors.red.shade800,
|
||||
border: Colors.red.shade100,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
return banners;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user