package com.example.punyaria;

import android.os.Bundle;
import android.view.MenuItem;

import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.NavigationUI;

import com.google.android.material.bottomnavigation.BottomNavigationView;

public class  AdminActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_admin);
        getSupportActionBar().hide();

        // Inisialisasi NavController
        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);

        // Menghubungkan BottomNavigationView dengan NavController
        BottomNavigationView bottomNav = findViewById(R.id.bottom_navigation);
        NavigationUI.setupWithNavController(bottomNav, navController);

        // Atur listener untuk menangani perubahan item yang dipilih
        bottomNav.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.navigation_home:
                        navController.navigate(R.id.berandaFragment);
                        return true;
                    case R.id.navigation_history:
                        navController.navigate(R.id.riwayatFragment);
                        return true;
                    case R.id.navigation_account:
                        navController.navigate(R.id.akunFragment);
                        return true;
                }
                return false;
            }
        });
    }
}