package view;

import feathers.controls.Panel;
import feathers.controls.navigators.StackItem;
import feathers.controls.navigators.StackNavigator;
import feathers.events.FeathersEvent;
import feathers.layout.AnchorLayout;
import feathers.layout.AnchorLayoutData;
import feathers.skins.RectangleSkin;
import model.Constants;
import t9.util.ColorTraces.*;

class MainPanel extends Panel {

	private var mh:MainHeader;
	private var mf:MainFooter;
	private var sn:StackNavigator;
	private var rcd:RiderCardDrawer;

	public function new() {
		super();

		addEventListener(FeathersEvent.CREATION_COMPLETE, onCreationComplete);
	}

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

		autoSizeMode = STAGE;
		backgroundSkin = new RectangleSkin(SolidColor(Constants.MAIN_COLOR2, 1));

		layout = new AnchorLayout();

		mh = new MainHeader();
		header = mh;

		mf = new MainFooter();
		footer = mf;

		sn = new StackNavigator();
		//sn.autoSizeMode = STAGE;
		sn.layoutData = AnchorLayoutData.fill();
		sn.addItem(StackItem.withClass("ridersScreen", RidersScreen));
		sn.rootItemID = "ridersScreen";
		addChild(sn);

		rcd = new RiderCardDrawer();
		addChild(rcd);

	}

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