package com.haussteuerung;

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

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.lifecycle.ProcessLifecycleOwner;

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

public class activityLWP extends AppCompatActivity implements NavigationBarView.OnItemSelectedListener {
    BottomNavigationView bottomNavigationView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ProcessLifecycleOwner.get().getLifecycle().addObserver(new AppLifecycleTracker());

        // Ändern der Statusbar-Farbe
        androidx.appcompat.app.ActionBar actionBar = getSupportActionBar();
        assert actionBar != null;
        actionBar.setBackgroundDrawable(AppCompatResources.getDrawable(getApplicationContext(), R.drawable.gradient_titlebar));


        setContentView(R.layout.activity_lwp);
        setTitle("Haussteuerung - Wärmepumpe");

        bottomNavigationView = findViewById(R.id.bottomNavigationView);

        bottomNavigationView.setOnItemSelectedListener(this);
        bottomNavigationView.setSelectedItemId(R.id.heizkoerper);
        bottomNavigationView.setItemIconTintList(null);
    }

    FragmentWW fragmentWW = new FragmentWW();
    FragmentHeizung fragmentHeizung = new FragmentHeizung();
    FragmentHeizkoerper fragmentHeizkoerper = new FragmentHeizkoerper();

    @Override
    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
        int itemId = item.getItemId();
        if (itemId == R.id.warmwasser) {
            getSupportFragmentManager().beginTransaction().replace(R.id.flFragment, fragmentWW).commit();
            return true;
        } else if (itemId == R.id.heizung) {
            getSupportFragmentManager().beginTransaction().replace(R.id.flFragment, fragmentHeizung).commit();
            return true;
        } else if (itemId == R.id.heizkoerper) {
            getSupportFragmentManager().beginTransaction().replace(R.id.flFragment, fragmentHeizkoerper).commit();
            return true;
        }
        return false;
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onStop() {
        super.onStop();
    }
}