Newer
Older
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#import "BLRootViewController.h"
#import "ChatViewController.h"
@interface BLRootViewController ()
//@property (nonatomic, strong) NSMutableArray * objects;
@end
@implementation BLRootViewController
- (void)loadView {
// [self setDefinesPresentationContext:YES];
// [self setModalPresentationStyle:UIModalPresentationOverCurrentContext];
[super loadView];
[BrooklynBridge riseAndShineIMDaemon];
[BrooklynBridge conversationArray];
//_objects = [NSMutableArray array];
self.title = @"Brooklyn";
self.navigationItem.leftBarButtonItem = self.editButtonItem;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addButtonTapped:)];
[self.tableView reloadData];
// [self.tableView setBackgroundColor:[UIColor clearColor]];
// []
// [self.tableView setSeparatorEffect:<#(API_AVAILABLE(ios(8.0)) UIVisualEffect *)#>]
}
-(void)viewDidLoad {
[super viewDidLoad];
self.tableView.dataSource = self;
self.tableView.delegate = self;
[self.tableView reloadData];
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 1)] withRowAnimation:UITableViewRowAnimationAutomatic];
}
- (void)addButtonTapped:(id)sender {
BLNewChatViewController * newc = [[BLNewChatViewController alloc] initWithNibName: @"BLNewChatViewController" bundle:nil];
[self.navigationController pushViewController:newc animated:YES];
}
#pragma mark - Table View Data Source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
[BrooklynBridge conversationArray];
return [BrooklynBridge conversationArray].count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"ChatCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
CKConversation * chat = [BrooklynBridge conversationArray][indexPath.row];
cell.textLabel.text = chat.name;
cell.detailTextLabel.text = chat.description;
if (chat.outgoingBubbleColor) {
cell.detailTextLabel.textColor = [UIColor colorWithRed: 0.10 green: 0.51 blue: 0.99 alpha: 1.00];
} else {
cell.detailTextLabel.textColor = [UIColor colorWithRed: 0.26 green: 0.80 blue: 0.28 alpha: 1.00];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
//[_objects removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:@[ indexPath ] withRowAnimation:UITableViewRowAnimationAutomatic];
}
#pragma mark - Table View Delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
CKConversation * chat2 = [BrooklynBridge conversationArray][indexPath.row];
ChatViewController * cvc = [[ChatViewController alloc] initWithConversation:chat2];
[self.navigationController pushViewController:cvc animated:YES];
}
@end