Skip to content
This repository was archived by the owner on Nov 10, 2022. It is now read-only.

Commit 4afe9c1

Browse files
committed
MAKE A SEND WORK! :O
1 parent 7bc9e36 commit 4afe9c1

File tree

3 files changed

+47
-27
lines changed

3 files changed

+47
-27
lines changed

Chaincase/ViewModels/SendViewModel.cs

+16-15
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,10 @@ public class SendViewModel : ViewModelBase
2121
private string _password;
2222
private string _address;
2323
private bool _isBusy;
24-
private string _label;
24+
private string _memo;
2525
private string _amountText;
2626
private CoinListViewModel _coinList;
27-
28-
public string Address
29-
{
30-
get => Address;
31-
set => this.RaiseAndSetIfChanged(ref _address, value);
32-
}
27+
private string _warning;
3328

3429
public SendViewModel(IScreen hostScreen) : base(hostScreen)
3530
{
@@ -72,7 +67,7 @@ public SendViewModel(IScreen hostScreen) : base(hostScreen)
7267
{
7368
IsBusy = true;
7469
Password = Guard.Correct(Password);
75-
Label = Label.Trim(',', ' ').Trim();
70+
Memo = Memo.Trim(',', ' ').Trim();
7671

7772
var selectedCoinViewModels = CoinList.Coins.Where(cvm => cvm.IsSelected);
7873
var selectedCoinReferences = selectedCoinViewModels.Select(cvm => new TxoRef(cvm.Model.TransactionId, cvm.Model.Index)).ToList();
@@ -107,8 +102,8 @@ public SendViewModel(IScreen hostScreen) : base(hostScreen)
107102
return;
108103
}
109104

110-
var label = Label;
111-
var operation = new WalletService.Operation(script, amount, label);
105+
var memo = Memo;
106+
var operation = new WalletService.Operation(script, amount, memo);
112107

113108
var feeTarget = 500;
114109
var result = await Task.Run(() => Global.WalletService.BuildTransaction(Password, new[] { operation }, feeTarget, allowUnconfirmed: true, allowedInputs: selectedCoinReferences));
@@ -131,9 +126,10 @@ public SendViewModel(IScreen hostScreen) : base(hostScreen)
131126
{
132127
IsBusy = false;
133128
}
134-
});
129+
},
135130
this.WhenAny(x => x.AmountText, x => x.Address, x => x.IsBusy,
136-
(amountText, address, busy) => !string.IsNullOrWhiteSpace(amountText.Value) && !string.IsNullOrWhiteSpace(Address) && !IsBusy);
131+
(amountText, address, busy) => !string.IsNullOrWhiteSpace(amountText.Value) && !string.IsNullOrWhiteSpace(address.Value) && !busy.Value)
132+
.ObserveOn(RxApp.MainThreadScheduler));
137133
}
138134

139135
public string Password
@@ -142,6 +138,11 @@ public string Password
142138
set => this.RaiseAndSetIfChanged(ref _password, value);
143139
}
144140

141+
public string Address
142+
{
143+
get => _address;
144+
set => this.RaiseAndSetIfChanged(ref _address, value);
145+
}
145146

146147
public bool IsBusy
147148
{
@@ -155,10 +156,10 @@ public string AmountText
155156
set => this.RaiseAndSetIfChanged(ref _amountText, value);
156157
}
157158

158-
public string Label
159+
public string Memo
159160
{
160-
get => _label;
161-
set => this.RaiseAndSetIfChanged(ref _label, value);
161+
get => _memo;
162+
set => this.RaiseAndSetIfChanged(ref _memo, value);
162163
}
163164

164165
public CoinListViewModel CoinList

Chaincase/Views/SendPage.xaml

+11-12
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@
88
xmlns="http://xamarin.com/schemas/2014/forms">
99
<StackLayout>
1010
<Label Text="PAY TO THE ORDER OF:" />
11-
<Entry Placeholder="bc1qa24tsgchvuxsaccp8vrnkfd85hrcpafg20kmjw"
12-
Text="{Binding PayToTheOrderOf}" />
11+
<Entry Placeholder="bc1qa24tsgchvuxsaccp8vrnkfd85hrcpafg20kmjw"
12+
x:Name="Address" />
1313
<Label Text="BTC" />
14-
<Entry BackgroundColor="#ccc"
15-
Text="{Binding Amount}"
16-
x:Name="Amount"/>
14+
<Entry BackgroundColor="#ccc"
15+
x:Name="Amount" />
1716
<Label Text="MEMO:" />
18-
<Entry Placeholder="BTCPayServer Hosting 2020"
19-
Text="{Binding Memo}" />
17+
<Entry Placeholder="BTCPayServer Hosting 2020"
18+
x:Name="Memo" />
2019
<Label Text="PASSWORD" />
2120
<Entry IsPassword="true"
22-
Text="{Binding Password}"
23-
Placeholder="+9m{S5>aegs?*MZ^" />
24-
<Button Text="Send"
25-
Command="{Binding SendCommand}" />
26-
<templates:CoinListTemplate x:Name="CoinList"
21+
Placeholder="+9m{S5>aegs?*MZ^"
22+
x:Name="Password" />
23+
<Button Text="Send"
24+
x:Name="Send" />
25+
<templates:CoinListTemplate x:Name="CoinList"
2726
VerticalOptions="FillAndExpand" />
2827
</StackLayout>
2928
</rxui:ReactiveContentPage>

Chaincase/Views/SendPage.xaml.cs

+20
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@ public SendPage()
1313

1414
this.WhenActivated(disposables =>
1515
{
16+
this.Bind(ViewModel,
17+
vm => vm.Address,
18+
v => v.Address.Text)
19+
.DisposeWith(disposables);
20+
this.Bind(ViewModel,
21+
vm => vm.AmountText,
22+
v => v.Amount.Text)
23+
.DisposeWith(disposables);
24+
this.Bind(ViewModel,
25+
vm => vm.Memo,
26+
v => v.Memo.Text)
27+
.DisposeWith(disposables);
28+
this.Bind(ViewModel,
29+
vm => vm.Password,
30+
v => v.Password.Text)
31+
.DisposeWith(disposables);
32+
this.BindCommand(ViewModel,
33+
vm => vm.BuildTransactionCommand,
34+
v => v.Send)
35+
.DisposeWith(disposables);
1636
this.OneWayBind(ViewModel,
1737
vm => vm.CoinList,
1838
v => v.CoinList.ViewModel)

0 commit comments

Comments
 (0)