package ctbrec.ui.sites.cam4;

import ctbrec.sites.cam4.Cam4;
import ctbrec.ui.sites.AbstractTabProvider;
import ctbrec.ui.tabs.ThumbOverviewTab;
import javafx.scene.Scene;
import javafx.scene.control.Tab;

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

public class Cam4TabProvider extends AbstractTabProvider {

    private Cam4FollowedTab followed;

    public Cam4TabProvider(Cam4 cam4) {
        super(cam4);
    }

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

        tabs.add(createTab("Female", site.getBaseUrl() + "/directoryResults?online=true&gender=female&orderBy=MOST_VIEWERS"));
        tabs.add(createTab("Male", site.getBaseUrl() + "/directoryResults?online=true&gender=male&orderBy=MOST_VIEWERS"));
        tabs.add(createTab("Couples", site.getBaseUrl() + "/directoryResults?online=true&broadcastType=male_group&broadcastType=female_group&broadcastType=male_female_group&orderBy=MOST_VIEWERS"));
        tabs.add(createTab("HD", site.getBaseUrl() + "/directoryResults?online=true&hd=true&orderBy=MOST_VIEWERS"));
        tabs.add(createTab("New", site.getBaseUrl() + "/directoryResults?online=true&gender=female&orderBy=MOST_VIEWERS&newPerformer=true"));

        followed = new Cam4FollowedTab((Cam4) site);
        followed.setRecorder(recorder);
        tabs.add(followed);

        return tabs;
    }

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

    private Tab createTab(String name, String url) {
        var updateService = new Cam4UpdateService(url, false, (Cam4) site);
        var tab = new ThumbOverviewTab(name, updateService, site);
        tab.setImageAspectRatio(9.0 / 16.0);
        tab.setRecorder(recorder);
        return tab;
    }

}
