package com.adealink.weparty.room.applymic


interface ITabManager {
    fun initTabs(tabs: List<Tab>) {}

    fun getTabs(): List<Tab> = arrayListOf()

    fun getCount(): Int = 0

    fun getTab(index: Int): Tab? = null

    fun getTabIndex(tab: Tab): Int = 0
}

class TabManager : ITabManager {
    private var tabs = mutableListOf<Tab>()

    override fun initTabs(tabs: List<Tab>) {
        this.tabs.clear()
        this.tabs.addAll(tabs)
    }

    override fun getTabs() = tabs

    override fun getCount(): Int {
        return tabs.size
    }

    override fun getTab(index: Int): Tab? {
        return if (index in tabs.indices) tabs[index] else null
    }

    override fun getTabIndex(tab: Tab): Int {
        return tabs.indexOf(tab)
    }
}