merge: integrate boxing module from remote with sound/vibration feedback
Merge remote boxing module (one2one, one2many, many2one modes) with local sound and vibration feedback feature. Migrate SharedPreferences to AppConfigService across all services including SoundService. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:vibration/vibration.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:pad_scanner/services/app_config_service.dart';
|
||||
import 'package:pad_scanner/services/scanner_service.dart';
|
||||
import 'package:pad_scanner/services/code_parser.dart';
|
||||
import 'package:pad_scanner/services/api_service.dart';
|
||||
import 'package:pad_scanner/services/sound_service.dart';
|
||||
import 'package:pad_scanner/pages/settings_page.dart';
|
||||
|
||||
class RegistrationPage extends StatefulWidget {
|
||||
const RegistrationPage({super.key});
|
||||
@@ -129,8 +128,8 @@ class _RegistrationPageState extends State<RegistrationPage> {
|
||||
Future<void> _submit() async {
|
||||
if (!_canSubmit) return;
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final baseUrl = prefs.getString('api_url') ?? '';
|
||||
final configService = AppConfigService();
|
||||
final baseUrl = await configService.getString('api_url') ?? '';
|
||||
if (baseUrl.isEmpty) {
|
||||
_showFeedback('未配置 API 地址,请前往设置', isError: true);
|
||||
return;
|
||||
@@ -166,8 +165,7 @@ class _RegistrationPageState extends State<RegistrationPage> {
|
||||
_locationCode = null;
|
||||
_locationType = null;
|
||||
}
|
||||
_successMessage =
|
||||
_isLocked ? '货位已锁定,请扫描下一张执行卡' : '上架成功';
|
||||
_successMessage = _isLocked ? '货位已锁定,请扫描下一张执行卡' : '上架成功';
|
||||
});
|
||||
_showFeedback('上架成功', isError: false);
|
||||
Future.delayed(const Duration(milliseconds: 1500), () {
|
||||
@@ -259,8 +257,10 @@ class _RegistrationPageState extends State<RegistrationPage> {
|
||||
const SizedBox(height: 4),
|
||||
Text('登记时间:${info?["registered_at"] ?? "未知"}'),
|
||||
const SizedBox(height: 12),
|
||||
const Text('请核查实物,确认是否操作错误。',
|
||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
const Text(
|
||||
'请核查实物,确认是否操作错误。',
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
@@ -315,17 +315,7 @@ class _RegistrationPageState extends State<RegistrationPage> {
|
||||
child: Row(
|
||||
children: [
|
||||
const Text('锁定货位', style: TextStyle(fontSize: 13)),
|
||||
Switch(
|
||||
value: _isLocked,
|
||||
onChanged: _toggleLock,
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.settings),
|
||||
onPressed: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const SettingsPage()),
|
||||
),
|
||||
),
|
||||
Switch(value: _isLocked, onChanged: _toggleLock),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -337,8 +327,7 @@ class _RegistrationPageState extends State<RegistrationPage> {
|
||||
if (_snackbarMessage != null)
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
|
||||
color: _snackbarColor,
|
||||
child: Text(
|
||||
_snackbarMessage!,
|
||||
@@ -356,17 +345,24 @@ class _RegistrationPageState extends State<RegistrationPage> {
|
||||
// ---- 目标货位 (上方) ----
|
||||
Row(
|
||||
children: [
|
||||
const Text('目标货位',
|
||||
style: TextStyle(
|
||||
fontSize: 14, fontWeight: FontWeight.w500)),
|
||||
const Text(
|
||||
'目标货位',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
if (_locationCode != null) ...[
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 6, vertical: 2),
|
||||
horizontal: 6,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: _locationLabelColor(_locationType)
|
||||
.withValues(alpha: 0.15),
|
||||
color: _locationLabelColor(
|
||||
_locationType,
|
||||
).withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
@@ -385,7 +381,9 @@ class _RegistrationPageState extends State<RegistrationPage> {
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 14),
|
||||
horizontal: 12,
|
||||
vertical: 14,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: _locationCode != null
|
||||
@@ -410,8 +408,11 @@ class _RegistrationPageState extends State<RegistrationPage> {
|
||||
),
|
||||
),
|
||||
if (_isLocked)
|
||||
const Icon(Icons.lock,
|
||||
color: Colors.orange, size: 20),
|
||||
const Icon(
|
||||
Icons.lock,
|
||||
color: Colors.orange,
|
||||
size: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -421,14 +422,20 @@ class _RegistrationPageState extends State<RegistrationPage> {
|
||||
// ---- 总排号 (下方) ----
|
||||
Row(
|
||||
children: [
|
||||
const Text('总排号',
|
||||
style: TextStyle(
|
||||
fontSize: 14, fontWeight: FontWeight.w500)),
|
||||
const Text(
|
||||
'总排号',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
if (_isLocked && _zongpaiNos.isNotEmpty) ...[
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 6, vertical: 2),
|
||||
horizontal: 6,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue.withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
@@ -455,14 +462,15 @@ class _RegistrationPageState extends State<RegistrationPage> {
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.grey.shade400),
|
||||
border: Border.all(color: Colors.grey.shade400),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: const Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: 20, color: Colors.grey),
|
||||
fontSize: 20,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
)
|
||||
: ListView.separated(
|
||||
@@ -471,36 +479,32 @@ class _RegistrationPageState extends State<RegistrationPage> {
|
||||
const SizedBox(height: 6),
|
||||
itemBuilder: (context, index) {
|
||||
return Dismissible(
|
||||
key: ValueKey(
|
||||
'${_zongpaiNos[index]}-$index'),
|
||||
direction:
|
||||
DismissDirection.endToStart,
|
||||
onDismissed: (_) =>
|
||||
_removeZongpai(index),
|
||||
key: ValueKey('${_zongpaiNos[index]}-$index'),
|
||||
direction: DismissDirection.endToStart,
|
||||
onDismissed: (_) => _removeZongpai(index),
|
||||
background: Container(
|
||||
alignment:
|
||||
Alignment.centerRight,
|
||||
padding: const EdgeInsets.only(
|
||||
right: 16),
|
||||
alignment: Alignment.centerRight,
|
||||
padding: const EdgeInsets.only(right: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red.shade100,
|
||||
borderRadius:
|
||||
BorderRadius.circular(8),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.delete,
|
||||
color: Colors.red,
|
||||
),
|
||||
child: const Icon(Icons.delete,
|
||||
color: Colors.red),
|
||||
),
|
||||
child: Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 12,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.green,
|
||||
width: 2),
|
||||
borderRadius:
|
||||
BorderRadius.circular(8),
|
||||
color: Colors.green,
|
||||
width: 2,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
@@ -509,21 +513,20 @@ class _RegistrationPageState extends State<RegistrationPage> {
|
||||
_zongpaiNos[index],
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight:
|
||||
FontWeight.bold,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.close,
|
||||
size: 20),
|
||||
Icons.close,
|
||||
size: 20,
|
||||
),
|
||||
onPressed: () =>
|
||||
_removeZongpai(index),
|
||||
padding: EdgeInsets.zero,
|
||||
constraints:
|
||||
const BoxConstraints(),
|
||||
constraints: const BoxConstraints(),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -537,7 +540,9 @@ class _RegistrationPageState extends State<RegistrationPage> {
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 14),
|
||||
horizontal: 12,
|
||||
vertical: 14,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: _zongpaiNos.isNotEmpty
|
||||
@@ -615,8 +620,8 @@ class _RegistrationPageState extends State<RegistrationPage> {
|
||||
color: _isSubmitting
|
||||
? Colors.orange
|
||||
: _successMessage != null
|
||||
? Colors.green
|
||||
: Colors.blue,
|
||||
? Colors.green
|
||||
: Colors.blue,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user