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

import com.imyeyu.fx.ui.TimiFXUI;
import com.imyeyu.fx.ui.components.TextAreaEditor;
import com.imyeyu.fx.ui.components.TextAreaEditorField;
import com.imyeyu.fx.ui.examples.component.AbstractDemoPane;
import com.imyeyu.fx.ui.examples.component.sidebar.SidebarItem;
import com.imyeyu.fx.utils.grid.Column;
import com.imyeyu.inject.annotation.Component;
import javafx.geometry.Insets;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;

/**
 * 文本编辑器
 *
 * @author 夜雨
 * @since 2022-08-30 09:32
 */
@Component
public class TextAreaEditorDemo extends AbstractDemoPane {

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

		Label labelField = TimiFXUI.label(TimiFXUI.MULTILINGUAL.text("fx.example.text_area_editor.field"));
		TextAreaEditorField field = new TextAreaEditorField();
		field.setTitle("TextAreaEditorField");

		TextAreaEditor editor = new TextAreaEditor();
		editor.setBorder(Stroke.LEFT);

		setCenter(new BorderPane() {{
			setBorder(Stroke.TOP);
			setLeft(new BorderPane() {{
				setPadding(new Insets(12, 20, 12, 20));
				setTop(new GridPane() {{
					getColumnConstraints().addAll(Column.key(), Column.valueFill());
					setVgap(8);
					setHgap(10);

					int row = 0;
					addRow(row++, TimiFXUI.label(TimiFXUI.MULTILINGUAL.text("fx.example.text_area_editor.key_tips.ctrl_shift_enter")), new Label("Ctrl + Shift + ENTER"));
					addRow(row++, TimiFXUI.label(TimiFXUI.MULTILINGUAL.text("fx.example.text_area_editor.key_tips.shift_enter")), new Label("Shift + ENTER"));
					addRow(row++, TimiFXUI.label(TimiFXUI.MULTILINGUAL.text("fx.example.text_area_editor.key_tips.ctrl_shift_u")), new Label("Ctrl + Shift + U"));
					addRow(row++, TimiFXUI.label(TimiFXUI.MULTILINGUAL.text("fx.example.text_area_editor.key_tips.ctrl_f")), new Label("Ctrl + F"));
					addRow(row, TimiFXUI.label(TimiFXUI.MULTILINGUAL.text("fx.example.text_area_editor.key_tips.ctrl_d")), new Label("Ctrl + D"));
				}});
				setCenter(new VBox() {{
					setPadding(new Insets(24, 0, 0, 0));
					setSpacing(6);
					getChildren().addAll(labelField, field);
				}});
			}});
			setCenter(editor);
		}});
	}
}
