Beispiel #1
0
 public void Clear()
 {
     foreach (var row in _messageRows)
     {
         _page.RemoveView(row);
     }
     _messageRows.Clear();
 }
Beispiel #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);
        }