import 'package:flutter/material.dart';
import 'package:get/get_rx/src/rx_types/rx_types.dart';
import 'package:get/get_state_manager/src/rx_flutter/rx_ticket_provider_mixin.dart';
import 'package:injectable/injectable.dart';
import 'package:keyboard/base/base_controller.dart';

import '../../../resource/string.gen.dart';

/// 亲密度分析-截图回复Tab页-controller
@injectable
class IntimacyAnalyseScreenshotReplyController extends BaseController
    with GetTickerProviderStateMixin {
  /// Tab列表
  RxList<String> tabBarList =
      <String>[
        StringName.intimacyAnalyseTabConversationAnalysis,
        StringName.intimacyAnalyseTabScanImageReply,
      ].obs;

  /// Tab控制器
  late final TabController tabController = TabController(
    length: tabBarList.length,
    vsync: this,
  );

  /// PageView控制器
  final PageController pageController = PageController();

  @override
  void onClose() {
    tabController.dispose();
    pageController.dispose();
    super.onClose();
  }

  /// 处理Tab切换，联动PageView
  void handleTabChange(int index) {
    pageController.animateToPage(
      index,
      duration: const Duration(milliseconds: 300),
      curve: Curves.easeInToLinear,
    );
  }

  /// 处理PageView切换，联动Tab
  void handlePageChange(int index) {
    tabController.animateTo(index, duration: const Duration(milliseconds: 300));
  }
}
