package ctbrec.ui.sites.flirt4free;

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

import ctbrec.sites.flirt4free.Flirt4Free;
import ctbrec.ui.tabs.TabProvider;
import ctbrec.ui.tabs.ThumbOverviewTab;
import javafx.scene.Scene;
import javafx.scene.control.Tab;
import javafx.util.Duration;

public class Flirt4FreeTabProvider extends TabProvider {

    private Flirt4Free flirt4Free;
    private ThumbOverviewTab followedTab;

    public Flirt4FreeTabProvider(Flirt4Free flirt4Free) {
        this.flirt4Free = flirt4Free;
        followedTab = new Flirt4FreeFavoritesTab(flirt4Free);
        followedTab.setRecorder(flirt4Free.getRecorder());
    }

    @Override
    public List<Tab> getTabs(Scene scene) {
        List<Tab> tabs = new ArrayList<>();
        tabs.add(createTab("Girls", flirt4Free.getBaseUrl() + "/live/girls/"));
        tabs.add(createTab("Boys", flirt4Free.getBaseUrl() + "/live/guys/"));
        tabs.add(createTab("Trans", flirt4Free.getBaseUrl() + "/live/trans/"));
        tabs.add(followedTab);
        return tabs;
    }

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

    private ThumbOverviewTab createTab(String title, String url) {
        Flirt4FreeUpdateService s = new Flirt4FreeUpdateService(flirt4Free, url);
        ThumbOverviewTab tab = new ThumbOverviewTab(title, s, flirt4Free);
        tab.setRecorder(flirt4Free.getRecorder());
        s.setPeriod(Duration.seconds(60));
        return tab;
    }
}
