public EndpointPage(ChainPage chainPage, List <ChainItem <string> > endPoints) : base("EndpointPage") { _chainPage = chainPage; _endPoints = endPoints; AddTitleRow("Title"); AddHeaderRow("EndPoint"); _endPoint = AddEntryRow("https://", "EndPoint"); _endPoint.Edit.TextChanged += Entry_TextChanged; _endPoint.SetDetailViewIcon(Icons.RowLink); AddFooterRow("EndPointInfo"); _submit = AddSubmitRow("Submit", Submit); _submit.IsEnabled = false; }
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); }
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); }