File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change 25
25
#import " OTPTokenEntryViewController.h"
26
26
27
27
28
+ @protocol OTPTokenEditorDelegate <OTPTokenSourceDelegate>
29
+
30
+ - (void )tokenSource : (id )tokenSource didEditToken : (OTPToken *)token ;
31
+
32
+ @end
33
+
34
+
28
35
@interface OTPTokenEditViewController : OTPTokenEntryViewController
29
36
37
+ @property (nonatomic , weak ) id <OTPTokenEditorDelegate> delegate;
38
+
30
39
@property (nonatomic , strong ) OTPToken *token;
31
40
32
41
@end
Original file line number Diff line number Diff line change 24
24
25
25
#import " OTPTokenEditViewController.h"
26
26
#import " OTPTextFieldCell.h"
27
- #import " OTPToken.h"
27
+ #import " OTPToken+Persistence .h"
28
28
29
29
30
30
@interface OTPTokenEntryViewController () <UITextFieldDelegate>
@@ -71,8 +71,17 @@ - (void)setToken:(OTPToken *)token
71
71
72
72
- (void )updateToken
73
73
{
74
- NSLog ( @" !!! " ) ;
74
+ if (!self. formIsValid ) return ;
75
75
76
+ if (![self .token.name isEqualToString: self .accountNameCell.textField.text] ||
77
+ ![self .token.issuer isEqualToString: self .issuerCell.textField.text]) {
78
+ self.token .name = self.accountNameCell .textField .text ;
79
+ self.token .issuer = self.issuerCell .textField .text ;
80
+ [self .token saveToKeychain ];
81
+ }
82
+
83
+ id <OTPTokenEditorDelegate> delegate = self.delegate ;
84
+ [delegate tokenSource: self didEditToken: self .token];
76
85
}
77
86
78
87
Original file line number Diff line number Diff line change 33
33
#import " OTPTokenEditViewController.h"
34
34
35
35
36
- @interface OTPTokenListViewController ()
36
+ @interface OTPTokenListViewController () <OTPTokenEditorDelegate>
37
37
38
38
@property (nonatomic , strong ) OTPTokenManager *tokenManager;
39
39
@property (nonatomic , strong ) OTPProgressRing *ring;
@@ -144,6 +144,8 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
144
144
- (void )tableView : (UITableView *)tableView didSelectRowAtIndexPath : (NSIndexPath *)indexPath
145
145
{
146
146
if (self.isEditing ) {
147
+ self.editing = NO ;
148
+
147
149
OTPTokenEditViewController *editController = [OTPTokenEditViewController new ];
148
150
editController.token = self.tokenManager .tokens [(NSUInteger )indexPath.row];
149
151
editController.delegate = self;
@@ -191,4 +193,13 @@ - (void)tokenSource:(id)tokenSource didCreateToken:(OTPToken *)token
191
193
}
192
194
}
193
195
196
+
197
+ #pragma mark - OTPTokenEditorDelegate
198
+
199
+ - (void )tokenSource : (id )tokenSource didEditToken : (OTPToken *)token
200
+ {
201
+ [self dismissViewControllerAnimated: YES completion: nil ];
202
+ [self .tableView reloadData ];
203
+ }
204
+
194
205
@end
You can’t perform that action at this time.
0 commit comments