content: package genuinecoder.main;
  
  import com.genuinecoder.Launcher;
  import com.jfoenix.controls.JFXDrawer;
  import com.jfoenix.controls.JFXHamburger;
  import com.jfoenix.transitions.hamburger.HamburgerBackArrowBasicTransition;
  import genuinecoder.panel.SidePanelController;
  import java.io.IOException;
  import java.net.URL;
  import java.util.ResourceBundle;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import javafx.animation.FadeTransition;
  import javafx.fxml.FXML;
  import javafx.fxml.FXMLLoader;
  import javafx.fxml.Initializable;
  import javafx.scene.input.MouseEvent;
  import javafx.scene.layout.AnchorPane;
  import javafx.scene.layout.StackPane;
  import javafx.scene.layout.VBox;
  import javafx.util.Duration;
  
  public class MainController implements Initializable, ColorChangeCallback {
  
      @FXML
      private JFXDrawer drawer;
  
      @FXML
      private JFXHamburger hamburger;
  
      @FXML
      private AnchorPane root;
  
      @Override
      public void initialize(URL url, ResourceBundle rb) {
          if (!Launcher.isSplashLoaded) {
              loadSplashScreen();
          }
  
          try {
              FXMLLoader loader = new FXMLLoader(getClass().getResource("/genuinecoder/panel/sidepanel.fxml"));
              VBox box = loader.load();
              SidePanelController controller = loader.getController();
              controller.setCallback(this);
              drawer.setSidePane(box);
          } catch (IOException ex) {
              Logger.getLogger(MainController.class.getName()).log(Level.SEVERE, null, ex);
          }
  
          HamburgerBackArrowBasicTransition transition = new HamburgerBackArrowBasicTransition(hamburger);
          transition.setRate(-1);
          hamburger.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> {
              transition.setRate(transition.getRate() * -1);
              transition.play();
  
              if (drawer.isOpened()) {
                  drawer.close();
              } else {
                  drawer.open();
              }
          });
      }
  
      private void loadSplashScreen() {
          try {
              Launcher.isSplashLoaded = true;
  
              StackPane pane = FXMLLoader.load(getClass().getResource(("/genuinecoder/splash/splash.fxml")));
              root.getChildren().setAll(pane);
  
              FadeTransition fadeIn = new FadeTransition(Duration.seconds(3), pane);
              fadeIn.setFromValue(0);
              fadeIn.setToValue(1);
              fadeIn.setCycleCount(1);
  
              FadeTransition fadeOut = new FadeTransition(Duration.seconds(3), pane);
              fadeOut.setFromValue(1);
              fadeOut.setToValue(0);
              fadeOut.setCycleCount(1);
  
              fadeIn.play();
  
              fadeIn.setOnFinished((e) -> {
                  fadeOut.play();
              });
  
              fadeOut.setOnFinished((e) -> {
                  try {
                      AnchorPane parentContent = FXMLLoader.load(getClass().getResource(("/genuinecoder/main/main.fxml")));
                      root.getChildren().setAll(parentContent);
                  } catch (IOException ex) {
                      Logger.getLogger(MainController.class.getName()).log(Level.SEVERE, null, ex);
                  }
              });
  
          } catch (IOException ex) {
              Logger.getLogger(MainController.class.getName()).log(Level.SEVERE, null, ex);
          }
      }
  
      @Override
      public void updateColor(String newColor) {
          root.setStyle("-fx-background-color:" + newColor);
      }
  }
  