TestMultiChildState.cs 667 B

1234567891011121314151617181920212223242526
  1. using System.Collections;
  2. using PixiEditor.Extensions.CommonApi.FlyUI.Events;
  3. using PixiEditor.Extensions.FlyUI.Elements;
  4. namespace PixiEditor.Extensions.Test;
  5. public class TestMultiChildState : State
  6. {
  7. private LayoutElement[] rows = Array.Empty<LayoutElement>();
  8. public LayoutElement[] Rows => rows;
  9. public override LayoutElement BuildElement()
  10. {
  11. return new Column(
  12. new Button(new Text("Add row"), OnClick),
  13. new Row(rows));
  14. }
  15. private void OnClick(ElementEventArgs args)
  16. {
  17. SetState(() =>
  18. {
  19. rows = rows.Append(new Text("Row " + rows.Length)).ToArray();
  20. });
  21. }
  22. }