add_invite_rooms_section

-> add the customized invite cell.
not yet plugged.
This commit is contained in:
yannick
2015-12-09 17:01:29 +01:00
parent 2ff73cded1
commit c96d6fb9cd
6 changed files with 234 additions and 5 deletions
+29
View File
@@ -20,6 +20,8 @@
#import "VectorDesignValues.h"
#import "InviteRecentTableViewCell.h"
@interface RecentsDataSource()
{
NSMutableArray* invitesCellDataArray;
@@ -195,6 +197,33 @@
return [super viewForHeaderInSection:section withFrame:frame];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
id<MXKRecentCellDataStoring> roomData = [self cellDataAtIndexPath:indexPath];
if (roomData && self.delegate)
{
NSString *cellIdentifier = [self.delegate cellReuseIdentifierForCellData:roomData];
if (cellIdentifier)
{
UITableViewCell<MXKCellRendering> *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
// Make the bubble display the data
[cell render:roomData];
// Clear the user flag, if only one recents list is available
if (displayedRecentsDataSourceArray.count == 1 && [cell isKindOfClass:[MXKInterleavedRecentTableViewCell class]])
{
((MXKInterleavedRecentTableViewCell*)cell).userFlag.backgroundColor = [UIColor clearColor];
}
return cell;
}
}
return nil;
}
- (id<MXKRecentCellDataStoring>)cellDataAtIndexPath:(NSIndexPath *)indexPath
{
id<MXKRecentCellDataStoring> cellData = nil;
+24 -5
View File
@@ -27,6 +27,8 @@
#import "VectorDesignValues.h"
#import "InviteRecentTableViewCell.h"
@interface RecentsViewController ()
{
// Recents refresh handling
@@ -81,6 +83,7 @@
// Register here the customized cell view class used to render recents
[self.recentsTableView registerNib:RecentTableViewCell.nib forCellReuseIdentifier:RecentTableViewCell.defaultReuseIdentifier];
[self.recentsTableView registerNib:InviteRecentTableViewCell.nib forCellReuseIdentifier:InviteRecentTableViewCell.defaultReuseIdentifier];
}
- (void)dealloc
@@ -423,15 +426,31 @@
#pragma mark - MXKDataSourceDelegate
- (Class<MXKCellRendering>)cellViewClassForCellData:(MXKCellData*)cellData
{
// Return the customized recent table view cell
return RecentTableViewCell.class;
{
id<MXKRecentCellDataStoring> cellDataStoring = (id<MXKRecentCellDataStoring> )cellData;
if (NSNotFound == [cellDataStoring.recentsDataSource.mxSession.invitedRooms indexOfObject:cellDataStoring.roomDataSource.room])
{
return RecentTableViewCell.class;
}
else
{
return InviteRecentTableViewCell.class;
}
}
- (NSString *)cellReuseIdentifierForCellData:(MXKCellData*)cellData
{
// Return the customized recent table view cell identifier
return RecentTableViewCell.defaultReuseIdentifier;
id<MXKRecentCellDataStoring> cellDataStoring = (id<MXKRecentCellDataStoring> )cellData;
if (NSNotFound == [cellDataStoring.recentsDataSource.mxSession.invitedRooms indexOfObject:cellDataStoring.roomDataSource.room])
{
return RecentTableViewCell.defaultReuseIdentifier;
}
else
{
return InviteRecentTableViewCell.defaultReuseIdentifier;
}
}
- (void)dataSource:(MXKDataSource *)dataSource didCellChange:(id)changes
@@ -0,0 +1,26 @@
/*
Copyright 2015 OpenMarket 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 <MatrixKit/MatrixKit.h>
#import "RecentTableViewCell.h"
/**
`InviteRecentTableViewCell` instances display an invite to a room in the context of the recents list.
*/
@interface InviteRecentTableViewCell : RecentTableViewCell
@end
@@ -0,0 +1,45 @@
/*
Copyright 2015 OpenMarket 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 "InviteRecentTableViewCell.h"
#import "AvatarGenerator.h"
#import "MXEvent.h"
#import "VectorDesignValues.h"
@implementation InviteRecentTableViewCell
#pragma mark - Class methods
- (void)awakeFromNib
{
[super awakeFromNib];
}
- (void)render:(MXKCellData *)cellData
{
[super render:cellData];
}
+ (CGFloat)heightForCellData:(MXKCellData *)cellData withMaximumWidth:(CGFloat)maxWidth
{
// The height is fixed
return 79;
}
@end
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9060" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9051"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="L2L-l5-wPx" customClass="InviteRecentTableViewCell">
<rect key="frame" x="0.0" y="0.0" width="600" height="79"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="L2L-l5-wPx" id="aXz-IR-jj5">
<rect key="frame" x="0.0" y="0.0" width="600" height="78"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="e7r-zL-9bw" userLabel="Bing indicator">
<rect key="frame" x="0.0" y="0.0" width="8" height="74"/>
<animations/>
<color key="backgroundColor" red="0.028153735484073149" green="0.82494870580808077" blue="0.051896891282274656" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="74" id="C2z-3m-zJG"/>
<constraint firstAttribute="width" constant="8" id="TWc-jq-awv"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RX5-eD-c3c" userLabel="Room avatar" customClass="MXKImageView">
<rect key="frame" x="11" y="10" width="34" height="34"/>
<animations/>
<color key="backgroundColor" white="0.89720269880000003" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="34" id="7Ys-gS-ja8"/>
<constraint firstAttribute="height" constant="34" id="WPC-tL-hnM"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="LastEventDescription" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dQt-mN-T6b">
<rect key="frame" x="53" y="31" width="538" height="14"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<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="360-Go-RcG">
<rect key="frame" x="522" y="9" width="70" height="14"/>
<animations/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="70" id="uOj-6w-G8q"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="RoomTitle" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lg1-xQ-AGn">
<rect key="frame" x="53" y="9" width="461" height="21"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="tjf-WP-vTl" userLabel="buttonsContainer">
<rect key="frame" x="53" y="51" width="461" height="20"/>
<animations/>
<color key="backgroundColor" red="1" green="0.42877345709999998" blue="0.42329320510000001" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="lTf-u3-Z4R"/>
</constraints>
</view>
</subviews>
<animations/>
<constraints>
<constraint firstItem="tjf-WP-vTl" firstAttribute="width" secondItem="Lg1-xQ-AGn" secondAttribute="width" id="536-Lp-oHC"/>
<constraint firstItem="RX5-eD-c3c" firstAttribute="leading" secondItem="e7r-zL-9bw" secondAttribute="trailing" constant="3" id="LV7-DF-69l"/>
<constraint firstItem="e7r-zL-9bw" firstAttribute="leading" secondItem="aXz-IR-jj5" secondAttribute="leading" id="PUW-if-ewh"/>
<constraint firstItem="Lg1-xQ-AGn" firstAttribute="leading" secondItem="RX5-eD-c3c" secondAttribute="trailing" constant="8" id="Pgp-JM-oQd"/>
<constraint firstItem="e7r-zL-9bw" firstAttribute="top" secondItem="aXz-IR-jj5" secondAttribute="top" id="VHj-kc-U2A"/>
<constraint firstAttribute="bottom" secondItem="dQt-mN-T6b" secondAttribute="bottom" constant="33" id="VTl-c8-5s2"/>
<constraint firstItem="dQt-mN-T6b" firstAttribute="leading" secondItem="RX5-eD-c3c" secondAttribute="trailing" constant="8" id="XFM-LG-4uJ"/>
<constraint firstItem="360-Go-RcG" firstAttribute="top" secondItem="aXz-IR-jj5" secondAttribute="top" constant="9" id="XyO-tl-6SX"/>
<constraint firstAttribute="trailing" secondItem="360-Go-RcG" secondAttribute="trailing" constant="8" id="YqC-WC-Wqe"/>
<constraint firstItem="360-Go-RcG" firstAttribute="leading" secondItem="Lg1-xQ-AGn" secondAttribute="trailing" constant="8" id="cmh-bM-EmX"/>
<constraint firstAttribute="trailing" secondItem="dQt-mN-T6b" secondAttribute="trailing" constant="9" id="t2m-pb-5zd"/>
<constraint firstItem="Lg1-xQ-AGn" firstAttribute="top" secondItem="aXz-IR-jj5" secondAttribute="top" constant="9" id="tY3-6V-A3B"/>
<constraint firstItem="tjf-WP-vTl" firstAttribute="leading" secondItem="RX5-eD-c3c" secondAttribute="trailing" constant="8" id="wEB-VM-vz8"/>
</constraints>
</tableViewCellContentView>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="tjf-WP-vTl" secondAttribute="bottom" constant="8" id="NTY-0b-Ylt"/>
<constraint firstItem="RX5-eD-c3c" firstAttribute="top" secondItem="L2L-l5-wPx" secondAttribute="top" constant="10" id="uLf-cg-Vge"/>
</constraints>
<connections>
<outlet property="bingIndicator" destination="e7r-zL-9bw" id="j7L-SI-ec7"/>
<outlet property="lastEventDate" destination="360-Go-RcG" id="Y0L-Dj-ZVn"/>
<outlet property="lastEventDescription" destination="dQt-mN-T6b" id="MSz-h1-cAL"/>
<outlet property="roomAvatar" destination="RX5-eD-c3c" id="dIC-8p-inL"/>
<outlet property="roomTitle" destination="Lg1-xQ-AGn" id="q7Q-TM-5C8"/>
</connections>
</tableViewCell>
</objects>
</document>