58 lines
1.3 KiB
Haxe
Executable File
58 lines
1.3 KiB
Haxe
Executable File
package haxework.gui.popup;
|
|
|
|
import haxework.net.callback.Callback;
|
|
import haxework.net.callback.ICallback;
|
|
import haxe.Timer;
|
|
import haxework.provider.Provider;
|
|
import haxework.dispath.Dispatcher;
|
|
import haxework.dispath.IDispatcher;
|
|
import haxework.gui.IGroupView;
|
|
import haxework.gui.ButtonView;
|
|
import haxework.gui.skin.ColorSkin;
|
|
import haxework.gui.GroupView;
|
|
|
|
class PopupView<V:IView> extends GroupView {
|
|
|
|
private var buttonId:String;
|
|
private var contentView:V;
|
|
private var callback:ICallback<String>;
|
|
|
|
public function new(contentViewFactory:Class<V>) {
|
|
super();
|
|
|
|
pWidth = 100;
|
|
pHeight = 100;
|
|
inLayout = false;
|
|
skin = new ColorSkin(0x000000, 0.6);
|
|
|
|
this.contentView = Type.createInstance(contentViewFactory, [{listener:this}]);
|
|
addView(contentView);
|
|
}
|
|
|
|
public function onPress(button:ButtonView) {
|
|
this.buttonId = button.id;
|
|
close();
|
|
}
|
|
|
|
public function show():ICallback<String> {
|
|
Provider.get(PopupManager).show(this);
|
|
callback = Callback.build();
|
|
return callback;
|
|
}
|
|
|
|
public function close():Void {
|
|
Provider.get(PopupManager).close(this);
|
|
}
|
|
|
|
public function onShow():Void {
|
|
buttonId = "close";
|
|
}
|
|
|
|
public function onClose():Void {
|
|
if (callback != null) {
|
|
callback.callSuccess(buttonId);
|
|
callback = null;
|
|
}
|
|
}
|
|
}
|