Browse Source

优化语言选择对话框的布局和样式

删除未使用的语言描述文件
newdev_shunjiawei
lxm 2 years ago
parent
commit
885984a03a
  1. 12
      ios/Runner/Info.plist
  2. 4
      ios/Runner/en.lproj/InfoPlist.strings
  3. 3
      ios/Runner/zh.lproj/InfoPlist.strings
  4. 2
      lib/modules/settings/controllers/settings_controller.dart
  5. 186
      lib/modules/settings/views/settings_view.dart

12
ios/Runner/Info.plist

@ -41,7 +41,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>NSUserTrackingUsageDescription</key>
<string>UserTrackingUsageDescription</string>
<string>This application needs to access your tracking data in order to offer better personalized services and advertisements</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
@ -59,19 +59,17 @@
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>BluetoothUsageDescription</string>
<string>Bluetooth permission is required to connect and manage audio devices</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>BluetoothUsageDescription</string>
<string>Bluetooth permission is required to connect and manage audio devices</string>
<key>NSMicrophoneUsageDescription</key>
<string>MicrophoneUsageDescription</string>
<string>Microphone permission is required for voice recognition</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>SpeechRecognitionUsageDescription</string>
<string>Speech recognition permission is required to provide voice interaction services</string>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
<string>voip</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>

4
ios/Runner/en.lproj/InfoPlist.strings

@ -1,4 +0,0 @@
"BluetoothUsageDescription" = "Bluetooth permission is required to connect and manage audio devices";
"MicrophoneUsageDescription" = "Microphone permission is required for voice recognition";
"SpeechRecognitionUsageDescription" = "Speech recognition permission is required to provide voice interaction services";
"UserTrackingUsageDescription" = "This application needs to access your tracking data in order to offer better personalized services and advertisements";

3
ios/Runner/zh.lproj/InfoPlist.strings

@ -1,3 +0,0 @@
"BluetoothUsageDescription" = "需要蓝牙权限来连接和管理音频设备";
"MicrophoneUsageDescription" = "需要麦克风权限来进行语音识别";
"SpeechRecognitionUsageDescription" = "需要语音识别权限来提供语音交互服务";

2
lib/modules/settings/controllers/settings_controller.dart

@ -20,7 +20,7 @@ class SettingsController extends GetxController {
final List<LanguageModel> languageList = [
LanguageModel(
name: 'followingSystem', // 跟随系统.tr
alias: 'followingSystem', // 跟随系统.tr
alias: '',
value: 'system'),
LanguageModel(name: 'english', alias: 'English', value: 'en_US'), // 英语.tr
LanguageModel(name: 'chinese', alias: '中文', value: 'zh_CN'), // 中文.tr

186
lib/modules/settings/views/settings_view.dart

@ -653,12 +653,17 @@ class SettingsView extends GetView<SettingsController> {
),
InkWell(
onTap: () {
print(controller.appVersion.value);
// 在这里添加检查更新的逻辑
},
child: Container(
padding:
EdgeInsets.symmetric(horizontal: 12.w, vertical: 6.h),
constraints: BoxConstraints(
minWidth: 100.w,
maxWidth: 180.w,
),
padding: EdgeInsets.symmetric(
horizontal: 16.w,
vertical: 8.h,
),
decoration: BoxDecoration(
color: isDarkMode
? Colors.blue[900]!.withOpacity(0.3)
@ -666,12 +671,14 @@ class SettingsView extends GetView<SettingsController> {
borderRadius: BorderRadius.circular(16.r),
),
child: Text(
'checkUpdates'.tr, // 检查更新
'checkUpdates'.tr,
style: TextStyle(
fontSize: 12.sp,
color:
isDarkMode ? Colors.blue[300] : Colors.blue[600],
color: isDarkMode ? Colors.blue[300] : Colors.blue[600],
),
overflow: TextOverflow.ellipsis, // 添加省略号
maxLines: 1, // 限制为单行
textAlign: TextAlign.center, // 保持居中
),
),
),
@ -1099,7 +1106,7 @@ class SettingsView extends GetView<SettingsController> {
return Obx(() {
final isSelected =
controller.speechServiceType.value == service['type'];
return InkWell(
return GestureDetector(
onTap: () {
controller.setSpeechServiceType(service['type']);
Get.back();
@ -1127,28 +1134,6 @@ class SettingsView extends GetView<SettingsController> {
),
child: Row(
children: [
Container(
width: 24.w,
height: 24.w,
decoration: BoxDecoration(
color: isSelected
? (isDarkMode
? Colors.teal[300]
: Colors.teal[600])
: (isDarkMode
? Colors.white.withOpacity(0.1)
: Colors.grey[300]),
shape: BoxShape.circle,
),
child: isSelected
? Icon(
Icons.check,
size: 16.w,
color: Colors.white,
)
: null,
),
SizedBox(width: 12.w),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -1179,6 +1164,28 @@ class SettingsView extends GetView<SettingsController> {
],
),
),
SizedBox(width: 12.w),
Container(
width: 24.w,
height: 24.w,
decoration: BoxDecoration(
color: isSelected
? (isDarkMode
? Colors.teal[300]
: Colors.teal[600])
: (isDarkMode
? Colors.white.withOpacity(0.1)
: Colors.grey[300]),
shape: BoxShape.circle,
),
child: isSelected
? Icon(
Icons.check,
size: 16.w,
color: Colors.white,
)
: null,
),
],
),
),
@ -1211,27 +1218,22 @@ class SettingsView extends GetView<SettingsController> {
void _showLanguageSelectionDialog(bool isDarkMode) {
Get.dialog(
Dialog(
backgroundColor: isDarkMode ? Colors.grey[900] : Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24.r),
borderRadius: BorderRadius.circular(16.r),
),
insetPadding: EdgeInsets.symmetric(horizontal: 20.w),
backgroundColor: isDarkMode ? AppColors.cardBackground : Colors.white,
child: Container(
width: 0.9.sw,
padding: EdgeInsets.only(top: 32.h, bottom: 16.h),
child: Padding(
padding: EdgeInsets.all(12.w),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 24.w),
child: Text(
Text(
'selectLanguage'.tr, // 选择语言
style: TextStyle(
fontSize: 20.sp,
fontWeight: FontWeight.bold,
color: isDarkMode ? Colors.white : Colors.black,
),
fontSize: 18.sp,
fontWeight: FontWeight.w600,
color: isDarkMode ? Colors.white : Colors.black87,
),
),
SizedBox(height: 16.h),
@ -1241,46 +1243,104 @@ class SettingsView extends GetView<SettingsController> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: controller.languageList.map((language) {
return ListTile(
title: Text(
return Obx(() {
final isSelected =
controller.language.value.value == language.value;
return GestureDetector(
onTap: () {
controller.setLanguage(language);
Get.back();
},
child: Container(
margin: EdgeInsets.only(bottom: 10.h),
padding: EdgeInsets.all(10.w),
decoration: BoxDecoration(
color: isSelected
? (isDarkMode
? Colors.teal[900]!.withOpacity(0.3)
: Colors.teal[50]!)
: (isDarkMode
? Colors.white.withOpacity(0.05)
: Colors.grey[100]!),
borderRadius: BorderRadius.circular(12.r),
border: Border.all(
color: isSelected
? (isDarkMode
? Colors.teal[300]!
: Colors.teal[600]!)
: Colors.transparent,
width: 1,
),
),
child: Row(
children: [
Expanded(
child: Text(
language.name.tr,
style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black,
fontSize: 16.sp,
fontWeight: FontWeight.w500,
color: isDarkMode
? Colors.white
: Colors.black87,
),
overflow: TextOverflow.ellipsis,
),
),
trailing:
controller.language.value.value == language.value
? Icon(
Icons.check_circle,
Text(
language.alias, // 这里使用原始名称,不加 .tr
style: TextStyle(
fontSize: 14.sp,
color: isDarkMode
? AppColors.primary
: Colors.blue,
? Colors.white70
: Colors.black54,
),
),
SizedBox(width: 10.w),
Container(
width: 24.w,
height: 24.w,
decoration: BoxDecoration(
color: isSelected
? (isDarkMode
? Colors.teal[300]
: Colors.teal[600])
: (isDarkMode
? Colors.white.withOpacity(0.1)
: Colors.grey[300]),
shape: BoxShape.circle,
),
child: isSelected
? Icon(
Icons.check,
size: 16.w,
color: Colors.white,
)
: const SizedBox.shrink(),
onTap: () {
controller.setLanguage(language);
},
: null,
),
],
),
),
);
});
}).toList(),
),
),
),
SizedBox(height: 16.h),
Align(
alignment: Alignment.centerRight,
child: Padding(
padding: EdgeInsets.only(right: 24.w),
child: TextButton(
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () => Get.back(),
child: Text(
'cancel'.tr, // 取消
style: TextStyle(
color: isDarkMode ? AppColors.primary : Colors.blue,
fontSize: 16.sp,
),
color: isDarkMode ? Colors.white70 : Colors.black54,
),
),
),
],
),
],
),

Loading…
Cancel
Save