package ctbrec.ui.sites.manyvids;

import ctbrec.Config;
import ctbrec.Settings;
import ctbrec.sites.manyvids.MVLive;
import ctbrec.ui.settings.SettingsTab;
import ctbrec.ui.sites.AbstractConfigUI;
import javafx.geometry.Insets;
import javafx.scene.Parent;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;

public class MVLiveConfigUi extends AbstractConfigUI {
    private MVLive site;

    public MVLiveConfigUi(MVLive site) {
        this.site = site;
    }

    @Override
    public Parent createConfigPanel() {
        Settings settings = Config.getInstance().getSettings();
        GridPane layout = SettingsTab.createGridLayout();

        int row = 0;
        Label l = new Label("Active");
        layout.add(l, 0, row);
        CheckBox enabled = new CheckBox();
        enabled.setSelected(!settings.disabledSites.contains(site.getName()));
        enabled.setOnAction((e) -> {
            if(enabled.isSelected()) {
                settings.disabledSites.remove(site.getName());
            } else {
                settings.disabledSites.add(site.getName());
            }
            save();
        });
        GridPane.setMargin(enabled, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN));
        layout.add(enabled, 1, row++);
        return layout;
    }
}
