package com.youra.qlicker.Acitvitys.Espace;
import com.youra.qlicker.R;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;

public class EspaceProfilActivity extends AppCompatActivity {

    CheckBox checkboxId , checkboxRes , checkboxFa , checkboxProf , checkboxAgenc ;
    LinearLayout ly_id , ly_res , ly_sit_fa , ly_sit_prof , ly_agenc;

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

        //checkbox
        checkboxId = (CheckBox)findViewById(R.id.checkbox_identifiant);
        checkboxRes = (CheckBox)findViewById(R.id.checkbox_res);
        checkboxFa = (CheckBox)findViewById(R.id.checkbox_sit_fa);
        checkboxProf = (CheckBox)findViewById(R.id.checkbox_sit_prof);
        checkboxAgenc  = (CheckBox)findViewById(R.id.checkbox_agence);

        //Linerlayout

        ly_id  = (LinearLayout)findViewById(R.id.ly_ident);
        ly_res  = (LinearLayout)findViewById(R.id.ly_res);
        ly_sit_fa  = (LinearLayout)findViewById(R.id.ly_sit_fa);
        ly_sit_prof  = (LinearLayout)findViewById(R.id.ly_sit_prof);
        ly_agenc  = (LinearLayout)findViewById(R.id.ly_agence);

        ///traitement is checked show layout
        toggelCheckBox();
    }


    private void toggelCheckBox() {
        checkboxId.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    ly_id.setVisibility(View.VISIBLE);
                }else {
                    ly_id.setVisibility(View.GONE);
                }
            }
        });
        checkboxRes.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    ly_res.setVisibility(View.VISIBLE);
                }else {
                    ly_res.setVisibility(View.GONE);
                }
            }
        });
        checkboxFa.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    ly_sit_fa.setVisibility(View.VISIBLE);
                }else {
                    ly_sit_fa.setVisibility(View.GONE);
                }
            }
        });
        checkboxProf.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    ly_sit_prof.setVisibility(View.VISIBLE);
                }else {
                    ly_sit_prof.setVisibility(View.GONE);
                }
            }
        });
        checkboxAgenc.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    ly_agenc.setVisibility(View.VISIBLE);
                }else {
                    ly_agenc.setVisibility(View.GONE);
                }
            }
        });
    }
}