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);
            });
        }
        public override async Task InitAsync()
        {
            if (!IsBusy)
            {
                return;
            }

            var name = TodoApp.GetTodoListName(null);

            var nameId = await Group.DownloadIndexLastTransactionInfo(_serviceNode.Client, Chain.ChainType.Data, _serviceNode.ChainId, TodoServiceInfo.TodoDataChainIndex, _invitation.ListId, TodoServiceInfo.TodoListNameIndex);

            if (nameId?.Item?.TransactionId != Operation.InvalidTransactionId)
            {
                var nameTransaction = (await _serviceNode.Client.DownloadDataTransactionItem(_serviceNode.ChainId, TodoServiceInfo.TodoDataChainIndex, nameId.Item.TransactionId)).Data?.Transaction;
                if (nameTransaction != null)
                {
                    var encryptedRecord = TodoList.GetEncrytpedTodoRedord <TodoListNameRecord>(nameTransaction);
                    var record          = await encryptedRecord.GetRecord(_invitation.SecretKey);

                    if (record != null)
                    {
                        name = record.Name;
                    }
                }
            }

            IsBusy = false;

            AddViewRow(new InvitationView(name, _invitation.SenderAccountId));
            AddButtonRow("Profile", Profile);

            AddSubmitRow("Submit", Submit);

            AddHeaderRow("Common.SubmitAccount");
            _submitAccount = AddRow(new SubmitAccountButtonRow(this, () => _serviceNode.GetSubmitAccounts <SubmitAccount>(TodoServiceInfo.TodoSubmitIndex)));
            AddInfoRow("Common.SubmitAccountInfo");
            AddFooterRow();
        }
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);
        }