import 'package:flutter/Material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:lottie/lottie.dart';
import '../../../../base/base_view.dart';
import '../../../../resource/assets.gen.dart';
import '../../../../resource/string.gen.dart';
import '../../../../utils/status_bar_util.dart';
import '../../../../widget/gradient_btn.dart';
import '../../../../widget/status_bar_placeholder_widget.dart';
import '../../../../widget/top_bar.dart';
import '../../widget/tutorial_header_widget.dart';
import 'keyboard_tutorial_video_android_ios_controller.dart';

/// 键盘教程页-视频引导页-Android平台
class KeyboardTutorialVideoIosView
    extends BaseView<KeyboardTutorialVideoIosViewController> {
  const KeyboardTutorialVideoIosView({super.key});

  @override
  Color backgroundColor() {
    return Color(0xFFF6F5FA);
  }

  @override
  Widget buildBody(BuildContext context) {
    return Stack(
      children: [
        // 头部
        Positioned(left: 0, top: 0, right: 0, child: _buildHeader(context)),
        // 状态栏和标题栏
        Positioned(
          left: 0,
          top: 0,
          right: 0,
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [StatusBarPlaceholderWidget(), _buildTopBar()],
          ),
        ),
        // 内容，填充剩余部分
        Positioned.fill(
          top: 170.h + StatusBarUtil.getStatusBarHeight(Get.context!),
          left: 0,
          right: 0,
          child: Column(children: [_buildContent()]),
        ),
        // 底部按钮
        Positioned(
          left: 0,
          right: 0,
          bottom: 0,
          child: _buildBottomActionBtn(),
        ),
      ],
    );
  }

  /// 顶部栏
  Widget _buildTopBar() {
    return TopBar(
      // 返回按钮
      leftWidget: GestureDetector(
        onTap: controller.clickBack,
        child: Assets.images.iconBlackBackArrow.image(
          width: 24.w,
          height: 24.h,
        ),
      ),
    );
  }

  /// 头部布局
  Widget _buildHeader(BuildContext context) {
    return TutorialHeaderWidget();
  }

  /// 内容
  Widget _buildContent() {
    return Expanded(child: Column(children: [_buildTutorialAnimation()]));
  }

  /// 键盘设置引导动画
  Widget _buildTutorialAnimation() {
    return Lottie.asset(
      Assets.anim.animKeyboardTutorialSettingIos,
      repeat: true,
      width: 340.w,
    );
  }

  /// 去开启键盘按钮
  Widget _buildEnableKeyboard() {
    return Container(
      margin: EdgeInsets.symmetric(horizontal: 50.w),
      child: GradientTextBtn(
        StringName.tutorialEnableKeyboardIos,
        onPressed: () {
          controller.goEnableKeyboard();
        },
      ),
    );
  }

  /// 底部操作按钮
  Widget _buildBottomActionBtn() {
    return Column(
      children: [
        // 去开启键盘按钮
        _buildEnableKeyboard(),
        // 距离底部一定距离
        SizedBox(height: 52.h),
      ],
    );
  }
}
