import 'package:flutter/Material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:keyboard/module/store/subscribe/recover_subscribe_view.dart';

/// 恢复订阅弹窗
class RecoverSubscribeDialog {
  static const String _tag = "RecoverSubscribeDialog";

  /// 显示弹窗
  /// [desc] 描述
  /// [OnConfirmCallback] 确定时回调
  static void show(String desc, OnConfirmCallback onConfirmCallback) {
    SmartDialog.show(
      tag: _tag,
      // 点击遮罩，不关闭弹窗
      clickMaskDismiss: false,
      // 内容居中显示
      alignment: Alignment.center,
      // 动画类型
      animationType: SmartAnimationType.fade,
      builder:
          (BuildContext context) => IntrinsicHeight(
            child: Container(
              padding: EdgeInsets.symmetric(horizontal: 32.w),
              child: RecoverSubscribeView(
                desc: desc,
                onConfirmCallback: () {
                  // 点击了确定
                  onConfirmCallback();
                  SmartDialog.dismiss(tag: _tag);
                },
                onCloseCallback: () {
                  // 关闭弹窗
                  SmartDialog.dismiss(tag: _tag);
                },
              ),
            ),
          ),
    );
  }
}
