package in.techware.carrefour.activity.merchandise;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.TextView;

import in.techware.carrefour.R;
import in.techware.carrefour.util.AppConstants;

public class PrintLabelSelectedActivity extends AppCompatActivity implements View.OnClickListener{

    TextView mTitleTextView;
    CheckBox mQtyCheckBox;
    EditText mQtyEditText;
    EditText mBarcodeEditText;
    String selectedSubMenu;
    Button mBackButton;
    Button mModifyButton;
    Button mDeleteButton;

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

        mTitleTextView = findViewById(R.id.txt_title);
        mQtyCheckBox = findViewById(R.id.check_qty);
        mQtyEditText = findViewById(R.id.etxt_waste_quantity);
        mBarcodeEditText = findViewById(R.id.etxt_barcode);
        mBackButton = findViewById(R.id.btn_back);
        mModifyButton = findViewById(R.id.btn_modify);
        mDeleteButton = findViewById(R.id.btn_delete);
        mBackButton.setOnClickListener(this);
        mModifyButton.setOnClickListener(this);
        mDeleteButton.setOnClickListener(this);

        if (getIntent() != null && getIntent().getStringExtra("print_type") != null){
            selectedSubMenu = getIntent().getStringExtra("print_type");
            mTitleTextView.setText(selectedSubMenu);
        }

        mQtyCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mQtyEditText.setEnabled(isChecked);
            }
        });

        handleKeyboard();
    }

    private void handleKeyboard() {
        if (getSharedPreferences(AppConstants.PREF_FILE, 0).getBoolean(AppConstants.KEYBOARD_STATUS, false)){
            mQtyEditText.setFocusableInTouchMode(true);
            mBarcodeEditText.setFocusableInTouchMode(true);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_back:
                finish();
                break;

            case R.id.btn_modify:

                break;

            case R.id.btn_delete:
                break;
        }
    }
}
