import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:lottie/lottie.dart';

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

class KeyboardGeneratingDialog {
  static const tag = "KeyboardGeneratingDialog";

  static void show({text = "生成中..."}) {
    SmartDialog.show(
      tag: tag,
      backType: SmartBackType.block,
      clickMaskDismiss: false,
      alignment: Alignment.center,
      animationType: SmartAnimationType.centerScale_otherSlide,
      builder: (_) {
        return Container(
          width: 298.w,
          height: 234.w,
          decoration: ShapeDecoration(
            gradient: LinearGradient(
              begin: Alignment(0.50, 0.00),
              end: Alignment(0.50, 1.00),
              colors: [const Color(0xFFE0D5FD), Colors.white],
            ),
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(20.r),
            ),
          ),
          child: Stack(
            alignment: Alignment.center,
            children: [
              Lottie.asset(
                Assets.anim.animKeyboardGeneratingData,
                repeat: true,
                width: 196.w,
                fit: BoxFit.contain,
              ),
              Positioned(
                bottom: 20.w,
                child: Text(
                  text,
                  textAlign: TextAlign.center,
                  style: TextStyle(
                    color: Colors.black.withAlpha(204),
                    fontSize: 16.sp,
                    fontWeight: FontWeight.w500,
                  ),
                ),
              ),
            ],
          ),
        );
      },
    );
  }

  static void hide() {
    SmartDialog.dismiss(tag: tag);
  }
}
