import 'package:flutter/cupertino.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:keyboard/dialog/login/login_dialog_controller.dart';
import '../../module/login/login_controller.dart';
import '../../utils/event_bus.dart';
import 'login_dialog_view.dart';

/// 登录弹窗显示事件
const eventLoginDialogShow = "event_login_dialog_show";

class LoginDialog {
  static const String TAG = "LoginDialog";

  static void show() {
    SmartDialog.show(
      backType: SmartBackType.normal,
      clickMaskDismiss: true,
      alignment: Alignment.bottomCenter,
      animationType: SmartAnimationType.centerScale_otherSlide,
      tag: TAG,
      keepSingle: true,
      onDismiss: () => Get.delete<LoginDialogController>(),
      builder: (context) {
        // 通知外部，登录弹窗显示
        WidgetsBinding.instance.addPostFrameCallback((_) {
          eventBus.post(eventLoginDialogShow);
        });
        return const LoginDialogView();
      },
    );
  }
}
