Пример #1
0
        protected override ButtonRow AddRow(StackPage page, TransactionDownloadData<Transaction> transaction)
        {
            var message = _chat.GetMessage(transaction);
            var accountId = transaction.Transaction.AccountId;

            var button = page.AddButtonRow(null, Message);
            button.LabelPadding = 0;
            button.RowStyle = Theme.MessageButton;

            button.RowLayout.Children.RemoveAt(0);
            button.RowLayout.Children.Remove(button.FontIcon);
            button.Label.Margin = new Thickness(5, 2, 5, 2);

            var (text, detail) = GetMessageText(message);
            button.SetMultilineText(text, detail);
            button.Tag = message;

            if (accountId == _chat.AccountId)
            {
                button.Margin = new Thickness(0, 0, 46, 0);
            }
            else
            {
                button.Margin = new Thickness(46, 0, 0, 0);
            }

            return button;
        }
Пример #2
0
        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);
        }
Пример #3
0
        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();
        }