package leigh.elements.jfoenix.type1;

import leigh.elements.javafx.type1.ElementFactoryJFX;
import leigh.elements.sdk.AppScreenInstance;
import leigh.elements.sdk.type1.*;
import leigh.eo.EO;
import leigh.mecha.nodegraph.NodeConfig;

import java.util.List;

public class ElementsFactoryJFoenix extends ElementFactoryJFX {
    public ElementsFactoryJFoenix(List<NodeConfig> nodeConfigs) {
        super(nodeConfigs);
    }

    /**
     * Impementation which overrides <code>ElementFactoryJFX.newNode()</code> to provide the JFoenix
     * replacements. If a replacement is not available, the parent implementation is called.
     */
    public Element newNode(EO cfg, AppScreenInstance screen) {
        return switch (cfg.getApiType()) {
            case TextFieldElement.EO_TYPE -> new FieldElementJFoenix(cfg, screen);
            case FormLayout.EO_TYPE -> new FormLayoutJFoenix(cfg, screen);
            case DateFieldElement.EO_TYPE -> new DateFieldElementJFoenix(cfg, screen);
            case TextAreaElement.EO_TYPE -> new TextAreaJFoenix(cfg, screen);
            case ColorFieldElement.EO_TYPE -> new ColorFieldJFoenix(cfg, screen);
            default -> super.newNode(cfg, screen);
        };
    }
}
