package com.zhangmeng.online.exam.ui.utils;

import com.zhangmeng.online.exam.ui.api.form.QuestionForm;
import com.zhangmeng.online.exam.ui.api.form.RoleForm;
import com.zhangmeng.online.exam.ui.api.form.UserForm;
import com.zhangmeng.online.exam.ui.api.form.base.Form;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;

import java.io.IOException;

/**
 * @author zm
 * @date 2025/3/31 15:48
 * @version: 1.0
 */
public class FxUtils {

    public final static double DEFAULT_WIDTH = 1280;
    public final static double DEFAULT_HEIGHT = 720;

    public static void alert(String title, Parent node, Stage primaryStage) {

        Form form = (Form) node;
        if (form instanceof UserForm) {
            form = new UserForm(true);
        }
        if (form instanceof RoleForm) {
            form = new RoleForm();
        }

        if (form instanceof QuestionForm){
            form = new QuestionForm();
        }

        Scene scene = new Scene(form);
        Stage dialogStage = new Stage();
        dialogStage.setTitle(title);
        dialogStage.setResizable(false);
        dialogStage.initModality(Modality.WINDOW_MODAL);
        dialogStage.initOwner(primaryStage);
        dialogStage.setScene(scene);
        dialogStage.showAndWait();

    }
}
