diff --git a/Riot.xcodeproj/project.pbxproj b/Riot.xcodeproj/project.pbxproj index c767c6dd3..064e13a62 100644 --- a/Riot.xcodeproj/project.pbxproj +++ b/Riot.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 24B5103E1EFA7083004C6AD2 /* ReadReceiptsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 24B5103D1EFA7083004C6AD2 /* ReadReceiptsViewController.m */; }; + 24B510401EFA88CC004C6AD2 /* ReadReceiptsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 24B5103F1EFA88CC004C6AD2 /* ReadReceiptsViewController.xib */; }; 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 */; }; @@ -468,6 +470,9 @@ /* Begin PBXFileReference section */ 1129C74A281B080432B1A1A1 /* Pods-Riot.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Riot.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Riot/Pods-Riot.debug.xcconfig"; sourceTree = ""; }; + 24B5103C1EFA7083004C6AD2 /* ReadReceiptsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadReceiptsViewController.h; sourceTree = ""; }; + 24B5103D1EFA7083004C6AD2 /* ReadReceiptsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReadReceiptsViewController.m; sourceTree = ""; }; + 24B5103F1EFA88CC004C6AD2 /* ReadReceiptsViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ReadReceiptsViewController.xib; sourceTree = ""; }; 3205ED7B1E976C8A003D65FA /* DirectoryServerPickerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectoryServerPickerViewController.h; sourceTree = ""; }; 3205ED7C1E976C8A003D65FA /* DirectoryServerPickerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DirectoryServerPickerViewController.m; sourceTree = ""; }; 3205ED811E97725E003D65FA /* DirectoryServerTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectoryServerTableViewCell.h; sourceTree = ""; }; @@ -1576,6 +1581,9 @@ F083BC541E7009EC00A9B29C /* StartChatViewController.xib */, F083BC551E7009EC00A9B29C /* UsersDevicesViewController.h */, F083BC561E7009EC00A9B29C /* UsersDevicesViewController.m */, + 24B5103C1EFA7083004C6AD2 /* ReadReceiptsViewController.h */, + 24B5103D1EFA7083004C6AD2 /* ReadReceiptsViewController.m */, + 24B5103F1EFA88CC004C6AD2 /* ReadReceiptsViewController.xib */, ); path = ViewController; sourceTree = ""; @@ -2032,6 +2040,7 @@ F083BD881E7009ED00A9B29C /* file_doc_icon@3x.png in Resources */, F083BDAB1E7009ED00A9B29C /* placeholder@2x.png in Resources */, F083BE4D1E7009ED00A9B29C /* RoomOutgoingEncryptedAttachmentWithoutSenderInfoBubbleCell.xib in Resources */, + 24B510401EFA88CC004C6AD2 /* ReadReceiptsViewController.xib in Resources */, F083BDC81E7009ED00A9B29C /* search_icon.png in Resources */, F083BDE91E7009ED00A9B29C /* ring.mp3 in Resources */, F083BE431E7009ED00A9B29C /* RoomIncomingEncryptedTextMsgWithoutSenderInfoBubbleCell.xib in Resources */, @@ -2393,7 +2402,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -2445,6 +2454,7 @@ F083BE761E7009ED00A9B29C /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m in Sources */, F083BE5A1E7009ED00A9B29C /* RoomIncomingAttachmentBubbleCell.m in Sources */, F083BE541E7009ED00A9B29C /* RoomOutgoingEncryptedTextMsgWithoutSenderNameBubbleCell.m in Sources */, + 24B5103E1EFA7083004C6AD2 /* ReadReceiptsViewController.m in Sources */, F083BE621E7009ED00A9B29C /* RoomIncomingTextMsgWithoutSenderInfoBubbleCell.m in Sources */, F083BE881E7009ED00A9B29C /* RoomMemberTitleView.m in Sources */, F083BE701E7009ED00A9B29C /* RoomOutgoingTextMsgBubbleCell.m in Sources */, diff --git a/Riot/Model/Room/RoomDataSource.m b/Riot/Model/Room/RoomDataSource.m index 4a1a71d77..f4a01c719 100644 --- a/Riot/Model/Room/RoomDataSource.m +++ b/Riot/Model/Room/RoomDataSource.m @@ -17,6 +17,7 @@ #import "RoomDataSource.h" +#import "AppDelegate.h" #import "EventFormatter.h" #import "RoomBubbleCellData.h" @@ -148,7 +149,7 @@ // Some vertical whitespaces are added in message text view (see RoomBubbleCellData class) to insert correctly multiple receipts. bubbleCell.bubbleOverlayContainer.backgroundColor = [UIColor clearColor]; bubbleCell.bubbleOverlayContainer.alpha = 1; - bubbleCell.bubbleOverlayContainer.userInteractionEnabled = NO; + bubbleCell.bubbleOverlayContainer.userInteractionEnabled = YES; bubbleCell.bubbleOverlayContainer.hidden = NO; NSInteger index = bubbleComponents.count; @@ -166,6 +167,7 @@ NSArray* receipts = [self.room getEventReceipts:component.event.eventId sorted:YES]; NSMutableArray *roomMembers; NSMutableArray *placeholders; + NSMutableArray *receiptDescriptions; // Check whether some receipts are found if (receipts.count) @@ -173,6 +175,9 @@ // Retrieve the corresponding room members roomMembers = [[NSMutableArray alloc] initWithCapacity:receipts.count]; placeholders = [[NSMutableArray alloc] initWithCapacity:receipts.count]; + receiptDescriptions = [[NSMutableArray alloc] initWithCapacity:receipts.count]; + + MXKEventFormatter *formatter = (MXKEventFormatter*)self.mxSession.roomSummaryUpdateDelegate; for (MXReceiptData* data in receipts) { @@ -181,6 +186,7 @@ { [roomMembers addObject:roomMember]; [placeholders addObject:[AvatarGenerator generateAvatarForMatrixItem:roomMember.userId withDisplayName:roomMember.displayname]]; + [receiptDescriptions addObject:[formatter dateStringFromTimestamp:data.ts withTime:YES]]; } } } @@ -190,6 +196,7 @@ { // Define the read receipts container, positioned on the right border of the bubble cell (Note the right margin 6 pts). MXKReceiptSendersContainer* avatarsContainer = [[MXKReceiptSendersContainer alloc] initWithFrame:CGRectMake(bubbleCell.frame.size.width - 156, bottomPositionY - 13, 150, 12) andRestClient:self.mxSession.matrixRestClient]; + avatarsContainer.delegate = [AppDelegate theDelegate].masterTabBarController.currentRoomViewController; // Custom avatar display avatarsContainer.maxDisplayedAvatars = 5; @@ -199,6 +206,7 @@ avatarsContainer.tag = index; [avatarsContainer refreshReceiptSenders:roomMembers withPlaceHolders:placeholders andAlignment:ReadReceiptAlignmentRight]; + avatarsContainer.recieptDescriptions = receiptDescriptions; avatarsContainer.translatesAutoresizingMaskIntoConstraints = NO; avatarsContainer.accessibilityIdentifier = @"readReceiptsContainer"; diff --git a/Riot/ViewController/ReadReceiptsViewController.h b/Riot/ViewController/ReadReceiptsViewController.h new file mode 100644 index 000000000..d8a7ad9b9 --- /dev/null +++ b/Riot/ViewController/ReadReceiptsViewController.h @@ -0,0 +1,24 @@ +/* + Copyright 2017 Aram Sargsyan + + 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 +#import + +@interface ReadReceiptsViewController : UIViewController + ++ (void)openInViewController:(UIViewController *)viewController withRestClient:(MXRestClient *)restClient withRoomMembers:(NSArray *)roomMembers placeholders:(NSArray *)placeholders receiptDescriptions:(NSArray *)receiptDescriptions; + +@end diff --git a/Riot/ViewController/ReadReceiptsViewController.m b/Riot/ViewController/ReadReceiptsViewController.m new file mode 100644 index 000000000..768024156 --- /dev/null +++ b/Riot/ViewController/ReadReceiptsViewController.m @@ -0,0 +1,137 @@ +/* + Copyright 2017 Aram Sargsyan + + 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 "ReadReceiptsViewController.h" +#import + +@interface ReadReceiptsViewController () + +@property (nonatomic) MXRestClient* restClient; + +@property (nonatomic) NSArray *roomMembers; +@property (nonatomic) NSArray *placeholders; +@property (nonatomic) NSArray *recieptDescriptions; + +@property (weak, nonatomic) IBOutlet UIView *overlayView; +@property (weak, nonatomic) IBOutlet UILabel *titleLabel; +@property (weak, nonatomic) IBOutlet UIView *containerView; +@property (nonatomic) IBOutlet UITableView *receiptsTableView; + +@end + +@implementation ReadReceiptsViewController + +#pragma mark - Public + ++ (void)openInViewController:(UIViewController *)viewController withRestClient:(MXRestClient *)restClient withRoomMembers:(NSArray *)roomMembers placeholders:(NSArray *)placeholders receiptDescriptions:(NSArray *)receiptDescriptions +{ + ReadReceiptsViewController *receiptsController = [[[self class] alloc] initWithNibName:NSStringFromClass([self class]) bundle:nil]; + receiptsController.restClient = restClient; + receiptsController.roomMembers = roomMembers; + receiptsController.placeholders = placeholders; + receiptsController.recieptDescriptions = receiptDescriptions; + + receiptsController.providesPresentationContextTransitionStyle = YES; + receiptsController.definesPresentationContext = YES; + receiptsController.modalPresentationStyle = UIModalPresentationOverFullScreen; + receiptsController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; + + [viewController presentViewController:receiptsController animated:YES completion:nil]; +} + +#pragma mark - Lifecycle + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + [self configureViews]; + [self configureReceiptsTableView]; + [self addOverlayViewGesture]; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - Views + +- (void)configureViews { + self.containerView.layer.cornerRadius = 20; + self.titleLabel.text = @"Read Receipts List"; +} + +- (void)configureReceiptsTableView { + self.receiptsTableView.dataSource = self; + [self.receiptsTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"id"]; + + //[self.receiptsTableView registerNib:[MXKReadReceiptTableview nib] forCellReuseIdentifier:@"s"]; + +} + +- (void)addOverlayViewGesture { + UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(overlayTap)]; + [tapRecognizer setNumberOfTapsRequired:1]; + [tapRecognizer setNumberOfTouchesRequired:1]; + [self.overlayView addGestureRecognizer:tapRecognizer]; +} + +#pragma mark - Actions + +- (void)overlayTap { + [self dismissViewControllerAnimated:YES completion:nil]; +} + +#pragma mark - UITableViewDataSource + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return self.roomMembers.count; +} + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 1; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"id" forIndexPath:indexPath]; + + //configure cell + //add custom cell later + if (indexPath.row < self.roomMembers.count) + { + cell.textLabel.text = self.roomMembers[indexPath.row].displayname; + } + if (indexPath.row < self.placeholders.count) + { + [cell.imageView setImage:self.placeholders[indexPath.row]]; + } + if (indexPath.row < self.recieptDescriptions.count) + { + cell.detailTextLabel.text = self.recieptDescriptions[indexPath.row]; + } + + cell.selectionStyle = UITableViewCellSelectionStyleNone; + + return cell; +} + + +@end diff --git a/Riot/ViewController/ReadReceiptsViewController.xib b/Riot/ViewController/ReadReceiptsViewController.xib new file mode 100644 index 000000000..23813ac75 --- /dev/null +++ b/Riot/ViewController/ReadReceiptsViewController.xib @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Riot/ViewController/RoomViewController.h b/Riot/ViewController/RoomViewController.h index 45fd0f0bd..0dcdd0bda 100644 --- a/Riot/ViewController/RoomViewController.h +++ b/Riot/ViewController/RoomViewController.h @@ -25,7 +25,7 @@ #import "UIViewController+RiotSearch.h" -@interface RoomViewController : MXKRoomViewController +@interface RoomViewController : MXKRoomViewController // The expanded header @property (weak, nonatomic) IBOutlet UIView *expandedHeaderContainer; diff --git a/Riot/ViewController/RoomViewController.m b/Riot/ViewController/RoomViewController.m index 47a74d510..bfdc50054 100644 --- a/Riot/ViewController/RoomViewController.m +++ b/Riot/ViewController/RoomViewController.m @@ -45,6 +45,8 @@ #import "UsersDevicesViewController.h" +#import "ReadReceiptsViewController.h" + #import "RoomEmptyBubbleCell.h" #import "RoomIncomingTextMsgBubbleCell.h" @@ -2817,6 +2819,13 @@ } } +#pragma mark - MXKRecieptSendersContainerDelegate + +- (void)didTapReceiptsContainerWithRestClient:(MXRestClient *)restClient RoomMembers:(NSArray *)roomMembers avatars:(NSArray *)avatars recieptDescriptions:(NSArray *)recieptDescriptions { + NSLog(@"!!! SHOW RR DETAILS !!!"); + [ReadReceiptsViewController openInViewController:self withRestClient:restClient withRoomMembers:roomMembers placeholders:avatars receiptDescriptions:recieptDescriptions]; +} + #pragma mark - Typing management - (void)removeTypingNotificationsListener