public void HandleTransactions(TransactionDownloadResult <Transaction> download) { if (download.Transactions.Count == 0) { if (_page.GetRow("NoMessageFound") == null) { _page.AddIndex = _header; _page.AddInfoRow("NoMessageFound"); } } else { _page.RemoveView(_page.GetRow("NoMessageFound")); var diff = ListDiff.Compute(_messageRows, download.Transactions, (a, b) => (a.Tag as MessageViewBase).Transaction.TransactionId == b.TransactionId); diff.Process(_messageRows, download.Transactions, (message) => { _page.RemoveView(message); return(true); }, (idx, item) => { _page.AddIndexBefore = false; if (idx == 0) { _page.AddIndex = _header; } else { _page.AddIndex = _messageRows[idx - 1]; } var r = AddMessageRow(item); _messageRows.Insert(idx, r); }); _page.AddIndex = null; } }
public static bool SetupTodoList(StackPage stackPage, Func <ButtonRow, Task> action) { var hasTodoList = false; var header = stackPage.GetRow <HeaderRow>("TodoLists"); if (header != null) { var rows = stackPage.GetHeaderSectionRows(header); var rowIndex = 0; stackPage.AddIndexBefore = false; stackPage.AddIndex = header; foreach (var serviceNode in ServiceNodeManager.Current.ServiceNodes) { var todo = TodoApp.Current.GetTodo(serviceNode); if (todo != null) { foreach (var todoList in todo.TodoLists) { hasTodoList = true; if (!(rowIndex < rows.Count && rows[rowIndex] is ButtonRow button && button.Tag is TodoList)) { button = stackPage.AddButtonRow(null, action); } var name = TodoApp.GetTodoListName(todoList); if (button.Label.Text != name) { button.Label.Text = name; } button.RowLayout.SetAccentColor(serviceNode.AccentColor); button.Tag = todoList; stackPage.AddIndex = button; ++rowIndex; } } } for (var i = rowIndex; i < rows.Count; i++) { if (rows[i] is ButtonRow button && button.Tag is TodoList) { stackPage.RemoveView(button); } } } return(hasTodoList); }
void AddInboxes(StackPage page, long accountId, Func <ButtonRow, Task> action, InboxRecordDownloadEvent downloadResult) { page.RemoveHeaderSection("Inboxes"); page.AddIndex = page.GetRow("Title"); page.AddIndex = page.AddHeaderRow("Inboxes"); var result = downloadResult; //if(result == null) //result = await node.DownloadInboxRecords(accountId); if (result.Result == MessageNodeEventResultTypes.Ok) { foreach (var item in result.InboxRecords) { var button = page.AddButtonRow(null, action); page.AddIndex = button; var inboxName = item.InboxRecord?.Title; if (inboxName == null) { inboxName = Tr.Get("Common.Inbox"); } button.SetMultilineText(inboxName, Tr.Get("Common.InboxName", accountId, item.KeyIndex)); button.SetDetailViewIcon(Icons.Inbox); button.Tag = item; } } else { if (result.Result == MessageNodeEventResultTypes.InvalidAccount) { page.AddIndex = page.AddInfoRow("InvalidAccount"); } else { page.AddIndex = page.AddInfoRow("DownloadFailed"); } } page.AddIndex = page.AddFooterRow(); }