Files
puzzlez/src/haxe/ru/m/puzzlez/view/StartFrame.hx
2020-02-04 21:34:18 +03:00

40 lines
1.4 KiB
Haxe

package ru.m.puzzlez.view;
import haxework.view.data.DataView;
import haxework.view.form.ButtonView;
import haxework.view.frame.FrameSwitcher;
import haxework.view.frame.FrameView;
import ru.m.puzzlez.source.AssetSource;
import ru.m.puzzlez.source.FileSource;
import ru.m.puzzlez.storage.ImageStorage;
import ru.m.puzzlez.source.PixabaySource;
@:template class StartFrame extends FrameView<Dynamic> {
public static var ID = "start";
@:view var sources:DataView<ImageListSource<Dynamic>, ButtonView>;
@:provide var storage:ImageStorage;
@:provide var switcher:FrameSwitcher;
public function new() {
super(ID);
var data:Array<ImageListSource<Dynamic>> = [];
data.push({source: storage.sources.get(AssetSource.ID), type: "asset"});
data.push({source: storage.sources.get(FileSource.ID), type: "file"});
for (type in AbstractEnumTools.getValues(PixabayCategory)) {
data.push({source: storage.sources.get(PixabaySource.ID), type: type});
}
sources.data = data;
}
private function sourceViewFactory(index:Int, source:ImageListSource<Dynamic>):ButtonView {
var result = new ButtonView();
result.text = Std.string(source.type != null ? source.type : "custom");
return result;
}
private function load(source:ImageListSource<Dynamic>):Void {
switcher.change(ImageListFrame.ID, source);
}
}