[view] ListView: add selected style
This commit is contained in:
@@ -180,6 +180,13 @@ class ListView<D> extends GroupView {
|
||||
item.visible = true;
|
||||
item.item_index = index;
|
||||
item.data = filteredData[item.item_index];
|
||||
if (
|
||||
selected != null && selected.indexOf(item.data) > -1 ?
|
||||
item.style.add("selected") :
|
||||
item.style.remove("selected")
|
||||
) {
|
||||
item.style = item.style;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,18 @@ abstract StyleId(Array<String>) {
|
||||
this = value != null ? value : [];
|
||||
}
|
||||
|
||||
public function add(value:String):Bool {
|
||||
if (this.indexOf(value) == -1) {
|
||||
this.push(value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public inline function remove(value:String):Bool {
|
||||
return this.remove(value);
|
||||
}
|
||||
|
||||
@:to public inline function toArray():Array<String> {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -104,6 +104,12 @@ class Theme implements ITheme {
|
||||
register(new Style("text1", [
|
||||
"skin.background.color" => colors.light.diff(16),
|
||||
], ["text"]));
|
||||
register(new Style("text0.selected", [
|
||||
"font.color" => colors.active,
|
||||
], ["text0"]));
|
||||
register(new Style("text1.selected", [
|
||||
"font.color" => colors.active,
|
||||
], ["text1"]));
|
||||
register(new Style("label", [
|
||||
"geometry.padding" => Box.fromArray([8, 2]),
|
||||
], ["text"]));
|
||||
|
||||
Reference in New Issue
Block a user