mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-30 21:26:57 +02:00
Search in room: Applied Vector design (ie stole the cells from the RoomViewController to display search results)
This commit is contained in:
@@ -18,13 +18,27 @@
|
||||
|
||||
#import "UIViewController+VectorSearch.h"
|
||||
|
||||
// Use RoomViewController cells to display results
|
||||
#import "RoomIncomingAttachmentBubbleCell.h"
|
||||
#import "RoomIncomingTextMsgBubbleCell.h"
|
||||
|
||||
|
||||
@implementation RoomSearchViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
// Reuse cells from the RoomViewController to display results
|
||||
[self.searchTableView registerClass:RoomIncomingTextMsgBubbleCell.class forCellReuseIdentifier:RoomIncomingTextMsgBubbleCell.defaultReuseIdentifier];
|
||||
[self.searchTableView registerClass:RoomIncomingAttachmentBubbleCell.class forCellReuseIdentifier:RoomIncomingAttachmentBubbleCell.defaultReuseIdentifier];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
// Enable the search field at the opening
|
||||
// Enable the search field at the screen opening
|
||||
[self showSearch:animated];
|
||||
}
|
||||
|
||||
@@ -45,4 +59,51 @@
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
|
||||
#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.isAttachmentWithThumbnail)
|
||||
{
|
||||
cellViewClass = RoomIncomingAttachmentBubbleCell.class;
|
||||
}
|
||||
else
|
||||
{
|
||||
cellViewClass = RoomIncomingTextMsgBubbleCell.class;
|
||||
}
|
||||
}
|
||||
|
||||
return cellViewClass;
|
||||
}
|
||||
|
||||
- (NSString *)cellReuseIdentifierForCellData:(MXKCellData*)cellData
|
||||
{
|
||||
Class class = [self cellViewClassForCellData:cellData];
|
||||
|
||||
if ([class respondsToSelector:@selector(defaultReuseIdentifier)])
|
||||
{
|
||||
return [class defaultReuseIdentifier];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
#pragma mark - Override UITableView delegate
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
// `MXKRoomBubbleTableViewCell` cells displayed by the `RoomViewController`
|
||||
// do not have line separators.
|
||||
// The +1 here is for the line separator which is displayed by `RoomSearchViewController`.
|
||||
return [super tableView:tableView heightForRowAtIndexPath:indexPath] + 1;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user