TODO : set temporary rider in AppModelLocator when RiderList item is clicked
This commit is contained in:
@@ -13,7 +13,6 @@ class AppController extends FrontController {
|
|||||||
public static final CLOSE_DRAWER_EVENT = "closeDrawerEvent";
|
public static final CLOSE_DRAWER_EVENT = "closeDrawerEvent";
|
||||||
public static final RIDER_SELECT_EVENT = "riderSelect";
|
public static final RIDER_SELECT_EVENT = "riderSelect";
|
||||||
|
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super();
|
super();
|
||||||
addCommand(AppController.LOAD_RIDERS_EVENT, LoadRidersCommand);
|
addCommand(AppController.LOAD_RIDERS_EVENT, LoadRidersCommand);
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package control;
|
||||||
|
|
||||||
|
import com.adobe.cairngorm.control.CairngormEvent;
|
||||||
|
import vo.RiderVO;
|
||||||
|
|
||||||
|
class RiderSelecEvent extends CairngormEvent {
|
||||||
|
public var selectedItem:RiderVO;
|
||||||
|
|
||||||
|
public function new(selectedItem:RiderVO) {
|
||||||
|
super(AppController.RIDER_SELECT_EVENT);
|
||||||
|
this.selectedItem = selectedItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,26 +44,16 @@ class AppModelLocator extends EventDispatcher implements IModelLocator {
|
|||||||
return drawerIsOpen;
|
return drawerIsOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
// selected rider
|
// temporary holding space for rider we're creating or editing
|
||||||
|
// this gets copied into or added onto the main rider list
|
||||||
public var selectedRider(default, set):RiderVO = null;
|
public var selectedRider(default, set):RiderVO = null;
|
||||||
|
|
||||||
private function set_selectedRider(pRider:RiderVO):RiderVO {
|
private function set_selectedRider(pRider:RiderVO):RiderVO {
|
||||||
selectedRider = pRider;
|
selectedRider = pRider;
|
||||||
dispatchEvent(new Event(AppModelLocator.DRAWER_STATE_CHANGE));
|
dispatchEvent(new Event(AppModelLocator.RIDER_SELECT));
|
||||||
return selectedRider;
|
return selectedRider;
|
||||||
}
|
}
|
||||||
|
|
||||||
// rider object contains uid/passwd
|
|
||||||
// its value gets set at login and cleared at logout but nothing binds to it or uses it
|
|
||||||
// retained since it was used in the original Adobe CafeTownsend example app
|
|
||||||
/*public var user(default, set):User;
|
|
||||||
|
|
||||||
private function set_user(value:User):User {
|
|
||||||
user = value;
|
|
||||||
dispatchEvent(new Event(USER_CHANGE));
|
|
||||||
return user;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// contains the main riders list which is populated on startup
|
// contains the main riders list which is populated on startup
|
||||||
// mx:application's creationComplete event is mutated into a cairngorm event
|
// mx:application's creationComplete event is mutated into a cairngorm event
|
||||||
// that calls the httpservice for the data
|
// that calls the httpservice for the data
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ class Constants {
|
|||||||
public static final BUTTON_DOWN_COLOR:Int = 0x69808A;
|
public static final BUTTON_DOWN_COLOR:Int = 0x69808A;
|
||||||
public static final BUTTON_INVERTED_UP_COLOR:Int = 0xECEFF0;
|
public static final BUTTON_INVERTED_UP_COLOR:Int = 0xECEFF0;
|
||||||
|
|
||||||
|
public static final LIST_SEPARATOR_COLOR:Int = 0xE1E3E4;
|
||||||
|
|
||||||
// Fonts
|
// Fonts
|
||||||
public static final MONTSERRAT_LIGHT_300:String = "MontserratLight300";
|
public static final MONTSERRAT_LIGHT_300:String = "MontserratLight300";
|
||||||
public static final MONTSERRAT_REGULAR_400:String = "MontserratRegular400";
|
public static final MONTSERRAT_REGULAR_400:String = "MontserratRegular400";
|
||||||
|
|||||||
+19
-5
@@ -1,5 +1,9 @@
|
|||||||
package view;
|
package view;
|
||||||
|
|
||||||
|
import control.RiderSelecEvent;
|
||||||
|
import feathers.events.ListViewEvent;
|
||||||
|
import feathers.events.TriggerEvent;
|
||||||
|
import feathers.skins.RectangleSkin;
|
||||||
import com.adobe.cairngorm.control.CairngormEventDispatcher;
|
import com.adobe.cairngorm.control.CairngormEventDispatcher;
|
||||||
import control.AppController;
|
import control.AppController;
|
||||||
import com.adobe.cairngorm.control.CairngormEvent;
|
import com.adobe.cairngorm.control.CairngormEvent;
|
||||||
@@ -26,7 +30,8 @@ class RidersList extends ListView {
|
|||||||
public function new() {
|
public function new() {
|
||||||
super();
|
super();
|
||||||
addEventListener(FeathersEvent.CREATION_COMPLETE, onCreationComplete);
|
addEventListener(FeathersEvent.CREATION_COMPLETE, onCreationComplete);
|
||||||
addEventListener(Event.CHANGE, onRiderSelect);
|
//addEventListener(Event.CHANGE, onRiderSelect);
|
||||||
|
addEventListener(ListViewEvent.ITEM_TRIGGER, onRiderSelect);
|
||||||
}
|
}
|
||||||
|
|
||||||
override private function initialize():Void {
|
override private function initialize():Void {
|
||||||
@@ -45,7 +50,14 @@ class RidersList extends ListView {
|
|||||||
itemRenderer.textFormat = new TextFormat(fnt1.fontName, Std.int(rowHeight * 0.27), Constants.MAIN_COLOR1);
|
itemRenderer.textFormat = new TextFormat(fnt1.fontName, Std.int(rowHeight * 0.27), Constants.MAIN_COLOR1);
|
||||||
itemRenderer.secondaryTextFormat = new TextFormat(fnt2.fontName, Std.int(rowHeight * 0.2), Constants.MAIN_COLOR2);
|
itemRenderer.secondaryTextFormat = new TextFormat(fnt2.fontName, Std.int(rowHeight * 0.2), Constants.MAIN_COLOR2);
|
||||||
|
|
||||||
|
var rs1 = new RectangleSkin(SolidColor(Constants.MAIN_COLOR3, 1), SolidColor(1, Constants.LIST_SEPARATOR_COLOR));
|
||||||
|
var rs2 = new RectangleSkin(SolidColor(Constants.LIST_SEPARATOR_COLOR, 1), SolidColor(1, Constants.LIST_SEPARATOR_COLOR));
|
||||||
|
itemRenderer.backgroundSkin = rs1;
|
||||||
|
//itemRenderer.selectedBackgroundSkin = rs2;
|
||||||
|
itemRenderer.setSkinForState(ToggleButtonState.DOWN(false), rs2);
|
||||||
|
|
||||||
return itemRenderer;
|
return itemRenderer;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
itemRendererRecycler = recycler;
|
itemRendererRecycler = recycler;
|
||||||
@@ -86,10 +98,12 @@ class RidersList extends ListView {
|
|||||||
traceGreen(this + " --> onRideListDpChange() - w: " + width + " h: " + height);
|
traceGreen(this + " --> onRideListDpChange() - w: " + width + " h: " + height);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onRiderSelect(e:Event):Void {
|
function onRiderSelect(e:ListViewEvent):Void {
|
||||||
var riderVO:RiderVO = cast(selectedItem, RiderVO);
|
|
||||||
var ce:CairngormEvent = new CairngormEvent(AppController.RIDER_SELECT_EVENT);
|
// broadcast a cairngorm event that contains the selectedItem from the List
|
||||||
CairngormEventDispatcher.getInstance().dispatchEvent(ce); //TODO how to pass the selected user to AppModelLocator ?
|
var riderVO:RiderVO = cast(e.state.data, RiderVO);
|
||||||
|
var rse:RiderSelecEvent = new RiderSelecEvent(riderVO);
|
||||||
|
CairngormEventDispatcher.getInstance().dispatchEvent(rse);
|
||||||
//trace(riderVO.firstName);
|
//trace(riderVO.firstName);
|
||||||
//clearSelectedRider();
|
//clearSelectedRider();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user