package ctbrec.ui.sites.amateurtv;

import java.util.ArrayList;
import java.util.List;

import ctbrec.recorder.Recorder;
import ctbrec.sites.amateurtv.AmateurTv;
import ctbrec.ui.tabs.PaginatedScheduledService;
import ctbrec.ui.tabs.TabProvider;
import ctbrec.ui.tabs.ThumbOverviewTab;
import javafx.scene.Scene;
import javafx.scene.control.Tab;

public class AmateurTvTabProvider implements TabProvider {

    private AmateurTv amateurTv;
    private Recorder recorder;

    public AmateurTvTabProvider(AmateurTv amateurTv) {
        this.amateurTv = amateurTv;
        this.recorder = amateurTv.getRecorder();
    }

    @Override
    public List<Tab> getTabs(Scene scene) {
        List<Tab> tabs = new ArrayList<>();

        // all
        var url = AmateurTv.baseUrl + "/v3/readmodel/cache/cams/A";
        var updateService = new AmateurTvUpdateService(amateurTv, url);
        tabs.add(createTab("All", updateService));

        // female
        url = AmateurTv.baseUrl + "/v3/readmodel/cache/cams/W";
        updateService = new AmateurTvUpdateService(amateurTv, url);
        tabs.add(createTab("Female", updateService));

        // male
        url = AmateurTv.baseUrl + "/v3/readmodel/cache/cams/M";
        updateService = new AmateurTvUpdateService(amateurTv, url);
        tabs.add(createTab("Male", updateService));

        // couples
        url = AmateurTv.baseUrl + "/v3/readmodel/cache/cams/C";
        updateService = new AmateurTvUpdateService(amateurTv, url);
        tabs.add(createTab("Couples", updateService));

        // trans
        url = AmateurTv.baseUrl + "/v3/readmodel/cache/cams/T";
        updateService = new AmateurTvUpdateService(amateurTv, url);
        tabs.add(createTab("Trans", updateService));

        return tabs;
    }

    private Tab createTab(String title, PaginatedScheduledService updateService) {
        var tab = new ThumbOverviewTab(title, updateService, amateurTv);
        tab.setRecorder(recorder);
        return tab;
    }

    @Override
    public Tab getFollowedTab() {
        return null;
    }

}
