- GLobal styling with LPTCTheme class

- SVGIconFactory
This commit is contained in:
2025-12-20 15:41:16 +01:00
parent ba89991a80
commit 9c3e0c85c8
14 changed files with 139 additions and 13 deletions
+74
View File
@@ -0,0 +1,74 @@
package ui;
import openfl.Assets;
import model.Constants;
import feathers.text.TextFormat;
import feathers.controls.ButtonState;
import feathers.skins.RectangleSkin;
import feathers.controls.Button;
import feathers.themes.ClassVariantTheme;
class LPTCTheme extends ClassVariantTheme {
public static final VARIANT_WHITE:String = "whiteButton";
public static final VARIANT_RED:String = "redButton";
public function new() {
super();
initialize();
}
private function initialize():Void {
styleProvider.setStyleFunction(Button, null, setButtonStyles);
styleProvider.setStyleFunction(Button, LPTCTheme.VARIANT_WHITE, setWhiteButtonStyles);
styleProvider.setStyleFunction(Button, LPTCTheme.VARIANT_RED, setRedButtonStyles);
}
private function setButtonStyles(button:Button):Void {
var backgroundSkin = new RectangleSkin();
backgroundSkin.border = SolidColor(1.0, Constants.HERO_COLOR);
backgroundSkin.fill = SolidColor(Constants.HERO_COLOR);
backgroundSkin.cornerRadius = 6.0;
button.backgroundSkin = backgroundSkin;
var downSkin = new RectangleSkin();
downSkin.border = SolidColor(1.0, Constants.HERO_COLOR);
downSkin.fill = SolidColor(Constants.MAIN_COLOR3);
downSkin.cornerRadius = 6.0;
button.setSkinForState(ButtonState.DOWN, downSkin);
var format = new TextFormat(Assets.getFont(Constants.MONTSERRAT_MEDIUM_500).fontName, Constants.FONT_SIZE_14, Constants.MAIN_COLOR3);
button.textFormat = format;
var downFormat = new TextFormat(Assets.getFont(Constants.MONTSERRAT_MEDIUM_500).fontName, Constants.FONT_SIZE_14, Constants.HERO_COLOR);
button.setTextFormatForState(ButtonState.DOWN, downFormat);
button.setPadding(10);
}
private function setWhiteButtonStyles(button:Button):Void {
var backgroundSkin = new RectangleSkin();
backgroundSkin.border = SolidColor(1.0, Constants.HERO_COLOR);
backgroundSkin.fill = SolidColor(Constants.MAIN_COLOR3);
backgroundSkin.cornerRadius = 6.0;
button.backgroundSkin = backgroundSkin;
var downSkin = new RectangleSkin();
downSkin.border = SolidColor(1.0, Constants.HERO_COLOR);
downSkin.fill = SolidColor(Constants.HERO_COLOR);
downSkin.cornerRadius = 6.0;
button.setSkinForState(ButtonState.DOWN, downSkin);
var format = new TextFormat(Assets.getFont(Constants.MONTSERRAT_MEDIUM_500).fontName, Constants.FONT_SIZE_14, Constants.HERO_COLOR);
button.textFormat = format;
var downFormat = new TextFormat(Assets.getFont(Constants.MONTSERRAT_MEDIUM_500).fontName, Constants.FONT_SIZE_14, Constants.MAIN_COLOR3);
button.setTextFormatForState(ButtonState.DOWN, downFormat);
button.setPadding(10);
}
private function setRedButtonStyles(button:Button):Void {
}
}
+24
View File
@@ -0,0 +1,24 @@
package ui;
import openfl.Assets;
import openfl.geom.ColorTransform;
import format.SVG;
import openfl.display.Shape;
class SVGIconFactory {
public static function makeIcon(pSvgIconPath:String = null, pIconSize:Int = 64, pIconColor:Int = 0x000000):Shape {
// icon
var svgIcon:Shape = new Shape();
new SVG(Assets.getText(pSvgIconPath)).render(svgIcon.graphics);
var ct = new ColorTransform();
ct.color = pIconColor;
svgIcon.transform.colorTransform = ct;
svgIcon.width = svgIcon.height = pIconSize;
return svgIcon;
}
}