package org.example.petshopdesktop;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import org.example.petshopdesktop.util.DesktopNotificationService;

import java.io.IOException;
import java.util.Objects;

public class PetShopApplication extends Application {
    @Override
    public void start(Stage stage) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader(PetShopApplication.class.getResource("login-view.fxml"));
        Scene scene = new Scene(fxmlLoader.load());
        stage.setTitle("Leon's Pet Store - Login");

        try {
            stage.getIcons().add(new Image(Objects.requireNonNull(
                getClass().getResourceAsStream("/org/example/petshopdesktop/images/leons-pet-store-badge.png")
            )));
        } catch (Exception e) {
            System.err.println("Could not load application icon: " + e.getMessage());
        }

        stage.setScene(scene);
        stage.show();

        DesktopNotificationService.getInstance().init(
                stage.getIcons().isEmpty() ? null : stage.getIcons().get(0)
        );
    }
}
