package com.yono.messeripos;

import android.os.Build;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.tabs.TabLayout;
import com.yono.messeripos.adapter.TabAdapterTransaction;
import com.yono.messeripos.transactiontab.TransactionPending;
import com.yono.messeripos.transactiontab.TransactionSuccess;

import java.util.Objects;

public class TransactionActivity extends AppCompatActivity {
    private TabAdapterTransaction adapter;
    private TabLayout tabLayout;
    private ViewPager viewPager;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list_transaction);
        viewPager = findViewById(R.id.viewPager);
        tabLayout = findViewById(R.id.tabLayout);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window w = getWindow();
            w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        }

        MaterialToolbar toolbars = findViewById(R.id.toolbar);
        setSupportActionBar(toolbars);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
        getSupportActionBar().setTitle("All Transaction");
        toolbars.setNavigationOnClickListener(view -> onBackPressed());

        adapter = new TabAdapterTransaction(getSupportFragmentManager());
        adapter.addFragment(new TransactionSuccess(), "Transaction Success");
        adapter.addFragment(new TransactionPending(), "Transaction Pending");

        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);

    }
}
