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. 204
      lib/modules/settings/views/settings_view.dart

12
ios/Runner/Info.plist

@ -41,7 +41,7 @@
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string> <string>$(EXECUTABLE_NAME)</string>
<key>NSUserTrackingUsageDescription</key> <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> <key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
@ -59,19 +59,17 @@
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>NSBluetoothAlwaysUsageDescription</key> <key>NSBluetoothAlwaysUsageDescription</key>
<string>BluetoothUsageDescription</string> <string>Bluetooth permission is required to connect and manage audio devices</string>
<key>NSBluetoothPeripheralUsageDescription</key> <key>NSBluetoothPeripheralUsageDescription</key>
<string>BluetoothUsageDescription</string> <string>Bluetooth permission is required to connect and manage audio devices</string>
<key>NSMicrophoneUsageDescription</key> <key>NSMicrophoneUsageDescription</key>
<string>MicrophoneUsageDescription</string> <string>Microphone permission is required for voice recognition</string>
<key>NSSpeechRecognitionUsageDescription</key> <key>NSSpeechRecognitionUsageDescription</key>
<string>SpeechRecognitionUsageDescription</string> <string>Speech recognition permission is required to provide voice interaction services</string>
<key>UIApplicationSupportsIndirectInputEvents</key> <key>UIApplicationSupportsIndirectInputEvents</key>
<true/> <true/>
<key>UIBackgroundModes</key> <key>UIBackgroundModes</key>
<array> <array>
<string>audio</string>
<string>voip</string>
</array> </array>
<key>UILaunchStoryboardName</key> <key>UILaunchStoryboardName</key>
<string>LaunchScreen</string> <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 = [ final List<LanguageModel> languageList = [
LanguageModel( LanguageModel(
name: 'followingSystem', // 跟随系统.tr name: 'followingSystem', // 跟随系统.tr
alias: 'followingSystem', // 跟随系统.tr alias: '',
value: 'system'), value: 'system'),
LanguageModel(name: 'english', alias: 'English', value: 'en_US'), // 英语.tr LanguageModel(name: 'english', alias: 'English', value: 'en_US'), // 英语.tr
LanguageModel(name: 'chinese', alias: '中文', value: 'zh_CN'), // 中文.tr LanguageModel(name: 'chinese', alias: '中文', value: 'zh_CN'), // 中文.tr

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

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

Loading…
Cancel
Save