Beispiel #1
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);
        }
 public static bool HeleusPasswordValidator(StatusView statusView, ExtEntry edit, string newText, string oldText)
 {
     return(WalletApp.IsValidPassword(newText));
 }
        public RegisterPage() : base("RegisterPage")
        {
            EnableStatus();

            Subscribe <CoreAccountRegisterEvent>(AccountRegistered);

            AddTitleRow("Title");

            AddHeaderRow("NewAccount");

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

            Status.Add(_password1.Edit, T("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();

            AddLinkRow("Common.DataLicence", Tr.Get("Link.DataLicence"));
            var _agree = AddSwitchRow("Agree", Tr.Get("Common.DataLicence"));

            AddFooterRow();

            Status.

            Add(_agree.Switch, T("AgreeStatus", Tr.Get("Common.DataLicence")), StatusValidators.IsToggled);

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

            AddSubmitRow("Register", Register);

            AddHeaderRow("SignatureKeyInfo");

            _selectionRow = AddSelectionRows(new SelectionItemList <AuthorizeType>
            {
                new SelectionItem <AuthorizeType>(AuthorizeType.Random, Tr.Get("AuthorizeType.Random")),
                new SelectionItem <AuthorizeType>(AuthorizeType.Passphrase, Tr.Get("AuthorizeType.Passphrase"))
            }, AuthorizeType.Random);
            _selectionRow.SelectionChanged = SecretTypeChanged;

            AddSeparatorRow();

            _keyRow = AddEditorRow("", "SignatureKey");
            _keyRow.SetDetailViewIcon(Icons.Key);

            Status.Add(_keyRow.Edit, T("AuthorizeAccountPage.KeyStatus"), (sv, edit, newText, oldText) =>
            {
                return(StatusValidators.HexValidator(64, sv, edit, newText, oldText));
            });

            AddInfoRow("AuthorizeAccountPage.SignatureKeyInfo");

            AddFooterRow();

            AddHeaderRow();
            AddLinkRow("Common.TermsOfUse", Tr.Get("Link.TermsOfUse"));
            AddLinkRow("Common.Privacy", Tr.Get("Link.Privacy"));
            AddFooterRow();

            IsBusy = true;
            Update();
        }
Beispiel #4
0
        public ChainKeyPage(ChainPage chainPage, List <ChainKeyItem> chainKeys) : base("ChainKeyPage")
        {
            _chainPage = chainPage;

            AddTitleRow("Title");

            AddHeaderRow("Key");

            _name = AddEntryRow(null, "Name");
            _name.SetDetailViewIcon(Icons.Pencil);

            _key = AddEditorRow(null, "Key");
            _key.SetDetailViewIcon(Icons.Key);

            AddButtonRow("KeyButton", NewKey);

            _keyIndex = AddEntryRow(string.Empty, "KeyIndex");
            _keyIndex.SetDetailViewIcon(Icons.Highlighter);

            AddFooterRow();

            AddHeaderRow("KeyOptions");

            _admin       = AddSwitchRow("Admin");
            _serviceKey  = AddSwitchRow("ServiceKey");
            _serviceVote = AddSwitchRow("ServiceVote");
            _dataKey     = AddSwitchRow("DataKey");
            _dataVote    = AddSwitchRow("DataVote");
            _chainIndex  = AddEntryRow(string.Empty, "ChainIndex");

            _admin.Switch.Toggled = (swt) =>
            {
                if (swt.IsToggled)
                {
                    _serviceKey.Switch.IsToggled  = false;
                    _serviceVote.Switch.IsToggled = false;
                    _dataKey.Switch.IsToggled     = false;
                    _dataVote.Switch.IsToggled    = false;
                    _chainIndex.Edit.Text         = null;
                }
                Status.ReValidate();
            };

            _serviceKey.Switch.Toggled = (swt) =>
            {
                if (swt.IsToggled)
                {
                    _admin.Switch.IsToggled    = false;
                    _dataKey.Switch.IsToggled  = false;
                    _dataVote.Switch.IsToggled = false;
                    _chainIndex.Edit.Text      = null;
                }
                else
                {
                    _serviceVote.Switch.IsToggled = false;
                }
                Status.ReValidate();
            };

            _serviceVote.Switch.Toggled = (swt) =>
            {
                if (swt.IsToggled)
                {
                    _serviceKey.Switch.IsToggled = true;
                }
            };

            _dataKey.Switch.Toggled = (swt) =>
            {
                if (swt.IsToggled)
                {
                    _admin.Switch.IsToggled       = false;
                    _serviceKey.Switch.IsToggled  = false;
                    _serviceVote.Switch.IsToggled = false;
                }
                else
                {
                    _dataVote.Switch.IsToggled = false;
                }
                Status.ReValidate();
            };

            _dataVote.Switch.Toggled = (swt) =>
            {
                if (swt.IsToggled)
                {
                    _dataKey.Switch.IsToggled = true;
                }
            };

            AddFooterRow();

            AddHeaderRow("Password");

            _pw1 = AddEntryRow(string.Empty, "Password");
            _pw1.SetDetailViewIcon(Icons.Unlock);
            _pw2 = AddEntryRow(string.Empty, "Password2");
            _pw2.SetDetailViewIcon(Icons.Unlock);
            _pw1.Edit.IsPassword = _pw2.Edit.IsPassword = true;

            AddFooterRow();

            Status.Add(_key.Edit, T("KeyStatus"), (view, entry, newText, oldtext) =>
            {
                try
                {
                    var key = Key.Restore(entry.Text);
                    return(key.KeyType == Protocol.TransactionKeyType);
                }
                catch { }
                return(false);
            }).
            Add(_keyIndex.Edit, T("KeyIndexStatus", short.MinValue, short.MaxValue), (view, entry, newText, oldText) =>
            {
                if (short.TryParse(newText, out var idx))
                {
                    foreach (var key in chainKeys)
                    {
                        if (key.Item.KeyIndex == idx)
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
                if (!newText.IsNullOrEmpty())
                {
                    entry.Text = oldText;
                }
                return(false);
            }).
            Add(_chainIndex.Edit, T("ChainIndexStatus"), (view, entry, newText, oldText) =>
            {
                if (_dataKey.Switch.IsToggled)
                {
                    return(StatusValidators.PositiveNumberValidatorWithZero(view, entry, newText, oldText));
                }

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

                return(true);
            }).
            Add(_name.Edit, T("NameStatus"), (view, entry, newText, oldtext) =>
            {
                return(!newText.IsNullOrWhiteSpace());
            }).
            Add(_pw1.Edit, T("PasswordStatus", WalletApp.MinPasswordLength), (view, entry, newText, oldtext) =>
            {
                var pw1 = _pw1.Edit.Text;
                var pw2 = _pw2.Edit.Text;

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

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

            AddSubmitRow("Submit", Submit);
        }
Beispiel #5
0
 void UnlockPasswordChanged(object sender, Xamarin.Forms.TextChangedEventArgs e)
 {
     _unlockButton.IsEnabled = WalletApp.IsValidPassword(_unlockPassword.Edit.Text);
 }