first test with https://github.com/profelis/bindx2
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
<haxelib name="svg" />
|
<haxelib name="svg" />
|
||||||
<haxelib name="haxe-strings" />
|
<haxelib name="haxe-strings" />
|
||||||
<haxelib name="fuzzaldrin" />
|
<haxelib name="fuzzaldrin" />
|
||||||
|
<haxelib name="bindx2" />
|
||||||
|
|
||||||
<icon path="assets/icons/app_icon.svg"/>
|
<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.setIconForState(ButtonState.DOWN, SVGIconFactory.makeIcon("vector/check_icon_black.svg", Constants.BUTTONS_ICON_SIZE, Constants.HERO_COLOR));
|
||||||
b2.addEventListener(TriggerEvent.TRIGGER, (e) -> {
|
b2.addEventListener(TriggerEvent.TRIGGER, (e) -> {
|
||||||
confirmFunction();
|
confirmFunction();
|
||||||
|
PopUpManager.removePopUp(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
// footer
|
// footer
|
||||||
|
|||||||
+29
-25
@@ -1,5 +1,7 @@
|
|||||||
package view;
|
package view;
|
||||||
|
|
||||||
|
import haxe.macro.Expr;
|
||||||
|
import bindx.Bind;
|
||||||
import openfl.utils.Function;
|
import openfl.utils.Function;
|
||||||
import feathers.core.PopUpManager;
|
import feathers.core.PopUpManager;
|
||||||
import components.VSpacer;
|
import components.VSpacer;
|
||||||
@@ -65,7 +67,7 @@ class RiderCardDrawer extends Drawer {
|
|||||||
|
|
||||||
var mainVerticalLayout = new VerticalLayout();
|
var mainVerticalLayout = new VerticalLayout();
|
||||||
mainVerticalLayout.paddingLeft = mainVerticalLayout.paddingRight = Constants.GLOBAL_PADDING;
|
mainVerticalLayout.paddingLeft = mainVerticalLayout.paddingRight = Constants.GLOBAL_PADDING;
|
||||||
//mainVerticalLayout.gap = Constants.GLOBAL_PADDING;
|
// mainVerticalLayout.gap = Constants.GLOBAL_PADDING;
|
||||||
mainVerticalLayout.horizontalAlign = JUSTIFY;
|
mainVerticalLayout.horizontalAlign = JUSTIFY;
|
||||||
mainVerticalLayout.verticalAlign = TOP;
|
mainVerticalLayout.verticalAlign = TOP;
|
||||||
mainScrollContainer.layout = mainVerticalLayout;
|
mainScrollContainer.layout = mainVerticalLayout;
|
||||||
@@ -86,7 +88,7 @@ class RiderCardDrawer extends Drawer {
|
|||||||
|
|
||||||
// profile picture
|
// profile picture
|
||||||
ppal = new AssetLoader();
|
ppal = new AssetLoader();
|
||||||
ppal.addEventListener(Event.COMPLETE, onPPLoaded);
|
// ppal.addEventListener(Event.COMPLETE, (e:Event) -> cast(e.currentTarget, AssetLoader).validateNow());
|
||||||
mainScrollContainer.addChild(ppal);
|
mainScrollContainer.addChild(ppal);
|
||||||
|
|
||||||
// ##### SPACER
|
// ##### SPACER
|
||||||
@@ -145,9 +147,10 @@ class RiderCardDrawer extends Drawer {
|
|||||||
removeOneCredit.addEventListener(TriggerEvent.TRIGGER, (e) -> {
|
removeOneCredit.addEventListener(TriggerEvent.TRIGGER, (e) -> {
|
||||||
traceRed("removeOneCredit()");
|
traceRed("removeOneCredit()");
|
||||||
// this function will be exectuted when the user will click on the ConfirmationPanel's "confirm" button
|
// this function will be exectuted when the user will click on the ConfirmationPanel's "confirm" button
|
||||||
var f:Function = function () {
|
var f:Function = function() {
|
||||||
trace("remove 1 credit to selected rider in model");
|
trace("remove 1 credit to selected rider in model");
|
||||||
// TODO 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);
|
PopUpManager.addPopUp(new ConfirmationPanel(Strings.CP_S2, Strings.CP_S3, f), parent, true, true);
|
||||||
});
|
});
|
||||||
@@ -155,7 +158,7 @@ class RiderCardDrawer extends Drawer {
|
|||||||
|
|
||||||
// ##### SPACER
|
// ##### SPACER
|
||||||
mainScrollContainer.addChild(new VSpacer(10));
|
mainScrollContainer.addChild(new VSpacer(10));
|
||||||
//mainScrollContainer.addChild(new VSpacer(2, Constants.MAIN_COLOR2, 1));
|
// mainScrollContainer.addChild(new VSpacer(2, Constants.MAIN_COLOR2, 1));
|
||||||
|
|
||||||
drawer = mainScrollContainer;
|
drawer = mainScrollContainer;
|
||||||
}
|
}
|
||||||
@@ -165,13 +168,13 @@ class RiderCardDrawer extends Drawer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function populateAndShow() {
|
public function populateAndShow() {
|
||||||
var rvo:RiderVO = model.selectedRider;
|
// var rvo:RiderVO = model.selectedRider;
|
||||||
|
|
||||||
// profile picture
|
// 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
|
// first name text input
|
||||||
firstNameLabel.text = rvo.firstName;
|
firstNameLabel.text = model.selectedRider.firstName;
|
||||||
if (!firstNameLabel.hasEventListener(Event.CHANGE)) {
|
if (!firstNameLabel.hasEventListener(Event.CHANGE)) {
|
||||||
firstNameLabel.addEventListener(Event.CHANGE, (e) -> {
|
firstNameLabel.addEventListener(Event.CHANGE, (e) -> {
|
||||||
if (firstNameLabel.text != model.selectedRider.firstName) {
|
if (firstNameLabel.text != model.selectedRider.firstName) {
|
||||||
@@ -181,7 +184,7 @@ class RiderCardDrawer extends Drawer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// name text input
|
// name text input
|
||||||
nameLabel.text = rvo.name;
|
nameLabel.text = model.selectedRider.name;
|
||||||
if (!nameLabel.hasEventListener(Event.CHANGE)) {
|
if (!nameLabel.hasEventListener(Event.CHANGE)) {
|
||||||
nameLabel.addEventListener(Event.CHANGE, (e) -> {
|
nameLabel.addEventListener(Event.CHANGE, (e) -> {
|
||||||
if (nameLabel.text != model.selectedRider.name) {
|
if (nameLabel.text != model.selectedRider.name) {
|
||||||
@@ -190,27 +193,28 @@ class RiderCardDrawer extends Drawer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// remaing credit text
|
// remaining credit label & progress bar
|
||||||
creditLabel.text = Strings.RCD_S1 + Std.string(rvo.credit);
|
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();
|
openDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function onPPLoaded(e:Event):Void {
|
// update remaining credit label and progress bar
|
||||||
var rvo:RiderVO = model.selectedRider;
|
private function updateCreditUIElments(pFromValue:Dynamic, pToValue:Dynamic) {
|
||||||
var al:AssetLoader = cast(e.currentTarget, AssetLoader);
|
|
||||||
al.validateNow();
|
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;
|
package vo;
|
||||||
|
import bindx.IBindable;
|
||||||
|
|
||||||
class RiderVO {
|
@:bindable
|
||||||
|
class RiderVO implements IBindable {
|
||||||
|
|
||||||
// constants for use with Reflect api when updating SelectedRider VO
|
// constants for use with Reflect api when updating SelectedRider VO
|
||||||
public static final ID:String = "id";
|
public static final ID:String = "id";
|
||||||
|
|||||||
Reference in New Issue
Block a user