diff --git a/Podfile b/Podfile index 39eeec830..484dcc414 100644 --- a/Podfile +++ b/Podfile @@ -8,7 +8,7 @@ target "Riot" do # Different flavours of pods to MatrixKit # The tagged version on which this version of Riot has been built -pod 'MatrixKit', '0.6.2' +#pod 'MatrixKit', '0.6.2' # The lastest release available on the CocoaPods repository #pod 'MatrixKit' @@ -19,8 +19,8 @@ pod 'MatrixKit', '0.6.2' # The one used for developing both MatrixSDK and MatrixKit # Note that MatrixSDK must be cloned into a folder called matrix-ios-sdk next to the MatrixKit folder -#pod 'MatrixKit', :path => '../matrix-ios-kit/MatrixKit.podspec' -#pod 'MatrixSDK', :path => '../matrix-ios-sdk/MatrixSDK.podspec' +pod 'MatrixKit', :path => '../matrix-ios-kit/MatrixKit.podspec' +pod 'MatrixSDK', :path => '../matrix-ios-sdk/MatrixSDK.podspec' pod 'GBDeviceInfo', '~> 4.3.0' @@ -53,7 +53,7 @@ pod 'OLMKit' pod 'Realm', '~> 2.8.1' # The tagged version on which this version of Riot share extension has been built -pod 'MatrixKit/AppExtension', '0.6.2' +#pod 'MatrixKit/AppExtension', '0.6.2' # The lastest release available on the CocoaPods repository #pod 'MatrixKit/AppExtension' @@ -64,8 +64,8 @@ pod 'MatrixKit/AppExtension', '0.6.2' # The one used for developing both MatrixSDK and MatrixKit # Note that MatrixSDK must be cloned into a folder called matrix-ios-sdk next to the MatrixKit folder -#pod 'MatrixSDK', :path => '../matrix-ios-sdk/MatrixSDK.podspec' -#pod 'MatrixKit/AppExtension', :path => '../matrix-ios-kit/MatrixKit.podspec' +pod 'MatrixSDK', :path => '../matrix-ios-sdk/MatrixSDK.podspec' +pod 'MatrixKit/AppExtension', :path => '../matrix-ios-kit/MatrixKit.podspec' # Remove warnings from "bad" pods pod 'OLMKit', :inhibit_warnings => true diff --git a/Podfile.lock b/Podfile.lock index 7264c3ab8..0e86dd238 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -82,12 +82,19 @@ DEPENDENCIES: - DTCoreText - GBDeviceInfo (~> 4.3.0) - GoogleAnalytics - - MatrixKit (= 0.6.2) - - MatrixKit/AppExtension (= 0.6.2) + - MatrixKit (from `../matrix-ios-kit/MatrixKit.podspec`) + - MatrixKit/AppExtension (from `../matrix-ios-kit/MatrixKit.podspec`) + - MatrixSDK (from `../matrix-ios-sdk/MatrixSDK.podspec`) - OLMKit - Realm (~> 2.8.1) - WebRTC (= 58.17.16937) +EXTERNAL SOURCES: + MatrixKit: + :path: ../matrix-ios-kit/MatrixKit.podspec + MatrixSDK: + :path: ../matrix-ios-sdk/MatrixSDK.podspec + SPEC CHECKSUMS: AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67 cmark: ec0275215b504780287b6fca360224e384368af8 @@ -104,6 +111,6 @@ SPEC CHECKSUMS: Realm: 3601ef091c8c499a31101d8563b991e75546cdce WebRTC: 1e9a85bf75509eec44be6478c64e9de65ac82332 -PODFILE CHECKSUM: db0ae7d6037f7768feb2adf17119ba69d9e1a77b +PODFILE CHECKSUM: 8ae33ab2c0496d3c6b498371fd13e7ccb0a96283 COCOAPODS: 1.3.1 diff --git a/Riot.xcodeproj/project.pbxproj b/Riot.xcodeproj/project.pbxproj index b7164fff2..da3fbd8b8 100644 --- a/Riot.xcodeproj/project.pbxproj +++ b/Riot.xcodeproj/project.pbxproj @@ -10,6 +10,8 @@ 05D592A32FF1D1877B89F73C /* libPods-Riot.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FD9D0BDE9232898950554DD5 /* libPods-Riot.a */; }; 2435179C1F375B9400D0683E /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 2466B7551F2F80B800AE27B0 /* Info.plist */; }; 2435179F1F375C0F00D0683E /* Vector.strings in Resources */ = {isa = PBXBuildFile; fileRef = 327382C01F276AED00356143 /* Vector.strings */; }; + 2439DD621F6BBE760090F42D /* RecentRoomTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2439DD611F6BBE760090F42D /* RecentRoomTableViewCell.m */; }; + 2439DD641F6BBEA50090F42D /* RecentRoomTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2439DD631F6BBEA50090F42D /* RecentRoomTableViewCell.xib */; }; 245FC3ED1F3D079A00603C6A /* ShareExtensionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 245FC3EB1F3CAF9800603C6A /* ShareExtensionManager.m */; }; 245FC3EF1F3DD30800603C6A /* RecentCellData.m in Sources */ = {isa = PBXBuildFile; fileRef = F083BC071E7009EC00A9B29C /* RecentCellData.m */; }; 2466B73E1F2DFAC100AE27B0 /* animatedLogo-4.png in Resources */ = {isa = PBXBuildFile; fileRef = F083BB201E7009EC00A9B29C /* animatedLogo-4.png */; }; @@ -568,6 +570,9 @@ /* Begin PBXFileReference section */ 12AA0005C8B3D8D8162584C5 /* Pods-RiotShareExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RiotShareExtension.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RiotShareExtension/Pods-RiotShareExtension.debug.xcconfig"; sourceTree = ""; }; + 2439DD601F6BBE760090F42D /* RecentRoomTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RecentRoomTableViewCell.h; sourceTree = ""; }; + 2439DD611F6BBE760090F42D /* RecentRoomTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RecentRoomTableViewCell.m; sourceTree = ""; }; + 2439DD631F6BBEA50090F42D /* RecentRoomTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RecentRoomTableViewCell.xib; sourceTree = ""; }; 245FC3EA1F3CAF9800603C6A /* ShareExtensionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShareExtensionManager.h; sourceTree = ""; }; 245FC3EB1F3CAF9800603C6A /* ShareExtensionManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShareExtensionManager.m; sourceTree = ""; }; 2466B7551F2F80B800AE27B0 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = RiotShareExtension/Info.plist; sourceTree = SOURCE_ROOT; }; @@ -646,6 +651,11 @@ 7246451C668D6782166E22EC /* libPods-RiotShareExtension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RiotShareExtension.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 765F5104DB3EC39713DEB3A4 /* Pods-RiotShareExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RiotShareExtension.release.xcconfig"; path = "Pods/Target Support Files/Pods-RiotShareExtension/Pods-RiotShareExtension.release.xcconfig"; sourceTree = ""; }; 839BB91240D350D5607D55BA /* 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 = ""; }; + 92324BE11F4F66D3009DE194 /* IncomingCallView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IncomingCallView.h; sourceTree = ""; }; + 92324BE21F4F66D3009DE194 /* IncomingCallView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IncomingCallView.m; sourceTree = ""; }; + 92324BE41F4F6A60009DE194 /* CircleButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CircleButton.h; sourceTree = ""; }; + 92324BE51F4F6A60009DE194 /* CircleButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CircleButton.m; sourceTree = ""; }; + 9E07AE9A3C5A90D68D90B6F9 /* Pods-RiotTodayWidget.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RiotTodayWidget.release.xcconfig"; path = "Pods/Target Support Files/Pods-RiotTodayWidget/Pods-RiotTodayWidget.release.xcconfig"; sourceTree = ""; }; C195C53961EA28E6900AEB68 /* Pods-Riot.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Riot.release.xcconfig"; path = "Pods/Target Support Files/Pods-Riot/Pods-Riot.release.xcconfig"; sourceTree = ""; }; F0131DE31F2200D600CBF707 /* RiotSplitViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RiotSplitViewController.h; sourceTree = ""; }; F0131DE41F2200D600CBF707 /* RiotSplitViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RiotSplitViewController.m; sourceTree = ""; }; @@ -1250,12 +1260,36 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 2439DD5F1F6BBE390090F42D /* Views */ = { + isa = PBXGroup; + children = ( + 2439DD601F6BBE760090F42D /* RecentRoomTableViewCell.h */, + 2439DD611F6BBE760090F42D /* RecentRoomTableViewCell.m */, + 2439DD631F6BBEA50090F42D /* RecentRoomTableViewCell.xib */, + ); + name = Views; + path = RiotShareExtension/Views; + sourceTree = SOURCE_ROOT; + }; + 246B30B81F5300A0009ED3AD /* RiotTodayWidget */ = { + isa = PBXGroup; + children = ( + 246B30C81F530C84009ED3AD /* RiotTodayWidget.entitlements */, + 246B30BF1F5300A0009ED3AD /* Info.plist */, + 246B30B91F5300A0009ED3AD /* TodayViewController.h */, + 246B30BA1F5300A0009ED3AD /* TodayViewController.m */, + 246B30C61F5300F2009ED3AD /* TodayViewController.xib */, + ); + path = RiotTodayWidget; + sourceTree = ""; + }; 24CBEC4F1F0EAD310093EABB /* RiotShareExtension */ = { isa = PBXGroup; children = ( 2466B7551F2F80B800AE27B0 /* Info.plist */, 2466B7561F2F80B800AE27B0 /* RiotShareExtension.entitlements */, 24D6B3441F3C8F8A00FC7A71 /* ViewController */, + 2439DD5F1F6BBE390090F42D /* Views */, 24D6B3551F3C8FCC00FC7A71 /* Model */, ); name = RiotShareExtension; @@ -2439,6 +2473,8 @@ 24EEE5AA1F25529C00B3C705 /* cancel.png in Resources */, 24D6B35E1F3CA03E00FC7A71 /* FallbackViewController.xib in Resources */, 24EEE5A41F24C06E00B3C705 /* BuildFile in Resources */, + 2439DD641F6BBEA50090F42D /* RecentRoomTableViewCell.xib in Resources */, + 24EEE5A41F24C06E00B3C705 /* (null) in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2973,6 +3009,7 @@ 24D6B35D1F3CA03A00FC7A71 /* FallbackViewController.m in Sources */, 24EEE5A11F23A09A00B3C705 /* RiotDesignValues.m in Sources */, 24EEE5A21F23A8B400B3C705 /* MXRoom+Riot.m in Sources */, + 2439DD621F6BBE760090F42D /* RecentRoomTableViewCell.m in Sources */, 245FC3ED1F3D079A00603C6A /* ShareExtensionManager.m in Sources */, 24EEE5B41F2607C000B3C705 /* SegmentedViewController.m in Sources */, ); diff --git a/RiotShareExtension/Model/ShareDataSource.m b/RiotShareExtension/Model/ShareDataSource.m index ffa6f1f79..1711d2d55 100644 --- a/RiotShareExtension/Model/ShareDataSource.m +++ b/RiotShareExtension/Model/ShareDataSource.m @@ -16,15 +16,15 @@ #import "ShareDataSource.h" #import "ShareExtensionManager.h" -#import "RoomTableViewCell.h" -#import "MXRoom+Riot.h" +#import "RecentRoomTableViewCell.h" +//#import "MXRoom+Riot.h" @interface ShareDataSource () @property (nonatomic, readwrite) ShareDataSourceMode dataSourceMode; -@property NSArray *rooms; -@property NSMutableArray *visibleRooms; +@property NSArray *recentCellDatas; +@property NSMutableArray *visibleRoomCellDatas; @end @@ -36,7 +36,7 @@ if (self) { self.dataSourceMode = dataSourceMode; - _rooms = [NSMutableArray array]; + _recentCellDatas = [NSMutableArray array]; [self updateRooms]; } return self; @@ -54,48 +54,39 @@ [session setStore:fileStore success:^{ if (weakSession) { - __strong MXSession *session = weakSession; - [self getRoomsFromStore:fileStore session:session]; + //__strong MXSession *session = weakSession; + [self getCellDatasFromStore:fileStore]; } } failure:^(NSError *error) { - NSLog(@"[ShareExtensionManager failed to set store]"); + NSLog(@"[ShareDataSource failed to set store]"); }]; } -- (void)getRoomsFromStore:(MXFileStore *)fileStore session:(MXSession *)session +- (void)getCellDatasFromStore:(MXFileStore *)fileStore { - NSMutableArray *rooms = [NSMutableArray array]; + NSMutableArray *cellDatas = [NSMutableArray array]; [fileStore asyncRoomsSummaries:^(NSArray * _Nonnull roomsSummaries) { for (MXRoomSummary *roomSummary in roomsSummaries) { - [fileStore asyncAccountDataOfRoom:roomSummary.roomId success:^(MXRoomAccountData * _Nonnull accountData) { - [fileStore asyncStateEventsOfRoom:roomSummary.roomId success:^(NSArray * _Nonnull roomStateEvents) { - - MXRoom *room = [[MXRoom alloc] initWithRoomId:roomSummary.roomId andMatrixSession:session andStateEvents:roomStateEvents andAccountData:accountData]; - - if ((self.dataSourceMode == DataSourceModeRooms) ^ roomSummary.isDirect) - { - [rooms addObject:room]; - } - - if ([roomsSummaries indexOfObject:roomSummary] == roomsSummaries.count - 1) - { - self.rooms = rooms; - dispatch_async(dispatch_get_main_queue(), ^{ - [self.delegate dataSource:self didCellChange:nil]; - }); - } - - } failure:^(NSError * _Nonnull error) { - NSLog(@"[ShareExtensionManager failed to get state events]"); - }]; - } failure:^(NSError * _Nonnull error) { - NSLog(@"[ShareExtensionManager failed to get account data]"); - }]; + MXKRecentCellData *recentCellData = [[MXKRecentCellData alloc] initWithRoomSummary:roomSummary andRecentListDataSource:nil]; + + + if ((self.dataSourceMode == DataSourceModeRooms) ^ roomSummary.isDirect) + { + [cellDatas addObject:recentCellData]; + } + + if ([roomsSummaries indexOfObject:roomSummary] == roomsSummaries.count - 1) + { + self.recentCellDatas = cellDatas; + dispatch_async(dispatch_get_main_queue(), ^{ + [self.delegate dataSource:self didCellChange:nil]; + }); + } } } failure:^(NSError * _Nonnull error) { - NSLog(@"[ShareExtensionManager failed to get room summaries]"); + NSLog(@"[ShareDataSource failed to get room summaries]"); }]; } @@ -110,32 +101,42 @@ - (MXRoom *)getRoomAtIndexPath:(NSIndexPath *)indexPath { - if (self.visibleRooms) + NSLog(@"vori"); + /*if (self.visibleRoomCellDatas) { - return self.visibleRooms[indexPath.row]; + return self.visibleRoomCellDatas[indexPath.row]; } - return self.rooms[indexPath.row]; + return self.visibleRoomCellDatas[indexPath.row];*/ + return nil; +} + +- (id)cellDataAtIndexPath:(NSIndexPath *)indexPath { + if (self.visibleRoomCellDatas) + { + return self.visibleRoomCellDatas[indexPath.row]; + } + return self.recentCellDatas[indexPath.row]; } - (void)searchWithPatterns:(NSArray *)patternsList { - if (self.visibleRooms) + if (self.visibleRoomCellDatas) { - [self.visibleRooms removeAllObjects]; + [self.visibleRoomCellDatas removeAllObjects]; } else { - self.visibleRooms = [NSMutableArray arrayWithCapacity:self.rooms.count]; + self.visibleRoomCellDatas = [NSMutableArray arrayWithCapacity:self.recentCellDatas.count]; } if (patternsList.count) { - for (MXRoom *room in self.rooms) + for (MXKRecentCellData *cellData in self.recentCellDatas) { for (NSString* pattern in patternsList) { - if (room.riotDisplayname && [room.riotDisplayname rangeOfString:pattern options:NSCaseInsensitiveSearch].location != NSNotFound) + if (cellData.roomSummary.displayname && [cellData.roomSummary.displayname rangeOfString:pattern options:NSCaseInsensitiveSearch].location != NSNotFound) { - [self.visibleRooms addObject:room]; + [self.visibleRoomCellDatas addObject:cellData]; break; } } @@ -143,7 +144,7 @@ } else { - self.visibleRooms = nil; + self.visibleRoomCellDatas = nil; } [self.delegate dataSource:self didCellChange:nil]; } @@ -157,20 +158,18 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - if (self.visibleRooms) + if (self.visibleRoomCellDatas) { - return self.visibleRooms.count; + return self.visibleRoomCellDatas.count; } - return self.rooms.count; + return self.recentCellDatas.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - RoomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[RoomTableViewCell defaultReuseIdentifier]]; + RecentRoomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[RecentRoomTableViewCell defaultReuseIdentifier]]; - MXRoom *room = [self getRoomAtIndexPath:indexPath]; - - [cell render:room]; + [cell render:[self cellDataAtIndexPath:indexPath]]; return cell; } diff --git a/RiotShareExtension/Model/ShareExtensionManager.m b/RiotShareExtension/Model/ShareExtensionManager.m index 2643e877d..3096b5c72 100644 --- a/RiotShareExtension/Model/ShareExtensionManager.m +++ b/RiotShareExtension/Model/ShareExtensionManager.m @@ -271,12 +271,24 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) self.primaryViewController = nil; } +- (void)roomFromRoomSummary:(MXRoomSummary *)roomSummary store:(MXFileStore *)fileStore session:(MXSession *)session +{ + [fileStore asyncAccountDataOfRoom:roomSummary.roomId success:^(MXRoomAccountData * _Nonnull accountData) { + [fileStore asyncStateEventsOfRoom:roomSummary.roomId success:^(NSArray * _Nonnull roomStateEvents) { + MXRoom *room = [[MXRoom alloc] initWithRoomId:roomSummary.roomId andMatrixSession:session andStateEvents:roomStateEvents andAccountData:accountData]; + } failure:^(NSError * _Nonnull error) { + //sjh + }]; + } failure:^(NSError * _Nonnull error) { + //shj + }]; + +} + #pragma mark - Private - (void)completeRequestReturningItems:(nullable NSArray *)items completionHandler:(void(^ __nullable)(BOOL expired))completionHandler; { - //[self suspendSession]; - [self.shareExtensionContext completeRequestReturningItems:items completionHandler:completionHandler]; [self.primaryViewController destroy]; diff --git a/RiotShareExtension/ViewController/RoomsListViewController.m b/RiotShareExtension/ViewController/RoomsListViewController.m index a493aaad0..3aec39eec 100644 --- a/RiotShareExtension/ViewController/RoomsListViewController.m +++ b/RiotShareExtension/ViewController/RoomsListViewController.m @@ -15,7 +15,7 @@ */ #import "RoomsListViewController.h" -#import "RoomTableViewCell.h" +#import "RecentRoomTableViewCell.h" #import "NSBundle+MatrixKit.h" #import "ShareExtensionManager.h" #import "RecentCellData.h" @@ -73,7 +73,7 @@ { [super viewDidLoad]; - [self.recentsTableView registerNib:[RoomTableViewCell nib] forCellReuseIdentifier:[RoomTableViewCell defaultReuseIdentifier]]; + [self.recentsTableView registerNib:[RecentRoomTableViewCell nib] forCellReuseIdentifier:[RecentRoomTableViewCell defaultReuseIdentifier]]; [self configureSearchBar]; } @@ -173,7 +173,7 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - return [RoomTableViewCell cellHeight]; + return [RecentRoomTableViewCell cellHeight]; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath @@ -189,7 +189,7 @@ { if ([cellData isKindOfClass:[RecentCellData class]]) { - return [RoomTableViewCell class]; + return [RecentRoomTableViewCell class]; } return nil; } @@ -198,7 +198,7 @@ { if ([cellData isKindOfClass:[MXKRecentCellData class]]) { - return [RoomTableViewCell defaultReuseIdentifier]; + return [RecentRoomTableViewCell defaultReuseIdentifier]; } return nil; } diff --git a/RiotShareExtension/Views/RecentRoomTableViewCell.h b/RiotShareExtension/Views/RecentRoomTableViewCell.h new file mode 100644 index 000000000..959ca786e --- /dev/null +++ b/RiotShareExtension/Views/RecentRoomTableViewCell.h @@ -0,0 +1,23 @@ +/* + 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 + +@interface RecentRoomTableViewCell : MXKRecentTableViewCell + ++ (CGFloat)cellHeight; + +@end diff --git a/RiotShareExtension/Views/RecentRoomTableViewCell.m b/RiotShareExtension/Views/RecentRoomTableViewCell.m new file mode 100644 index 000000000..c1fe01de2 --- /dev/null +++ b/RiotShareExtension/Views/RecentRoomTableViewCell.m @@ -0,0 +1,77 @@ +/* + 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 "RecentRoomTableViewCell.h" + +@interface RecentRoomTableViewCell () + +@property (weak, nonatomic) IBOutlet MXKImageView *avatarImageView; +@property (weak, nonatomic) IBOutlet UIView *directRoomBorderView; +@property (weak, nonatomic) IBOutlet UILabel *roomTitleLabel; +@property (weak, nonatomic) IBOutlet UIImageView *encryptedRoomIcon; + + + +@end + +@implementation RecentRoomTableViewCell + +#pragma mark - MXKRecentTableViewCell + ++ (UINib *)nib +{ + // Check whether a nib file is available + NSBundle *mainBundle = [NSBundle bundleForClass:self.class]; + + NSString *path = [mainBundle pathForResource:NSStringFromClass([self class]) ofType:@"nib"]; + if (path) + { + return [UINib nibWithNibName:NSStringFromClass([self class]) bundle:mainBundle]; + } + return nil; +} + +- (void)render:(MXKRecentCellData *)cellData +{ + + //NSString *imageUrl = [self.matrixRestClient urlOfContentThumbnail:cellData toFitViewSize:mxkImageView.frame.size withMethod:MXThumbnailingMethodCrop]; + //[self.avatarImageView setImageURL:nil withType:nil andImageOrientation:UIImageOrientationUp previewImage:nil]; + + self.roomTitleLabel.text = cellData.roomDisplayname; + + self.directRoomBorderView.hidden = !cellData.roomSummary.isDirect; + + self.encryptedRoomIcon.hidden = !cellData.roomSummary.isEncrypted; + +} + ++ (CGFloat)cellHeight +{ + return 74; +} + +/*- (void)render:(MXRoom *)room +{ + [room setRoomAvatarImageIn:self.avatarImageView]; + + self.titleLabel.text = room.riotDisplayname; + + self.directRoomBorderView.hidden = !room.isDirect; + + self.encryptedRoomIcon.hidden = !room.state.isEncrypted; +}*/ + +@end diff --git a/RiotShareExtension/Views/RecentRoomTableViewCell.xib b/RiotShareExtension/Views/RecentRoomTableViewCell.xib new file mode 100644 index 000000000..f1c18122c --- /dev/null +++ b/RiotShareExtension/Views/RecentRoomTableViewCell.xib @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +