public AddressViewModel(ReceiveAddressesViewModel parent, Wallet wallet, HdPubKey model, Network network) { _address = model.GetP2wpkhAddress(network).ToString(); Label = model.Label; CopyAddressCommand = ReactiveCommand.CreateFromTask(async() => { if (Application.Current is { Clipboard: { } clipboard }) { await clipboard.SetTextAsync(Address); } });
public AddressLabelEditViewModel(ReceiveAddressesViewModel owner, HdPubKey hdPubKey, KeyManager keyManager, HashSet <string> suggestions) { Suggestions = suggestions; _labels = new(hdPubKey.Label); SetupCancel(enableCancel: true, enableCancelOnEscape: true, enableCancelOnPressed: true); Labels .WhenAnyValue(x => x.Count) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => FinalLabel = new SmartLabel(Labels)); var canExecute = this.WhenAnyValue(x => x.FinalLabel, x => x.IsCurrentTextValid) .Select(tup => { var(finalLabel, isCurrentTextValid) = tup; return(finalLabel is { IsEmpty: false } || isCurrentTextValid); });
public AddressLabelEditViewModel(ReceiveAddressesViewModel owner, HdPubKey hdPubKey, KeyManager keyManager) { SuggestionLabels = new SuggestionLabelsViewModel(keyManager, Intent.Receive, 3, hdPubKey.Label); SetupCancel(enableCancel: true, enableCancelOnEscape: true, enableCancelOnPressed: true); var canExecute = this.WhenAnyValue(x => x.SuggestionLabels.Labels.Count, x => x.IsCurrentTextValid) .Select(tup => { var(labelsCount, isCurrentTextValid) = tup; return(labelsCount > 0 || isCurrentTextValid); }); NextCommand = ReactiveCommand.Create( () => { hdPubKey.SetLabel(new SmartLabel(SuggestionLabels.Labels), kmToFile: keyManager); owner.InitializeAddresses(); Navigate().Back(); }, canExecute); }