diff --git a/Riot.xcodeproj/project.pbxproj b/Riot.xcodeproj/project.pbxproj index ef32cdca7..0ce19d304 100644 --- a/Riot.xcodeproj/project.pbxproj +++ b/Riot.xcodeproj/project.pbxproj @@ -14,6 +14,8 @@ 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 */; }; + 322806A01F0F64C4008C53D7 /* RoomMembershipExpandedBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 3228069E1F0F64C4008C53D7 /* RoomMembershipExpandedBubbleCell.m */; }; + 322806A11F0F64C4008C53D7 /* RoomMembershipExpandedBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3228069F1F0F64C4008C53D7 /* RoomMembershipExpandedBubbleCell.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 */; }; @@ -493,6 +495,9 @@ 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 = ""; }; + 3228069D1F0F64C4008C53D7 /* RoomMembershipExpandedBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomMembershipExpandedBubbleCell.h; sourceTree = ""; }; + 3228069E1F0F64C4008C53D7 /* RoomMembershipExpandedBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomMembershipExpandedBubbleCell.m; sourceTree = ""; }; + 3228069F1F0F64C4008C53D7 /* RoomMembershipExpandedBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomMembershipExpandedBubbleCell.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 = ""; }; @@ -1730,6 +1735,9 @@ 321082AF1F0E9F40002E0091 /* RoomMembershipCollapsedBubbleCell.h */, 321082B01F0E9F40002E0091 /* RoomMembershipCollapsedBubbleCell.m */, 321082B11F0E9F40002E0091 /* RoomMembershipCollapsedBubbleCell.xib */, + 3228069D1F0F64C4008C53D7 /* RoomMembershipExpandedBubbleCell.h */, + 3228069E1F0F64C4008C53D7 /* RoomMembershipExpandedBubbleCell.m */, + 3228069F1F0F64C4008C53D7 /* RoomMembershipExpandedBubbleCell.xib */, F083BCA81E7009EC00A9B29C /* RoomIncomingAttachmentBubbleCell.h */, F083BCA91E7009EC00A9B29C /* RoomIncomingAttachmentBubbleCell.m */, F083BCAA1E7009EC00A9B29C /* RoomIncomingAttachmentBubbleCell.xib */, @@ -2383,6 +2391,7 @@ F083BD421E7009ED00A9B29C /* call_speaker_on_icon.png in Resources */, F083BD9A1E7009ED00A9B29C /* logo@3x.png in Resources */, F083BDE51E7009ED00A9B29C /* voice_call_icon@3x.png in Resources */, + 322806A11F0F64C4008C53D7 /* RoomMembershipExpandedBubbleCell.xib in Resources */, F083BE201E7009ED00A9B29C /* RoomParticipantsViewController.xib in Resources */, F083BE471E7009ED00A9B29C /* RoomIncomingEncryptedTextMsgWithPaginationTitleBubbleCell.xib in Resources */, 32AE61E51F0A971B007255F4 /* RoomMembershipBubbleCell.xib in Resources */, @@ -2524,6 +2533,7 @@ F083BE7C1E7009ED00A9B29C /* DirectoryRecentTableViewCell.m in Sources */, F0E05A031E963103004B83FB /* RoomsViewController.m in Sources */, F083BE801E7009ED00A9B29C /* PublicRoomTableViewCell.m in Sources */, + 322806A01F0F64C4008C53D7 /* RoomMembershipExpandedBubbleCell.m in Sources */, F083BE031E7009ED00A9B29C /* EventFormatter.m in Sources */, F083BE4A1E7009ED00A9B29C /* RoomOutgoingEncryptedAttachmentBubbleCell.m in Sources */, F083BE601E7009ED00A9B29C /* RoomIncomingTextMsgBubbleCell.m in Sources */, diff --git a/Riot/Model/Room/RoomDataSource.m b/Riot/Model/Room/RoomDataSource.m index d9e94693a..52e32e400 100644 --- a/Riot/Model/Room/RoomDataSource.m +++ b/Riot/Model/Room/RoomDataSource.m @@ -381,7 +381,7 @@ if (cellData.collapsed) { // Select nothing for a collased cell but open it - [self expandRoomBubble:cellData]; + [self collapseRoomBubble:cellData collapsed:NO]; return; } else @@ -393,14 +393,4 @@ _selectedEventId = selectedEventId; } -- (void)expandRoomBubble:(RoomBubbleCellData*)cellData -{ - RoomBubbleCellData *nextBubbleData = (RoomBubbleCellData*)cellData; - do - { - nextBubbleData.collapsed = NO; - } - while ((nextBubbleData = nextBubbleData.nextCollapsableCellData)); -} - @end diff --git a/Riot/ViewController/RoomViewController.m b/Riot/ViewController/RoomViewController.m index 76cfd85fc..22f174422 100644 --- a/Riot/ViewController/RoomViewController.m +++ b/Riot/ViewController/RoomViewController.m @@ -88,6 +88,7 @@ #import "RoomMembershipBubbleCell.h" #import "RoomMembershipBubbleCellWithPaginationTitleBubbleCell.h" #import "RoomMembershipCollapsedBubbleCell.h" +#import "RoomMembershipExpandedBubbleCell.h" #import "MXKRoomBubbleTableViewCell+Riot.h" @@ -285,6 +286,7 @@ [self.bubblesTableView registerClass:RoomMembershipBubbleCell.class forCellReuseIdentifier:RoomMembershipBubbleCell.defaultReuseIdentifier]; [self.bubblesTableView registerClass:RoomMembershipBubbleCellWithPaginationTitleBubbleCell.class forCellReuseIdentifier:RoomMembershipBubbleCellWithPaginationTitleBubbleCell.defaultReuseIdentifier]; [self.bubblesTableView registerClass:RoomMembershipCollapsedBubbleCell.class forCellReuseIdentifier:RoomMembershipCollapsedBubbleCell.defaultReuseIdentifier]; + [self.bubblesTableView registerClass:RoomMembershipExpandedBubbleCell.class forCellReuseIdentifier:RoomMembershipExpandedBubbleCell.defaultReuseIdentifier]; // Prepare jump to last unread banner self.jumpToLastUnreadLabel.attributedText = [[NSAttributedString alloc] initWithString:NSLocalizedStringFromTable(@"room_jump_to_first_unread", @"Vector", nil) attributes:@{NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle), NSUnderlineColorAttributeName: kRiotTextColorBlack, NSForegroundColorAttributeName: kRiotTextColorBlack}]; @@ -1557,7 +1559,20 @@ } else { - cellViewClass = bubbleData.collapsed ? RoomMembershipCollapsedBubbleCell.class : RoomMembershipBubbleCell.class; + if (bubbleData.collapsed) + { + cellViewClass = RoomMembershipCollapsedBubbleCell.class; + } + else if (bubbleData.collapsedAttributedTextMessage) + { + // The cell (and its serie) is not collapsed but this cell is the first + // of the serie. So, use the cell with the "collapse" button + cellViewClass = RoomMembershipExpandedBubbleCell.class; + } + else + { + cellViewClass = RoomMembershipBubbleCell.class; + } } } else if (bubbleData.isIncoming) diff --git a/Riot/Views/RoomBubbleList/RoomMembershipExpandedBubbleCell.h b/Riot/Views/RoomBubbleList/RoomMembershipExpandedBubbleCell.h new file mode 100644 index 000000000..728fa75c9 --- /dev/null +++ b/Riot/Views/RoomBubbleList/RoomMembershipExpandedBubbleCell.h @@ -0,0 +1,28 @@ +/* + 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 "RoomMembershipBubbleCell.h" + +/** + `RoomMembershipExpandedBubbleCell` displays the first membership event of serie + that can be collapsable. + */ +@interface RoomMembershipExpandedBubbleCell : RoomMembershipBubbleCell + +@property (weak, nonatomic) IBOutlet UIButton *collapseButton; +@property (weak, nonatomic) IBOutlet UIView *separatorView; + +@end diff --git a/Riot/Views/RoomBubbleList/RoomMembershipExpandedBubbleCell.m b/Riot/Views/RoomBubbleList/RoomMembershipExpandedBubbleCell.m new file mode 100644 index 000000000..838d79f35 --- /dev/null +++ b/Riot/Views/RoomBubbleList/RoomMembershipExpandedBubbleCell.m @@ -0,0 +1,44 @@ +/* + 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 "RoomMembershipExpandedBubbleCell.h" + +#import "RiotDesignValues.h" + +#import "RoomBubbleCellData.h" + +@implementation RoomMembershipExpandedBubbleCell + +- (void)awakeFromNib +{ + [super awakeFromNib]; + + self.separatorView.backgroundColor = kRiotColorLightGrey; + + NSString* title = NSLocalizedStringFromTable(@"collapse", @"Vector", nil); + [self.collapseButton setTitle:title forState:UIControlStateNormal]; + [self.collapseButton setTitle:title forState:UIControlStateHighlighted]; + [self.collapseButton setTintColor:kRiotColorGreen]; + self.collapseButton.titleLabel.font = [UIFont systemFontOfSize:14]; +} + +- (IBAction)onCollapseButtonTap:(id)sender +{ + [((MXKRoomBubbleCellData*)self.bubbleData).roomDataSource collapseRoomBubble:self.bubbleData collapsed:YES]; + +} + +@end diff --git a/Riot/Views/RoomBubbleList/RoomMembershipExpandedBubbleCell.xib b/Riot/Views/RoomBubbleList/RoomMembershipExpandedBubbleCell.xib new file mode 100644 index 000000000..0f3ec86a2 --- /dev/null +++ b/Riot/Views/RoomBubbleList/RoomMembershipExpandedBubbleCell.xib @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +