mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
fix(list-view): Layout list-view items on request (#6159)
* test: list items relayout example * fix(list-view): Layout list-view items on request * refactor(tests): refactor list-view tests imports
This commit is contained in:

committed by
GitHub

parent
9c67d7ba02
commit
ec24c5a96f
20
apps/app/ui-tests-app/list-view/item-re-layout.css
Normal file
20
apps/app/ui-tests-app/list-view/item-re-layout.css
Normal file
@ -0,0 +1,20 @@
|
||||
Label {
|
||||
margin: 6;
|
||||
padding: 4;
|
||||
}
|
||||
|
||||
.unselected {
|
||||
border-width: 4;
|
||||
border-color: gray;
|
||||
border-radius: 10;
|
||||
background: white;
|
||||
color: gray
|
||||
}
|
||||
|
||||
.selected {
|
||||
border-width: 4;
|
||||
border-color: blue;
|
||||
border-radius: 10;
|
||||
background: lightcoral;
|
||||
color: blue;
|
||||
}
|
21
apps/app/ui-tests-app/list-view/item-re-layout.ts
Normal file
21
apps/app/ui-tests-app/list-view/item-re-layout.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { fromObject } from "tns-core-modules/data/observable";
|
||||
|
||||
export function loaded(args) {
|
||||
var items = [];
|
||||
|
||||
for (let i = 0; i < 100; i++) {
|
||||
items.push(fromObject({
|
||||
text: "<" + i + ">",
|
||||
selected: !!!(i % 5)
|
||||
}));
|
||||
}
|
||||
args.object.bindingContext = { items: items };
|
||||
}
|
||||
|
||||
export function toggle(args) {
|
||||
console.log("toggle : ")
|
||||
let context = args.object.bindingContext;
|
||||
console.dir(context);
|
||||
context.set("selected", !context.selected);
|
||||
// args.object.requestLayout();
|
||||
}
|
15
apps/app/ui-tests-app/list-view/item-re-layout.xml
Normal file
15
apps/app/ui-tests-app/list-view/item-re-layout.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<Page loaded="loaded">
|
||||
<StackLayout>
|
||||
<ListView items="{{ items }}">
|
||||
<ListView.itemTemplate>
|
||||
<StackLayout orientation="horizontal" tap="toggle">
|
||||
<Label text="{{ text }}" />
|
||||
<Label text="marked" visibility="{{ selected ? 'visible' : 'collapse' }}" />
|
||||
<Label text="{{ selected ? 'yep' : 'nope' }}" />
|
||||
<Label text="test" class="{{ selected ? 'selected' : 'unselected' }}" />
|
||||
<Label text="{{ selected ? 'yep' : 'nope' }}" class="{{ selected ? 'selected' : 'unselected' }}" />
|
||||
</StackLayout>
|
||||
</ListView.itemTemplate>
|
||||
</ListView>
|
||||
</StackLayout>
|
||||
</Page>
|
@ -19,6 +19,7 @@ export function loadExamples() {
|
||||
examples.set("scrolling-and-sizing", "list-view/scrolling-and-sizing");
|
||||
examples.set("row-height", "list-view/row-height");
|
||||
examples.set("width-percent", "list-view/width-percent");
|
||||
examples.set("item-re-layout", "list-view/item-re-layout");
|
||||
|
||||
return examples;
|
||||
}
|
||||
|
Reference in New Issue
Block a user