Browse Source

feat(配对): 添加iOS蓝牙引导对话框并支持国际化

添加蓝牙引导对话框的国际化文本
使用flutter_screenutil进行响应式布局
移除未使用的导入
weicu
lxm 1 year ago
parent
commit
ed99e75cce
  1. 13
      lib/core/translations/language/en_us.dart
  2. 9
      lib/core/translations/language/zh_cn.dart
  3. 56
      lib/modules/pairing/controllers/pairing_controller.dart

13
lib/core/translations/language/en_us.dart

@ -813,6 +813,19 @@ const Map<String, String> enUS = {
'deviceAuthorizationFailedCheckCode':
'Device authorization failed, please check authorization code',
///iOS蓝牙引导窗
'bluetoothGuideTitle': 'Manual Bluetooth Activation Required', // 需要手动开启蓝牙
'bluetoothGuideSteps': 'Please follow these steps:', // 请按照以下步骤操作:
'bluetoothGuideStep1':
'Enable Bluetooth: Settings → Bluetooth → Turn On', // 开启蓝牙:设置 → 蓝牙 → 开启
'bluetoothGuideStep2':
'Connect Device: Find your device in "My Devices" and tap to connect', // 连接设备:在"我的设备"中找到您的设备并点击连接
'bluetoothGuideStep3':
'Return to app to continue pairing process', // 返回应用继续配对流程
'bluetoothGuideTip':
'Tip: You can also long press the Bluetooth icon in Control Center to quickly access Bluetooth settings', // 提示:也可以从控制中心长按蓝牙图标快速进入蓝牙设置
'iKnow': 'I Know', // 我知道了
// 用户反馈页
"feedback": "Feedback",
'feedbackInfo': 'Provide feedback or suggestions',

9
lib/core/translations/language/zh_cn.dart

@ -746,6 +746,15 @@ const Map<String, String> zhCN = {
'bleConnectionFailed': 'BLE连接失败',
'deviceAuthorizationFailedCheckCode': '设备授权失败,请检查授权码',
///iOS蓝牙引导窗
'bluetoothGuideTitle': '需要手动开启蓝牙', // 需要手动开启蓝牙
'bluetoothGuideSteps': '请按照以下步骤操作:', // 请按照以下步骤操作:
'bluetoothGuideStep1': '开启蓝牙:设置 → 蓝牙 → 开启', // 开启蓝牙:设置 → 蓝牙 → 开启
'bluetoothGuideStep2': '连接设备:在"我的设备"中找到您的设备并点击连接', // 连接设备:在"我的设备"中找到您的设备并点击连接
'bluetoothGuideStep3': '返回应用继续配对流程', // 返回应用继续配对流程
'bluetoothGuideTip': '提示:也可以从控制中心长按蓝牙图标快速进入蓝牙设置', // 提示:也可以从控制中心长按蓝牙图标快速进入蓝牙设置
'iKnow': '我知道了', // 我知道了
//用户反馈页
"feedback": "用户反馈",
'feedbackInfo': '提供反馈或建议',

56
lib/modules/pairing/controllers/pairing_controller.dart

@ -1,12 +1,10 @@
import 'dart:convert';
import 'dart:typed_data';
import 'package:app_settings/app_settings.dart';
import 'package:voitrans/data/models/appconfig_model.dart';
import '/data/models/appconfig.dart';
import '/data/models/user_Info.dart';
import '/data/services/network/api.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'dart:async';
import 'package:permission_handler/permission_handler.dart';
@ -16,7 +14,6 @@ import 'dart:io';
import '../../../data/services/bluetooth_manager.dart';
import '../../../data/services/ble_manager.dart';
import '../../../core/utils/permission_util.dart';
import 'package:url_launcher/url_launcher.dart';
/// 配对状态枚举 - 简化版本
enum PairingState {
@ -1028,52 +1025,65 @@ class PairingController extends GetxController {
void _showBluetoothGuideDialog() {
Get.dialog(
AlertDialog(
title: Text('需要手动开启蓝牙'),
title: Text('bluetoothGuideTitle'.tr),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('请按照以下步骤操作:'),
SizedBox(height: 16),
Text('bluetoothGuideSteps'.tr),
SizedBox(height: 16.h),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('1. ', style: TextStyle(fontWeight: FontWeight.bold)),
Expanded(child: Text('开启蓝牙:设置 → 蓝牙 → 开启')),
Text('1. ',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 14.sp)),
Expanded(
child: Text('bluetoothGuideStep1'.tr,
style: TextStyle(fontSize: 14.sp))),
],
),
SizedBox(height: 8),
SizedBox(height: 8.h),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('2. ', style: TextStyle(fontWeight: FontWeight.bold)),
Expanded(child: Text('连接设备:在"我的设备"中找到您的设备并点击连接')),
Text('2. ',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 14.sp)),
Expanded(
child: Text('bluetoothGuideStep2'.tr,
style: TextStyle(fontSize: 14.sp))),
],
),
SizedBox(height: 8),
SizedBox(height: 8.h),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('3. ', style: TextStyle(fontWeight: FontWeight.bold)),
Expanded(child: Text('返回应用继续配对流程')),
Text('3. ',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 14.sp)),
Expanded(
child: Text('bluetoothGuideStep3'.tr,
style: TextStyle(fontSize: 14.sp))),
],
),
SizedBox(height: 16),
SizedBox(height: 16.h),
Container(
padding: EdgeInsets.all(12),
padding: EdgeInsets.all(12.w),
decoration: BoxDecoration(
color: Colors.blue.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
borderRadius: BorderRadius.circular(8.r),
border: Border.all(color: Colors.blue.withOpacity(0.3)),
),
child: Row(
children: [
Icon(Icons.info_outline, color: Colors.blue, size: 20),
SizedBox(width: 8),
Icon(Icons.info_outline, color: Colors.blue, size: 20.sp),
SizedBox(width: 8.w),
Expanded(
child: Text(
'提示:也可以从控制中心长按蓝牙图标快速进入蓝牙设置',
style: TextStyle(fontSize: 12, color: Colors.blue[700]),
'bluetoothGuideTip'.tr,
style:
TextStyle(fontSize: 12.sp, color: Colors.blue[700]),
),
),
],
@ -1084,7 +1094,7 @@ class PairingController extends GetxController {
actions: [
TextButton(
onPressed: () => Get.back(),
child: Text('我知道了'),
child: Text('iKnow'.tr, style: TextStyle(fontSize: 14.sp)),
),
],
),

Loading…
Cancel
Save