Пример #1
0
        public void AddUpdateFile(VerifyFileJson verifyItem)
        {
            var buttons = GetHeaderSectionRows("Files");

            foreach (var button in buttons)
            {
                if (button.Tag == verifyItem)
                {
                    var v = (button as ButtonRow).RowLayout.Children.Last() as VerifyFileView;
                    v.Update(verifyItem);
                    Status.ReValidate();
                    return;
                }
            }

            AddIndex       = _addButton;
            AddIndexBefore = true;

            var view = new VerifyFileView(true);

            view.Update(verifyItem);

            var newButton = AddButtonViewRow(view, EditFile);

            newButton.Tag = verifyItem;
            Status.AddBusyView(newButton);
            Status.ReValidate();
        }
Пример #2
0
        public RestorePage() : base("RestorePage")
        {
            EnableStatus();

            AddTitleRow("Title");

            AddHeaderRow("Account");

            _accountId = AddEntryRow(null, "AccountId");
            _accountId.SetDetailViewIcon(Icons.Coins);

            AddSeparatorRow();

            _name = AddEntryRow("", "RegisterPage.Name");
            _name.SetDetailViewIcon(Icons.Pencil);
            _password1 = AddPasswordRow("", "RegisterPage.Password1");
            var password2 = AddPasswordRow("", "RegisterPage.Password2");

            Status.AddBusyView(_accountId);
            Status.Add(_accountId.Edit, T("AccountStatus"), StatusValidators.PositiveNumberValidator);

            Status.Add(_password1.Edit, T("RegisterPage.PasswordStatus", WalletApp.MinPasswordLength), (sv, entry, newText, oldText) =>
            {
                var pw1 = _password1.Edit.Text;
                var pw2 = password2.Edit.Text;

                return(WalletApp.IsValidPassword(pw1) && WalletApp.IsValidPassword(pw2) && pw1 == pw2);
            }).
            AddBusyView(password2);

            AddFooterRow();


            AddHeaderRow("AuthorizeAccountPage.SignatureKey");

            _passphrase = AddEntryRow(null, "AuthorizeAccountPage.Passphrase", ServiceNodeManager.MinimumServiceAccountPassphraseLength);
            var button = AddButtonRow("AuthorizeAccountPage.NewPassphrase", Generate);

            Status.AddBusyView(button);

            _key = AddEditorRow(null, "AuthorizeAccountPage.SignatureKey");
            _key.SetDetailViewIcon(Icons.Key);
            Status.Add(_key.Edit, T("RestoreAccountPage.KeyStatus"), (sv, edit, newText, oldText) =>
            {
                return(StatusValidators.HexValidator(64, sv, edit, newText, oldText));
            });

            AddFooterRow();


            password2.Edit.TextChanged += (sender, e) =>
            {
                Status.ReValidate();
            };

            AddSubmitRow("Restore", Restore);
        }
Пример #3
0
        void AddProfileButton(ProfileItemJson profileItem)
        {
            if (profileItem.p == ProfileItemJson.BioItem || profileItem.p == ProfileItemJson.ProfileNameItem || profileItem.p == ProfileItemJson.RealNameItem)
            {
                return;
            }

            var button = AddButtonRow(null, ProfileItemSelect);

            button.SetMultilineText(profileItem.k, profileItem.v);
            button.Tag = new ProfileItemJson(profileItem);

            Status.AddBusyView(button);
        }
Пример #4
0
        public override async Task InitAsync()
        {
            var accounts = await GroupAdministration.DownloadAccounts(_todoList.ServiceNode.Client, ChainType.Data, _todoList.ServiceNode.ChainId, TodoServiceInfo.GroupChainIndex, _todoList.ListId);

            var pendingAccounts = await GroupAdministration.DownloadPendingAccounts(_todoList.ServiceNode.Client, ChainType.Data, _todoList.ServiceNode.ChainId, TodoServiceInfo.GroupChainIndex, _todoList.ListId);

            IsBusy = false;

            if (accounts?.Item == null || pendingAccounts?.Item == null)
            {
                InfoFrame("DownloadFailed");
                return;
            }

            if (accounts.Item.Count > 0)
            {
                AddHeaderRow("ActiveUsers");
                foreach (var account in accounts.Item)
                {
                    var b = AddRow(new ProfileButtonRow(account.Key, User));
                    b.Tag = false;
                    Status.AddBusyView(b);
                }
                AddFooterRow();
            }

            if (pendingAccounts.Item.Count > 0)
            {
                AddHeaderRow("PendingUsers");
                foreach (var account in pendingAccounts.Item)
                {
                    var b = AddRow(new ProfileButtonRow(account.Key, User));
                    b.Tag = true;
                    Status.AddBusyView(b);
                }

                AddFooterRow();
            }

            AddHeaderRow("Invite");

            var invite = AddButtonRow("InviteButton", Invite);

            invite.RowStyle = Theme.SubmitButton;

            Status.AddBusyView(invite);

            AddFooterRow();
        }
Пример #5
0
        VerificationFilePage(AddVerificationPage verificationPage, VerifyFileJson verifyItem, OpenFile file = null) : base("VerificationFilePage")
        {
            _verificationPage = verificationPage;
            _item             = verifyItem ?? new VerifyFileJson();

            AddTitleRow("Title");
            AddHeaderRow("File");
            Status.AddBusyView(AddButtonRow("Select", Select));

            _link = AddEntryRow(null, "Link");
            _link.SetDetailViewIcon(Icons.RowLink);

            _verifyView = new VerifyFileView(false);
            AddViewRow(_verifyView);

            if (verifyItem != null)
            {
                _link.Edit.Text = verifyItem.link;
                _fileName       = verifyItem.name;
                _fileHash       = verifyItem.GetHash();
                _length         = verifyItem.length;
                _verifyView.Update(verifyItem);
            }

            Status.Add(_link.Edit, T("LinkStatus"), (view, entry, newText, oldText) =>
            {
                if (string.IsNullOrEmpty(newText))
                {
                    return(true);
                }

                return(newText.IsValdiUrl(true));
            });

            Status.Add(T("FileStatus"), (sv) =>
            {
                return(!string.IsNullOrEmpty(_fileName) && _fileHash != null && _length > 0);
            });

            AddFooterRow();

            AddSubmitRow("Submit", Submit);

            if (file != null)
            {
                UIApp.Run(() => HashFile(file));
            }
        }
Пример #6
0
        public TodoListPage(TodoList todoList, bool edit) : base("TodoListPage")
        {
            Subscribe <QueryTodoListEvent>(QueryTodoList);

            if (edit)
            {
                Subscribe <TodoListNameChangedEvent>(ListName);
                Subscribe <TodoListDeletetEvent>(GroupDeleted);
            }

            TodoList = todoList;
            _edit    = edit;


            var header = AddTitleRow(null);

            header.Identifier = "Title";
            var title = TodoApp.GetTodoListName(todoList);

            header.Label.Text = title;
            SetTitle(title);

            UpdateSecretKeyButton();

            var items = todoList.GetTasks(TodoTaskStatusTypes.Open, TodoListSortMethod.ByTimestampDesc);

            AddHeaderRow("OpenTasks");

            if (items.Count > 0)
            {
                foreach (var item in items)
                {
                    var b = AddTaskButtonRow(item);
                    _openTasks.Add(b);
                }
            }
            else
            {
                AddInfoRow("NoOpenTasks");
            }

            AddFooterRow();

            if (!_edit)
            {
                AddHeaderRow("More");

                var button = AddButtonRow("TodoListView.Add", NewTask);
                //add.Margin = new Thickness(40, 0, 0, 0);
                button.RowStyle           = Theme.SubmitButton;
                button.FontIcon.IsVisible = false;
                button.SetDetailViewIcon(Icons.Plus);
                //add.IsEnabled = !todoList.HasMissingSecretKeys;

                button = AddButtonRow("Edit", Edit);
                button.SetDetailViewIcon(Icons.Pencil);

                button = AddButtonRow("Reload", Reload);
                button.SetDetailViewIcon(Icons.Sync);
                AddFooterRow();
            }

            if (_edit)
            {
                items = todoList.GetTasks(TodoTaskStatusTypes.Closed, TodoListSortMethod.ByTimestampDesc);

                AddHeaderRow("ClosedTasks");
                if (items.Count > 0)
                {
                    foreach (var item in items)
                    {
                        var b = AddTaskButtonRow(item);
                        _closedTasks.Add(b);
                    }
                }
                else
                {
                    AddInfoRow("NoClosedTasks");
                }
                AddFooterRow();

                AddHeaderRow("UsersSection");

                var button = AddButtonRow("ViewUsers", Users);
                button.SetDetailViewIcon(Icons.Users);
                button = AddButtonRow("Invite", Invite);
                button.SetDetailViewIcon(Icons.UserPlus);

                AddFooterRow();

                AddHeaderRow("NameHeader");

                _nameEntry = AddEntryRow(todoList.Name, "Name");
                _nameEntry.SetDetailViewIcon(Icons.Pencil);
                _nameButton          = AddSubmitButtonRow("NameButton", Name);
                _nameButton.RowStyle = Theme.SubmitButton;

                Status.AddBusyView(_nameEntry.Edit);
                Status.AddBusyView(_nameButton);
                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 del = AddButtonRow("DeleteButton", Delete);
                del.RowStyle = Theme.CancelButton;
                del.SetDetailViewIcon(Icons.TrashAlt);

                Status.AddBusyView(del);

                AddFooterRow();
            }
        }
Пример #7
0
        void SetupEdit(ProfileDataResult profileData)
        {
            _profileData = profileData;

            AddHeaderRow("ImageSection");
            _image = AddImageRow(1, "Image");
            if (profileData.Image != null)
            {
                _image.ImageView.Source = ImageSource.FromStream(() => new MemoryStream(profileData.Image));
            }
            else
            {
                _image.ImageView.Source = AccountDummyImage.ImageSource;
            }

            var sel = AddButtonRow("SelectImage", SelectImage);

            sel.SetDetailViewIcon(Icons.UserCircle);
            Status.AddBusyView(sel);
            AddFooterRow();

            AddHeaderRow("EditSection");

            _profileName = AddEntryRow(ProfileItemJson.GetItemValue(profileData.ProfileJsonItems, ProfileItemJson.ProfileNameItem), "ProfileName");
            _profileName.SetDetailViewIcon(Icons.FullName);

            _realName = AddEntryRow(ProfileItemJson.GetItemValue(profileData.ProfileJsonItems, ProfileItemJson.RealNameItem), "RealName");
            _realName.SetDetailViewIcon(Icons.UserAlt);

            _bio = AddEntryRow(ProfileItemJson.GetItemValue(profileData.ProfileJsonItems, ProfileItemJson.BioItem), "Bio");
            _bio.SetDetailViewIcon(Icons.Info);

            Status.Add(_profileName.Edit, T("ProfileNameStatus"), (sv, edit, newValue, oldVAlue) =>
            {
                var valid = ProfileServiceInfo.IsProfileNameValid(newValue);
                if (!valid)
                {
                    edit.Text = ProfileServiceInfo.ToValidProfileName(newValue);
                }
                return(valid);
            });
            Status.Add(_realName.Edit, T("RealNameStatus"), (sv, edit, newValue, oldVAlue) =>
            {
                return(ProfileServiceInfo.IsRealNameValid(newValue));
            });

            Status.Add(_bio.Edit, T("BioStatus"), StatusValidators.NoEmptyString);

            if (profileData.ProfileJsonItems != null)
            {
                foreach (var item in profileData.ProfileJsonItems)
                {
                    AddProfileButton(item);
                }
            }

            Status.AddBusyView(AddButtonRow("AddItemButton", AddItem));

            AddFooterRow();

            AddSubmitRow("Common.Submit", Submit);
        }
Пример #8
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);
        }
Пример #9
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();
        }
Пример #10
0
        public ChainPage(ChainInfo chainInfo, ChainKeyStore chainKey) : base("ChainPage")
        {
            ChainInfo = chainInfo;
            _chainKey = chainKey;
            Subscribe <ChainRegistrationEvent>(Chain);

            if (chainInfo != null)
            {
                var endPoints = chainInfo.GetPublicEndpoints();
                foreach (var endPoint in endPoints)
                {
                    _endPoints.Add(new ChainItem <string>(ChainItemStatus.Live, endPoint));
                }
                foreach (var key in chainInfo.GetRevokeableChainKeys())
                {
                    _chainKeys.Add(new ChainKeyItem(key.IsRevoked ? ChainItemStatus.Revoked : ChainItemStatus.Live, key.Item));
                }
                foreach (var purchase in chainInfo.GetChainPurchases())
                {
                    _purchases.Add(new ChainItem <PurchaseInfo>(purchase.IsRevoked ? ChainItemStatus.Revoked : ChainItemStatus.Live, purchase.Item));
                }
            }

            AddTitleRow("Title");

            AddHeaderRow("Info");
            _name = AddEntryRow(null, "Name");
            _name.SetDetailViewIcon(Icons.Pencil);
            if (chainInfo != null)
            {
                _name.Edit.Text = chainInfo.Name;
            }
            _website = AddEntryRow(null, "Website");
            _website.SetDetailViewIcon(Icons.RowLink);
            if (chainInfo != null)
            {
                _website.Edit.Text = chainInfo.Website;
            }
            AddFooterRow();

            AddHeaderRow("ChainKeys");
            _chainKeysButton = AddButtonRow("ChainKeysButton", NewChainKey);
            Status.AddBusyView(_chainKeysButton);
            AddFooterRow();

            AddHeaderRow("EndPoints");
            _endPointsButton = AddButtonRow("EndPointsButton", NewEndPoint);
            Status.AddBusyView(_endPointsButton);
            AddFooterRow();

            /*
             * AddHeaderRow("Purchases");
             * _purchasesButton = AddButtonRow("PurchasesButton", NewPurchase);
             * Status.AddBusyView(_purchasesButton);
             * AddFooterRow();
             */

            Status.Add(_name.Edit, T("NameStatus"), (view, entry, newText, oldTex) =>
            {
                if (string.IsNullOrEmpty(newText))
                {
                    return(false);
                }

                return(true);
            }).
            Add(_website.Edit, T("WebsiteStatus"), (view, entry, newText, oldText) =>
            {
                if (string.IsNullOrEmpty(newText))
                {
                    return(true);
                }

                return(newText.IsValdiUrl(true));
            });

            _adminKeyStatus = Status.Add(T("AdminKeyStatus"), (sv) =>
            {
                foreach (var key in _chainKeys)
                {
                    if ((key.Status == ChainItemStatus.Live || key.Status == ChainItemStatus.New) && ((key.Item.Flags & PublicChainKeyFlags.ChainAdminKey) != 0))
                    {
                        return(true);
                    }
                }

                return(false);
            });

            _endPointStatus = Status.Add(T("EndPointStatus"), (sv) =>
            {
                return(_endPoints.Any((a) => a.Status == ChainItemStatus.New || a.Status == ChainItemStatus.Live));
            });

            AddIndex       = AddSubmitRow("Submit", Submit);
            AddIndexBefore = true;
            if (_chainKey != null)
            {
                _keyPassword = AddPasswordRow("", "KeyPassword");

                Status.Add(_keyPassword.Edit, T("PasswordStatus"), (sv, entry, newText, oldText) =>
                {
                    return(_chainKey.IsPasswordValid(newText));
                });
            }

            AddIndex       = null;
            AddIndexBefore = false;

            UpdateChainKeys();
            UpdateEndpoints();
            UpdatePurchases();
        }
Пример #11
0
        public ChatPage(Chat chat) : base("ChatPage")
        {
            Subscribe <MessageSentEvent>(MessageSent);
            Subscribe <ChatMessageDownloadEvent>(MessagesDownloaded);

            IsSuspendedLayout = true;

            _node = chat.Node;
            _chat = chat;

            var title = AddTitleRow("Title");

            var friend = chat.Node.GetFriend(chat.FriendAccountId);
            var name   = friend?.Profile?.RealName;

            if (name == null)
            {
                name = $"Account {chat.FriendAccountId}";
            }

            title.Label.Text = name;
            SetTitle(name);

            _text = new EntryRow(Icons.StickyNote);
            _text.Edit.Placeholder = T("TypeText");
            _text.SetDetailViewIcon(Icons.Pencil);

            _text.RowLayout.Children.Remove(_text.FontIcon);
            _text.RowLayout.Children.Remove(_text.Label);

            _text.VerticalOptions   = LayoutOptions.FillAndExpand;
            _text.HorizontalOptions = LayoutOptions.FillAndExpand;

            _submit                 = new ButtonRow(Icons.RowSubmit, Submit);
            _submit.RowStyle        = Theme.SubmitButton;
            _submit.FontIcon.Margin = new Thickness(0, 0, 0, 0);
            _submit.WidthRequest    = _submit.HeightRequest = 40;

            AbsoluteLayout.SetLayoutBounds(_submit.FontIcon, new Rectangle(0.5, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));

            Status.AddBusyView(_submit);
            Status.AddBusyView(_text);

            _text.Edit.TextChanged += Edit_TextChanged;
            Edit_TextChanged(_text.Edit, null);

            var layout = new StackLayout();

            layout.Orientation = StackOrientation.Horizontal;

            layout.Children.Add(_text);
            layout.Children.Add(_submit);

            AddView(layout);

            _listView = new ChatListView(chat, this, layout);

            ToolbarItems.Add(new ExtToolbarItem(T("Info"), null, Info));

            IsBusy = true;
            UIApp.Run(Update);
        }