- added uid RiderVO prop
- fixed RiderCardDrawer layout - added fake avatars - avatars are now loaded dynammically
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import hx.strings.RandomStrings;
|
||||
import utils.StringUtils;
|
||||
import view.RiderCardDrawer;
|
||||
import openfl.system.Security;
|
||||
import business.Services;
|
||||
@@ -37,6 +39,10 @@ class LPTCManager2026 extends Application {
|
||||
stage.displayState = NORMAL;
|
||||
stage.scaleMode = NO_SCALE;
|
||||
|
||||
/*for (i in 0...23){
|
||||
traceYellow(RandomStrings.randomUUIDv4());
|
||||
}*/
|
||||
|
||||
mainPanel = new MainPanel();
|
||||
addChild(mainPanel);
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ class LoadRidersCommand implements ICommand implements IResponder {
|
||||
var riders:Array<RiderVO> = data.map((r:Dynamic) -> {
|
||||
|
||||
final id:Int = Std.parseInt(r.id);
|
||||
final uid:String = r.uid;
|
||||
final name:String = r.name;
|
||||
final firstName:String = r.firstName;
|
||||
final age:Int = Std.parseInt(r.age);
|
||||
@@ -52,7 +53,7 @@ class LoadRidersCommand implements ICommand implements IResponder {
|
||||
final legalGuardianPhoneNumber:String = r.legalGuardianPhoneNumber;
|
||||
final legalGuardianEmail:String = r.legalGuardianEmail;
|
||||
|
||||
return new RiderVO(id, name, firstName, age, lastLessonDate, level, credit, address, notes, ffeLicence, ffeLicenceValidityYear,ffeLicenceNumber,legalGuardianName,legalGuardianFirstName,legalGuardianRole,legalGuardianPhoneNumber,legalGuardianEmail);
|
||||
return new RiderVO(id, uid, name, firstName, age, lastLessonDate, level, credit, address, notes, ffeLicence, ffeLicenceValidityYear,ffeLicenceNumber,legalGuardianName,legalGuardianFirstName,legalGuardianRole,legalGuardianPhoneNumber,legalGuardianEmail);
|
||||
});
|
||||
|
||||
model.ridersListDP = new ArrayCollection(riders);
|
||||
|
||||
@@ -12,13 +12,10 @@ import feathers.skins.RectangleSkin;
|
||||
import feathers.controls.LayoutGroup;
|
||||
|
||||
class RidersListRendererAccessory extends LayoutGroup {
|
||||
private var elementSize:Int;
|
||||
private var riderCredit:Int;
|
||||
|
||||
public function new(pElementSize:Int = 14, pRiderCredit:Int = 0) {
|
||||
public function new(pRiderCredit:Int = 0) {
|
||||
super();
|
||||
|
||||
elementSize = pElementSize;
|
||||
riderCredit = pRiderCredit;
|
||||
}
|
||||
|
||||
@@ -28,7 +25,7 @@ class RidersListRendererAccessory extends LayoutGroup {
|
||||
var l:HorizontalLayout = new HorizontalLayout();
|
||||
// l.setPadding(Std.int(headerHeight * .1));
|
||||
l.verticalAlign = MIDDLE;
|
||||
l.gap = Std.int(elementSize * .3);
|
||||
l.gap = 10;
|
||||
layout = l;
|
||||
|
||||
backgroundSkin = new RectangleSkin(SolidColor(Constants.PURE_WHITE, 0));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package components;
|
||||
|
||||
import model.AppModelLocator;
|
||||
import openfl.display.Bitmap;
|
||||
import openfl.system.ApplicationDomain;
|
||||
import openfl.system.LoaderContext;
|
||||
@@ -24,10 +25,12 @@ import t9.util.ColorTraces.*;
|
||||
class RoundAvatar extends LayoutGroup {
|
||||
|
||||
private var avatarSize:Int;
|
||||
private var riderUID:String;
|
||||
|
||||
public function new(pAvatarSize:Int = 32) {
|
||||
public function new(pAvatarSize:Int = 32, pRiderUID:String) {
|
||||
super();
|
||||
avatarSize = pAvatarSize;
|
||||
riderUID = pRiderUID;
|
||||
}
|
||||
|
||||
override private function initialize():Void {
|
||||
@@ -56,7 +59,8 @@ class RoundAvatar extends LayoutGroup {
|
||||
mask = m;
|
||||
|
||||
var l:Loader = new Loader();
|
||||
l.load(new URLRequest("https://lepetittrot.com/lptcm/assets/profile-pictures/pp256/pp_test_256.jpg"));
|
||||
//l.load(new URLRequest("https://lepetittrot.com/lptcm/assets/profile-pictures/pp256/pp_test_256.jpg"));
|
||||
l.load(new URLRequest(Constants.PROFIL_PICTURES_PATH_512 + riderUID + ".jpg"));
|
||||
l.contentLoaderInfo.addEventListener (Event.COMPLETE, onLoadComplete);
|
||||
addChild(l);
|
||||
|
||||
|
||||
+11
-6
@@ -4,6 +4,9 @@ import openfl.system.Capabilities;
|
||||
|
||||
class Constants {
|
||||
|
||||
// Paths
|
||||
public static final PROFIL_PICTURES_PATH_512:String = "https://lepetittrot.com/lptcm/assets/profile-pictures/pp512/";
|
||||
|
||||
// Colors
|
||||
public static final HERO_COLOR:Int = 0x050EB7;
|
||||
public static final ACCENT_COLOR1:Int = 0xFF9F1C;
|
||||
@@ -32,11 +35,12 @@ class Constants {
|
||||
public static final MONTSERRAT_BOLD_700:String = "MontserratBold700";
|
||||
|
||||
// Fonts sizes
|
||||
public static final FONT_SIZE_1:Int = Std.int(Capabilities.screenDPI * .15);
|
||||
public static final FONT_SIZE_2:Int = Std.int(Capabilities.screenDPI * .2);
|
||||
public static final FONT_SIZE_3:Int = Std.int(Capabilities.screenDPI * .25);
|
||||
public static final FONT_SIZE_4:Int = Std.int(Capabilities.screenDPI * .3);
|
||||
public static final FONT_SIZE_5:Int = Std.int(Capabilities.screenDPI * .5);
|
||||
public static final FONT_SIZE_10:Int = 10;
|
||||
public static final FONT_SIZE_12:Int = 12;
|
||||
public static final FONT_SIZE_14:Int = 14;
|
||||
public static final FONT_SIZE_16:Int = 16;
|
||||
public static final FONT_SIZE_22:Int = 22;
|
||||
public static final FONT_SIZE_26:Int = 26;
|
||||
|
||||
// UI Proportions against stage dimmensions
|
||||
public static final MAIN_HEADER_WIDTH_RATIO:Float = 1;
|
||||
@@ -47,10 +51,11 @@ class Constants {
|
||||
public static final CLOSE_DRAWER:String = "closeDrawer";
|
||||
public static final DRAWER_IS_OPEN:Bool = false;
|
||||
|
||||
// Strings
|
||||
// Text Strings
|
||||
public static final MENU_ITEM_0_STRING:String = "Cavalier·e·s";
|
||||
public static final MENU_ITEM_1_STRING:String = "Licences FFE";
|
||||
public static final RIDERS_LIST_CREDIT_TEXT:String = "Crédit: ";
|
||||
public static final RIDER_CARD_REMAIN_CREDIT_TEXT:String = "Cours restants sur la carte : ";
|
||||
|
||||
// UI
|
||||
// number of rows in RidersList
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package utils;
|
||||
|
||||
class StringUtils {
|
||||
/*
|
||||
returns a random string of n characters with Hex chars (0123456789ABCDEF)
|
||||
*/
|
||||
static public function getRandomHexString(pStringLength:Int = 8) {
|
||||
{
|
||||
var chars:String = "0123456789abcdef";
|
||||
var rndString:String = "";
|
||||
for (i in 0...pStringLength)
|
||||
rndString += chars.charAt(Math.round(Math.random() * chars.length));
|
||||
return rndString;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
returns a random string of n characters within ASCII visible chars range (33 ! -> 126 ~)
|
||||
*/
|
||||
static public function getRandomStringFromASCII(pStringLength:Int = 8):String {
|
||||
var rndString:String = "";
|
||||
for (i in 0...pStringLength)
|
||||
rndString += String.fromCharCode(Math.round(Math.random() * 93) + 33);
|
||||
return rndString;
|
||||
}
|
||||
|
||||
/*
|
||||
returns a unique id
|
||||
*/
|
||||
public static function generateUID():String {
|
||||
var s1:String = StringUtils.getRandomHexString(8);
|
||||
var s2:String = Std.string(Date.now().getTime());
|
||||
|
||||
return s1 + s2.substr(s2.length - 4, 4);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,7 +36,7 @@ class MainFooter extends LayoutGroup {
|
||||
Constants.MAIN_COLOR2,
|
||||
Constants.HERO_COLOR,
|
||||
30,
|
||||
14);
|
||||
Constants.FONT_SIZE_14);
|
||||
btn1.text = Constants.MENU_ITEM_0_STRING;
|
||||
addChild(btn1);
|
||||
|
||||
@@ -44,7 +44,7 @@ class MainFooter extends LayoutGroup {
|
||||
Constants.MAIN_COLOR2,
|
||||
Constants.HERO_COLOR,
|
||||
30,
|
||||
14);
|
||||
Constants.FONT_SIZE_14);
|
||||
btn2.text = Constants.MENU_ITEM_1_STRING;
|
||||
addChild(btn2);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package view;
|
||||
|
||||
import haxe.macro.Expr.Constant;
|
||||
import com.adobe.cairngorm.control.CairngormEvent;
|
||||
import com.adobe.cairngorm.control.CairngormEventDispatcher;
|
||||
import components.IconButton;
|
||||
@@ -62,8 +63,7 @@ class MainHeader extends LayoutGroup {
|
||||
lbl1 = new Label();
|
||||
lbl1.text = Constants.MENU_ITEM_0_STRING;
|
||||
lbl1.embedFonts = true;
|
||||
var fnt:Font = Assets.getFont(Constants.MONTSERRAT_MEDIUM_500);
|
||||
lbl1.textFormat = new TextFormat(fnt.fontName, Std.int(headerHeight * .3), Constants.MAIN_COLOR3);
|
||||
lbl1.textFormat = new TextFormat(Assets.getFont(Constants.MONTSERRAT_MEDIUM_500).fontName, Constants.FONT_SIZE_22, Constants.MAIN_COLOR3);
|
||||
addChild(lbl1);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package view;
|
||||
|
||||
import feathers.controls.Label;
|
||||
import feathers.controls.AssetLoader;
|
||||
import feathers.controls.Button;
|
||||
import feathers.controls.Drawer;
|
||||
@@ -28,6 +29,7 @@ class RiderCardDrawer extends Drawer {
|
||||
private var ppal:AssetLoader;
|
||||
private var firstNameTextInput:TextInput;
|
||||
private var nameTextInput:TextInput;
|
||||
private var remainingCreditLabel:Label;
|
||||
private var closeDrawerButton:Button;
|
||||
|
||||
public function new() {
|
||||
@@ -41,11 +43,16 @@ class RiderCardDrawer extends Drawer {
|
||||
model = AppModelLocator.getInstance();
|
||||
|
||||
overlaySkin = new RectangleSkin(SolidColor(Constants.MAIN_COLOR3, 1));
|
||||
pullableEdge = TOP;
|
||||
swipeCloseEnabled = true;
|
||||
//swipeOpenEnabled = false;
|
||||
autoSizeMode = STAGE;
|
||||
pullableEdge = LEFT;
|
||||
clickOverlayToClose = false;
|
||||
|
||||
// main Layout
|
||||
var mainLaytoutGroup = new LayoutGroup();
|
||||
mainLaytoutGroup.autoSizeMode = STAGE;
|
||||
|
||||
var mainVerticalLayout = new VerticalLayout();
|
||||
mainVerticalLayout.setPadding(spacing);
|
||||
mainVerticalLayout.gap = spacing;
|
||||
@@ -72,6 +79,7 @@ class RiderCardDrawer extends Drawer {
|
||||
lg1.backgroundSkin = new RectangleSkin(SolidColor(Constants.MAIN_COLOR1, 0.1));
|
||||
var vl1:VerticalLayout = new VerticalLayout();
|
||||
vl1.setPadding(spacing);
|
||||
vl1.gap = -spacing;
|
||||
vl1.horizontalAlign = JUSTIFY;
|
||||
lg1.layout = vl1;
|
||||
mainLaytoutGroup.addChild(lg1);
|
||||
@@ -80,16 +88,22 @@ class RiderCardDrawer extends Drawer {
|
||||
firstNameTextInput = new TextInput();
|
||||
firstNameTextInput.backgroundSkin = null;
|
||||
firstNameTextInput.embedFonts = true;
|
||||
firstNameTextInput.textFormat = new TextFormat(Assets.getFont(Constants.MONTSERRAT_BOLD_700).fontName, Constants.FONT_SIZE_5, Constants.MAIN_COLOR1);
|
||||
firstNameTextInput.textFormat = new TextFormat(Assets.getFont(Constants.MONTSERRAT_BOLD_700).fontName, Constants.FONT_SIZE_26, Constants.MAIN_COLOR1);
|
||||
lg1.addChild(firstNameTextInput);
|
||||
|
||||
// name label
|
||||
nameTextInput = new TextInput();
|
||||
nameTextInput.backgroundSkin = null;
|
||||
nameTextInput.embedFonts = true;
|
||||
nameTextInput.textFormat = new TextFormat(Assets.getFont(Constants.MONTSERRAT_MEDIUM_500).fontName, Constants.FONT_SIZE_4, Constants.MAIN_COLOR2);
|
||||
nameTextInput.textFormat = new TextFormat(Assets.getFont(Constants.MONTSERRAT_MEDIUM_500).fontName, Constants.FONT_SIZE_22, Constants.MAIN_COLOR2);
|
||||
lg1.addChild(nameTextInput);
|
||||
|
||||
// ########################################################################## Remaining credit label
|
||||
remainingCreditLabel = new Label();
|
||||
remainingCreditLabel.embedFonts = true;
|
||||
remainingCreditLabel.textFormat = new TextFormat(Assets.getFont(Constants.MONTSERRAT_BOLD_700).fontName, Constants.FONT_SIZE_16, Constants.MAIN_COLOR1);
|
||||
mainLaytoutGroup.addChild(remainingCreditLabel);
|
||||
|
||||
drawer = mainLaytoutGroup;
|
||||
}
|
||||
|
||||
@@ -99,8 +113,10 @@ class RiderCardDrawer extends Drawer {
|
||||
|
||||
public function populateAndShow() {
|
||||
var rvo:RiderVO = model.selectedRider;
|
||||
|
||||
// profile picture
|
||||
ppal.source = "https://lepetittrot.com/lptcm/assets/profile-pictures/pp512/pp_test_512.jpg";
|
||||
ppal.source = Constants.PROFIL_PICTURES_PATH_512 + rvo.uid + ".jpg";
|
||||
|
||||
// first name text input
|
||||
firstNameTextInput.text = rvo.firstName;
|
||||
@@ -111,7 +127,7 @@ class RiderCardDrawer extends Drawer {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// name text input
|
||||
nameTextInput.text = rvo.name;
|
||||
if (!nameTextInput.hasEventListener(Event.CHANGE)) {
|
||||
@@ -122,6 +138,9 @@ class RiderCardDrawer extends Drawer {
|
||||
});
|
||||
}
|
||||
|
||||
// remaing credit text
|
||||
remainingCreditLabel.text = Constants.RIDER_CARD_REMAIN_CREDIT_TEXT + Std.string(rvo.credit);
|
||||
|
||||
openDrawer();
|
||||
}
|
||||
|
||||
|
||||
+8
-16
@@ -1,25 +1,21 @@
|
||||
package view;
|
||||
|
||||
import control.RiderSelectEvent;
|
||||
import feathers.events.ListViewEvent;
|
||||
import feathers.events.TriggerEvent;
|
||||
import feathers.skins.RectangleSkin;
|
||||
import com.adobe.cairngorm.control.CairngormEventDispatcher;
|
||||
import control.AppController;
|
||||
import com.adobe.cairngorm.control.CairngormEvent;
|
||||
import components.RidersListRendererAccessory;
|
||||
import components.RoundAvatar;
|
||||
import control.RiderSelectEvent;
|
||||
import feathers.controls.ListView;
|
||||
import feathers.controls.dataRenderers.ItemRenderer;
|
||||
import feathers.data.ListViewItemState;
|
||||
import feathers.events.FeathersEvent;
|
||||
import feathers.events.ListViewEvent;
|
||||
import feathers.skins.RectangleSkin;
|
||||
import feathers.text.TextFormat;
|
||||
import feathers.utils.DisplayObjectRecycler;
|
||||
import model.AppModelLocator;
|
||||
import model.Constants;
|
||||
import openfl.Assets;
|
||||
import openfl.events.Event;
|
||||
import openfl.text.Font;
|
||||
import t9.util.ColorTraces.*;
|
||||
import vo.RiderVO;
|
||||
|
||||
@@ -44,9 +40,8 @@ class RidersList extends ListView {
|
||||
|
||||
var itemRenderer = new ItemRenderer();
|
||||
itemRenderer.height = rowHeight;
|
||||
itemRenderer.icon = new RoundAvatar(Std.int(rowHeight * 0.9));
|
||||
itemRenderer.textFormat = new TextFormat(Assets.getFont(Constants.MONTSERRAT_BOLD_700).fontName, Constants.FONT_SIZE_3, Constants.MAIN_COLOR1);
|
||||
itemRenderer.secondaryTextFormat = new TextFormat(Assets.getFont(Constants.MONTSERRAT_MEDIUM_500).fontName, Constants.FONT_SIZE_2, Constants.MAIN_COLOR2);
|
||||
itemRenderer.textFormat = new TextFormat(Assets.getFont(Constants.MONTSERRAT_BOLD_700).fontName, Constants.FONT_SIZE_16, Constants.MAIN_COLOR1);
|
||||
itemRenderer.secondaryTextFormat = new TextFormat(Assets.getFont(Constants.MONTSERRAT_MEDIUM_500).fontName, Constants.FONT_SIZE_12, 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));
|
||||
@@ -66,13 +61,10 @@ class RidersList extends ListView {
|
||||
var rider:RiderVO = cast(state.data, RiderVO);
|
||||
itemRenderer.text = rider.firstName;
|
||||
itemRenderer.secondaryText = rider.name;
|
||||
|
||||
itemRenderer.icon = new RoundAvatar(Std.int(rowHeight * 0.9), rider.uid);
|
||||
|
||||
var rlra:RidersListRendererAccessory = new RidersListRendererAccessory(Std.int(rowHeight * 0.8), rider.credit);
|
||||
itemRenderer.accessoryView = rlra;
|
||||
|
||||
// TODO change this to real image path
|
||||
// loader.source = "https://lepetittrot.com/path/to/pp_pictures" + state.data.id + ".jpg";
|
||||
// loader.source = "https://testingbot.com/free-online-tools/random-avatar/50?u=" + Uuid.nanoId();
|
||||
itemRenderer.accessoryView = new RidersListRendererAccessory(rider.credit);
|
||||
};
|
||||
|
||||
recycler.reset = (itemRenderer:ItemRenderer, state:ListViewItemState) -> {
|
||||
|
||||
+2
-3
@@ -36,7 +36,7 @@ class ToolBar extends LayoutGroup {
|
||||
|
||||
// Layout settings
|
||||
var l:HorizontalLayout = new HorizontalLayout();
|
||||
l.setPadding(Std.int(headerHeight * .1));
|
||||
l.setPadding(10);
|
||||
l.verticalAlign = MIDDLE;
|
||||
layout = l;
|
||||
|
||||
@@ -47,10 +47,9 @@ class ToolBar extends LayoutGroup {
|
||||
//lb1.backgroundSkin = new RectangleSkin(SolidColor(Constants.ACCENT_COLOR2, 1));
|
||||
|
||||
//lb1.verticalAlign = VerticalAlign.TOP;
|
||||
var fnt:Font = Assets.getFont(Constants.MONTSERRAT_MEDIUM_500);
|
||||
lbl1.text = "Toolbar";
|
||||
lbl1.embedFonts = true;
|
||||
lbl1.textFormat = new TextFormat(fnt.fontName, Std.int(headerHeight * .3), Constants.MAIN_COLOR3);
|
||||
lbl1.textFormat = new TextFormat(Assets.getFont(Constants.MONTSERRAT_MEDIUM_500).fontName, Constants.FONT_SIZE_16, Constants.MAIN_COLOR3);
|
||||
addChild(lbl1);
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -1,10 +1,10 @@
|
||||
package vo;
|
||||
|
||||
class RiderVO {
|
||||
private static var currentIndex:Int = 0;
|
||||
|
||||
// constants for use with Reflect api when updating SelectedRider VO
|
||||
public static final ID:String = "id";
|
||||
public static final UID:String = "uid";
|
||||
public static final NAME:String = "name";
|
||||
public static final FIRST_NAME:String = "firstName";
|
||||
public static final AGE:String = "age";
|
||||
@@ -23,6 +23,7 @@ class RiderVO {
|
||||
public static final LEGAL_GUARDIAN_EMAIL:String = "legalGuardianEmail";
|
||||
|
||||
public var id:Int;
|
||||
public var uid:String;
|
||||
public var name:String;
|
||||
public var firstName:String;
|
||||
public var age:Int;
|
||||
@@ -42,6 +43,7 @@ class RiderVO {
|
||||
|
||||
|
||||
public function new(?pId:Int = 0,
|
||||
?pUId:String = "",
|
||||
?pName:String = "",
|
||||
?pFirstName:String = "",
|
||||
?pAge:Int = 0,
|
||||
@@ -59,7 +61,8 @@ class RiderVO {
|
||||
?pLegalGuardianPhoneNumber:String = "",
|
||||
?pLegalGuardianEmail:String = "") {
|
||||
|
||||
id = (pId == 0) ? currentIndex++ : pId;
|
||||
id = pId;
|
||||
uid = pUId;
|
||||
name = pName;
|
||||
firstName = pFirstName;
|
||||
age = pAge;
|
||||
|
||||
Reference in New Issue
Block a user