8b8f0b9712
- removed NekoDrawerEvent Button related refactoring : - removed NekoIconButton
88 lines
2.8 KiB
Haxe
88 lines
2.8 KiB
Haxe
package model;
|
|
|
|
import vo.Rider;
|
|
import feathers.data.ArrayCollection;
|
|
import openfl.errors.Error;
|
|
import openfl.events.Event;
|
|
import com.adobe.cairngorm.model.IModelLocator;
|
|
import openfl.events.EventDispatcher;
|
|
import t9.util.ColorTraces.*;
|
|
|
|
class AppModelLocator extends EventDispatcher implements IModelLocator {
|
|
|
|
// events constants
|
|
public static final VIEWING_CHANGE:String = "viewingChange";
|
|
public static final RIDERS_LIST_DP_CHANGE:String = "ridersListDPChange";
|
|
public static final DRAWER_STATE_CHANGE:String = "drawerStateChange";
|
|
|
|
|
|
// this instance stores a static reference to itself
|
|
private static var model:AppModelLocator;
|
|
|
|
// available values for the main viewstack defined as constants to help uncover errors at compile time instead of run time
|
|
// Navigator
|
|
public static final ADMIN_LOGIN = 0;
|
|
public static final RIDERS_LIST = 1;
|
|
public static final RIDER_DETAIL = 2;
|
|
|
|
// viewstack starts out on the admin login screen
|
|
public var viewing(default, set):Int = ADMIN_LOGIN;
|
|
|
|
private function set_viewing(value:Int):Int {
|
|
viewing = value;
|
|
dispatchEvent(new Event(VIEWING_CHANGE));
|
|
return viewing;
|
|
}
|
|
|
|
// at startup, the drawer is closed
|
|
public var drawerIsOpen(default, set):Bool = false;
|
|
|
|
private function set_drawerIsOpen(pIsOpen:Bool):Bool {
|
|
drawerIsOpen = pIsOpen;
|
|
dispatchEvent(new Event(AppModelLocator.DRAWER_STATE_CHANGE));
|
|
return drawerIsOpen;
|
|
}
|
|
|
|
// 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
|
|
// mx:application's creationComplete event is mutated into a cairngorm event
|
|
// that calls the httpservice for the data
|
|
public var ridersListDP(default, set):ArrayCollection<Rider>;
|
|
|
|
private function set_ridersListDP(value:ArrayCollection<Rider>):ArrayCollection<Rider> {
|
|
ridersListDP = value;
|
|
dispatchEvent(new Event(RIDERS_LIST_DP_CHANGE));
|
|
return ridersListDP;
|
|
}
|
|
|
|
// variable to store error messages from the httpservice
|
|
// nothinng currently binds to it, but an Alert or the login box could to show startup errors
|
|
public var errorStatus:String;
|
|
|
|
|
|
// singleton: constructor only allows one model locator
|
|
public function new() {
|
|
super();
|
|
if (AppModelLocator.model != null) {
|
|
throw new Error("Only one ModelLocator instance should be instantiated");
|
|
}
|
|
}
|
|
|
|
// singleton: always returns the one existing static instance to itself
|
|
public static function getInstance():AppModelLocator {
|
|
if (model == null)
|
|
model = new AppModelLocator();
|
|
return model;
|
|
}
|
|
|
|
} |