Skip to content

Commit 3a1ffb2

Browse files
committed
Added contact choose to send dialog
1 parent 1b3f273 commit 3a1ffb2

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

BitStore/Controller/Account/Send/SendViewController.m

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727
#import "AmountView.h"
2828
#import "AmountViewDelegate.h"
2929
#import "HTAutocompleteTextField.h"
30+
#import "ChooseContactsViewController.h"
31+
#import "ChooseContactDelegate.h"
3032

31-
@interface SendViewController () <ScanDelegate, ExchangeListener, AddressListener, AmountViewDelegate, UITextFieldDelegate, HTAutocompleteDataSource, HTAutocompleteTextFieldDelegate>
33+
@interface SendViewController () <ScanDelegate, ExchangeListener, AddressListener, AmountViewDelegate, UITextFieldDelegate, HTAutocompleteDataSource, HTAutocompleteTextFieldDelegate, ChooseContactDelegate>
3234
@end
3335

3436
static double FEE = 10000;
@@ -37,6 +39,7 @@ @implementation SendViewController {
3739
HTAutocompleteTextField* _addressField;
3840
AmountView* _amountView;
3941
UILabel* _infoLabel;
42+
ChooseContactsViewController* _chooseContactsViewController;
4043
ScanNavigationController* _scanViewController;
4144
Exchange* _exchange;
4245
Address* _address;
@@ -93,7 +96,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
9396
UITableViewCell* cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
9497
cell.selectionStyle = UITableViewCellSelectionStyleNone;
9598
if (indexPath.row == 0) {
96-
_addressField = [[HTAutocompleteTextField alloc] initWithFrame:CGRectMake(16, 16, self.view.frame.size.width - 70, 30)];
99+
_addressField = [[HTAutocompleteTextField alloc] initWithFrame:CGRectMake(16, 16, self.view.frame.size.width - 108, 30)];
97100
_addressField.placeholder = l10n(@"contact_or_btc_address");
98101
_addressField.autocompleteDataSource = self;
99102
_addressField.autoCompleteTextFieldDelegate = self;
@@ -111,6 +114,11 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
111114
[scanButton addTarget:self action:@selector(scan:) forControlEvents:UIControlEventTouchUpInside];
112115
[cell.contentView addSubview:scanButton];
113116

117+
UIButton* contactButton = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width - 82, 14, 32, 32)];
118+
[contactButton setImage:[UIImage imageNamed:@"user"] forState:UIControlStateNormal];
119+
[contactButton addTarget:self action:@selector(chooseContact:) forControlEvents:UIControlEventTouchUpInside];
120+
[cell.contentView addSubview:contactButton];
121+
114122
_amountView = [[AmountView alloc] initWithDelegate:self frame:CGRectMake(0, 58, self.view.frame.size.width, 60)];
115123
_amountView.amountField.returnKeyType = UIReturnKeyNext;
116124
[cell.contentView addSubview:_amountView];
@@ -225,6 +233,12 @@ - (void)scan:(id)sender {
225233
[self presentViewController:_scanViewController animated:YES completion:nil];
226234
}
227235

236+
- (void)chooseContact:(id)sender {
237+
_chooseContactsViewController = [[ChooseContactsViewController alloc] init];
238+
_chooseContactsViewController.delegate = self;
239+
[self.navigationController pushViewController:_chooseContactsViewController animated:YES];
240+
}
241+
228242
- (void)setAddress:(NSString *)address amount:(NSString *)amount {
229243
[self setAddressText:[[ContactHelper instance].contactList displayTextForAddress:address]];
230244
if (amount) {
@@ -293,8 +307,17 @@ - (void)amountValueChanged:(BTCSatoshi)satoshi {
293307
- (void)scannedAddress:(NSString *)address amount:(NSString *)amount {
294308
[_scanViewController dismissViewControllerAnimated:YES completion:nil];
295309
[self setAddress:address amount:amount];
310+
[_amountView becomeFirstResponder];
296311
}
297312

313+
#pragma mark - ChooseContactDelegate
314+
- (void)choseContact:(Address *)contact {
315+
[_chooseContactsViewController.navigationController popViewControllerAnimated:YES];
316+
[self setAddressText:contact.address];
317+
[_amountView becomeFirstResponder];
318+
}
319+
320+
298321
#pragma mark - Send TX
299322
- (void)startSend {
300323
_loadingAlert = [[UIAlertView alloc] init];

0 commit comments

Comments
 (0)