mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-30 21:26:57 +02:00
MXKDataSource refactoring
Table view cell are now defined at view controller level.
This commit is contained in:
@@ -30,6 +30,9 @@
|
||||
#import "SegmentedViewController.h"
|
||||
#import "RoomSettingsViewController.h"
|
||||
|
||||
#import "RoomOutgoingBubbleTableViewCell.h"
|
||||
#import "RoomIncomingBubbleTableViewCell.h"
|
||||
|
||||
#import "AvatarGenerator.h"
|
||||
|
||||
@interface RoomViewController ()
|
||||
@@ -78,6 +81,10 @@
|
||||
// this room view controller has its own typing management.
|
||||
self.roomDataSource.showTypingNotifications = NO;
|
||||
}
|
||||
|
||||
// Register here customized cell view classes used to render bubbles
|
||||
[self.bubblesTableView registerClass:RoomOutgoingBubbleTableViewCell.class forCellReuseIdentifier:RoomOutgoingBubbleTableViewCell.defaultReuseIdentifier];
|
||||
[self.bubblesTableView registerClass:RoomIncomingBubbleTableViewCell.class forCellReuseIdentifier:RoomIncomingBubbleTableViewCell.defaultReuseIdentifier];
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
@@ -212,6 +219,31 @@
|
||||
[super destroy];
|
||||
}
|
||||
|
||||
#pragma mark - MXKDataSourceDelegate
|
||||
|
||||
- (Class<MXKCellRendering>)cellViewClassForCellData:(MXKCellData*)cellData
|
||||
{
|
||||
Class cellViewClass = nil;
|
||||
|
||||
// Sanity check
|
||||
if ([cellData conformsToProtocol:@protocol(MXKRoomBubbleCellDataStoring)])
|
||||
{
|
||||
id<MXKRoomBubbleCellDataStoring> bubbleData = (id<MXKRoomBubbleCellDataStoring>)cellData;
|
||||
|
||||
// Select the suitable table view cell class
|
||||
if (bubbleData.isIncoming)
|
||||
{
|
||||
cellViewClass = RoomIncomingBubbleTableViewCell.class;
|
||||
}
|
||||
else
|
||||
{
|
||||
cellViewClass = RoomOutgoingBubbleTableViewCell.class;
|
||||
}
|
||||
}
|
||||
|
||||
return cellViewClass;
|
||||
}
|
||||
|
||||
#pragma mark - MXKDataSource delegate
|
||||
|
||||
- (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)actionIdentifier inCell:(id<MXKCellRendering>)cell userInfo:(NSDictionary *)userInfo
|
||||
|
||||
Reference in New Issue
Block a user