分区相关
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
|
||||
/// 添加机器人扫码页 V2 —— 按「01_添加设备_支持跳过」设计稿换皮。
|
||||
///
|
||||
@@ -77,7 +78,11 @@ class _QrScannerPageV2State extends State<QrScannerPageV2>
|
||||
if (file == null) return;
|
||||
final ok = await _controller.analyzeImage(file.path);
|
||||
if (!ok && mounted) {
|
||||
CapsuleToast.show('未识别到二维码,请换一张清晰图片');
|
||||
CapsuleToast.show(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_pages_v2.qr_err_no_code'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +91,11 @@ class _QrScannerPageV2State extends State<QrScannerPageV2>
|
||||
if (_isScanned) return;
|
||||
final sn = _snController.text.trim();
|
||||
if (sn.isEmpty) {
|
||||
CapsuleToast.show('请输入设备 SN');
|
||||
CapsuleToast.show(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_pages_v2.qr_err_sn_empty'),
|
||||
);
|
||||
return;
|
||||
}
|
||||
_isScanned = true;
|
||||
@@ -169,10 +178,12 @@ class _QrScannerPageV2State extends State<QrScannerPageV2>
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
const Expanded(
|
||||
Expanded(
|
||||
child: Text(
|
||||
'添加机器人',
|
||||
style: TextStyle(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_pages_v2.qr_title'),
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _navy,
|
||||
@@ -193,8 +204,10 @@ class _QrScannerPageV2State extends State<QrScannerPageV2>
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Text(
|
||||
'暂时跳过',
|
||||
style: TextStyle(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_pages_v2.qr_skip'),
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: _blue,
|
||||
@@ -211,16 +224,17 @@ class _QrScannerPageV2State extends State<QrScannerPageV2>
|
||||
|
||||
// ===== 步骤条:1 识别设备(当前)→ 2 确认信息 → 3 绑定激活 =====
|
||||
Widget _buildSteps() {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(28, 6, 28, 0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildStep(1, '识别设备', true),
|
||||
_buildStep(1, l10n.translate('device_pages_v2.step_scan'), true),
|
||||
_buildStepLine(),
|
||||
_buildStep(2, '确认信息', false),
|
||||
_buildStep(2, l10n.translate('device_pages_v2.step_confirm'), false),
|
||||
_buildStepLine(),
|
||||
_buildStep(3, '绑定激活', false),
|
||||
_buildStep(3, l10n.translate('device_pages_v2.step_bind'), false),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -280,17 +294,22 @@ class _QrScannerPageV2State extends State<QrScannerPageV2>
|
||||
|
||||
// ===== 标题区 =====
|
||||
Widget _buildTitleBlock() {
|
||||
return const Column(
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'扫描设备二维码',
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: _navy),
|
||||
l10n.translate('device_pages_v2.qr_scan_title'),
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'将机器人机身上的二维码放入扫描框内',
|
||||
style: TextStyle(fontSize: 12, color: _gray),
|
||||
l10n.translate('device_pages_v2.qr_scan_desc'),
|
||||
style: const TextStyle(fontSize: 12, color: _gray),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -298,6 +317,7 @@ class _QrScannerPageV2State extends State<QrScannerPageV2>
|
||||
|
||||
// ===== 扫码卡:相机预览 + 扫描框/扫描线 + 闪光灯/相册识别 =====
|
||||
Widget _buildScanCard() {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Stack(
|
||||
@@ -365,13 +385,13 @@ class _QrScannerPageV2State extends State<QrScannerPageV2>
|
||||
children: [
|
||||
_buildPill(
|
||||
Icons.bolt_rounded,
|
||||
'闪光灯',
|
||||
l10n.translate('device_pages_v2.qr_flash'),
|
||||
() async => _controller.toggleTorch(),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
_buildPill(
|
||||
Icons.photo_library_outlined,
|
||||
'相册识别',
|
||||
l10n.translate('device_pages_v2.qr_album'),
|
||||
_pickFromAlbum,
|
||||
),
|
||||
],
|
||||
@@ -456,9 +476,12 @@ class _QrScannerPageV2State extends State<QrScannerPageV2>
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(child: Container(height: 1, color: const Color(0xFFDCE6F2))),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Text('或手动输入 SN', style: TextStyle(fontSize: 11, color: _gray)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('device_pages_v2.qr_manual'),
|
||||
style: const TextStyle(fontSize: 11, color: _gray),
|
||||
),
|
||||
),
|
||||
Expanded(child: Container(height: 1, color: const Color(0xFFDCE6F2))),
|
||||
],
|
||||
@@ -472,7 +495,7 @@ class _QrScannerPageV2State extends State<QrScannerPageV2>
|
||||
style: const TextStyle(fontSize: 14, color: _navy),
|
||||
cursorColor: _blue,
|
||||
decoration: InputDecoration(
|
||||
hintText: '请输入设备 SN,如 SA260002',
|
||||
hintText: AppLocalizations.of(context).translate('device_pages_v2.qr_sn_hint'),
|
||||
hintStyle: const TextStyle(color: _gray, fontSize: 14),
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
@@ -512,14 +535,14 @@ class _QrScannerPageV2State extends State<QrScannerPageV2>
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Row(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.center_focus_strong, size: 18, color: Colors.white),
|
||||
SizedBox(width: 8),
|
||||
const Icon(Icons.center_focus_strong, size: 18, color: Colors.white),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'识别设备',
|
||||
style: TextStyle(
|
||||
AppLocalizations.of(context).translate('device_pages_v2.qr_confirm'),
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
@@ -557,18 +580,22 @@ class _QrScannerPageV2State extends State<QrScannerPageV2>
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'机器人还没到货?',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_pages_v2.qr_not_arrived'),
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
const Text(
|
||||
'可以先体验 APP,收到设备后再添加',
|
||||
style: TextStyle(fontSize: 11, color: _gray),
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_pages_v2.qr_not_arrived_desc'),
|
||||
style: const TextStyle(fontSize: 11, color: _gray),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
GestureDetector(
|
||||
@@ -577,11 +604,13 @@ class _QrScannerPageV2State extends State<QrScannerPageV2>
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 4),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: Text(
|
||||
'暂时跳过,稍后添加 →',
|
||||
style: TextStyle(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_pages_v2.qr_skip_later'),
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _blue,
|
||||
|
||||
Reference in New Issue
Block a user