import 'package:flyinsono/architecture/utils/global_logout.dart';
import 'package:flyinsono/architecture/utils/window_state.dart';
import 'package:flyinsono/js_platform/methods.dart';
import 'package:flyinsono/pages/main/home/controller.dart';
import 'package:get/get.dart';

import 'base.dart';

class LogoutHandler extends MethodHandlerBase {
  LogoutHandler() : super(TargetMethodName.Logout);

  @override
  void execute(List<String> args) {
    GlobalLogout.relogin();
  }
}

// 处理窗口状态改变事件
class WindowStateChangeHandler extends MethodHandlerBase {
  WindowStateChangeHandler() : super(TargetMethodName.OnWindowStateChange);

  @override
  void execute(List<String> args) {
    var state = int.parse(args[0].toString());
    var windowState = WindowState.values
        .firstWhereOrNull((element) => element.index == state);
    print("windowState0:" + windowState.toString());
    var controller = Get.find<HomeController>();
    print("windowState1:" + windowState.toString());
    controller.onWindowStateChange(windowState);
  }
}
