import 'package:get/get.dart';
import 'package:injectable/injectable.dart';
import 'package:keyboard/base/base_controller.dart';

import '../../router/app_page_arguments.dart';
import '../../utils/atmob_log.dart';

/// 键盘使用教程-引导页Controller
@injectable
class KeyboardTutorialController extends BaseController {
  final String _tag = "KeyboardTutorialController";

  /// 是否检查完成教程，完成了就自动跳转去键盘引导页
  Rx<bool> checkTutorialComplete = true.obs;

  @override
  void onInit() {
    super.onInit();
    _initArgs();
  }

  /// 初始化参数
  void _initArgs() {
    final arguments = Get.arguments as Map<String, dynamic>?;

    // 当前索引
    if (arguments?[AppPageArguments.isCheckTutorialComplete] == null) {
      AtmobLog.i(_tag, '没有传递 isCheckTutorialComplete 参数');
    } else {
      final bool? isCheckTutorialComplete =
          arguments?[AppPageArguments.isCheckTutorialComplete] as bool?;
      if (isCheckTutorialComplete != null) {
        checkTutorialComplete.value = isCheckTutorialComplete;
        AtmobLog.i(_tag, "isCheckTutorialComplete: $isCheckTutorialComplete");
      }
    }
  }
}
