Skip to content

Commit

Permalink
AssetLoader: default styles
Browse files Browse the repository at this point in the history
Allows for listening to changes to darkMode and things
  • Loading branch information
joshtynjala committed Sep 11, 2024
1 parent 0a888d7 commit b378fc2
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/feathers/controls/AssetLoader.hx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class AssetLoader extends FeathersControl {
@since 1.0.0
**/
public function new(?source:String, ?completeListener:(Event) -> Void) {
initializeAssetLoaderTheme();
super();

this.source = source;
Expand Down Expand Up @@ -317,6 +318,12 @@ class AssetLoader extends FeathersControl {
return this._scaleMode;
}

private function initializeAssetLoaderTheme():Void {
#if !feathersui_disable_default_theme
feathers.themes.steel.components.SteelAssetLoaderStyles.initialize();
#end
}

override public function dispose():Void {
this.source = null;
super.dispose();
Expand Down
2 changes: 2 additions & 0 deletions src/feathers/themes/steel/SteelTheme.hx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package feathers.themes.steel;
import feathers.themes.steel.components.SteelActivityIndicatorStyles;
import feathers.themes.steel.components.SteelAlertStyles;
import feathers.themes.steel.components.SteelApplicationStyles;
import feathers.themes.steel.components.SteelAssetLoaderStyles;
import feathers.themes.steel.components.SteelButtonBarStyles;
import feathers.themes.steel.components.SteelButtonStyles;
import feathers.themes.steel.components.SteelCalloutStyles;
Expand Down Expand Up @@ -79,6 +80,7 @@ class SteelTheme extends BaseSteelTheme {
SteelActivityIndicatorStyles.initialize(this);
SteelAlertStyles.initialize(this);
SteelApplicationStyles.initialize(this);
SteelAssetLoaderStyles.initialize(this);
SteelButtonStyles.initialize(this);
SteelButtonBarStyles.initialize(this);
SteelCalloutStyles.initialize(this);
Expand Down
36 changes: 36 additions & 0 deletions src/feathers/themes/steel/components/SteelAssetLoaderStyles.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Feathers UI
Copyright 2024 Bowler Hat LLC. All Rights Reserved.
This program is free software. You can redistribute and/or modify it in
accordance with the terms of the accompanying license agreement.
*/

package feathers.themes.steel.components;

import feathers.controls.AssetLoader;
import feathers.style.Theme;
import feathers.themes.steel.BaseSteelTheme;

/**
Initialize "steel" styles for the `AssetLoader` component.
@since 1.0.0
**/
@:dox(hide)
@:access(feathers.themes.steel.BaseSteelTheme)
class SteelAssetLoaderStyles {
public static function initialize(?theme:BaseSteelTheme):Void {
if (theme == null) {
theme = Std.downcast(Theme.fallbackTheme, BaseSteelTheme);
}
if (theme == null) {
return;
}

var styleProvider = theme.styleProvider;
if (styleProvider.getStyleFunction(AssetLoader, null) == null) {
styleProvider.setStyleFunction(AssetLoader, null, function(loader:AssetLoader):Void {});
}
}
}

0 comments on commit b378fc2

Please sign in to comment.