private void MoveSelection(int delta) { int index = allCells.IndexOf(selection); if (index + delta >= allCells.Count || index + delta < 0) { return; } PhuneCell next = allCells[index + delta]; if (next is PhuneHeaderCell && !(selection is PhuneHeaderCell)) { return; } if (selection is PhuneHeaderCell) { while (!(next is PhuneHeaderCell)) { index += delta; if (index >= allCells.Count || index == -1) { return; } next = allCells[index]; } } selection.Populate(false); next.Populate(true); selection = next; UpdateSelection(); }
public void CollapseEntry() { if (selection is PhuneHeaderCell) { PhuneHeaderCell header = (PhuneHeaderCell)selection; header.expanded = true; header.Populate(false); int index = allCells.IndexOf(selection); selection = allCells[index + 1]; selection.Populate(true); } else { selection.Populate(false); PhuneHeaderCell header = null; foreach (PhuneCell cell in allCells) { if (cell is PhuneHeaderCell) { header = (PhuneHeaderCell)cell; } if (cell == selection) { header.expanded = false; header.Populate(true); selection = header; break; } } } UpdateSelection(); }
private void ReloadData() { allCells.Clear(); foreach (Transform child in attachPoint.transform) { Destroy(child.gameObject); } Dictionary <PhuneCategoryData, List <PhuneEntryCell> > entriesByCategory = new Dictionary <PhuneCategoryData, List <PhuneEntryCell> >(); foreach (PhuneEntryData data in dataModel) { if (!entriesByCategory.ContainsKey(data.category)) { List <PhuneEntryCell> newSiblings = new List <PhuneEntryCell>(); entriesByCategory[data.category] = newSiblings; } List <PhuneEntryCell> siblings = entriesByCategory[data.category]; siblings.Add(GenerateEntry(data)); } foreach (PhuneCategoryData category in entriesByCategory.Keys) { AddSection(category.GetSummary(), entriesByCategory[category]); } selection = allCells[0]; foreach (PhuneCell cell in allCells) { if (cell is PhuneHeaderCell) { PhuneHeaderCell header = (PhuneHeaderCell)cell; if (defaultCat != null && header.text.text == defaultCat.headerName) { selection = cell; } } } selection.Populate(true); UpdateSelection(); }