package ctbrec.ui.sites.chaturbate;

import ctbrec.sites.chaturbate.Chaturbate;
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 ChaturbateTabProvider extends AbstractTabProvider {

    private final ChaturbateFollowedTab followedTab;

    public ChaturbateTabProvider(Chaturbate chaturbate) {
        super(chaturbate);
        this.followedTab = new ChaturbateFollowedTab("Followed", chaturbate.getBaseUrl() + "/followed-cams/", chaturbate);
    }

    @Override
    protected List<Tab> getSiteTabs(Scene scene) {
        List<Tab> tabs = new ArrayList<>();
        tabs.add(createTab("Featured", site.getBaseUrl() + "/"));
        tabs.add(createTab("Female", site.getBaseUrl() + "/female-cams/"));
        tabs.add(createTab("New Female", site.getBaseUrl() + "/new-cams/female/"));
        tabs.add(createTab("Male", site.getBaseUrl() + "/male-cams/"));
        tabs.add(createTab("Couples", site.getBaseUrl() + "/couple-cams/"));
        tabs.add(createTab("Trans", site.getBaseUrl() + "/trans-cams/"));
        followedTab.setScene(scene);
        followedTab.setRecorder(recorder);
        followedTab.setImageAspectRatio(9.0 / 16.0);
        tabs.add(followedTab);
        return tabs;
    }

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

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