package com.example.smartlab

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import androidx.fragment.app.Fragment
import com.example.smartlab.databinding.ActivityMainBinding
import com.google.android.material.bottomnavigation.BottomNavigationView

class MainActivity : AppCompatActivity() {
    lateinit var binding: ActivityMainBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)

        loadFragment(AnaliseFragment())

        binding.bottomNav.setOnNavigationItemSelectedListener {
            when (it.itemId) {
                R.id.analise -> {
                    loadFragment(AnaliseFragment())
                }
                R.id.user_card -> {
                    loadFragment(PatientCardFragment())
                }
                R.id.support -> {
                    loadFragment(BlockFragment())
                    Toast.makeText(this, "Странница поддержки временно недоступна",Toast.LENGTH_SHORT).show()
                }
                R.id.result -> {
                    loadFragment(BlockFragment())
                    Toast.makeText(this, "Странница результатов временно недоступна",Toast.LENGTH_SHORT).show()
                }
            }
            true
        }
    }

    private  fun loadFragment(fragment: Fragment){
        val transaction = supportFragmentManager.beginTransaction()
        transaction.replace(R.id.container,fragment)
        transaction.commit()
    }

}