first test with https://github.com/profelis/bindx2
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
<haxelib name="svg" />
|
||||
<haxelib name="haxe-strings" />
|
||||
<haxelib name="fuzzaldrin" />
|
||||
<haxelib name="bindx2" />
|
||||
|
||||
<icon path="assets/icons/app_icon.svg"/>
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ class ConfirmationPanel extends Panel {
|
||||
b2.setIconForState(ButtonState.DOWN, SVGIconFactory.makeIcon("vector/check_icon_black.svg", Constants.BUTTONS_ICON_SIZE, Constants.HERO_COLOR));
|
||||
b2.addEventListener(TriggerEvent.TRIGGER, (e) -> {
|
||||
confirmFunction();
|
||||
PopUpManager.removePopUp(this);
|
||||
});
|
||||
|
||||
// footer
|
||||
|
||||
+26
-22
@@ -1,5 +1,7 @@
|
||||
package view;
|
||||
|
||||
import haxe.macro.Expr;
|
||||
import bindx.Bind;
|
||||
import openfl.utils.Function;
|
||||
import feathers.core.PopUpManager;
|
||||
import components.VSpacer;
|
||||
@@ -86,7 +88,7 @@ class RiderCardDrawer extends Drawer {
|
||||
|
||||
// profile picture
|
||||
ppal = new AssetLoader();
|
||||
ppal.addEventListener(Event.COMPLETE, onPPLoaded);
|
||||
// ppal.addEventListener(Event.COMPLETE, (e:Event) -> cast(e.currentTarget, AssetLoader).validateNow());
|
||||
mainScrollContainer.addChild(ppal);
|
||||
|
||||
// ##### SPACER
|
||||
@@ -148,6 +150,7 @@ class RiderCardDrawer extends Drawer {
|
||||
var f:Function = function() {
|
||||
trace("remove 1 credit to selected rider in model");
|
||||
// TODO remove 1 credit to selected rider in model
|
||||
model.selectedRider.credit--;
|
||||
}
|
||||
PopUpManager.addPopUp(new ConfirmationPanel(Strings.CP_S2, Strings.CP_S3, f), parent, true, true);
|
||||
});
|
||||
@@ -165,13 +168,13 @@ class RiderCardDrawer extends Drawer {
|
||||
}
|
||||
|
||||
public function populateAndShow() {
|
||||
var rvo:RiderVO = model.selectedRider;
|
||||
// var rvo:RiderVO = model.selectedRider;
|
||||
|
||||
// profile picture
|
||||
ppal.source = Constants.PROFIL_PICTURES_PATH_512 + rvo.uid + ".jpg";
|
||||
ppal.source = Constants.PROFIL_PICTURES_PATH_512 + model.selectedRider.uid + ".jpg";
|
||||
|
||||
// first name text input
|
||||
firstNameLabel.text = rvo.firstName;
|
||||
firstNameLabel.text = model.selectedRider.firstName;
|
||||
if (!firstNameLabel.hasEventListener(Event.CHANGE)) {
|
||||
firstNameLabel.addEventListener(Event.CHANGE, (e) -> {
|
||||
if (firstNameLabel.text != model.selectedRider.firstName) {
|
||||
@@ -181,7 +184,7 @@ class RiderCardDrawer extends Drawer {
|
||||
}
|
||||
|
||||
// name text input
|
||||
nameLabel.text = rvo.name;
|
||||
nameLabel.text = model.selectedRider.name;
|
||||
if (!nameLabel.hasEventListener(Event.CHANGE)) {
|
||||
nameLabel.addEventListener(Event.CHANGE, (e) -> {
|
||||
if (nameLabel.text != model.selectedRider.name) {
|
||||
@@ -190,27 +193,28 @@ class RiderCardDrawer extends Drawer {
|
||||
});
|
||||
}
|
||||
|
||||
// remaing credit text
|
||||
creditLabel.text = Strings.RCD_S1 + Std.string(rvo.credit);
|
||||
// remaining credit label & progress bar
|
||||
updateCreditUIElments(null, model.selectedRider.credit);
|
||||
Bind.bind(model.selectedRider.credit, updateCreditUIElments);
|
||||
|
||||
// remaining credit progress bar
|
||||
if (rvo.credit <= Constants.CREDIT_ULTRA_LOW_LIMIT) {
|
||||
creditProgressBar.variant = LPTCTheme.H_PROGRESS_BAR_VARIANT_ALARM;
|
||||
} else if (rvo.credit <= Constants.CREDIT_LOW_LIMIT) {
|
||||
creditProgressBar.variant = LPTCTheme.H_PROGRESS_BAR_VARIANT_ALERT;
|
||||
} else if (rvo.credit <= Constants.CREDIT_AVERAGE_LIMIT) {
|
||||
creditProgressBar.variant = LPTCTheme.H_PROGRESS_BAR_VARIANT_WARNING;
|
||||
} else {
|
||||
creditProgressBar.variant = LPTCTheme.H_PROGRESS_BAR_VARIANT_INFO;
|
||||
}
|
||||
creditProgressBar.value = rvo.credit;
|
||||
|
||||
openDrawer();
|
||||
}
|
||||
|
||||
private function onPPLoaded(e:Event):Void {
|
||||
var rvo:RiderVO = model.selectedRider;
|
||||
var al:AssetLoader = cast(e.currentTarget, AssetLoader);
|
||||
al.validateNow();
|
||||
// update remaining credit label and progress bar
|
||||
private function updateCreditUIElments(pFromValue:Dynamic, pToValue:Dynamic) {
|
||||
|
||||
creditLabel.text = Strings.RCD_S1 + Std.string(pToValue);
|
||||
|
||||
if (pToValue <= Constants.CREDIT_ULTRA_LOW_LIMIT) {
|
||||
creditProgressBar.variant = LPTCTheme.H_PROGRESS_BAR_VARIANT_ALARM;
|
||||
} else if (pToValue <= Constants.CREDIT_LOW_LIMIT) {
|
||||
creditProgressBar.variant = LPTCTheme.H_PROGRESS_BAR_VARIANT_ALERT;
|
||||
} else if (pToValue <= Constants.CREDIT_AVERAGE_LIMIT) {
|
||||
creditProgressBar.variant = LPTCTheme.H_PROGRESS_BAR_VARIANT_WARNING;
|
||||
} else {
|
||||
creditProgressBar.variant = LPTCTheme.H_PROGRESS_BAR_VARIANT_INFO;
|
||||
}
|
||||
creditProgressBar.value = pToValue;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,6 +1,8 @@
|
||||
package vo;
|
||||
import bindx.IBindable;
|
||||
|
||||
class RiderVO {
|
||||
@:bindable
|
||||
class RiderVO implements IBindable {
|
||||
|
||||
// constants for use with Reflect api when updating SelectedRider VO
|
||||
public static final ID:String = "id";
|
||||
|
||||
Reference in New Issue
Block a user