diff --git a/lib/modules/settings/views/settings_view.dart b/lib/modules/settings/views/settings_view.dart index 42b9daa3d..d36801018 100644 --- a/lib/modules/settings/views/settings_view.dart +++ b/lib/modules/settings/views/settings_view.dart @@ -515,22 +515,27 @@ class SettingsView extends GetView { // ? Colors.white.withOpacity(0.1) // : Colors.grey[200]), // //BLE测试 - // _buildSimpleNavigationSetting( - // title: 'opus解码测试', - // subtitle: '测试opus解码', - // icon: Icons.bluetooth_searching, - // iconBgColor: isDarkMode - // ? Colors.green[900]!.withOpacity(0.3) - // : Colors.green[100]!, - // iconColor: - // isDarkMode ? Colors.green[300]! : Colors.green[600]!, - // titleColor: isDarkMode ? Colors.white : null, - // subtitleColor: isDarkMode ? Colors.white70 : null, - // onTap: () { - // Get.toNamed(Routes.opusTest); - // }, - // isDarkMode: isDarkMode, - // ), + + Obx(() => controller.showDebugInfo.value + ? _buildSimpleNavigationSetting( + title: 'opus解码测试', + subtitle: '测试opus解码', + icon: Icons.bluetooth_searching, + iconBgColor: isDarkMode + ? Colors.green[900]!.withOpacity(0.3) + : Colors.green[100]!, + iconColor: isDarkMode + ? Colors.green[300]! + : Colors.green[600]!, + titleColor: isDarkMode ? Colors.white : null, + subtitleColor: isDarkMode ? Colors.white70 : null, + onTap: () { + Get.toNamed(Routes.opusTest); + }, + isDarkMode: isDarkMode, + ) + : const SizedBox.shrink()), + // Divider( // height: 1, // color: isDarkMode diff --git a/lib/modules/translation/controllers/translation_list_controller.dart b/lib/modules/translation/controllers/translation_list_controller.dart index 55539706c..2d4bffc19 100644 --- a/lib/modules/translation/controllers/translation_list_controller.dart +++ b/lib/modules/translation/controllers/translation_list_controller.dart @@ -104,7 +104,7 @@ class TranslationListController extends GetxController { // Android 11+ (API 30+) 不需要存储权限 if (sdkVersion >= 30) { Logger.d("Permission", "Android 11+版本,无需请求存储权限"); - //return true; // 直接返回true,表示可以使用存储 + return; // 直接返回,表示可以使用存储 } } catch (e) { Logger.e("Permission", "获取Android版本信息失败: $e"); diff --git a/lib/modules/translation/views/widgets/draggable_floating_button.dart b/lib/modules/translation/views/widgets/draggable_floating_button.dart index 98b25adb3..80fa508f0 100644 --- a/lib/modules/translation/views/widgets/draggable_floating_button.dart +++ b/lib/modules/translation/views/widgets/draggable_floating_button.dart @@ -55,19 +55,7 @@ class DraggableFloatingButton extends StatelessWidget { ), ), onDragEnd: (details) { - // 计算新位置(相对于屏幕右下角) - final screenSize = MediaQuery.of(Get.context!).size; - final newRight = screenSize.width - details.offset.dx - 56.w; - final newBottom = screenSize.height - details.offset.dy - 56.w; - - // 边界检查,确保按钮不会超出屏幕 - final clampedRight = newRight.clamp(0.0, screenSize.width - 56.w); - final clampedBottom = - newBottom.clamp(0.0, screenSize.height - 56.w); - - // 保存新位置 - controller.saveFloatingButtonPosition( - Offset(clampedRight, clampedBottom)); + _handleDragEnd(context, details); }, child: GestureDetector( onTap: () => _showTranslationModeSelector(isDarkMode), @@ -96,6 +84,28 @@ class DraggableFloatingButton extends StatelessWidget { )); } + /// 处理拖拽结束事件 + void _handleDragEnd(BuildContext context, DraggableDetails details) { + final screenSize = MediaQuery.of(context).size; + final appBarHeight = Scaffold.of(context).appBarMaxHeight ?? kToolbarHeight; + final statusBarHeight = MediaQuery.of(context).padding.top; + final safeAreaTop = statusBarHeight + appBarHeight; + + // 计算新位置(相对于屏幕右下角) + final newRight = screenSize.width - details.offset.dx - 56.w; + final newBottom = screenSize.height - details.offset.dy - 56.w; + + // 边界检查,确保按钮不会超出屏幕或被AppBar遮盖 + final clampedRight = newRight.clamp(0.0, screenSize.width - 56.w); + final clampedBottom = newBottom.clamp( + 0.0, // 底部边界 + screenSize.height - safeAreaTop - 56.w, // 顶部边界(避免被AppBar遮盖) + ); + + // 保存新位置 + controller.saveFloatingButtonPosition(Offset(clampedRight, clampedBottom)); + } + /// 显示翻译模式选择器 void _showTranslationModeSelector(bool isDarkMode) { TranslationModeSelector.show(isDarkMode);