void UpdateTasks(TodoTaskStatusTypes status, string headerName, List <ButtonRow> taskButtons, string noIdentifier) { var header = GetRow <HeaderRow>(headerName); var tasks = TodoList.GetTasks(status, TodoListSortMethod.ByTimestampDesc); if (tasks.Count > 0) { RemoveView(GetRow(noIdentifier)); var diff = ListDiff.Compute(taskButtons, tasks, (a, b) => (a.Tag as TodoTask).Id == b.Id); diff.Process(taskButtons, tasks, (row) => { RemoveView(row); return(true); }, (idx, item) => { AddIndexBefore = false; if (idx == 0) { AddIndex = header; } else { AddIndex = taskButtons[idx - 1]; } var b = AddTaskButtonRow(item); taskButtons.Insert(idx, b); }); } else { taskButtons.Clear(); ClearHeaderSection(headerName); AddIndex = header; AddIndexBefore = false; AddInfoRow(noIdentifier); } }
public TodoListPage(TodoList todoList, bool edit) : base("TodoListPage") { Subscribe <QueryTodoListEvent>(QueryTodoList); if (edit) { Subscribe <TodoListNameChangedEvent>(ListName); Subscribe <TodoListDeletetEvent>(GroupDeleted); } TodoList = todoList; _edit = edit; var header = AddTitleRow(null); header.Identifier = "Title"; var title = TodoApp.GetTodoListName(todoList); header.Label.Text = title; SetTitle(title); UpdateSecretKeyButton(); var items = todoList.GetTasks(TodoTaskStatusTypes.Open, TodoListSortMethod.ByTimestampDesc); AddHeaderRow("OpenTasks"); if (items.Count > 0) { foreach (var item in items) { var b = AddTaskButtonRow(item); _openTasks.Add(b); } } else { AddInfoRow("NoOpenTasks"); } AddFooterRow(); if (!_edit) { AddHeaderRow("More"); var button = AddButtonRow("TodoListView.Add", NewTask); //add.Margin = new Thickness(40, 0, 0, 0); button.RowStyle = Theme.SubmitButton; button.FontIcon.IsVisible = false; button.SetDetailViewIcon(Icons.Plus); //add.IsEnabled = !todoList.HasMissingSecretKeys; button = AddButtonRow("Edit", Edit); button.SetDetailViewIcon(Icons.Pencil); button = AddButtonRow("Reload", Reload); button.SetDetailViewIcon(Icons.Sync); AddFooterRow(); } if (_edit) { items = todoList.GetTasks(TodoTaskStatusTypes.Closed, TodoListSortMethod.ByTimestampDesc); AddHeaderRow("ClosedTasks"); if (items.Count > 0) { foreach (var item in items) { var b = AddTaskButtonRow(item); _closedTasks.Add(b); } } else { AddInfoRow("NoClosedTasks"); } AddFooterRow(); AddHeaderRow("UsersSection"); var button = AddButtonRow("ViewUsers", Users); button.SetDetailViewIcon(Icons.Users); button = AddButtonRow("Invite", Invite); button.SetDetailViewIcon(Icons.UserPlus); AddFooterRow(); AddHeaderRow("NameHeader"); _nameEntry = AddEntryRow(todoList.Name, "Name"); _nameEntry.SetDetailViewIcon(Icons.Pencil); _nameButton = AddSubmitButtonRow("NameButton", Name); _nameButton.RowStyle = Theme.SubmitButton; Status.AddBusyView(_nameEntry.Edit); Status.AddBusyView(_nameButton); AddFooterRow(); AddHeaderRow("Common.SubmitAccount"); _submitAccount = AddRow(new SubmitAccountButtonRow <GroupSubmitAccount>(this, () => todoList.ServiceNode.GetSubmitAccounts <GroupSubmitAccount>(todoList.Index), todoList.ListId.ToString())); AddInfoRow("Common.SubmitAccountInfo"); AddFooterRow(); AddHeaderRow("DeleteHeader"); var del = AddButtonRow("DeleteButton", Delete); del.RowStyle = Theme.CancelButton; del.SetDetailViewIcon(Icons.TrashAlt); Status.AddBusyView(del); AddFooterRow(); } }