package com.imyeyu.fx.ui.examples.view.pages.component;

import com.imyeyu.fx.icon.TimiFXIcon;
import com.imyeyu.fx.icon.TimiIcon;
import com.imyeyu.fx.ui.TimiFXUI;
import com.imyeyu.fx.ui.components.ToggleIcon;
import com.imyeyu.fx.ui.examples.component.AbstractDemoPane;
import com.imyeyu.fx.ui.examples.component.sidebar.SidebarItem;
import com.imyeyu.inject.annotation.Component;
import javafx.geometry.Insets;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;

/**
 * 切换图标
 *
 * @author 夜雨
 * @since 2022-08-30 09:34
 */
@Component
public class ToggleIconDemo extends AbstractDemoPane {

	public ToggleIconDemo() {
		title.setText(SidebarItem.TOGGLE_ICON.getText());
		document.sync("https://doc.imyeyu.net/timi-fx/net/imyeyu/timifx/component/ToggleIcon.html");
		source.sync("https://git.imyeyu.net/Timi/timi-fx/src/master/src/main/java/net/imyeyu/timifx/component/ToggleIcon.java");
		tips.setText(TimiFXUI.MULTILINGUAL.text("fx.example.toggle_icon.tips"));

		// 默认
		Label labelDef = TimiFXUI.label(TimiFXUI.MULTILINGUAL.text("default"));
		ToggleIcon def = new ToggleIcon(TimiFXIcon.get(TimiIcon.ARROW_0_W));

		// 跟随状态变换
		Label labelDiff = TimiFXUI.label(TimiFXUI.MULTILINGUAL.text("fx.example.toggle_icon.diff"));
		ToggleIcon diff = new ToggleIcon(TimiFXIcon.get(TimiIcon.ARROW_0_W), TimiFXIcon.get(TimiIcon.ARROW_0_E));

		// 按钮背景
		Label labelWithBG = TimiFXUI.label(TimiFXUI.MULTILINGUAL.text("fx.example.toggle_icon.with_bg"));
		ToggleIcon withBG = new ToggleIcon(TimiFXIcon.get(TimiIcon.ARROW_0_W)).withBackground();
		withBG.setBorder(Stroke.DEFAULT);
		ToggleIcon withBGDiff = new ToggleIcon(TimiFXIcon.get(TimiIcon.ARROW_0_W), TimiFXIcon.get(TimiIcon.ARROW_0_E)).withBackground();
		withBGDiff.setBorder(Stroke.DEFAULT);

		setCenter(new GridPane() {{
			setHgap(5);
			setVgap(5);
			setPadding(new Insets(20));

			int row = 0;
			addRow(row++, labelDef, def);
			addRow(row++, labelDiff, diff);
			addRow(row, labelWithBG, withBG, withBGDiff);
		}});
	}
}
