Expanded Header: the height is now variable.

This commit is contained in:
giomfo 2016-04-25 17:26:39 +02:00
parent b3b51a03fc
commit 7007b18c88
7 changed files with 50 additions and 56 deletions

View file

@ -170,7 +170,6 @@
// Prepare expanded header
self.expandedHeaderContainer.backgroundColor = kVectorColorLightGrey;
self.expandedHeaderContainerHeightConstraint.constant = 240;
expandedHeader = [ExpandedRoomTitleView roomTitleView];
expandedHeader.delegate = self;
@ -178,6 +177,13 @@
expandedHeader.translatesAutoresizingMaskIntoConstraints = NO;
[self.expandedHeaderContainer addSubview:expandedHeader];
// Force expanded header in full width
NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:expandedHeader
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:self.expandedHeaderContainer
attribute:NSLayoutAttributeTop
multiplier:1.0
constant:0];
NSLayoutConstraint *leftConstraint = [NSLayoutConstraint constraintWithItem:expandedHeader
attribute:NSLayoutAttributeLeading
relatedBy:NSLayoutRelationEqual
@ -192,23 +198,8 @@
attribute:NSLayoutAttributeTrailing
multiplier:1.0
constant:0];
// Vertical constraints are required for iOS > 8
NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:expandedHeader
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:self.expandedHeaderContainer
attribute:NSLayoutAttributeTop
multiplier:1.0
constant:0];
NSLayoutConstraint *bottomConstraint = [NSLayoutConstraint constraintWithItem:expandedHeader
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationEqual
toItem:self.expandedHeaderContainer
attribute:NSLayoutAttributeBottom
multiplier:1.0
constant:0];
[NSLayoutConstraint activateConstraints:@[leftConstraint, rightConstraint, topConstraint, bottomConstraint]];
[NSLayoutConstraint activateConstraints:@[leftConstraint, rightConstraint, topConstraint]];
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(onSwipeGesture:)];
@ -457,8 +448,10 @@
self.navigationItem.rightBarButtonItem.enabled = (self.roomDataSource != nil);
self.titleView.editable = NO;
// Force expanded header refresh
expandedHeader.mxRoom = self.roomDataSource.room;
self.expandedHeaderContainerHeightConstraint.constant = expandedHeader.bottomBorderView.frame.origin.y + 1;
// Restore tool bar view and room activities view if none
if (!self.inputToolbarView)
@ -637,6 +630,12 @@
[self setRoomTitleViewClass:RoomTitleView.class];
((RoomTitleView*)self.titleView).tapGestureDelegate = self;
}
else
{
// Force expanded header refresh
expandedHeader.mxRoom = self.roomDataSource.room;
self.expandedHeaderContainerHeightConstraint.constant = expandedHeader.bottomBorderView.frame.origin.y + 1;
}
}
else
{
@ -824,10 +823,6 @@
{
// Warn the user that the email is not bound to his matrix account
previewHeader.subInvitationLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_preview_unlinked_email_warning", @"Vector", nil), roomPreviewData.emailInvitation.email];
// room_preview_unlinked_email_warning is long long long and overlaps
// bottomBorderView. So, hide this last one.
previewHeader.bottomBorderView.hidden = YES;
}
}

View file

@ -33,10 +33,10 @@
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</tableView>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uK2-9a-rZj" userLabel="Expanded Header Container" customClass="ExpandedRoomTitleView">
<rect key="frame" x="0.0" y="0.0" width="600" height="240"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="215"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="240" id="w9z-HS-7wJ"/>
<constraint firstAttribute="height" constant="215" id="w9z-HS-7wJ"/>
</constraints>
</view>
<scrollView hidden="YES" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" translatesAutoresizingMaskIntoConstraints="NO" id="RJ4-Os-6tg">

View file

@ -21,6 +21,6 @@
@property (weak, nonatomic) IBOutlet UILabel *roomTopic;
@property (weak, nonatomic) IBOutlet UILabel *roomMembers;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *roomMembersLabelTopConstraint;
@property (weak, nonatomic) IBOutlet UIView *bottomBorderView;
@end

View file

@ -56,18 +56,6 @@
self.roomTopic.text = [MXTools stripNewlineCharacters:self.mxRoom.state.topic];
// Adjust the position of the display name and the member status according to the presence of a room topic.
if (self.roomTopic.text.length)
{
self.displayNameTextFieldTopConstraint.constant = 126;
self.roomMembersLabelTopConstraint.constant = 203;
}
else
{
self.displayNameTextFieldTopConstraint.constant = 141;
self.roomMembersLabelTopConstraint.constant = 193;
}
// Compute active members count
NSArray *members = self.mxRoom.state.members;
NSUInteger activeCount = 0;
@ -110,6 +98,9 @@
self.roomTopic.text = nil;
self.roomMembers.text = nil;
}
// Force the layout of subviews to update the position of 'bottomBorderView' which is used to define the actual height of the preview container.
[self layoutIfNeeded];
}
@end

View file

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9532" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10116" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="BkF-x3-7fX" customClass="ExpandedRoomTitleView">
<rect key="frame" x="0.0" y="0.0" width="600" height="240"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="215"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="Room Name" textAlignment="center" adjustsFontSizeToFit="NO" minimumFontSize="14" translatesAutoresizingMaskIntoConstraints="NO" id="6uH-I3-RQg">
@ -21,36 +21,37 @@
</connections>
</textField>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qD3-kA-DSI">
<rect key="frame" x="282" y="153" width="36" height="34"/>
<constraints>
<constraint firstAttribute="height" constant="34" id="ix5-w4-Q3B"/>
</constraints>
<rect key="frame" x="282" y="153" width="36" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ou0-3Z-weL">
<rect key="frame" x="282" y="203" width="36" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="i81-a7-i4K"/>
</constraints>
<rect key="frame" x="282" y="184" width="36" height="17"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="details_icon" translatesAutoresizingMaskIntoConstraints="NO" id="S3Y-wJ-HOe">
<rect key="frame" x="325" y="208" width="6" height="12"/>
<rect key="frame" x="325" y="187" width="6" height="12"/>
<constraints>
<constraint firstAttribute="width" constant="6" id="XTx-6p-2wB"/>
<constraint firstAttribute="height" constant="12" id="tXh-eB-ave"/>
</constraints>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ckb-7c-sTg">
<rect key="frame" x="0.0" y="214" width="600" height="1"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="D7c-fR-aRY"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="8HH-9b-1yH">
<rect key="frame" x="0.0" y="0.0" width="600" height="186"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="177"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="MFb-0F-eO8">
<rect key="frame" x="0.0" y="186" width="600" height="54"/>
<rect key="frame" x="0.0" y="177" width="600" height="38"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
</subviews>
@ -64,29 +65,33 @@
<constraint firstItem="8HH-9b-1yH" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="top" id="4IU-hf-3R1"/>
<constraint firstItem="ou0-3Z-weL" firstAttribute="centerX" secondItem="BkF-x3-7fX" secondAttribute="centerX" id="9kY-pQ-khO"/>
<constraint firstItem="S3Y-wJ-HOe" firstAttribute="centerY" secondItem="ou0-3Z-weL" secondAttribute="centerY" id="C0N-Rf-ncJ"/>
<constraint firstItem="ou0-3Z-weL" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="top" constant="203" id="DWc-Lx-6Ta"/>
<constraint firstItem="qD3-kA-DSI" firstAttribute="top" secondItem="6uH-I3-RQg" secondAttribute="bottom" constant="5" id="IRZ-hl-lUU"/>
<constraint firstItem="S3Y-wJ-HOe" firstAttribute="leading" secondItem="ou0-3Z-weL" secondAttribute="trailing" constant="7" id="JrS-kW-PJv"/>
<constraint firstItem="MFb-0F-eO8" firstAttribute="leading" secondItem="BkF-x3-7fX" secondAttribute="leading" id="LTB-3D-soR"/>
<constraint firstItem="6uH-I3-RQg" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="top" constant="126" id="Piq-rp-Pae"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="qD3-kA-DSI" secondAttribute="trailing" constant="31" id="RSk-Fd-oq0"/>
<constraint firstAttribute="trailing" secondItem="8HH-9b-1yH" secondAttribute="trailing" id="SrK-30-YET"/>
<constraint firstItem="MFb-0F-eO8" firstAttribute="top" secondItem="8HH-9b-1yH" secondAttribute="bottom" id="ULI-RY-Ase"/>
<constraint firstItem="qD3-kA-DSI" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="top" constant="153" id="Xad-Ga-eTx"/>
<constraint firstItem="Ckb-7c-sTg" firstAttribute="leading" secondItem="BkF-x3-7fX" secondAttribute="leading" id="WJb-dz-Ak3"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="6uH-I3-RQg" secondAttribute="trailing" constant="31" id="aK3-vQ-EVu"/>
<constraint firstItem="Ckb-7c-sTg" firstAttribute="top" secondItem="ou0-3Z-weL" secondAttribute="bottom" constant="13" id="aRN-om-eWc"/>
<constraint firstItem="ou0-3Z-weL" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="BkF-x3-7fX" secondAttribute="leading" constant="31" id="c9h-h2-VEs"/>
<constraint firstAttribute="trailing" secondItem="Ckb-7c-sTg" secondAttribute="trailing" id="erV-R4-LXD"/>
<constraint firstItem="6uH-I3-RQg" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="BkF-x3-7fX" secondAttribute="leading" constant="31" id="gnq-cO-l4Y"/>
<constraint firstItem="qD3-kA-DSI" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="BkF-x3-7fX" secondAttribute="leading" constant="31" id="jjG-gN-eIv"/>
<constraint firstItem="8HH-9b-1yH" firstAttribute="bottom" secondItem="ou0-3Z-weL" secondAttribute="top" constant="-17" id="qhl-rY-1wD"/>
<constraint firstItem="ou0-3Z-weL" firstAttribute="top" secondItem="qD3-kA-DSI" secondAttribute="bottom" constant="14" id="sJB-Wr-gFl"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="ou0-3Z-weL" secondAttribute="trailing" constant="31" id="sPZ-Hp-JeH"/>
<constraint firstAttribute="trailing" secondItem="MFb-0F-eO8" secondAttribute="trailing" id="vjK-vS-uzY"/>
<constraint firstItem="8HH-9b-1yH" firstAttribute="bottom" secondItem="qD3-kA-DSI" secondAttribute="bottom" constant="7" id="wzH-3D-S6C"/>
<constraint firstAttribute="bottom" secondItem="ou0-3Z-weL" secondAttribute="bottom" constant="14" id="yXn-jl-DeG"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="bottomBorderView" destination="Ckb-7c-sTg" id="2Ky-GN-bO0"/>
<outlet property="displayNameTextField" destination="6uH-I3-RQg" id="MfX-LQ-C2K"/>
<outlet property="displayNameTextFieldTopConstraint" destination="Piq-rp-Pae" id="jnL-Hz-TWn"/>
<outlet property="roomDetailsMask" destination="MFb-0F-eO8" id="ajK-sr-qf7"/>
<outlet property="roomMembers" destination="ou0-3Z-weL" id="FCF-ki-HuP"/>
<outlet property="roomMembersLabelTopConstraint" destination="DWc-Lx-6Ta" id="09y-zp-t4o"/>
<outlet property="roomTopic" destination="qD3-kA-DSI" id="mOj-AU-7LM"/>
<outlet property="titleMask" destination="8HH-9b-1yH" id="MFh-3r-I5e"/>
</connections>

View file

@ -199,6 +199,9 @@
self.roomTopic.text = nil;
self.invitationLabel.text = nil;
}
// Force the layout of subviews to update the position of 'bottomBorderView' which is used to define the actual height of the preview container.
[self layoutIfNeeded];
}
- (void)setRoomPreviewData:(RoomPreviewData *)roomPreviewData

View file

@ -9,7 +9,7 @@
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="Cpa-Xt-cwB" customClass="PreviewRoomTitleView">
<rect key="frame" x="0.0" y="0.0" width="600" height="371"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="363"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BkF-x3-7fX">