package ui; import feathers.controls.HProgressBar; import feathers.controls.TextInputState; import feathers.controls.TextInput; 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 BUTTON_VARIANT_WHITE:String = "buttonVariantWhite"; public static final BUTTON_VARIANT_ORANGE:String = "buttonVariantOrange"; public static final TEXT_INPUT_VARIANT_SEARCH:String = "textInputVariantSearch"; public static final H_PROGRESS_BAR_VARIANT_INFO:String = "HProgressBarVariantInfo"; public static final H_PROGRESS_BAR_VARIANT_WARNING:String = "HProgressBarVariantWarning"; public static final H_PROGRESS_BAR_VARIANT_ALERT:String = "HProgressBarVariantAlert"; public static final H_PROGRESS_BAR_VARIANT_ALARM:String = "HProgressBarVariantAlarm"; public function new() { super(); initialize(); } private function initialize():Void { // Buttons styleProvider.setStyleFunction(Button, null, setButtonStyles); styleProvider.setStyleFunction(Button, LPTCTheme.BUTTON_VARIANT_WHITE, setWhiteButtonStyles); styleProvider.setStyleFunction(Button, LPTCTheme.BUTTON_VARIANT_ORANGE, setOrangeButtonStyles); // TextInput styleProvider.setStyleFunction(TextInput, LPTCTheme.TEXT_INPUT_VARIANT_SEARCH, setSearchTextInputStyles); //HProgressBar styleProvider.setStyleFunction(HProgressBar, LPTCTheme.H_PROGRESS_BAR_VARIANT_INFO, setHProgressBarInfoStyles); styleProvider.setStyleFunction(HProgressBar, LPTCTheme.H_PROGRESS_BAR_VARIANT_WARNING, setHProgressBarWarningStyles); styleProvider.setStyleFunction(HProgressBar, LPTCTheme.H_PROGRESS_BAR_VARIANT_ALERT, setHProgressBarAlertStyles); styleProvider.setStyleFunction(HProgressBar, LPTCTheme.H_PROGRESS_BAR_VARIANT_ALARM, setHProgressBarAlarmStyles); } //############################################################### BUTTONS 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 = Constants.GLOBAL_CORNER_RADIUS; button.backgroundSkin = backgroundSkin; var downSkin = new RectangleSkin(); downSkin.border = SolidColor(1.0, Constants.HERO_COLOR); downSkin.fill = SolidColor(Constants.MAIN_COLOR3); downSkin.cornerRadius = Constants.GLOBAL_CORNER_RADIUS; 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.paddingLeft = button.paddingRight = 10; button.paddingTop = button.paddingBottom = 5; button.iconOffsetX = Constants.GLOBAL_BUTTON_ICON_OFFSET; } 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 = Constants.GLOBAL_CORNER_RADIUS; button.backgroundSkin = backgroundSkin; var downSkin = new RectangleSkin(); downSkin.border = SolidColor(1.0, Constants.HERO_COLOR); downSkin.fill = SolidColor(Constants.HERO_COLOR); downSkin.cornerRadius = Constants.GLOBAL_CORNER_RADIUS; 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.paddingLeft = button.paddingRight = 10; button.paddingTop = button.paddingBottom = 5; button.iconOffsetX = Constants.GLOBAL_BUTTON_ICON_OFFSET; } private function setOrangeButtonStyles(button:Button):Void { var backgroundSkin = new RectangleSkin(); backgroundSkin.border = SolidColor(1.0, Constants.ACCENT_COLOR2); backgroundSkin.fill = SolidColor(Constants.ACCENT_COLOR2); backgroundSkin.cornerRadius = Constants.GLOBAL_CORNER_RADIUS; button.backgroundSkin = backgroundSkin; var downSkin = new RectangleSkin(); downSkin.border = SolidColor(1.0, Constants.ACCENT_COLOR2); downSkin.fill = SolidColor(Constants.MAIN_COLOR3); downSkin.cornerRadius = Constants.GLOBAL_CORNER_RADIUS; 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.paddingLeft = button.paddingRight = 10; button.paddingTop = button.paddingBottom = 5; button.iconOffsetX = Constants.GLOBAL_BUTTON_ICON_OFFSET; } //############################################################### TEXT INPUT private function setSearchTextInputStyles(pTextInput:TextInput):Void { var backgroundSkin = new RectangleSkin(); backgroundSkin.border = SolidColor(1, Constants.MAIN_COLOR3, .1); backgroundSkin.fill = SolidColor(Constants.MAIN_COLOR3, 0.1); backgroundSkin.cornerRadius = Constants.GLOBAL_CORNER_RADIUS; pTextInput.backgroundSkin = backgroundSkin; var disabledSkin = new RectangleSkin(); disabledSkin.border = SolidColor(1, Constants.MAIN_COLOR3, .1); disabledSkin.fill = SolidColor(Constants.MAIN_COLOR3, 0.1); disabledSkin.cornerRadius = Constants.GLOBAL_CORNER_RADIUS; pTextInput.setSkinForState(TextInputState.DISABLED, disabledSkin); var focusSkin = new RectangleSkin(); focusSkin.border = SolidColor(1, Constants.MAIN_COLOR3, .8); focusSkin.fill = SolidColor(Constants.MAIN_COLOR3, 0.2); focusSkin.cornerRadius = Constants.GLOBAL_CORNER_RADIUS; pTextInput.setSkinForState(TextInputState.FOCUSED, focusSkin); var format:TextFormat = new TextFormat(Assets.getFont(Constants.MONTSERRAT_MEDIUM_500).fontName, Constants.FONT_SIZE_14, Constants.MAIN_COLOR3); pTextInput.textFormat = format; var disabledFormat:TextFormat = new TextFormat(Assets.getFont(Constants.MONTSERRAT_MEDIUM_500).fontName, Constants.FONT_SIZE_14, Constants.MAIN_COLOR3); pTextInput.setTextFormatForState(TextInputState.DISABLED, disabledFormat); var focusFormat:TextFormat = new TextFormat(Assets.getFont(Constants.MONTSERRAT_MEDIUM_500).fontName, Constants.FONT_SIZE_14, Constants.MAIN_COLOR3); pTextInput.setTextFormatForState(TextInputState.FOCUSED, focusFormat); pTextInput.paddingLeft = pTextInput.paddingRight = 10; pTextInput.paddingTop = pTextInput.paddingBottom = 5; pTextInput.embedFonts = true; } //############################################################### PROGRESS BAR private function setHProgressBarInfoStyles(pHProgrssBar:HProgressBar):Void { var backgroundSkin = new RectangleSkin(); backgroundSkin.border = null; backgroundSkin.fill = SolidColor(Constants.MAIN_COLOR1, .2); backgroundSkin.height = 10; backgroundSkin.cornerRadius = 4; pHProgrssBar.backgroundSkin = backgroundSkin; var fillSkin = new RectangleSkin(); fillSkin.border = null; fillSkin.fill = SolidColor(Constants.INFO); backgroundSkin.height = 10; fillSkin.cornerRadius = 4; pHProgrssBar.fillSkin = fillSkin; } private function setHProgressBarWarningStyles(pHProgrssBar:HProgressBar):Void { var backgroundSkin = new RectangleSkin(); backgroundSkin.border = null; backgroundSkin.fill = SolidColor(Constants.MAIN_COLOR1, .2); backgroundSkin.height = 10; backgroundSkin.cornerRadius = 4; pHProgrssBar.backgroundSkin = backgroundSkin; var fillSkin = new RectangleSkin(); fillSkin.border = null; fillSkin.fill = SolidColor(Constants.WARNING); backgroundSkin.height = 10; fillSkin.cornerRadius = 4; pHProgrssBar.fillSkin = fillSkin; } private function setHProgressBarAlertStyles(pHProgrssBar:HProgressBar):Void { var backgroundSkin = new RectangleSkin(); backgroundSkin.border = null; backgroundSkin.fill = SolidColor(Constants.MAIN_COLOR1, .2); backgroundSkin.height = 10; backgroundSkin.cornerRadius = 4; pHProgrssBar.backgroundSkin = backgroundSkin; var fillSkin = new RectangleSkin(); fillSkin.border = null; fillSkin.fill = SolidColor(Constants.ALERT); backgroundSkin.height = 10; fillSkin.cornerRadius = 4; pHProgrssBar.fillSkin = fillSkin; } private function setHProgressBarAlarmStyles(pHProgrssBar:HProgressBar):Void { var backgroundSkin = new RectangleSkin(); backgroundSkin.border = null; backgroundSkin.fill = SolidColor(Constants.MAIN_COLOR1, .2); backgroundSkin.height = 10; backgroundSkin.cornerRadius = 4; pHProgrssBar.backgroundSkin = backgroundSkin; var fillSkin = new RectangleSkin(); fillSkin.border = null; fillSkin.fill = SolidColor(Constants.ALARM); backgroundSkin.height = 10; fillSkin.cornerRadius = 4; pHProgrssBar.fillSkin = fillSkin; } }