2015-12-18 09:59:45 +00:00
|
|
|
/*
|
|
|
|
Copyright 2015 OpenMarket Ltd
|
2017-03-08 15:14:41 +00:00
|
|
|
Copyright 2017 Vector Creations Ltd
|
2015-12-18 09:59:45 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import "DirectoryRecentTableViewCell.h"
|
|
|
|
|
|
|
|
#import "PublicRoomsDirectoryDataSource.h"
|
|
|
|
|
2017-03-08 15:14:41 +00:00
|
|
|
#import "RiotDesignValues.h"
|
2016-06-14 20:25:10 +00:00
|
|
|
|
2015-12-18 09:59:45 +00:00
|
|
|
@implementation DirectoryRecentTableViewCell
|
|
|
|
|
|
|
|
#pragma mark - Class methods
|
|
|
|
|
2017-08-08 14:05:43 +00:00
|
|
|
- (void)customizeTableViewCellRendering
|
2016-06-14 20:25:10 +00:00
|
|
|
{
|
2017-08-08 14:05:43 +00:00
|
|
|
[super customizeTableViewCellRendering];
|
2016-06-14 20:25:10 +00:00
|
|
|
|
2017-08-11 14:56:09 +00:00
|
|
|
self.titleLabel.textColor = kRiotPrimaryTextColor;
|
|
|
|
self.descriptionLabel.textColor = kRiotSecondaryTextColor;
|
2016-06-14 20:25:10 +00:00
|
|
|
}
|
|
|
|
|
2015-12-18 09:59:45 +00:00
|
|
|
- (void)render:(PublicRoomsDirectoryDataSource *)publicRoomsDirectoryDataSource
|
|
|
|
{
|
2015-12-21 10:31:30 +00:00
|
|
|
self.userInteractionEnabled = NO;
|
|
|
|
self.chevronImageView.hidden = YES;
|
|
|
|
|
2015-12-18 09:59:45 +00:00
|
|
|
// Show information according to the data source state
|
|
|
|
switch (publicRoomsDirectoryDataSource.state)
|
|
|
|
{
|
|
|
|
case MXKDataSourceStatePreparing:
|
|
|
|
self.titleLabel.text = NSLocalizedStringFromTable(@"directory_searching_title", @"Vector", nil);
|
|
|
|
self.descriptionLabel.text = @"";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MXKDataSourceStateReady:
|
2015-12-21 14:29:57 +00:00
|
|
|
{
|
2017-03-28 14:36:21 +00:00
|
|
|
if (publicRoomsDirectoryDataSource.searchPattern)
|
2016-05-30 11:42:45 +00:00
|
|
|
{
|
|
|
|
self.titleLabel.text = NSLocalizedStringFromTable(@"directory_search_results_title", @"Vector", nil);
|
2017-03-28 14:36:21 +00:00
|
|
|
|
|
|
|
// Do we need to display like ">20 results found" or "18 results found"?
|
|
|
|
NSString *descriptionLabel = publicRoomsDirectoryDataSource.moreThanRoomsCount ? NSLocalizedStringFromTable(@"directory_search_results_more_than", @"Vector", nil) : NSLocalizedStringFromTable(@"directory_search_results", @"Vector", nil);
|
|
|
|
|
|
|
|
self.descriptionLabel.text = [NSString stringWithFormat:descriptionLabel,
|
|
|
|
publicRoomsDirectoryDataSource.roomsCount,
|
|
|
|
publicRoomsDirectoryDataSource.searchPattern];
|
2016-05-30 11:42:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-06-14 09:10:37 +00:00
|
|
|
self.titleLabel.text = NSLocalizedStringFromTable(@"directory_cell_title", @"Vector", nil);
|
|
|
|
self.descriptionLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"directory_cell_description", @"Vector", nil),
|
2017-03-28 14:36:21 +00:00
|
|
|
publicRoomsDirectoryDataSource.roomsCount];
|
2016-05-30 11:42:45 +00:00
|
|
|
}
|
2015-12-18 09:59:45 +00:00
|
|
|
|
2017-03-28 14:36:21 +00:00
|
|
|
if (publicRoomsDirectoryDataSource.roomsCount)
|
2015-12-21 10:31:30 +00:00
|
|
|
{
|
|
|
|
self.userInteractionEnabled = YES;
|
|
|
|
self.chevronImageView.hidden = NO;
|
|
|
|
}
|
2015-12-18 09:59:45 +00:00
|
|
|
break;
|
2015-12-21 14:29:57 +00:00
|
|
|
}
|
2015-12-18 09:59:45 +00:00
|
|
|
|
|
|
|
case MXKDataSourceStateFailed:
|
|
|
|
self.titleLabel.text = NSLocalizedStringFromTable(@"directory_searching_title", @"Vector", nil);
|
|
|
|
self.descriptionLabel.text = NSLocalizedStringFromTable(@"directory_search_fail", @"Vector", nil);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (CGFloat)cellHeight
|
|
|
|
{
|
|
|
|
return 74;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|