[view] ListView: add selected style

This commit is contained in:
2019-09-10 19:48:08 +03:00
parent 32309389e5
commit 5989da3fe4
3 changed files with 25 additions and 0 deletions

View File

@@ -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;
}
}
}
}

View File

@@ -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;
}

View File

@@ -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"]));