blob: 794bf70c058527e300f1f5ac2ab91f6760408e65 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#import "AddSetVC.h"
#import "AddSetTableViewCell.h"
#import "SwiftBridge.h"
#import "UIViewController+Navigation.h"
#include "Framework.h"
@interface AddSetVC () <AddSetTableViewCellProtocol>
@property (nonatomic) AddSetTableViewCell * cell;
@end
@implementation AddSetVC
- (instancetype)init
{
self = [super initWithStyle:UITableViewStyleGrouped];
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(onSaveClicked)];
[(UIViewController *)self showBackButton];
self.title = L(@"add_new_set");
[self.tableView registerWithCellClass:[AddSetTableViewCell class]];
}
- (void)onSaveClicked
{
[self onDone:self.cell.textField.text];
}
- (void)onDone:(NSString *)text
{
if (text.length == 0)
return;
[self.delegate addSetVC:self didAddSetWithIndex:static_cast<int>(GetFramework().AddCategory([text UTF8String]))];
[self.navigationController popViewControllerAnimated:YES];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
self.cell = static_cast<AddSetTableViewCell *>(
[tableView dequeueReusableCellWithCellClass:[AddSetTableViewCell class] indexPath:indexPath]);
self.cell.delegate = self;
return self.cell;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(AddSetTableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
[cell.textField becomeFirstResponder];
}
@end
|