package com.kolobochki.memory.ui.home;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.navigation.Navigation;

import com.kolobochki.memory.R;
import com.kolobochki.memory.databinding.FragmentHomeBinding;

public class HomeFragment extends Fragment {

    private FragmentHomeBinding binding;

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        HomeViewModel homeViewModel =
                new ViewModelProvider(this).get(HomeViewModel.class);

        binding = FragmentHomeBinding.inflate(inflater, container, false);
        View root = binding.getRoot();

        //final TextView textView = binding.textHome;
        //homeViewModel.getText().observe(getViewLifecycleOwner(), textView::setText);

        binding.button.setOnClickListener(view -> {
            Navigation.findNavController(view).navigate(R.id.action_navigation_home_to_navigation_task1);
        });

        binding.button2.setOnClickListener(view-> {
            Navigation.findNavController(view).navigate(R.id.action_navigation_home_to_navigation_task2);
        });

        binding.button3.setOnClickListener(view -> {
            Navigation.findNavController(view).navigate(R.id.action_navigation_home_to_navigation_task3);
        });

        binding.button4.setOnClickListener(view -> {
            Navigation.findNavController(view).navigate(R.id.action_navigation_home_to_navigation_task4);
        });

        return root;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        binding = null;
    }
}