RidersListRendererAccessory UI
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package components;
|
||||
|
||||
import haxe.macro.Expr.Case;
|
||||
import feathers.text.TextFormat;
|
||||
import openfl.Assets;
|
||||
import openfl.text.Font;
|
||||
import feathers.controls.Label;
|
||||
import feathers.layout.HorizontalLayout;
|
||||
import openfl.display.Shape;
|
||||
import model.Constants;
|
||||
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) {
|
||||
super();
|
||||
|
||||
elementSize = pElementSize;
|
||||
riderCredit = pRiderCredit;
|
||||
}
|
||||
|
||||
override private function initialize():Void {
|
||||
super.initialize();
|
||||
|
||||
var l:HorizontalLayout = new HorizontalLayout();
|
||||
// l.setPadding(Std.int(headerHeight * .1));
|
||||
l.verticalAlign = MIDDLE;
|
||||
l.gap = Std.int(elementSize * .3);
|
||||
layout = l;
|
||||
|
||||
backgroundSkin = new RectangleSkin(SolidColor(Constants.PURE_WHITE, 0));
|
||||
|
||||
// Title label
|
||||
var lbl1 = new Label();
|
||||
|
||||
// lbl1.layoutData = ld1;
|
||||
// lb1.backgroundSkin = new RectangleSkin(SolidColor(Constants.ACCENT_COLOR2, 1));
|
||||
// lb1.verticalAlign = VerticalAlign.TOP;
|
||||
|
||||
var iconColor:Int;
|
||||
var fnt:Font = Assets.getFont(Constants.MONTSERRAT_MEDIUM_500);
|
||||
|
||||
if (riderCredit <= 0) {
|
||||
iconColor = Constants.ALARM;
|
||||
} else if (riderCredit <= 2) {
|
||||
iconColor = Constants.ALERT;
|
||||
} else if (riderCredit <= 6) {
|
||||
iconColor = Constants.WARNING;
|
||||
} else {
|
||||
iconColor = Constants.INFO;
|
||||
}
|
||||
|
||||
lbl1.text = Constants.RIDERS_LIST_CREDIT_TEXT + Std.string(riderCredit);
|
||||
lbl1.embedFonts = true;
|
||||
lbl1.textFormat = new TextFormat(fnt.fontName, 14, Constants.MAIN_COLOR1);
|
||||
addChild(lbl1);
|
||||
|
||||
var s:Shape = new Shape();
|
||||
s.graphics.beginFill(iconColor, 1);
|
||||
s.graphics.drawCircle(10, 10, 10);
|
||||
s.graphics.endFill();
|
||||
addChild(s);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package components;
|
||||
|
||||
import feathers.text.TextFormat;
|
||||
import openfl.Assets;
|
||||
import openfl.text.Font;
|
||||
import feathers.controls.Label;
|
||||
import feathers.layout.HorizontalLayout;
|
||||
import openfl.display.Shape;
|
||||
import model.Constants;
|
||||
import feathers.skins.RectangleSkin;
|
||||
import feathers.controls.LayoutGroup;
|
||||
|
||||
class RidersListRendererDecoration extends LayoutGroup {
|
||||
public function new() {
|
||||
super();
|
||||
}
|
||||
|
||||
override private function initialize():Void {
|
||||
super.initialize();
|
||||
|
||||
var l:HorizontalLayout = new HorizontalLayout();
|
||||
//l.setPadding(Std.int(headerHeight * .1));
|
||||
l.verticalAlign = MIDDLE;
|
||||
l.setPadding(10);
|
||||
l.gap = 10;
|
||||
layout = l;
|
||||
|
||||
backgroundSkin = new RectangleSkin(SolidColor(Constants.MAIN_COLOR2, 1));
|
||||
|
||||
// Title label
|
||||
var lbl1 = new Label();
|
||||
|
||||
//lbl1.layoutData = ld1;
|
||||
//lb1.backgroundSkin = new RectangleSkin(SolidColor(Constants.ACCENT_COLOR2, 1));
|
||||
|
||||
//lb1.verticalAlign = VerticalAlign.TOP;
|
||||
|
||||
|
||||
var s:Shape = new Shape();
|
||||
s.graphics.beginFill(0x228B42, 1);
|
||||
s.graphics.drawCircle(10, 10, 10);
|
||||
s.graphics.endFill();
|
||||
addChild(s);
|
||||
|
||||
var fnt:Font = Assets.getFont(Constants.MONTSERRAT_MEDIUM_500);
|
||||
lbl1.text = "CREDIT : 09 ";
|
||||
lbl1.embedFonts = true;
|
||||
lbl1.textFormat = new TextFormat(fnt.fontName, 14, Constants.MAIN_COLOR1);
|
||||
addChild(lbl1);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package components;
|
||||
|
||||
import openfl.system.ApplicationDomain;
|
||||
import openfl.system.LoaderContext;
|
||||
import openfl.display.LoaderInfo;
|
||||
import openfl.net.URLRequest;
|
||||
import openfl.display.Loader;
|
||||
@@ -30,11 +32,14 @@ class RoundAvatar extends LayoutGroup {
|
||||
override private function initialize():Void {
|
||||
super.initialize();
|
||||
|
||||
var hl:HorizontalLayout = new HorizontalLayout();
|
||||
/*var hl:HorizontalLayout = new HorizontalLayout();
|
||||
hl.horizontalAlign = LEFT;
|
||||
layout = hl;
|
||||
layout = hl;*/
|
||||
|
||||
//backgroundSkin = new RectangleSkin(SolidColor(0xFF0000, 1));
|
||||
var bkgs = new RectangleSkin(SolidColor(0xFFFFFF, 0));
|
||||
bkgs.width = Std.int(avatarSize * 1.2);
|
||||
bkgs.height = avatarSize;
|
||||
backgroundSkin = bkgs;
|
||||
|
||||
/*var al:AssetLoader = new AssetLoader();
|
||||
al.addEventListener(Event.COMPLETE, onLoadComplete);
|
||||
@@ -42,33 +47,27 @@ class RoundAvatar extends LayoutGroup {
|
||||
al.source = "https://ui-avatars.com/api/?background=random&size=128";
|
||||
addChild(al);*/
|
||||
|
||||
var bkg:Shape = new Shape();
|
||||
bkg.graphics.beginFill(Std.int(Math.random() * 0xFFFFFF), 1);
|
||||
bkg.graphics.drawCircle(avatarSize / 2, avatarSize / 2, avatarSize / 2);
|
||||
bkg.graphics.endFill();
|
||||
backgroundSkin = bkg;
|
||||
|
||||
var spacer:Shape = new Shape();
|
||||
spacer.graphics.beginFill(Std.int(0x933EA7), 1);
|
||||
spacer.graphics.drawRect(bkg.x + bkg.width, bkg.y, avatarSize / 2, bkg.height);
|
||||
spacer.graphics.endFill();
|
||||
addChild(spacer);
|
||||
var m:Shape = new Shape();
|
||||
m.graphics.beginFill(Std.int(Math.random() * 0xFFFFFF), 1);
|
||||
m.graphics.drawCircle(avatarSize / 2, avatarSize / 2, avatarSize / 2);
|
||||
m.graphics.endFill();
|
||||
addChild(m);
|
||||
mask = m;
|
||||
|
||||
var l:Loader = new Loader();
|
||||
var lc:LoaderContext = new LoaderContext(true, null);
|
||||
// l.load(new URLRequest("https://ui-avatars.com/api/?background=random&size=64"));
|
||||
l.load(new URLRequest("https://api.dicebear.com/9.x/pixel-art/png?size=32"));
|
||||
//l.load(new URLRequest("https://api.dicebear.com/9.x/pixel-art/png?size=32"));
|
||||
l.load(new URLRequest("https://lepetittrot.com/lptcm/assets/profile-pictures/pp256/pp_malo.jpeg"), lc);
|
||||
l.contentLoaderInfo.addEventListener (Event.COMPLETE, onLoadComplete);
|
||||
addChild(l);
|
||||
|
||||
}
|
||||
|
||||
private function onLoadComplete(e:Event) {
|
||||
|
||||
//var loader = cast(e.currentTarget, AssetLoader);
|
||||
//trace("asset loaded: " + loader.source);
|
||||
|
||||
var l:Loader = cast(e.currentTarget, LoaderInfo).loader;
|
||||
l.content.width = l.content.height = avatarSize;
|
||||
if(!contains(l)) addChild(l);
|
||||
traceMagenta(l.width + " / " + l.height);
|
||||
|
||||
l.content.width = l.content.height = avatarSize;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user