Exemplo n.º 1
0
        public TransferPage(long receiverId = 0, long amount = 0, string reason = null) : base("TransferPage")
        {
            _receiverId = receiverId;

            Subscribe <CoreAccountTransferEvent>(TransferEvent);

            AddTitleRow("Title");

            AddHeaderRow("TransferDetail");

            _receiver = AddEntryRow(null, "Receiver");
            _receiver.SetDetailViewIcon(Icons.Coins);

            if (receiverId > 0)
            {
                _receiver.Edit.Text      = receiverId.ToString();
                _receiver.Edit.IsEnabled = false;
            }

            var showreceiver = AddButtonRow("ReceiverButton", ShowReceiver);

            showreceiver.IsEnabled = false;

            _amount = AddEntryRow(null, "Amount");
            _amount.SetDetailViewIcon(Icons.CreditCardFront);
            if (amount > 0)
            {
                _amount.Edit.Text = Currency.ToString(amount, false);
            }

            _reason = AddEntryRow(null, "Reason");
            _reason.SetDetailViewIcon(Icons.Pencil);
            _reason.Edit.Text = reason;

            _reason.Edit.TextChanged += (sender, e) =>
            {
                var txt = e.NewTextValue;
                if (!string.IsNullOrEmpty(txt) && txt.Length > AccountUpdateOperation.MaxReasonLength)
                {
                    _reason.Edit.Text = txt.Substring(0, AccountUpdateOperation.MaxReasonLength);
                }
            };

            AddFooterRow();

            Status.Add(_receiver.Edit, T("ReceiverStatus"), (sv, edit, newText, oldText) =>
            {
                return(showreceiver.IsEnabled = StatusValidators.PositiveNumberValidator(sv, edit, newText, oldText));
            }).
            Add(_amount.Edit, T("AmountStatus"), StatusValidators.HeleusCoinValidator).
            AddBusyView(showreceiver).
            AddBusyView(_reason.Edit);

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

            _password = AddPasswordRow(null, "Password");

            Status.Add(_password.Edit, T("PasswordStatus"), StatusValidators.HeleusPasswordValidator);
        }
Exemplo n.º 2
0
        public VerifyPage(VerificationResult result) : base("VerifyPage")
        {
            Subscribe <ServiceNodesLoadedEvent>(ServiceNodesLoaded);

            var viewResult = result != null;

            AddTitleRow("Title");

            if (!viewResult)
            {
                AddHeaderRow("Search");

                _transactionId = AddEntryRow(null, "TransactionId");
                _transactionId.SetDetailViewIcon(Icons.ShieldCheck);
                _transactionId.Edit.TextChanged += (sender, e) =>
                {
                    StatusValidators.PositiveNumberValidator(null, _transactionId.Edit, e.NewTextValue, e.OldTextValue);
                };

                AddSubmitRow("SearchButton", Search, false);
                AddInfoRow("SearchInfo");
                AddFooterRow();
            }

            _verifyButton           = AddButtonRow("VerifyFile", VerifyFile);
            _verifyButton.RowStyle  = Theme.SubmitButton;
            _verifyButton.IsEnabled = false;

            _verifyView = new VerifyView();
            AddViewRow(_verifyView);

            _viewFiles           = AddButtonRow("ViewFiles", ViewFiles);
            _viewFiles.IsEnabled = false;

            _link                     = AddLinkRow("Link", "");
            _link.IsEnabled           = false;
            _verifyLink               = AddLinkRow("VerifyLink", "");
            _verifyLink.IsEnabled     = false;
            _copyVerifyLink           = AddButtonRow("CopyVerifyLink", Copy);
            _copyVerifyLink.IsEnabled = false;
            _account                  = AddButtonRow("Account", Account);
            _account.IsEnabled        = false;

            AddFooterRow();

            if (!viewResult)
            {
                AddHeaderRow("Common.ServiceNode");
                _serviceNode = AddRow(new ServiceNodeButtonRow(VerifyApp.Current.GetLastUsedServiceNode(), this, SelectServiceNode));
                AddInfoRow("Common.ServiceNodeInfo");
                AddFooterRow();
            }

            if (viewResult)
            {
                Update(result);
            }
        }
        public BuyPurchasePage(int chainId = 0, int purchaseId = 0) : base(chainId, "BuyPurchasePage")
		{
            if (chainId > 0 && purchaseId > 0)
                _purchaseId = purchaseId;

            Subscribe<PurchaseEvent>(Purchased);

            SetupPage();

            AddHeaderRow("PurchaseInfo");

            _selectPurchase = AddButtonRow("SelectPurchase", SelectPurchase);
            _selectPurchase.IsEnabled = false;

            _purchaseIdText = AddEntryRow(null, "PurchaseId");
            _purchaseView = new PurchaseInfoView();
            AddViewRow(_purchaseView);

            AddFooterRow();

            Status.Add(_purchaseIdText.Edit, T("PurchaseStatus"), (sv, edit, newText, oldText) =>
            {
                if(_chainInfo != null && StatusValidators.PositiveNumberValidator(sv, edit, newText, oldText))
                {
                    if(int.TryParse(newText, out var id))
                    {
                        var purchase = _chainInfo.GetPurchase(id);
                        if(purchase != null)
                        {
                            _purchaseView.Update(purchase);
                            return true;
                        }
                    }
                }
                _purchaseView.Reset();
                return false;
            });

            AddSubmitSection();
		}
Exemplo n.º 4
0
        protected void SetupPage()
        {
            AddTitleRow("Title");

            AddHeaderRow("Service");

#pragma warning disable RECS0021 // Warns about calls to virtual member functions occuring in the constructor
            PreAddRows();
#pragma warning restore RECS0021 // Warns about calls to virtual member functions occuring in the constructor

            _chainIdText = AddEntryRow(null, "ChainInfoBasePage.ChainId");
            _chainIdText.SetDetailViewIcon(Icons.Link);

            if (_chainId > 0)
            {
                _chainIdText.Edit.Text      = _chainId.ToString();
                _chainIdText.Edit.IsEnabled = false;
            }

            _chainView = new ChainInfoView();
            AddViewRow(_chainView);
            _link           = AddLinkRow("ChainInfoBasePage.ChainLink", "");
            _link.IsEnabled = false;

            _account = AddButtonRow("ChainInfoBasePage.AccountProfile", Account);
            _account.SetDetailViewIcon(Icons.Coins);
            _account.IsEnabled = false;

#pragma warning disable RECS0021 // Warns about calls to virtual member functions occuring in the constructor
            PostAddRows();
#pragma warning restore RECS0021 // Warns about calls to virtual member functions occuring in the constructor

            AddFooterRow();

            Status.Add(_chainIdText.Edit, T("ChainInfoBasePage.ChainIdStatus"), (sv, edit, newText, oldText) =>
            {
                var success = false;
                if (StatusValidators.PositiveNumberValidator(sv, edit, newText, oldText))
                {
                    if (int.TryParse(newText, out var id))
                    {
                        if (_chainInfo != null && _chainInfo.ChainId == id)
                        {
                            success = true;
                        }
                        else
                        {
                            _ = QueryChainInfo(id);
                        }
                    }
                }
                else
                {
                    _queryChainId = -1;
                    _chainInfo    = null;
                    QueryDone(-1, null);
                    UIApp.Run(() => QueryDoneAsync(-1, null));
                }

                _chainView.Update(_chainInfo);
                if (_chainInfo != null)
                {
                    if (!string.IsNullOrEmpty(_chainInfo.Website))
                    {
                        _link.IsEnabled = true;
                        _link.Tag       = _chainInfo.Website;
                    }
                    _account.IsEnabled = true;
                }
                else
                {
                    _link.IsEnabled    = false;
                    _account.IsEnabled = false;
                }

                ChainInfoChanged();

                return(success);
            });
        }
Exemplo n.º 5
0
        public PurchasePage(ChainPage chainPage, List <ChainItem <PurchaseInfo> > purchases) : base("PurchasePage")
        {
            _chainPage = chainPage;

            AddTitleRow("Title");

            AddHeaderRow("Type");

            _type = AddSelectionRows(new SelectionItem <PurchaseTypes>[] {
                new SelectionItem <PurchaseTypes>(PurchaseTypes.Feature, Tr.Get("PurchaseTypes.Feature")),
                new SelectionItem <PurchaseTypes>(PurchaseTypes.Subscription, Tr.Get("PurchaseTypes.Subscription"))
            }, PurchaseTypes.Feature);

            AddFooterRow();

            AddHeaderRow("Ids");

            _purchaseId = AddEntryRow(null, "PurchaseId");
            _purchaseId.SetDetailViewIcon(Icons.CreditCardFront);
            _groupId = AddEntryRow(null, "GroupId");
            _groupId.SetDetailViewIcon(Icons.LayerGroup);

            AddFooterRow("IdsInfo");

            AddHeaderRow("Info");

            _description = AddEntryRow(null, "Description");
            _description.SetDetailViewIcon(Icons.AlignLeft);
            _price = AddEntryRow(null, "Price");
            _price.SetDetailViewIcon(Icons.MoneyBillAlt, 22);

            _duration = AddEntryRow(null, "Duration");
            _duration.SetDetailViewIcon(Icons.Stopwatch);

            AddFooterRow();

            Status.Add(_purchaseId.Edit, T("PurchaseIdStatus"), (sv, entry, newText, oldText) =>
            {
                if (int.TryParse(newText, out var id))
                {
                    foreach (var p in purchases)
                    {
                        if (p.Item.PurchaseItemId == id)
                        {
                            return(false);
                        }
                    }
                    return(true);
                }

                if (!newText.IsNullOrEmpty())
                {
                    entry.Text = oldText;
                }

                return(false);
            }).Add(_groupId.Edit, T("GroupIdStatus"), (sv, entry, newText, oldText) =>
            {
                if (short.TryParse(newText, out var id))
                {
                    foreach (var p in purchases)
                    {
                        if (p.Item.PurchaseGroupId == id && _type.Selection != p.Item.PurchaseType)
                        {
                            return(false);
                        }
                    }
                    return(true);
                }

                if (!newText.IsNullOrEmpty())
                {
                    entry.Text = oldText;
                }

                return(false);
            }).Add(_description.Edit, T("DescriptionStatus"), (sv, entry, newText, oldText) =>
            {
                return(!string.IsNullOrWhiteSpace(newText));
            }).Add(_price.Edit, T("PriceStatus"), StatusValidators.HeleusCoinValidator).
            Add(_duration.Edit, T("DurationStatus"), (sv, entry, newText, oldText) =>
            {
                if (_type.Selection == PurchaseTypes.Feature)
                {
                    if (!newText.IsNullOrEmpty())
                    {
                        entry.Text = oldText;
                    }
                    return(true);
                }

                return(StatusValidators.PositiveNumberValidator(sv, entry, newText, oldText));
            });

            _type.SelectionChanged = (item) =>
            {
                Status.ReValidate();
                return(Task.CompletedTask);
            };

            AddSubmitRow("Submit", Submit);
        }
Exemplo n.º 6
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);
        }