Esempio n. 1
0
        public AddTodoTaskPage(TodoList todoList) : base("AddTodoTaskPage")
        {
            Subscribe <NewTodoTaskEvent>(TodoTask);

            AddTitleRow("Title");

            AddHeaderRow("TodoList");

            var selectionList = new SelectionItemList <TodoList>();

            foreach (var serviceNode in ServiceNodeManager.Current.ServiceNodes)
            {
                var todo = TodoApp.Current.GetTodo(serviceNode);
                if (todo != null)
                {
                    foreach (var list in todo.TodoLists)
                    {
                        selectionList.Add(new SelectionItem <TodoList>(list, TodoApp.GetTodoListName(list)));
                    }
                }
            }

            _listSelection = AddSelectionRows(selectionList, todoList);
            _listSelection.SelectionChanged = SelectionChanged;

            Status.Add(T("ListStatus"), (sv) =>
            {
                return(_listSelection.Selection != null);
            });

            AddFooterRow();

            _editor = AddEditorRow("", "Text");
            _editor.SetDetailViewIcon(Icons.Pencil);

            FocusElement = _editor.Edit;

            Status.Add(_editor.Edit, T("TextStatus"), (sv, edit, newText, oldText) =>
            {
                return(!string.IsNullOrWhiteSpace(newText) && newText.Length >= 2);
            });


            AddSubmitRow("Submit", Submit);

            AddHeaderRow("Common.SubmitAccount");
            _submitAccount = AddRow(new SubmitAccountButtonRow <TodoListSubmitAccount>(null, this, SelectSubmitAccount));
            AddInfoRow("Common.SubmitAccountInfo");
            AddFooterRow();
            SelectionChanged(todoList);

            Status.Add(T("SubmitAccountStatus"), (sv) =>
            {
                return(_submitAccount.SubmitAccount != null);
            });
        }
Esempio n. 2
0
        async Task Update()
        {
            await ProfileManager.Current.GetProfileData(_friendAccountId, ProfileDownloadType.DownloadIfNotAvailable, true);

            if (_chat == null)
            {
                AddIndex       = GetRow("Misc");
                AddIndexBefore = true;
                AddIndex       = AddHeaderRow("SelectInbox");
                AddIndexBefore = false;

                var result = await _node.DownloadInboxRecords(_friendAccountId);

                if (result.Result == MessageNodeEventResultTypes.Ok)
                {
                    SelectionItem <InboxNameRecordInfo> keyIndexItem = null;
                    var list = new SelectionItemList <InboxNameRecordInfo>();

                    foreach (var item in result.InboxRecords)
                    {
                        var selectionItem = new SelectionItem <InboxNameRecordInfo>(item, null);
                        list.Add(selectionItem);
                        if (item.KeyIndex == _friendKeyIndex)
                        {
                            keyIndexItem = selectionItem;
                        }
                    }

                    if (keyIndexItem != null)
                    {
                        list.Clear();
                        list.Add(keyIndexItem);
                    }

                    var row = AddSelectionRows(list, list[0].Key);
                    row.SelectionChanged = InboxChanged;

                    foreach (var button in row.Buttons)
                    {
                        var item = button.Tag as SelectionItem <InboxNameRecordInfo>;

                        var inboxName = item.Key.InboxRecord?.Title;
                        if (inboxName == null)
                        {
                            inboxName = Tr.Get("Common.Inbox");
                        }

                        button.SetMultilineText(inboxName, Tr.Get("Common.InboxName", _friendAccountId, item.Key.KeyIndex));
                        button.SetDetailViewIcon(Icons.Inbox);
                    }

                    AddIndex = row.Buttons[row.Buttons.Count - 1];
                    AddIndex = AddInfoRow("SelectInboxInfo");
                    var f = AddFooterRow();
                    f.Identifier = "SelectInboxFooter";

                    var friend = _node.GetFriend(_friendAccountId);
                    if (friend != null)
                    {
                        await InboxChanged(list[0].Key);
                    }
                }
                else
                {
                    if (result.Result == MessageNodeEventResultTypes.InvalidAccount)
                    {
                        AddIndex = AddInfoRow("InvalidAccount");
                    }
                    else
                    {
                        AddIndex = AddInfoRow("DownloadFailed");
                    }

                    var f = AddFooterRow();
                    f.Identifier = "SelectInboxFooter";
                }
            }

            IsBusy = false;
        }
Esempio n. 3
0
        public InvitationPage(ServiceNode serviceNode, long todoListId, long accountId = 0) : base("InvitationPage")
        {
            Subscribe <TodoListInvitationSentEvent>(InvitationResult);

            EnableStatus();

            AddTitleRow("Title");

            var todo = TodoApp.Current.GetTodo(serviceNode);

            if (todo.TodoLists.Count == 0)
            {
                AddInfoRow("NoLists");
                return;
            }

            AddHeaderRow("List");

            TodoList @default      = null;
            var      listSelection = new SelectionItemList <TodoList>();

            foreach (var list in todo.TodoLists)
            {
                listSelection.Add(new SelectionItem <TodoList>(list, TodoApp.GetTodoListName(list)));
                if (list.ListId == todoListId)
                {
                    @default = list;
                }
            }

            _listSelection = AddSelectionRows(listSelection, @default);
            _listSelection.SelectionChanged = SelectionChanged;

            Status.Add(T("ListStatus"), (sv) => {
                return(_listSelection.Selection != null);
            });

            AddFooterRow();

            AddHeaderRow("AccountId");

            _accountId = AddEntryRow(accountId > 0 ? accountId.ToString() : null, "AccountId");
            Status.Add(_accountId.Edit, T("AccountStatus"), (sv, edit, n, o) =>
            {
                var valid = StatusValidators.PositiveNumberValidator(sv, edit, n, o);
                if (_profile != null)
                {
                    _profile.IsEnabled = valid;
                    if (valid)
                    {
                        _profile.AccountId = long.Parse(n);
                    }
                    else
                    {
                        _profile.AccountId = 0;
                    }
                }
                return(valid);
            });

            _profile           = AddRow(new ProfileButtonRow(0, Profile));
            _profile.IsEnabled = accountId > 0;
            Status.AddBusyView(_profile);

            AddFooterRow();

            AddIndex       = AddSubmitRow("Submit", Submit);
            AddIndexBefore = true;

            _password = AddPasswordRow("", "Password");
            Status.Add(_password.Edit, T("PasswordStatus"), (sv, edit, newtext, oldtext) => true);

            AddIndex       = null;
            AddIndexBefore = false;

            AddHeaderRow("Common.SubmitAccount");
            _submitAccount = AddRow(new SubmitAccountButtonRow <GroupSubmitAccount>(null, this, SelectSubmitAccount));
            AddInfoRow("Common.SubmitAccountInfo");
            AddFooterRow();

            Status.Add(T("SubmitAccountStatus"), (sv) =>
            {
                return(_submitAccount.SubmitAccount != null);
            });

            SelectionChanged(@default);
        }
Esempio n. 4
0
        public TodoTaskPage(TodoList todoList, TodoTask task) : base("TodoTaskPage")
        {
            Subscribe <NewTodoTaskEvent>(TodoItem);
            Subscribe <TodoTaskStatusEvent>(TodoItemStatus);

            _todoList = todoList;
            _task     = task;

            AddTitleRow("Title");

            AddHeaderRow("StatusHeader");

            var statusItems = new SelectionItemList <TodoTaskStatusTypes>
            {
                new SelectionItem <TodoTaskStatusTypes>(TodoTaskStatusTypes.Open, Tr.Get("ItemStatusTypes.Open")),
                new SelectionItem <TodoTaskStatusTypes>(TodoTaskStatusTypes.Closed, Tr.Get("ItemStatusTypes.Closed"))
            };

            _status = AddSelectionRows(statusItems, task.Status);
            _status.SelectionChanged = StatusChanged;

            _statusButton           = AddSubmitButtonRow("SubmitStatus", StatusButton);
            _statusButton.RowStyle  = Theme.SubmitButton;
            _statusButton.IsEnabled = false;

            _status.Buttons[0].SetDetailViewIcon(Icons.Circle);
            _status.Buttons[1].SetDetailViewIcon(Icons.CircleCheck);

            foreach (var b in _status.Buttons)
            {
                Status.AddBusyView(b);
            }
            Status.AddBusyView(_statusButton);

            AddFooterRow();

            if (task.Status == TodoTaskStatusTypes.Open)
            {
                AddHeaderRow("ItemHeader");

                _text = AddEditorRow(task.Text, "Text");
                _text.SetDetailViewIcon(Icons.Pencil);
                _text.Edit.TextChanged += Edit_TextChanged;

                _textButton           = AddSubmitButtonRow("SubmitText", Submit);
                _textButton.RowStyle  = Theme.SubmitButton;
                _textButton.IsEnabled = false;

                Status.AddBusyView(_text.Edit);
                Status.AddBusyView(_textButton);

                AddFooterRow();
            }

            _history = AddHeaderRow("HistoryHeader");
            AddFooterRow();

            _transactionInfo = AddHeaderRow("TransactionInfo");
            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 delete = AddButtonRow("SubmitDelete", Delete);

            delete.RowStyle = Theme.CancelButton;
            delete.SetDetailViewIcon(Icons.TrashAlt);

            Status.AddBusyView(delete);

            AddFooterRow();

            _ = BuildHistory();
        }