Compare commits

...

4 Commits

Author SHA1 Message Date
Misaka_Company
3fd47f4d7b style: improve list layout — larger fonts, adjusted column widths, center alignment
Boxing number module:
- Data row base font size 12→15, quantity column / edit mode unified to 15
- Work order column width flex 24→30, quantity column flex 14→23, action column 64px→54px
- Multi-code boxing total row column width flex 22→26
- Center-align all table headers and data rows

Shelf registration module:
- Data row base font size 12→15
- Center-align all table headers and data rows (location number changed from right-align to center)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-20 16:26:41 +08:00
Misaka_Company
eb833c830d fix: increment new box number from max box number after completing current box
Unify optimization for single-code and multi-code boxing modes: after
completing a box, set the next box number to max(existing boxes) + 1,
avoiding duplicate box numbers when browsing historical boxes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-20 14:46:41 +08:00
Misaka_Company
b1a76287d6 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>
2026-05-20 14:21:38 +08:00
Misaka_Company
f587194267 refactor: replace boxing list with table layout matching registration design
Change single-code and multi-code boxing lists from card-style layout
(number + color bar + two-line content) to table-style layout
(column headers + flex columns + left border color bar),
matching the registration module design language.

Fields: Box No. / Total Row No. | Work Order | Quantity | Action Button

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-20 12:40:51 +08:00
3 changed files with 336 additions and 357 deletions

View File

@@ -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;
@@ -701,7 +701,7 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
} else {
setState(() {
_phase = _Phase.scanned;
_boxNoController.text = (boxNo + 1).toString();
_boxNoController.text = (_maxBoxNo + 1).toString();
_quantityController.text = remaining.toString();
_quantityController.selection = TextSelection(
baseOffset: 0,
@@ -846,7 +846,6 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
}
void _finishManyToOneBox() {
final currentBoxNo = int.tryParse(_boxNoController.text.trim());
setState(() {
_manyToOnePackedItems.clear();
_editingPackedItemId = null;
@@ -855,9 +854,7 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
_zongpaiNo = null;
_phase = _Phase.waiting;
_quantityController.clear();
if (currentBoxNo != null && currentBoxNo > 0) {
_boxNoController.text = (currentBoxNo + 1).toString();
}
_boxNoController.text = (_maxBoxNo + 1).toString();
_statusOverrideText = null;
_statusOverrideDot = null;
});
@@ -1230,6 +1227,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 +1438,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;
}
@@ -1684,31 +1709,23 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
Widget _buildSingleAssignedHeader(int count) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 7),
height: 28,
padding: const EdgeInsets.symmetric(horizontal: 12),
decoration: BoxDecoration(
color: Colors.white,
border: Border(bottom: BorderSide(color: Colors.grey.shade300)),
color: Colors.grey.shade200,
border: Border(bottom: BorderSide(color: Colors.grey.shade400)),
),
child: Row(
children: [
const Expanded(flex: 22, child: Text('箱号', textAlign: TextAlign.center, style: _headerStyle)),
const Expanded(flex: 30, child: Text('工令号', textAlign: TextAlign.center, style: _headerStyle)),
const Expanded(
child: Text(
'已分配(此总排号)',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w700,
color: Colors.black54,
letterSpacing: 0.5,
),
),
flex: 23,
child: Text('数量', textAlign: TextAlign.center, style: _headerStyle),
),
Text(
'$count',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w700,
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(
width: 54,
child: Text('操作', textAlign: TextAlign.center, style: _headerStyle),
),
],
),
@@ -1722,142 +1739,150 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
? Colors.amber
: (deleting ? Colors.red : Colors.green);
final Color bgColor;
if (editing) {
bgColor = Colors.yellow.shade50;
} else if (deleting) {
bgColor = Colors.red.shade50;
} else {
bgColor = Colors.transparent;
}
final rowStyle = TextStyle(
fontSize: 15,
fontWeight: FontWeight.w500,
color: Colors.black87,
);
return Column(
children: [
Container(
height: 40,
padding: const EdgeInsets.symmetric(horizontal: 12),
constraints: const BoxConstraints(minHeight: 36),
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: editing
? Colors.yellow.shade50
: (deleting ? Colors.red.shade50 : null),
border: Border(bottom: BorderSide(color: Colors.grey.shade200)),
color: bgColor,
border: Border(
left: BorderSide(color: barColor, width: 3),
bottom: BorderSide(color: Colors.grey.shade200),
),
),
child: Row(
children: [
SizedBox(
width: 14,
child: Text(
'$index',
textAlign: TextAlign.right,
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w600,
color: Colors.grey.shade500,
),
),
),
const SizedBox(width: 6),
Container(
width: 3,
height: 22,
decoration: BoxDecoration(
color: barColor,
borderRadius: BorderRadius.circular(2),
),
),
const SizedBox(width: 6),
Expanded(
child: Column(
flex: 22,
child: Text(
'${item.boxNo} 号箱',
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: rowStyle.copyWith(fontWeight: FontWeight.w700),
),
),
Expanded(
flex: 30,
child: Text(
_workOrderNo ?? '--',
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: rowStyle,
),
),
Expanded(
flex: 23,
child: editing
? SizedBox(
width: 52,
height: 28,
child: TextField(
keyboardType: TextInputType.none,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
],
textAlign: TextAlign.center,
controller: TextEditingController(
text: _editingAssignedQuantity,
)..selection = TextSelection.collapsed(
offset: _editingAssignedQuantity.length,
),
onChanged: (v) => _editingAssignedQuantity = v,
onSubmitted: (_) => _saveAssignedItem(item),
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(
horizontal: 4,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5),
borderSide: const BorderSide(
color: Colors.amber,
width: 1.5,
),
),
),
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w700,
),
),
)
: Text(
'${item.quantity}',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
color: deleting ? Colors.red : Colors.black54,
),
),
),
SizedBox(
width: 54,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'${item.boxNo} 号箱',
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w700,
if (editing) ...[
_iconBtn(
Icons.check,
color: Colors.green,
onTap: _isSubmitting
? null
: () => _saveAssignedItem(item),
),
overflow: TextOverflow.ellipsis,
),
Text(
_workOrderNo ?? '--',
style: TextStyle(
fontSize: 10,
color: Colors.grey.shade500,
_iconBtn(
Icons.close,
color: Colors.grey,
onTap: _isSubmitting ? null : _cancelEditAssigned,
),
),
] else ...[
_iconBtn(
Icons.edit,
color: Colors.grey.shade700,
onTap: _isSubmitting
? null
: () => _startEditAssigned(item),
),
_iconBtn(
Icons.delete_outline,
color: Colors.red,
onTap: _isSubmitting
? null
: () {
setState(() {
_deletingAssignedItemId = item.boxItemId;
_editingAssignedItemId = null;
_editingAssignedQuantity = '';
});
},
),
],
],
),
),
if (editing)
SizedBox(
width: 52,
height: 28,
child: TextField(
keyboardType: TextInputType.none,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
textAlign: TextAlign.center,
controller:
TextEditingController(text: _editingAssignedQuantity)
..selection = TextSelection.collapsed(
offset: _editingAssignedQuantity.length,
),
onChanged: (value) => _editingAssignedQuantity = value,
onSubmitted: (_) => _saveAssignedItem(item),
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(horizontal: 4),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5),
borderSide: const BorderSide(
color: Colors.amber,
width: 1.5,
),
),
),
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w700,
),
),
)
else
Text(
'${item.quantity}',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: deleting ? Colors.red : Colors.black54,
),
),
if (editing) ...[
_iconBtn(
Icons.check,
color: Colors.green,
onTap: _isSubmitting ? null : () => _saveAssignedItem(item),
),
_iconBtn(
Icons.close,
color: Colors.grey,
onTap: _isSubmitting ? null : _cancelEditAssigned,
),
] else ...[
_iconBtn(
Icons.edit,
color: Colors.grey.shade700,
onTap: _isSubmitting ? null : () => _startEditAssigned(item),
),
_iconBtn(
Icons.delete_outline,
color: Colors.red,
onTap: _isSubmitting
? null
: () {
setState(() {
_deletingAssignedItemId = item.boxItemId;
_editingAssignedItemId = null;
_editingAssignedQuantity = '';
});
},
),
],
],
),
),
if (deleting)
Container(
height: 28,
padding: const EdgeInsets.only(left: 34, right: 12),
padding: const EdgeInsets.only(left: 15, right: 12),
decoration: BoxDecoration(
color: Colors.red.shade50,
border: Border(bottom: BorderSide(color: Colors.red.shade200)),
@@ -2237,31 +2262,23 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
Widget _buildManyToOneListHeader(int count) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 7),
height: 28,
padding: const EdgeInsets.symmetric(horizontal: 12),
decoration: BoxDecoration(
color: Colors.white,
border: Border(bottom: BorderSide(color: Colors.grey.shade300)),
color: Colors.grey.shade200,
border: Border(bottom: BorderSide(color: Colors.grey.shade400)),
),
child: Row(
children: [
const Expanded(flex: 26, child: Text('总排号', textAlign: TextAlign.center, style: _headerStyle)),
const Expanded(flex: 30, child: Text('工令号', textAlign: TextAlign.center, style: _headerStyle)),
const Expanded(
child: Text(
'已装入本箱',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w700,
color: Colors.black54,
letterSpacing: 0.5,
),
),
flex: 23,
child: Text('数量', textAlign: TextAlign.center, style: _headerStyle),
),
Text(
'$count',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w700,
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(
width: 54,
child: Text('操作', textAlign: TextAlign.center, style: _headerStyle),
),
],
),
@@ -2279,164 +2296,159 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
? Colors.amber
: (deleting ? Colors.red : Colors.green);
final Color bgColor;
if (editing) {
bgColor = Colors.yellow.shade50;
} else if (deleting) {
bgColor = Colors.red.shade50;
} else {
bgColor = Colors.transparent;
}
final rowStyle = TextStyle(
fontSize: 15,
fontWeight: FontWeight.w500,
color: Colors.black87,
);
return Column(
children: [
Container(
height: 40,
padding: const EdgeInsets.symmetric(horizontal: 12),
constraints: const BoxConstraints(minHeight: 36),
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: editing
? Colors.yellow.shade50
: (deleting ? Colors.red.shade50 : null),
border: Border(bottom: BorderSide(color: Colors.grey.shade200)),
color: bgColor,
border: Border(
left: BorderSide(color: barColor, width: 3),
bottom: BorderSide(color: Colors.grey.shade200),
),
),
child: Row(
children: [
// Index
SizedBox(
width: 14,
child: Text(
'$index',
textAlign: TextAlign.right,
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w600,
color: Colors.grey.shade500,
),
),
),
const SizedBox(width: 6),
// Color bar
Container(
width: 3,
height: 26,
decoration: BoxDecoration(
color: barColor,
borderRadius: BorderRadius.circular(2),
),
),
const SizedBox(width: 6),
// Main info
Expanded(
child: Column(
flex: 26,
child: Text(
item.zongpaiNo,
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: rowStyle.copyWith(fontWeight: FontWeight.w700),
),
),
Expanded(
flex: 30,
child: Text(
item.workOrderNo ?? '--',
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: rowStyle,
),
),
Expanded(
flex: 23,
child: editing
? SizedBox(
width: 52,
height: 26,
child: TextField(
keyboardType: TextInputType.none,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
],
textAlign: TextAlign.center,
controller: TextEditingController(
text: _editingPackedQuantity,
)..selection = TextSelection.collapsed(
offset: _editingPackedQuantity.length,
),
onChanged: (v) => _editingPackedQuantity = v,
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(
horizontal: 4,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(4),
borderSide: const BorderSide(
color: Colors.amber,
width: 1.5,
),
),
),
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
),
),
)
: Text(
'${item.quantity} / $totalText',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
color: deleting ? Colors.red : Colors.green.shade700,
),
),
),
SizedBox(
width: 54,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item.zongpaiNo,
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w700,
if (editing) ...[
_iconBtn(
Icons.check,
color: Colors.green,
onTap: _isSubmitting
? null
: () => _savePackedItem(item),
),
overflow: TextOverflow.ellipsis,
),
Text(
item.workOrderNo ?? '--',
style: TextStyle(
fontSize: 11,
color: Colors.grey.shade500,
_iconBtn(
Icons.close,
color: Colors.grey,
onTap: _isSubmitting ? null : _cancelEditPackedItem,
),
overflow: TextOverflow.ellipsis,
),
] else ...[
_iconBtn(
Icons.edit,
color: Colors.grey.shade700,
onTap: _isSubmitting
? null
: () => _startEditPackedItem(item),
),
_iconBtn(
Icons.delete_outline,
color: Colors.red,
onTap: _isSubmitting
? null
: () {
setState(() {
_deletingPackedItemId = item.boxItemId;
_editingPackedItemId = null;
_editingPackedQuantity = '';
});
},
),
],
],
),
),
// Quantity / edit input
if (editing)
SizedBox(
width: 52,
height: 26,
child: TextField(
keyboardType: TextInputType.none,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
textAlign: TextAlign.center,
controller:
TextEditingController(text: _editingPackedQuantity)
..selection = TextSelection.collapsed(
offset: _editingPackedQuantity.length,
),
onChanged: (value) => _editingPackedQuantity = value,
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(horizontal: 4),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(4),
borderSide: const BorderSide(
color: Colors.amber,
width: 1.5,
),
),
),
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
),
),
)
else
Text(
'${item.quantity} / $totalText',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: deleting ? Colors.red : Colors.green.shade700,
),
),
// Action buttons
if (editing) ...[
_iconBtn(
Icons.check,
color: Colors.green,
onTap: _isSubmitting ? null : () => _savePackedItem(item),
),
_iconBtn(
Icons.close,
color: Colors.grey,
onTap: _isSubmitting ? null : _cancelEditPackedItem,
),
] else ...[
_iconBtn(
Icons.edit,
color: Colors.orange.shade700,
onTap: _isSubmitting
? null
: () => _startEditPackedItem(item),
),
_iconBtn(
Icons.delete_outline,
color: Colors.red,
onTap: _isSubmitting
? null
: () {
setState(() {
_deletingPackedItemId = item.boxItemId;
_editingPackedItemId = null;
_editingPackedQuantity = '';
});
},
),
],
],
),
),
// Inline delete confirmation
if (deleting)
Container(
padding: const EdgeInsets.only(
left: 34,
right: 12,
top: 2,
bottom: 5,
),
height: 28,
padding: const EdgeInsets.only(left: 15, right: 12),
decoration: BoxDecoration(
color: Colors.red.shade50,
border: Border(bottom: BorderSide(color: Colors.red.shade200)),
),
child: Row(
children: [
const Expanded(
Expanded(
child: Text(
'确认删除?',
style: TextStyle(
style: const TextStyle(
fontSize: 12,
color: Colors.red,
fontWeight: FontWeight.w500,
@@ -2735,3 +2747,5 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
);
}
}
const _headerStyle = TextStyle(fontSize: 10, fontWeight: FontWeight.w700);

View File

@@ -39,10 +39,6 @@ class HomePage extends StatefulWidget {
}
class _HomePageState extends State<HomePage> {
static const _androidKeyCode1 = 8;
static const _androidKeyCode2 = 9;
static const _androidKeyCode3 = 10;
final _apiService = ApiService();
final _focusNode = FocusNode();
bool _isCheckingConnection = false;
@@ -134,23 +130,6 @@ class _HomePageState extends State<HomePage> {
event.character == '3') {
return 3;
}
// Android keyCode fallback for scanner devices: 1/2/3 => 8/9/10.
final androidKeyCode = _androidKeyCodeFromLogicalKey(key);
return switch (androidKeyCode) {
_androidKeyCode1 => 1,
_androidKeyCode2 => 2,
_androidKeyCode3 => 3,
_ => null,
};
}
int? _androidKeyCodeFromLogicalKey(LogicalKeyboardKey key) {
final keyId = key.keyId;
const androidPlane = LogicalKeyboardKey.androidPlane;
if (keyId >= androidPlane && keyId < androidPlane + 0x100000000) {
return keyId - androidPlane;
}
return null;
}

View File

@@ -20,8 +20,6 @@ class RegistrationPage extends StatefulWidget {
}
class _RegistrationPageState extends State<RegistrationPage> {
static const _androidKeyCodeButtonR1 = 103;
final _scannerService = ScannerService();
final _apiService = ApiService();
final _feedbackService = FeedbackService();
@@ -101,17 +99,7 @@ class _RegistrationPageState extends State<RegistrationPage> {
bool _isLockToggleKey(KeyEvent event) {
final key = event.logicalKey;
return key == LogicalKeyboardKey.select ||
key == LogicalKeyboardKey.gameButtonRight1 ||
_androidKeyCodeFromLogicalKey(key) == _androidKeyCodeButtonR1;
}
int? _androidKeyCodeFromLogicalKey(LogicalKeyboardKey key) {
final keyId = key.keyId;
const androidPlane = LogicalKeyboardKey.androidPlane;
if (keyId >= androidPlane && keyId < androidPlane + 0x100000000) {
return keyId - androidPlane;
}
return null;
key == LogicalKeyboardKey.gameButtonRight1;
}
void _onScan(ScanResult result) {
@@ -676,13 +664,9 @@ class _RegistrationPageState extends State<RegistrationPage> {
focusNode: dialogFocus,
onKeyEvent: (event) {
if (event is! KeyDownEvent) return;
final androidKey =
_androidKeyCodeFromLogicalKey(event.logicalKey);
if (event.logicalKey == LogicalKeyboardKey.arrowUp ||
androidKey == 19) {
if (event.logicalKey == LogicalKeyboardKey.arrowUp) {
setDialogState(() => selectedIndex = 0);
} else if (event.logicalKey == LogicalKeyboardKey.arrowDown ||
androidKey == 20) {
} else if (event.logicalKey == LogicalKeyboardKey.arrowDown) {
setDialogState(() => selectedIndex = 1);
} else if (event.logicalKey == LogicalKeyboardKey.enter) {
selectedIndex == 0 ? dismissAsNo() : confirmSwitch();
@@ -1034,8 +1018,8 @@ class _RegistrationPageState extends State<RegistrationPage> {
),
child: const Row(
children: [
Expanded(flex: 22, child: Text('总排号', style: _headerStyle)),
Expanded(flex: 18, child: Text('工令号', style: _headerStyle)),
Expanded(flex: 22, child: Text('总排号', textAlign: TextAlign.center, style: _headerStyle)),
Expanded(flex: 18, child: Text('工令号', textAlign: TextAlign.center, style: _headerStyle)),
Expanded(
flex: 12,
child: Text(
@@ -1048,7 +1032,7 @@ class _RegistrationPageState extends State<RegistrationPage> {
flex: 28,
child: Text(
'货位号',
textAlign: TextAlign.right,
textAlign: TextAlign.center,
style: _headerStyle,
),
),
@@ -1164,7 +1148,7 @@ class _RegistrationPageState extends State<RegistrationPage> {
Widget _buildListRow(PaichaOverviewItem item, {required bool isScanned}) {
final rowStyle = TextStyle(
fontSize: 12,
fontSize: 15,
fontWeight: isScanned ? FontWeight.w700 : FontWeight.w500,
color: Colors.black87,
);
@@ -1201,6 +1185,7 @@ class _RegistrationPageState extends State<RegistrationPage> {
flex: 22,
child: Text(
item.zongpaiNo,
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: rowStyle,
),
@@ -1209,6 +1194,7 @@ class _RegistrationPageState extends State<RegistrationPage> {
flex: 18,
child: Text(
item.workOrderNo ?? '--',
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: rowStyle,
),
@@ -1226,7 +1212,7 @@ class _RegistrationPageState extends State<RegistrationPage> {
flex: 28,
child: Text(
item.locationCode ?? '\u2014',
textAlign: TextAlign.right,
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: rowStyle,
),