Room Details: fix layout of room members list

This commit is contained in:
giomfo
2014-10-28 15:45:10 +01:00
parent c6d35cd8de
commit e98d5ec112
3 changed files with 116 additions and 64 deletions

View File

@@ -200,6 +200,88 @@
<activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="dvT-c5-Ymf">
<rect key="frame" x="290" y="100" width="20" height="20"/>
</activityIndicatorView>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="OWi-J8-sFZ" userLabel="MembersView">
<rect key="frame" x="0.0" y="64" width="600" height="487"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" bounces="NO" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="50" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="pLY-I9-ghF" userLabel="MembersTableView">
<rect key="frame" x="0.0" y="0.0" width="600" height="437"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<view key="tableFooterView" contentMode="scaleToFill" id="fdb-ra-p9Z" userLabel="fakeTableFooterView">
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="RoomMemberCell" rowHeight="50" id="kac-Vi-XbY" customClass="RoomMemberTableCell">
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="kac-Vi-XbY" id="prD-ap-cDD">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="default-profile.png" translatesAutoresizingMaskIntoConstraints="NO" id="RW8-nh-DTj">
<rect key="frame" x="8" y="5" width="40" height="40"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="40" id="4c3-8w-4Tg"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="40" id="Af0-nI-bVY"/>
<constraint firstAttribute="height" constant="40" id="Ml6-Ri-Frz"/>
<constraint firstAttribute="width" constant="40" id="pLY-G3-fxB"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="userLabel" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="uVK-4R-arl" userLabel="userLabel">
<rect key="frame" x="56" y="5" width="464" height="34"/>
<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="lastActiveLabel" textAlignment="center" lineBreakMode="wordWrap" baselineAdjustment="alignBaselines" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="R86-SF-Vqh">
<rect key="frame" x="528" y="5" width="64" height="39"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<progressView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="UDn-QR-f6Q">
<rect key="frame" x="56" y="42" width="464" height="2"/>
</progressView>
</subviews>
<constraints>
<constraint firstItem="UDn-QR-f6Q" firstAttribute="leading" secondItem="prD-ap-cDD" secondAttribute="leading" constant="56" id="2HY-kb-aUu"/>
<constraint firstAttribute="bottom" secondItem="R86-SF-Vqh" secondAttribute="bottom" constant="5" id="3dt-Qu-01M"/>
<constraint firstAttribute="bottom" secondItem="UDn-QR-f6Q" secondAttribute="bottom" constant="5" id="49f-EW-vEr"/>
<constraint firstItem="RW8-nh-DTj" firstAttribute="top" secondItem="prD-ap-cDD" secondAttribute="top" constant="5" id="6La-Gc-4B8"/>
<constraint firstItem="UDn-QR-f6Q" firstAttribute="top" secondItem="uVK-4R-arl" secondAttribute="bottom" constant="3" id="81T-EM-1pe"/>
<constraint firstAttribute="trailing" secondItem="R86-SF-Vqh" secondAttribute="trailing" constant="8" id="BvW-r7-R0r"/>
<constraint firstAttribute="trailing" secondItem="UDn-QR-f6Q" secondAttribute="trailing" constant="80" id="Nrk-rv-6eb"/>
<constraint firstItem="uVK-4R-arl" firstAttribute="leading" secondItem="RW8-nh-DTj" secondAttribute="trailing" constant="8" id="O2H-DM-jOU"/>
<constraint firstAttribute="trailing" secondItem="uVK-4R-arl" secondAttribute="trailing" constant="80" id="RSx-Sk-WrV"/>
<constraint firstItem="uVK-4R-arl" firstAttribute="top" secondItem="prD-ap-cDD" secondAttribute="top" constant="5" id="cFa-Qa-p2W"/>
<constraint firstItem="RW8-nh-DTj" firstAttribute="leading" secondItem="prD-ap-cDD" secondAttribute="leading" constant="8" id="hXV-sM-uhV"/>
<constraint firstAttribute="bottom" secondItem="uVK-4R-arl" secondAttribute="bottom" constant="10" id="l5F-M4-LOB"/>
<constraint firstItem="R86-SF-Vqh" firstAttribute="top" secondItem="prD-ap-cDD" secondAttribute="top" constant="5" id="mNu-kF-Hb7"/>
<constraint firstItem="R86-SF-Vqh" firstAttribute="leading" secondItem="uVK-4R-arl" secondAttribute="trailing" constant="8" id="tz0-aZ-yaX"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<outlet property="lastActiveAgoLabel" destination="R86-SF-Vqh" id="AIr-OL-gqM"/>
<outlet property="pictureView" destination="RW8-nh-DTj" id="1Lk-bd-tKv"/>
<outlet property="userLabel" destination="uVK-4R-arl" id="OhP-VD-vj0"/>
<outlet property="userPowerLevel" destination="UDn-QR-f6Q" id="Ts8-l1-Lyv"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="msb-ol-2LB" id="syy-QA-aQI"/>
<outlet property="delegate" destination="msb-ol-2LB" id="1RP-DQ-mUd"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.40000000000000002" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="pLY-I9-ghF" firstAttribute="leading" secondItem="OWi-J8-sFZ" secondAttribute="leading" id="3h3-MI-LXi"/>
<constraint firstAttribute="trailing" secondItem="pLY-I9-ghF" secondAttribute="trailing" id="JAb-Eo-6OC"/>
<constraint firstItem="pLY-I9-ghF" firstAttribute="top" secondItem="OWi-J8-sFZ" secondAttribute="top" id="Tgu-no-t2P"/>
<constraint firstAttribute="bottom" secondItem="pLY-I9-ghF" secondAttribute="bottom" constant="50" id="lMV-nK-DVn"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
@@ -209,7 +291,11 @@
<constraint firstAttribute="bottom" secondItem="meV-kn-sxo" secondAttribute="bottom" constant="44" id="Cos-M5-WHG"/>
<constraint firstItem="dvT-c5-Ymf" firstAttribute="top" secondItem="it4-Tc-q7z" secondAttribute="bottom" constant="36" id="FV3-P0-ekh"/>
<constraint firstItem="meV-kn-sxo" firstAttribute="top" secondItem="1BF-nV-MTf" secondAttribute="top" id="OWt-4M-1DF"/>
<constraint firstItem="OWi-J8-sFZ" firstAttribute="leading" secondItem="1BF-nV-MTf" secondAttribute="leading" id="TAa-Ov-DlQ"/>
<constraint firstItem="OWi-J8-sFZ" firstAttribute="top" secondItem="it4-Tc-q7z" secondAttribute="bottom" id="YkW-6x-JOH"/>
<constraint firstItem="nNf-bE-8dQ" firstAttribute="top" secondItem="OWi-J8-sFZ" secondAttribute="bottom" id="ddz-rI-Y8M"/>
<constraint firstItem="meV-kn-sxo" firstAttribute="leading" secondItem="1BF-nV-MTf" secondAttribute="leading" id="ext-xr-eNx"/>
<constraint firstAttribute="trailing" secondItem="OWi-J8-sFZ" secondAttribute="trailing" id="sew-P4-axR"/>
<constraint firstAttribute="centerX" secondItem="dvT-c5-Ymf" secondAttribute="centerX" id="u9d-Bd-6Ci"/>
<constraint firstAttribute="trailing" secondItem="meV-kn-sxo" secondAttribute="trailing" id="vBl-Ri-4Hb"/>
</constraints>
@@ -219,6 +305,8 @@
<outlet property="activityIndicator" destination="dvT-c5-Ymf" id="F6h-Al-Vw6"/>
<outlet property="controlView" destination="6fM-aJ-d0M" id="13g-Wl-z5n"/>
<outlet property="controlViewBottomConstraint" destination="C5t-bm-3s8" id="Ks1-Z5-mzO"/>
<outlet property="membersTableView" destination="pLY-I9-ghF" id="Ioc-IJ-WYX"/>
<outlet property="membersView" destination="OWi-J8-sFZ" id="3n2-n5-r6B"/>
<outlet property="messageTextField" destination="k2m-aY-U73" id="fSA-Eg-duj"/>
<outlet property="messagesTableView" destination="meV-kn-sxo" id="W1n-q0-ml7"/>
<outlet property="optionBtn" destination="cfF-YG-Cvg" id="Ppb-dg-Tub"/>
@@ -228,7 +316,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="94y-cU-qQD" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1665" y="81"/>
<point key="canvasLocation" x="1665" y="75"/>
</scene>
<!--Home-->
<scene sceneID="3rt-8o-eGh">

View File

@@ -19,7 +19,8 @@
// Room Member Table View Cell
@interface RoomMemberTableCell : CustomTableViewCell
@property (strong, nonatomic) UILabel *userLabel;
@property (strong, nonatomic) UIProgressView *userPowerLevel;
@property (weak, nonatomic) IBOutlet UILabel *userLabel;
@property (weak, nonatomic) IBOutlet UIProgressView *userPowerLevel;
@property (weak, nonatomic) IBOutlet UILabel *lastActiveAgoLabel;
@end

View File

@@ -50,8 +50,6 @@ NSString *const kFailedEventId = @"failedEventId";
// Members list
NSArray *members;
UIView *membersTableViewBackground;
UITableView *membersTableView;
}
@property (weak, nonatomic) IBOutlet UINavigationItem *roomNavItem;
@@ -62,6 +60,8 @@ NSString *const kFailedEventId = @"failedEventId";
@property (weak, nonatomic) IBOutlet UIButton *sendBtn;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *controlViewBottomConstraint;
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;
@property (weak, nonatomic) IBOutlet UIView *membersView;
@property (weak, nonatomic) IBOutlet UITableView *membersTableView;
@end
@@ -95,8 +95,6 @@ NSString *const kFailedEventId = @"failedEventId";
}
mxRoomData = nil;
membersTableViewBackground = nil;
membersTableView = nil;
members = nil;
}
@@ -341,45 +339,17 @@ NSString *const kFailedEventId = @"failedEventId";
}
- (void)showRoomMembers {
// Dismiss keyboard
[self dismissKeyboard];
members = [mxRoomData members];
// define members table background
CGRect frame = self.messagesTableView.frame;
UIEdgeInsets roomTableInset = self.messagesTableView.contentInset;
frame.origin.x += roomTableInset.left;
frame.origin.y += roomTableInset.top;
frame.size.width -= roomTableInset.left + roomTableInset.right;
frame.size.height -= roomTableInset.top + roomTableInset.bottom;
// overlap the control view
frame.size.height += self.controlView.frame.size.height;
membersTableViewBackground = [[UIView alloc] initWithFrame:frame];
membersTableViewBackground.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4];
membersTableViewBackground.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideRoomMembers)];
[membersTableViewBackground addGestureRecognizer:tap];
// compute table height (the table should not cover all the screen to let the user be able to dismiss the table)
CGFloat tableHeight = members.count * 50;
CGFloat tableHeightMax = membersTableViewBackground.frame.size.height - 50;
if (tableHeightMax < tableHeight)
{
tableHeight = tableHeightMax;
}
frame.size.height = tableHeight;
membersTableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStylePlain];
membersTableView.delegate = self;
membersTableView.dataSource = self;
[self.view addSubview:membersTableViewBackground];
[self.view addSubview:membersTableView];
self.membersView.hidden = NO;
[self.membersTableView reloadData];
}
- (void)hideRoomMembers {
[membersTableView removeFromSuperview];
membersTableView = nil;
[membersTableViewBackground removeFromSuperview];
membersTableViewBackground = nil;
self.membersView.hidden = YES;
members = nil;
}
@@ -422,7 +392,7 @@ NSString *const kFailedEventId = @"failedEventId";
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Check table view members vs messages
if (tableView == membersTableView)
if (tableView == self.membersTableView)
{
return members.count;
}
@@ -432,7 +402,7 @@ NSString *const kFailedEventId = @"failedEventId";
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
// Check table view members vs messages
if (tableView == membersTableView)
if (tableView == self.membersTableView)
{
return 50;
}
@@ -477,31 +447,22 @@ NSString *const kFailedEventId = @"failedEventId";
MatrixHandler *mxHandler = [MatrixHandler sharedHandler];
// Check table view members vs messages
if (tableView == membersTableView)
if (tableView == self.membersTableView)
{
RoomMemberTableCell *cell = [membersTableView dequeueReusableCellWithIdentifier:@"RoomMemberCell"];
if (!cell) {
cell = [[RoomMemberTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"RoomMemberCell"];
cell.frame = CGRectMake(0, 0, membersTableView.frame.size.width, 50);
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.pictureView = [[UIImageView alloc] initWithFrame:CGRectMake(8, 5, 40, 40)];
cell.userLabel = [[UILabel alloc] initWithFrame:CGRectMake(56, 5, membersTableView.frame.size.width - 64, 40)];
cell.userPowerLevel = [[UIProgressView alloc] initWithFrame:CGRectMake(56, 45, 100, 5)];
[cell addSubview:cell.pictureView];
[cell addSubview:cell.userLabel];
[cell addSubview:cell.userPowerLevel];
}
RoomMemberTableCell *memberCell = [tableView dequeueReusableCellWithIdentifier:@"RoomMemberCell" forIndexPath:indexPath];
if (indexPath.row < members.count) {
MXRoomMember *roomMember = [members objectAtIndex:indexPath.row];
cell.userLabel.text = [mxRoomData memberName:roomMember.user_id];
cell.placeholder = @"default-profile";
cell.pictureURL = roomMember.avatar_url;
memberCell.userLabel.text = [mxRoomData memberName:roomMember.user_id];
memberCell.placeholder = @"default-profile";
memberCell.pictureURL = roomMember.avatar_url;
// TODO: set actual power level when it will be available from SDK
cell.userPowerLevel.progress = 0;
memberCell.userPowerLevel.progress = 0;
memberCell.lastActiveAgoLabel.backgroundColor = [UIColor greenColor];
memberCell.lastActiveAgoLabel.text = [NSString stringWithFormat:@"%ds ago", roomMember.last_active_ago];
memberCell.lastActiveAgoLabel.numberOfLines = 0;
}
return cell;
return memberCell;
}
// Handle here room message cells
@@ -576,8 +537,10 @@ NSString *const kFailedEventId = @"failedEventId";
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Dismiss keyboard when user taps on table view content
[self dismissKeyboard];
if (tableView == self.messagesTableView) {
// Dismiss keyboard when user taps on messages table view content
[self dismissKeyboard];
}
}
// Detect vertical bounce at the top of the tableview to trigger pagination