display the

-> swipe menu icons (recents)
-> room creation icon (recents)
This commit is contained in:
yannick
2015-12-04 16:32:20 +01:00
parent 36eca8d52c
commit 41e09d59f0
+41 -16
View File
@@ -140,12 +140,10 @@
[createNewRoomImageView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.view addSubview:createNewRoomImageView];
// TODO use a const value
createNewRoomImageView.backgroundColor = [UIColor colorWithRed:(98.0/256.0) green:(206.0/256.0) blue:(156.0/256.0) alpha:1.0];
createNewRoomImageView.backgroundColor = [UIColor clearColor];
createNewRoomImageView.image = [UIImage imageNamed:@"create_room"];
CGFloat side = 50.0f;
createNewRoomImageView.layer.cornerRadius = side / 2;
NSLayoutConstraint* widthConstraint = [NSLayoutConstraint constraintWithItem:createNewRoomImageView
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
@@ -441,9 +439,11 @@ static NSMutableDictionary* backgroundByImageNameDict;
- (UIColor*)getBackgroundColor:(NSString*)imageName
{
UIColor* backgroundColor = [UIColor colorWithRed:(242.0 / 256.0) green:(242.0 / 256.0) blue:(242.0 / 256.0) alpha:1.0];
if (!imageName)
{
return [UIColor lightGrayColor];
return backgroundColor;
}
if (!backgroundByImageNameDict)
@@ -455,7 +455,32 @@ static NSMutableDictionary* backgroundByImageNameDict;
if (!bgColor)
{
bgColor = [[UIColor alloc] initWithPatternImage:[MXKTools resizeImage:[UIImage imageNamed:imageName] toFitInSize:CGSizeMake(74, 74)]];
CGFloat backgroundSide = 74.0;
CGFloat sourceSide = 30.0;
UIImageView* backgroundView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, backgroundSide, backgroundSide)];
backgroundView.backgroundColor = backgroundColor;
CGFloat offset = (backgroundSide - sourceSide) / 2.0f;
UIImageView* resourceImageView = [[UIImageView alloc] initWithFrame:CGRectMake(offset, offset, sourceSide, sourceSide)];
resourceImageView.backgroundColor = [UIColor clearColor];
resourceImageView.image = [MXKTools resizeImage:[UIImage imageNamed:imageName] toSize:CGSizeMake(sourceSide, sourceSide)];
[backgroundView addSubview:resourceImageView];
// Create a "canvas" (image context) to draw in.
UIGraphicsBeginImageContextWithOptions(backgroundView.frame.size, NO, 0);
// set to the top quality
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
[[backgroundView layer] renderInContext: UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
bgColor = [[UIColor alloc] initWithPatternImage:image];
[backgroundByImageNameDict setObject:bgColor forKey:imageName];
}
@@ -471,19 +496,19 @@ static NSMutableDictionary* backgroundByImageNameDict;
if (room)
{
NSString* title = @" ";
// pushes settings
BOOL isMuted = ![self.dataSource isRoomNotifiedAtIndexPath:indexPath];
NSString* pushMessage = !isMuted ? @"Mute" : @"Unmute";
UITableViewRowAction *muteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:pushMessage handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
UITableViewRowAction *muteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:title handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self muteRoomNotifications:!isMuted atIndexPath:indexPath];
}];
muteAction.backgroundColor = [self getBackgroundColor:nil];
muteAction.backgroundColor = [self getBackgroundColor:isMuted ? @"unmute_icon" : @"mute_icon"];
[actions insertObject:muteAction atIndex:0];
// favorites management
@@ -507,12 +532,12 @@ static NSMutableDictionary* backgroundByImageNameDict;
if (!currentTag || ![kMXRoomTagFavourite isEqualToString:currentTag.name])
{
UITableViewRowAction* action = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Fav" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
UITableViewRowAction* action = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:title handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self updateRoomTagAtIndexPath:indexPath to:kMXRoomTagFavourite];
}];
action.backgroundColor = [self getBackgroundColor:nil];
action.backgroundColor = [self getBackgroundColor:@"favorite_icon"];
[actions insertObject:action atIndex:0];
}
@@ -529,19 +554,19 @@ static NSMutableDictionary* backgroundByImageNameDict;
if (!currentTag || ![kMXRoomTagLowPriority isEqualToString:currentTag.name])
{
UITableViewRowAction* action = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Low" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
UITableViewRowAction* action = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:title handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self updateRoomTagAtIndexPath:indexPath to:kMXRoomTagLowPriority];
}];
action.backgroundColor = [self getBackgroundColor:nil];
action.backgroundColor = [self getBackgroundColor:@"low_priority_icon"];
[actions insertObject:action atIndex:0];
}
UITableViewRowAction *leaveAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Leave" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
UITableViewRowAction *leaveAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:title handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self leaveRecentsAtIndexPath:indexPath];
}];
leaveAction.backgroundColor = [self getBackgroundColor:nil];
leaveAction.backgroundColor = [self getBackgroundColor:@"remove_icon"];
[actions insertObject:leaveAction atIndex:0];
}