diff --git a/Riot.xcodeproj/project.pbxproj b/Riot.xcodeproj/project.pbxproj index 9f6329224..ef32cdca7 100644 --- a/Riot.xcodeproj/project.pbxproj +++ b/Riot.xcodeproj/project.pbxproj @@ -12,6 +12,8 @@ 3205ED7D1E976C8A003D65FA /* DirectoryServerPickerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3205ED7C1E976C8A003D65FA /* DirectoryServerPickerViewController.m */; }; 3205ED841E97725E003D65FA /* DirectoryServerTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 3205ED821E97725E003D65FA /* DirectoryServerTableViewCell.m */; }; 3205ED851E97725E003D65FA /* DirectoryServerTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3205ED831E97725E003D65FA /* DirectoryServerTableViewCell.xib */; }; + 321082B21F0E9F40002E0091 /* RoomMembershipCollapsedBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 321082B01F0E9F40002E0091 /* RoomMembershipCollapsedBubbleCell.m */; }; + 321082B31F0E9F41002E0091 /* RoomMembershipCollapsedBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 321082B11F0E9F40002E0091 /* RoomMembershipCollapsedBubbleCell.xib */; }; 325072141E8C0AC900A084B6 /* LaunchScreenLogo.png in Resources */ = {isa = PBXBuildFile; fileRef = 325072131E8C0AC900A084B6 /* LaunchScreenLogo.png */; }; 325E1C151E8D03950018D91E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 325E1C131E8D03950018D91E /* LaunchScreen.storyboard */; }; 32AE61E41F0A971B007255F4 /* RoomMembershipBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 32AE61E21F0A971B007255F4 /* RoomMembershipBubbleCell.m */; }; @@ -488,6 +490,9 @@ 3205ED811E97725E003D65FA /* DirectoryServerTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectoryServerTableViewCell.h; sourceTree = ""; }; 3205ED821E97725E003D65FA /* DirectoryServerTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DirectoryServerTableViewCell.m; sourceTree = ""; }; 3205ED831E97725E003D65FA /* DirectoryServerTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DirectoryServerTableViewCell.xib; sourceTree = ""; }; + 321082AF1F0E9F40002E0091 /* RoomMembershipCollapsedBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomMembershipCollapsedBubbleCell.h; sourceTree = ""; }; + 321082B01F0E9F40002E0091 /* RoomMembershipCollapsedBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomMembershipCollapsedBubbleCell.m; sourceTree = ""; }; + 321082B11F0E9F40002E0091 /* RoomMembershipCollapsedBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomMembershipCollapsedBubbleCell.xib; sourceTree = ""; }; 325072131E8C0AC900A084B6 /* LaunchScreenLogo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = LaunchScreenLogo.png; path = Assets/Images/LaunchScreenLogo.png; sourceTree = ""; }; 325E1C141E8D03950018D91E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 32AE61E11F0A971B007255F4 /* RoomMembershipBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomMembershipBubbleCell.h; sourceTree = ""; }; @@ -1722,6 +1727,9 @@ 32AE61E61F0CE099007255F4 /* RoomMembershipBubbleCellWithPaginationTitleBubbleCell.h */, 32AE61E71F0CE099007255F4 /* RoomMembershipBubbleCellWithPaginationTitleBubbleCell.m */, 32AE61E81F0CE099007255F4 /* RoomMembershipBubbleCellWithPaginationTitleBubbleCell.xib */, + 321082AF1F0E9F40002E0091 /* RoomMembershipCollapsedBubbleCell.h */, + 321082B01F0E9F40002E0091 /* RoomMembershipCollapsedBubbleCell.m */, + 321082B11F0E9F40002E0091 /* RoomMembershipCollapsedBubbleCell.xib */, F083BCA81E7009EC00A9B29C /* RoomIncomingAttachmentBubbleCell.h */, F083BCA91E7009EC00A9B29C /* RoomIncomingAttachmentBubbleCell.m */, F083BCAA1E7009EC00A9B29C /* RoomIncomingAttachmentBubbleCell.xib */, @@ -2123,6 +2131,7 @@ F083BDC41E7009ED00A9B29C /* scrollup@3x.png in Resources */, F083BD291E7009ED00A9B29C /* animatedLogo-1.png in Resources */, F083BD4F1E7009ED00A9B29C /* camera_play@2x.png in Resources */, + 321082B31F0E9F41002E0091 /* RoomMembershipCollapsedBubbleCell.xib in Resources */, F083BD981E7009ED00A9B29C /* logo.png in Resources */, F083BD911E7009ED00A9B29C /* file_video_icon@3x.png in Resources */, F083BD991E7009ED00A9B29C /* logo@2x.png in Resources */, @@ -2489,6 +2498,7 @@ F083BDEE1E7009ED00A9B29C /* MXRoom+Riot.m in Sources */, F083BE331E7009ED00A9B29C /* DeviceView.m in Sources */, F083BE2B1E7009ED00A9B29C /* AuthInputsView.m in Sources */, + 321082B21F0E9F40002E0091 /* RoomMembershipCollapsedBubbleCell.m in Sources */, F083BE661E7009ED00A9B29C /* RoomIncomingTextMsgWithPaginationTitleBubbleCell.m in Sources */, F083BE141E7009ED00A9B29C /* HomeViewController.m in Sources */, F083BDFB1E7009ED00A9B29C /* RoomSearchDataSource.m in Sources */, diff --git a/Riot/Views/RoomBubbleList/RoomMembershipCollapsedBubbleCell.h b/Riot/Views/RoomBubbleList/RoomMembershipCollapsedBubbleCell.h new file mode 100644 index 000000000..cf13898d7 --- /dev/null +++ b/Riot/Views/RoomBubbleList/RoomMembershipCollapsedBubbleCell.h @@ -0,0 +1,26 @@ +/* + Copyright 2017 Vector Creations Ltd + + 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 "RoomIncomingTextMsgBubbleCell.h" + +/** + `RoomMembershipCollapsedBubbleCell` displays a sum-up of collapsed membership cells. + */ +@interface RoomMembershipCollapsedBubbleCell : RoomIncomingTextMsgBubbleCell + +@property (weak, nonatomic) IBOutlet UIView *avatarsView; + +@end diff --git a/Riot/Views/RoomBubbleList/RoomMembershipCollapsedBubbleCell.m b/Riot/Views/RoomBubbleList/RoomMembershipCollapsedBubbleCell.m new file mode 100644 index 000000000..3a8be5187 --- /dev/null +++ b/Riot/Views/RoomBubbleList/RoomMembershipCollapsedBubbleCell.m @@ -0,0 +1,83 @@ +/* + Copyright 2017 Vector Creations Ltd + + 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 "RoomMembershipCollapsedBubbleCell.h" + +#import "RiotDesignValues.h" + +#import "RoomBubbleCellData.h" + +@implementation RoomMembershipCollapsedBubbleCell + +- (void)awakeFromNib +{ + [super awakeFromNib]; + + self.messageTextView.tintColor = kRiotColorGreen; +} + +- (void)layoutSubviews +{ + [super layoutSubviews]; + + // Round avatars + for (UIView *avatarView in self.avatarsView.subviews) + { + [avatarView.layer setCornerRadius:avatarView.frame.size.width / 2]; + avatarView.clipsToBounds = YES; + } +} + +- (void)prepareForReuse +{ + // Reset avatars + for (UIView *avatarView in self.avatarsView.subviews) + { + [avatarView removeFromSuperview]; + } +} + +- (void)render:(MXKCellData *)cellData +{ + [super render:cellData]; + + // Add up to 5 avatars to self.avatarsView + RoomBubbleCellData *nextBubbleData = (RoomBubbleCellData*)bubbleData; + + do + { + MXKImageView *avatarView = [[MXKImageView alloc] initWithFrame:CGRectMake(12 * self.avatarsView.subviews.count, 0, 16, 16)]; + + // Handle user's picture + NSString *avatarThumbURL = nil; + if (nextBubbleData.senderAvatarUrl) + { + // Suppose this url is a matrix content uri, we use SDK to get the well adapted thumbnail from server + avatarThumbURL = [nextBubbleData.mxSession.matrixRestClient urlOfContentThumbnail:nextBubbleData.senderAvatarUrl toFitViewSize:avatarView.frame.size withMethod:MXThumbnailingMethodCrop]; + } + + avatarView.enableInMemoryCache = YES; + [avatarView setImageURL:avatarThumbURL withType:nil andImageOrientation:UIImageOrientationUp previewImage: nextBubbleData.senderAvatarPlaceholder ? nextBubbleData.senderAvatarPlaceholder : self.picturePlaceholder]; + + // Clear the default background color of a MXKImageView instance + avatarView.backgroundColor = [UIColor clearColor]; + + [self.avatarsView addSubview:avatarView]; + } + while ((nextBubbleData = nextBubbleData.nextCollapsableCellData) && self.avatarsView.subviews.count < 5); +} + +@end diff --git a/Riot/Views/RoomBubbleList/RoomMembershipCollapsedBubbleCell.xib b/Riot/Views/RoomBubbleList/RoomMembershipCollapsedBubbleCell.xib new file mode 100644 index 000000000..9cdd63b04 --- /dev/null +++ b/Riot/Views/RoomBubbleList/RoomMembershipCollapsedBubbleCell.xib @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +