package com.proyek.akhir.kodel.ui

import android.content.res.ColorStateList
import android.graphics.Color
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import com.google.android.material.tabs.TabLayoutMediator.TabConfigurationStrategy
import com.proyek.akhir.kodel.R
import kotlinx.android.synthetic.main.activity_login.*
import kotlin.math.abs

class LoginActivity : AppCompatActivity() {

    private val titles = arrayOf("Masuk", "Daftar")

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_login)
        tabLayoutLogin.tabGravity = TabLayout.GRAVITY_CENTER
        tabLayoutLogin.tabTextColors = ColorStateList.valueOf(Color.parseColor("#95E1D3"))
        init()
    }

    private fun init() {
        // removing toolbar elevation
        viewPagerLogin.adapter = LoginAdapter(this)

        // attaching tab mediator
        TabLayoutMediator(tabLayoutLogin, viewPagerLogin,
            TabConfigurationStrategy { tab: TabLayout.Tab, position: Int ->
                tab.text = titles[position]
            }
        ).attach()
    }


}
