package com.example.blu.toys.activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.SeekBar;
import android.widget.Switch;

import com.example.blu.toys.R;
import com.example.blu.toys.utils.SpUtils;
import com.example.blu.toys.view.TypefaceTextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

//设置
public class SelectTimerActivity extends BaseActivity {


	@BindView(R.id.back_but)
	TypefaceTextView backBut;
	@BindView(R.id.will)
	TypefaceTextView will;
	@BindView(R.id.alarm_switch)
	Switch alarmSwitch;
	@BindView(R.id.music_switch)
	Switch musicSwitch;
	@BindView(R.id.green_switch)
	Switch greenSwitch;
	@BindView(R.id.brightness_bar)
	SeekBar brightnessBar;

	@Override
	public int getLayout() {
		return R.layout.activity_select_timer;
	}

	@Override
	public void init(Bundle savedInstanceState) {

		SpUtils spUtils = SpUtils.getSpUtils(this);
//		spUtils.putSPValue("close", 1);
//		spUtils.putSPValue("open", 10);
		spUtils.putSPValue("brightness", 50);

		alarmSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
			if (isChecked) {
				spUtils.putSPValue("alarm", 1);
			} else {
				spUtils.putSPValue("alarm", 0);
			}
		});

		musicSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
			startActivity(new Intent(SelectTimerActivity.this, MusicActivity.class));
		});

		greenSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
			if (isChecked) {
				spUtils.putSPValue("green", 1);
			} else {
				spUtils.putSPValue("green", 0);
			}
		});

		brightnessBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
			@Override
			public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
				spUtils.putSPValue("brightness", progress);
			}

			@Override
			public void onStartTrackingTouch(SeekBar seekBar) {

			}

			@Override
			public void onStopTrackingTouch(SeekBar seekBar) {

			}
		});


	}

	@Override
	public void initData() {

	}


	@OnClick(R.id.back_but)
	public void onViewClicked() {
		Intent intent = new Intent(SelectTimerActivity.this, SelectDeviceActivity.class);

		startActivity(intent);
	}
}