package ctbrec.ui.sites.jasmin;

import ctbrec.sites.jasmin.LiveJasmin;
import ctbrec.ui.sites.AbstractTabProvider;
import ctbrec.ui.tabs.ThumbOverviewTab;
import javafx.scene.Scene;
import javafx.scene.control.Tab;
import javafx.util.Duration;

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

public class LiveJasminTabProvider extends AbstractTabProvider {


    private final LiveJasminFollowedTab followedTab;

    public LiveJasminTabProvider(LiveJasmin liveJasmin) {
        super(liveJasmin);
        followedTab = new LiveJasminFollowedTab(liveJasmin);
        followedTab.setRecorder(liveJasmin.getRecorder());
        followedTab.setImageAspectRatio(9.0 / 16.0);
    }

    @Override
    protected List<Tab> getSiteTabs(Scene scene) {
        List<Tab> tabs = new ArrayList<>();
        tabs.add(createTab("Girls", site.getBaseUrl() + "/en/girl/?listPageOrderType=most_popular"));
        tabs.add(createTab("Girls HD", site.getBaseUrl() + "/en/girl/hd/?listPageOrderType=most_popular"));
        tabs.add(createTab("New Girls", site.getBaseUrl() + "/en/girls/newbie/?listPageOrderType=most_popular"));
        tabs.add(createTab("Couples", site.getBaseUrl() + "/en/girls/couple/?listPageOrderType=most_popular"));
        tabs.add(createTab("Boys", site.getBaseUrl() + "/en/boy/?listPageOrderType=most_popular"));
        tabs.add(createTab("Boys HD", site.getBaseUrl() + "/en/boy/hd/?listPageOrderType=most_popular"));
        tabs.add(followedTab);
        return tabs;
    }

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

    private ThumbOverviewTab createTab(String title, String url) {
        var s = new LiveJasminUpdateService((LiveJasmin) site, url);
        s.setPeriod(Duration.seconds(60));
        ThumbOverviewTab tab = new LiveJasminTab(title, s, site);
        tab.setRecorder(site.getRecorder());
        tab.setImageAspectRatio(9.0 / 16.0);
        return tab;
    }
}
