Browse Source

refactor(translation): 将分页加载状态移至历史管理器

简化翻译控制器的状态管理,将分页加载相关状态移至历史管理器统一管理
weicu
lxm 1 year ago
parent
commit
66f3d94899
  1. 8
      lib/modules/translation/controllers/translation_controller.dart

8
lib/modules/translation/controllers/translation_controller.dart

@ -68,11 +68,7 @@ class TranslationController extends GetxController {
static const String _targetLanguageKey = 'translation_target_language';
// 分页加载相关状态
final isLoadingMore = false.obs; // 是否正在加载更多历史记录
final hasMoreHistory = true.obs; // 是否还有更多历史记录
final currentPage = 1.obs; // 当前页码
final pageSize = 20; // 每页记录数量
final isLoadingMoreError = false.obs; // 加载更多时是否出错
bool _scrollListenerSetup = false; // 滚动监听器设置标志
RxInt activeSpeaker = 0.obs; // 0=无激活, 1=按钮1, 2=按钮2
@ -110,6 +106,10 @@ class TranslationController extends GetxController {
RxList<TranslationItem> get translationHistory =>
_historyManager.translationHistory;
ScrollController get scrollController => _historyManager.scrollController;
// 添加历史管理器状态访问器
RxBool get hasMoreHistory => _historyManager.hasMoreHistory;
RxBool get isLoadingMore => _historyManager.isLoadingMore;
RxBool get isLoadingMoreError => _historyManager.isLoadingMoreError;
// 其他
StreamSubscription? _recognitionSubscription;
StreamSubscription? _voiceInteractionSubscription;

Loading…
Cancel
Save