package view;

import model.String.Strings;
import ui.SVGIconFactory;
import ui.LPTCTheme;
import feathers.controls.TextInput;
import feathers.layout.HorizontalLayoutData;
import feathers.controls.Label;
import feathers.controls.LayoutGroup;
import feathers.events.FeathersEvent;
import feathers.layout.HorizontalLayout;
import feathers.skins.RectangleSkin;
import feathers.text.TextFormat;
import model.Constants;
import openfl.Assets;
import openfl.text.Font;
import t9.util.ColorTraces.*;

class ToolBar extends LayoutGroup {

    private var searchTextInput:TextInput;

	public function new() {
		super();

		addEventListener(FeathersEvent.CREATION_COMPLETE, onCreationComplete);
	}

	override private function initialize():Void {
		super.initialize();

        final sw:Int = stage.stageWidth;
        final sh:Int = stage.stageHeight;
        final headerWidth = Std.int(sw * Constants.MAIN_HEADER_WIDTH_RATIO);
        final headerHeight = Std.int(sh * Constants.MAIN_HEADER_HEIGHT_RATIO);

		autoSizeMode = CONTENT;
		backgroundSkin = new RectangleSkin(SolidColor(Constants.ACCENT_COLOR2, 1));

        // Layout settings
		var hl:HorizontalLayout = new HorizontalLayout();
		hl.setPadding(10);
		hl.verticalAlign = MIDDLE;
        layout = hl;

		//search field
        searchTextInput = new TextInput();
		var ld1 = new HorizontalLayoutData();
		ld1.percentWidth = 100.0;
		searchTextInput.layoutData = ld1;
		searchTextInput.variant = LPTCTheme.TEXT_INPUT_VARIANT_SEARCH;
		searchTextInput.leftView = SVGIconFactory.makeIcon("vector/magnifier_icon_black.svg", Constants.FONT_SIZE_22, Constants.MAIN_COLOR3);
		searchTextInput.prompt = Strings.TB_S1;
		addChild(searchTextInput);
		
		//lbl1.layoutData = ld1;
        //lb1.backgroundSkin = new RectangleSkin(SolidColor(Constants.ACCENT_COLOR2, 1));
	}

	private function onCreationComplete(event:FeathersEvent):Void {
		traceBlue(this + " --> onCreationComplete() - w: " + width + " h: " + height );
	}

}