import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:keyboard/base/base_page.dart';
import 'package:keyboard/router/app_pages.dart';
import '../../router/app_page_arguments.dart';
import '../../widget/platform_util.dart';
import 'android/keyboard_tutorial_android_view.dart';
import 'ios/keyboard_tutorial_ios_view.dart';
import 'keyboard_tutorial_controller.dart';

/// 键盘使用教程-引导页
class KeyboardTutorialPage extends BasePage<KeyboardTutorialController> {
  const KeyboardTutorialPage({super.key});

  static start({required bool isCheckTutorialComplete}) {
    Map<String, dynamic> args = {
      AppPageArguments.isCheckTutorialComplete: isCheckTutorialComplete,
    };
    Get.toNamed(RoutePath.keyboardTutorial, arguments: args);
  }

  /// 跳转并关闭当前页
  static void startAndOffMe() {
    Get.offNamed(RoutePath.keyboardTutorial);
  }

  @override
  bool immersive() {
    // 开启沉浸式
    return true;
  }

  @override
  backgroundColor() {
    return Colors.transparent;
  }

  @override
  Widget buildBody(BuildContext context) {
    return Scaffold(backgroundColor: backgroundColor(), body: _buildContent());
  }

  /// 内容
  Widget _buildContent() {
    Widget content;
    if (PlatformUtil.isIOS) {
      content = const KeyboardTutorialIosView();
    } else {
      content = Obx(() {
        return KeyboardTutorialAndroidView(
          checkTutorialComplete: controller.checkTutorialComplete.value,
        );
      });
    }
    return content;
  }
}
