mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-16 06:28:27 +02:00
Lists user's recents in Recents
This commit is contained in:
@@ -103,7 +103,7 @@
|
||||
#pragma mark - Split view
|
||||
|
||||
- (BOOL)splitViewController:(UISplitViewController *)splitViewController collapseSecondaryViewController:(UIViewController *)secondaryViewController ontoPrimaryViewController:(UIViewController *)primaryViewController {
|
||||
if ([secondaryViewController isKindOfClass:[UINavigationController class]] && [[(UINavigationController *)secondaryViewController topViewController] isKindOfClass:[RoomViewController class]] && ([(RoomViewController *)[(UINavigationController *)secondaryViewController topViewController] detailItem] == nil)) {
|
||||
if ([secondaryViewController isKindOfClass:[UINavigationController class]] && [[(UINavigationController *)secondaryViewController topViewController] isKindOfClass:[RoomViewController class]] && ([(RoomViewController *)[(UINavigationController *)secondaryViewController topViewController] roomId] == nil)) {
|
||||
// Return YES to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded.
|
||||
return YES;
|
||||
} else {
|
||||
|
||||
@@ -182,6 +182,9 @@
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="J51-Cj-6mb">
|
||||
<rect key="frame" x="290" y="190" width="20" height="20"/>
|
||||
</activityIndicatorView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
@@ -192,6 +195,7 @@
|
||||
<constraint firstItem="bYl-BD-hfc" firstAttribute="top" secondItem="iBz-4w-0cv" secondAttribute="bottom" constant="10" id="Gba-vG-eZb"/>
|
||||
<constraint firstItem="fnl-LF-rEL" firstAttribute="top" secondItem="gDT-bj-MHE" secondAttribute="bottom" constant="10" id="Is5-SQ-bcL"/>
|
||||
<constraint firstAttribute="centerX" secondItem="9oD-IQ-d8J" secondAttribute="centerX" id="JLJ-dk-JdK"/>
|
||||
<constraint firstAttribute="centerY" secondItem="J51-Cj-6mb" secondAttribute="centerY" id="RJl-T1-G3f"/>
|
||||
<constraint firstAttribute="centerX" secondItem="fnl-LF-rEL" secondAttribute="centerX" id="Sgz-AH-2EN"/>
|
||||
<constraint firstAttribute="centerX" secondItem="TW9-CJ-pH0" secondAttribute="centerX" constant="105" id="V29-yw-qHo"/>
|
||||
<constraint firstAttribute="width" constant="600" placeholder="YES" id="b29-CD-6mb"/>
|
||||
@@ -201,6 +205,7 @@
|
||||
<constraint firstAttribute="centerX" secondItem="gDT-bj-MHE" secondAttribute="centerX" id="oih-er-0Uz"/>
|
||||
<constraint firstAttribute="centerX" secondItem="bYl-BD-hfc" secondAttribute="centerX" id="rLh-01-K2X"/>
|
||||
<constraint firstAttribute="centerX" secondItem="iBz-4w-0cv" secondAttribute="centerX" constant="-52" id="umi-df-iLV"/>
|
||||
<constraint firstAttribute="centerX" secondItem="J51-Cj-6mb" secondAttribute="centerX" id="xKM-Lu-0MM"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
@@ -222,6 +227,7 @@
|
||||
</constraints>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="activityIndicator" destination="J51-Cj-6mb" id="hYh-tr-rjl"/>
|
||||
<outlet property="contentView" destination="d6h-O8-aBs" id="hId-Ic-rv4"/>
|
||||
<outlet property="contentViewBottomConstraint" destination="3LQ-0u-kCA" id="LuL-eo-fCe"/>
|
||||
<outlet property="createAccountBtn" destination="bYl-BD-hfc" id="Kvu-Go-kEM"/>
|
||||
@@ -416,24 +422,48 @@
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<prototypes>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" textLabel="Arm-wq-HPj" style="IBUITableViewCellStyleDefault" id="WCw-Qf-5nD">
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="RecentsCell" rowHeight="70" id="WCw-Qf-5nD" customClass="RecentsTableViewCell">
|
||||
<rect key="frame" x="0.0" y="86" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="WCw-Qf-5nD" id="37f-cq-3Eg">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Arm-wq-HPj">
|
||||
<rect key="frame" x="15" y="0.0" width="290" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="RoomTitle" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="15" translatesAutoresizingMaskIntoConstraints="NO" id="YTM-8H-EpC">
|
||||
<rect key="frame" x="8" y="9" width="86" height="23"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="19"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="LastEventDescription" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="14" translatesAutoresizingMaskIntoConstraints="NO" id="5g8-vg-2EB">
|
||||
<rect key="frame" x="8" y="40" width="164" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Oct 12 18:15" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eKl-0r-wFc">
|
||||
<rect key="frame" x="514" y="8" width="80" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="YTM-8H-EpC" firstAttribute="leading" secondItem="37f-cq-3Eg" secondAttribute="leading" constant="8" id="0FC-Ly-dRv"/>
|
||||
<constraint firstAttribute="trailing" secondItem="5g8-vg-2EB" secondAttribute="trailing" constant="8" id="Avl-RN-f0J"/>
|
||||
<constraint firstItem="5g8-vg-2EB" firstAttribute="leading" secondItem="37f-cq-3Eg" secondAttribute="leading" constant="8" id="YEf-Sg-fK1"/>
|
||||
<constraint firstItem="eKl-0r-wFc" firstAttribute="leading" secondItem="YTM-8H-EpC" secondAttribute="trailing" constant="8" id="khz-VI-SUO"/>
|
||||
<constraint firstItem="eKl-0r-wFc" firstAttribute="top" secondItem="37f-cq-3Eg" secondAttribute="top" constant="8" id="m8Q-2Z-v8h"/>
|
||||
<constraint firstAttribute="bottom" secondItem="5g8-vg-2EB" secondAttribute="bottom" constant="9" id="oqT-mf-B3Y"/>
|
||||
<constraint firstItem="YTM-8H-EpC" firstAttribute="top" secondItem="37f-cq-3Eg" secondAttribute="top" constant="8" id="s5s-Hs-1tF"/>
|
||||
<constraint firstAttribute="trailing" secondItem="eKl-0r-wFc" secondAttribute="trailing" constant="8" id="zkS-cE-swl"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<connections>
|
||||
<outlet property="lastEventDescription" destination="5g8-vg-2EB" id="Usm-IJ-hlX"/>
|
||||
<outlet property="recentDate" destination="eKl-0r-wFc" id="W7l-rp-OVX"/>
|
||||
<outlet property="roomTitle" destination="YTM-8H-EpC" id="eZ8-OJ-Lpy"/>
|
||||
<segue destination="vC3-pB-5Vb" kind="showDetail" identifier="showDetail" id="6S0-TO-JiA"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
@@ -445,10 +475,17 @@
|
||||
</connections>
|
||||
</tableView>
|
||||
<navigationItem key="navigationItem" title="Recents" id="Zdf-7t-Un8"/>
|
||||
<connections>
|
||||
<outlet property="activityIndicator" destination="4dn-O0-IJ0" id="1dd-MZ-4V4"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="Rux-fX-hf1" sceneMemberID="firstResponder"/>
|
||||
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" animating="YES" style="gray" id="4dn-O0-IJ0">
|
||||
<rect key="frame" x="0.0" y="0.0" width="20" height="20"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
</activityIndicatorView>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1665" y="-678"/>
|
||||
<point key="canvasLocation" x="1665" y="-687"/>
|
||||
</scene>
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="r7l-gg-dq7">
|
||||
|
||||
@@ -34,6 +34,8 @@ NSString* const defaultHomeserver = @"http://www.matrix.org";
|
||||
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *createAccountBtn;
|
||||
|
||||
@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;
|
||||
|
||||
@end
|
||||
|
||||
@implementation LoginViewController
|
||||
@@ -179,6 +181,8 @@ NSString* const defaultHomeserver = @"http://www.matrix.org";
|
||||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (IBAction)onButtonPressed:(id)sender
|
||||
{
|
||||
[self dismissKeyboard];
|
||||
@@ -188,8 +192,12 @@ NSString* const defaultHomeserver = @"http://www.matrix.org";
|
||||
|
||||
if (matrix.homeServer)
|
||||
{
|
||||
[_activityIndicator startAnimating];
|
||||
|
||||
[matrix.homeServer loginWithUser:matrix.userLogin andPassword:_passWordTextField.text
|
||||
success:^(MXLoginResponse *credentials){
|
||||
[_activityIndicator stopAnimating];
|
||||
|
||||
// Report credentials
|
||||
[matrix setUserId:credentials.user_id];
|
||||
[matrix setAccessToken:credentials.access_token];
|
||||
@@ -197,6 +205,8 @@ NSString* const defaultHomeserver = @"http://www.matrix.org";
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
failure:^(NSError *error){
|
||||
[_activityIndicator stopAnimating];
|
||||
|
||||
NSLog(@"Login failed: %@", error);
|
||||
//Alert user
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
|
||||
@@ -19,15 +19,19 @@
|
||||
@interface MatrixHandler : NSObject
|
||||
|
||||
@property (strong, nonatomic) MXHomeServer *homeServer;
|
||||
@property (strong, nonatomic) MXData *mxData;
|
||||
|
||||
|
||||
@property (strong, nonatomic) NSString *homeServerURL;
|
||||
@property (strong, nonatomic) NSString *userLogin;
|
||||
@property (strong, nonatomic) NSString *userId;
|
||||
@property (strong, nonatomic) NSString *accessToken;
|
||||
|
||||
@property (nonatomic,readonly) BOOL isLogged;
|
||||
@property (nonatomic,readonly) BOOL isInitialSyncDone;
|
||||
|
||||
+ (id)sharedHandler;
|
||||
|
||||
- (BOOL)isLogged;
|
||||
- (void)logout;
|
||||
|
||||
@end
|
||||
|
||||
@@ -22,9 +22,8 @@ static MatrixHandler *sharedHandler = nil;
|
||||
@interface MatrixHandler ()
|
||||
|
||||
@property (strong, nonatomic) MXSession *mxSession;
|
||||
@property (strong, nonatomic) MXData *mxData;
|
||||
|
||||
@property BOOL isInitialSyncDone;
|
||||
@property (nonatomic,readwrite) BOOL isInitialSyncDone;
|
||||
|
||||
@end
|
||||
|
||||
@@ -65,7 +64,7 @@ static MatrixHandler *sharedHandler = nil;
|
||||
if (self.mxSession) {
|
||||
self.mxData = [[MXData alloc] initWithMatrixSession:self.mxSession];
|
||||
[self.mxData start:^{
|
||||
_isInitialSyncDone = YES;
|
||||
self.isInitialSyncDone = YES;
|
||||
} failure:^(NSError *error) {
|
||||
NSLog(@"Initial Sync failed: %@", error);
|
||||
//Alert user
|
||||
@@ -79,7 +78,7 @@ static MatrixHandler *sharedHandler = nil;
|
||||
self.mxData = nil;
|
||||
[self.mxSession close];
|
||||
self.mxSession = nil;
|
||||
_isInitialSyncDone = NO;
|
||||
self.isInitialSyncDone = NO;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
|
||||
@@ -17,9 +17,24 @@
|
||||
#import "RecentsViewController.h"
|
||||
#import "RoomViewController.h"
|
||||
|
||||
@interface RecentsViewController ()
|
||||
#import "AppDelegate.h"
|
||||
#import "MatrixHandler.h"
|
||||
|
||||
@property NSMutableArray *objects;
|
||||
@interface RecentsTableViewCell : UITableViewCell
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UILabel *roomTitle;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *lastEventDescription;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *recentDate;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RecentsTableViewCell
|
||||
@end
|
||||
|
||||
@interface RecentsViewController ()
|
||||
@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;
|
||||
|
||||
@property NSArray *recents;
|
||||
@end
|
||||
|
||||
@implementation RecentsViewController
|
||||
@@ -40,6 +55,15 @@
|
||||
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)];
|
||||
self.navigationItem.rightBarButtonItem = addButton;
|
||||
self.roomViewController = (RoomViewController *)[[self.splitViewController.viewControllers lastObject] topViewController];
|
||||
|
||||
// Add activity indicator
|
||||
[self.view addSubview:_activityIndicator];
|
||||
_activityIndicator.center = self.view.center;
|
||||
[self.view bringSubviewToFront:_activityIndicator];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
self.recents = nil;
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
@@ -47,13 +71,57 @@
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
- (void)insertNewObject:(id)sender {
|
||||
if (!self.objects) {
|
||||
self.objects = [[NSMutableArray alloc] init];
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
// Refresh recents table
|
||||
[self refresh];
|
||||
[[MatrixHandler sharedHandler] addObserver:self forKeyPath:@"isInitialSyncDone" options:0 context:nil];
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
[super viewWillDisappear:animated];
|
||||
[[MatrixHandler sharedHandler] removeObserver:self forKeyPath:@"isInitialSyncDone"];
|
||||
}
|
||||
|
||||
#pragma mark - recents
|
||||
|
||||
- (void)refresh {
|
||||
[_activityIndicator startAnimating];
|
||||
|
||||
MatrixHandler *mxHandler = [MatrixHandler sharedHandler];
|
||||
if ([mxHandler isInitialSyncDone] || [mxHandler isLogged] == NO) {
|
||||
// Update recents
|
||||
if (mxHandler.mxData) {
|
||||
self.recents = mxHandler.mxData.recents;
|
||||
} else {
|
||||
self.recents = nil;
|
||||
}
|
||||
|
||||
[self.tableView reloadData];
|
||||
[_activityIndicator stopAnimating];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)insertNewObject:(id)sender {
|
||||
// if (!self.recents) {
|
||||
// self.recents = [[NSMutableArray alloc] init];
|
||||
// }
|
||||
// [self.recents insertObject:[NSDate date] atIndex:0];
|
||||
// NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
|
||||
// [self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
|
||||
}
|
||||
|
||||
#pragma mark - KVO
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
||||
{
|
||||
if ([@"isInitialSyncDone" isEqualToString:keyPath])
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self refresh];
|
||||
});
|
||||
}
|
||||
[self.objects insertObject:[NSDate date] atIndex:0];
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
|
||||
[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
|
||||
}
|
||||
|
||||
#pragma mark - Segues
|
||||
@@ -61,18 +129,17 @@
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
if ([[segue identifier] isEqualToString:@"showDetail"]) {
|
||||
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
|
||||
NSDate *object = self.objects[indexPath.row];
|
||||
MXEvent *mxEvent = self.recents[indexPath.row];
|
||||
|
||||
UIViewController *controller;
|
||||
if ([[segue destinationViewController] isKindOfClass:[UINavigationController class]]) {
|
||||
controller = [[segue destinationViewController] topViewController];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
controller = [segue destinationViewController];
|
||||
}
|
||||
|
||||
if ([controller isKindOfClass:[RoomViewController class]]) {
|
||||
[(RoomViewController *)controller setDetailItem:object];
|
||||
[(RoomViewController *)controller setRoomId:mxEvent.room_id];
|
||||
}
|
||||
|
||||
controller.navigationItem.leftBarButtonItem = self.splitViewController.displayModeButtonItem;
|
||||
@@ -87,14 +154,32 @@
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return self.objects.count;
|
||||
return self.recents.count;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return 70;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
|
||||
RecentsTableViewCell *cell = (RecentsTableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"RecentsCell" forIndexPath:indexPath];
|
||||
|
||||
NSDate *object = self.objects[indexPath.row];
|
||||
cell.textLabel.text = [object description];
|
||||
MXEvent *mxEvent = self.recents[indexPath.row];
|
||||
MXRoomData *mxRoomData = [[[MatrixHandler sharedHandler] mxData] getRoomData:mxEvent.room_id];
|
||||
|
||||
cell.roomTitle.text = [mxRoomData room_id]; // TODO use room display name
|
||||
cell.lastEventDescription.text = [mxEvent description];
|
||||
|
||||
NSDate *date = [NSDate dateWithTimeIntervalSince1970:mxEvent.ts];
|
||||
NSString *dateFormat = @"MMM dd HH:mm";
|
||||
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
||||
[dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:[[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0]]];
|
||||
[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
|
||||
[dateFormatter setTimeStyle:NSDateFormatterNoStyle];
|
||||
[dateFormatter setDateFormat:dateFormat];
|
||||
cell.recentDate.text = [dateFormatter stringFromDate:date];
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
@@ -105,8 +190,8 @@
|
||||
|
||||
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (editingStyle == UITableViewCellEditingStyleDelete) {
|
||||
[self.objects removeObjectAtIndex:indexPath.row];
|
||||
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
|
||||
// [self.recents removeObjectAtIndex:indexPath.row];
|
||||
// [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
|
||||
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
|
||||
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
|
||||
@interface RoomViewController : UIViewController
|
||||
|
||||
@property (strong, nonatomic) id detailItem;
|
||||
@property (strong, nonatomic) NSString *roomId;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UILabel *detailDescriptionLabel;
|
||||
|
||||
@end
|
||||
|
||||
@@ -16,27 +16,30 @@
|
||||
|
||||
#import "RoomViewController.h"
|
||||
|
||||
#import "MatrixHandler.h"
|
||||
|
||||
@interface RoomViewController ()
|
||||
|
||||
@property (strong, nonatomic) MXRoomData *mxRoomData;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RoomViewController
|
||||
|
||||
#pragma mark - Managing the detail item
|
||||
|
||||
- (void)setDetailItem:(id)newDetailItem {
|
||||
if (_detailItem != newDetailItem) {
|
||||
_detailItem = newDetailItem;
|
||||
|
||||
// Update the view.
|
||||
[self configureView];
|
||||
}
|
||||
- (void)setDetailItem:(NSString*)roomId {
|
||||
_roomId = roomId;
|
||||
|
||||
// Update the view.
|
||||
[self configureView];
|
||||
}
|
||||
|
||||
- (void)configureView {
|
||||
// Update the user interface for the detail item.
|
||||
if (self.detailItem) {
|
||||
self.detailDescriptionLabel.text = [self.detailItem description];
|
||||
if (self.roomId) {
|
||||
self.mxRoomData = [[[MatrixHandler sharedHandler] mxData] getRoomData:self.roomId];
|
||||
self.detailDescriptionLabel.text = [self.mxRoomData.lastEvent event_id];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +49,10 @@
|
||||
[self configureView];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
_mxRoomData = nil;
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
|
||||
Reference in New Issue
Block a user