Organize views by feature

This commit is contained in:
SBiOSoftWhare
2018-07-06 16:42:45 +02:00
parent 263c8f9246
commit fbe1264a5a
247 changed files with 1085 additions and 972 deletions
@@ -0,0 +1,24 @@
/*
Copyright 2016 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>
@interface RoomAvatarTitleView : MXKRoomTitleView
@property (weak, nonatomic) IBOutlet UIView *roomAvatarMask;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *roomAvatarMaskCenterXConstraint;
@end
@@ -0,0 +1,94 @@
/*
Copyright 2016 OpenMarket Ltd
Copyright 2017 Vector Creations 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 "RoomAvatarTitleView.h"
#import "RiotDesignValues.h"
#import "MXRoomSummary+Riot.h"
@implementation RoomAvatarTitleView
+ (UINib *)nib
{
return [UINib nibWithNibName:NSStringFromClass([self class])
bundle:[NSBundle bundleForClass:[self class]]];
}
- (void)awakeFromNib
{
[super awakeFromNib];
}
- (void)layoutSubviews
{
[super layoutSubviews];
if (self.superview)
{
if (@available(iOS 11.0, *))
{
// Force the title view layout by adding 2 new constraints on the UINavigationBarContentView instance.
NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:self
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:self.superview
attribute:NSLayoutAttributeTop
multiplier:1.0f
constant:0.0f];
NSLayoutConstraint *centerXConstraint = [NSLayoutConstraint constraintWithItem:self
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:self.superview
attribute:NSLayoutAttributeCenterX
multiplier:1.0f
constant:0.0f];
[NSLayoutConstraint activateConstraints:@[topConstraint, centerXConstraint]];
// Do not crop the avatar
self.superview.clipsToBounds = NO;
}
else
{
// Center horizontally the avatar into the navigation bar
CGRect frame = self.superview.frame;
UINavigationBar *navigationBar;
UIView *superView = self;
while (superView.superview)
{
if ([superView.superview isKindOfClass:[UINavigationBar class]])
{
navigationBar = (UINavigationBar*)superView.superview;
break;
}
superView = superView.superview;
}
if (navigationBar)
{
CGSize navBarSize = navigationBar.frame.size;
CGFloat superviewCenterX = frame.origin.x + (frame.size.width / 2);
self.roomAvatarMaskCenterXConstraint.constant = (navBarSize.width / 2) - superviewCenterX;
}
}
}
}
@end
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13196"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</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="RoomAvatarTitleView">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="cCf-8Q-ono">
<rect key="frame" x="132" y="11" width="110" height="33"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="RoomMemberDetailsVCAvatarMask"/>
<constraints>
<constraint firstAttribute="width" constant="110" id="pWS-KO-25W"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="RoomTitle"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="cCf-8Q-ono" secondAttribute="bottom" id="Aog-XC-o0k"/>
<constraint firstItem="cCf-8Q-ono" firstAttribute="centerX" secondItem="BkF-x3-7fX" secondAttribute="centerX" id="WFK-47-fKx"/>
<constraint firstItem="cCf-8Q-ono" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="top" constant="11" id="bS7-H7-pxo"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="roomAvatarMask" destination="cCf-8Q-ono" id="7m3-ou-P9k"/>
<outlet property="roomAvatarMaskCenterXConstraint" destination="WFK-47-fKx" id="q9A-QQ-30L"/>
</connections>
</view>
</objects>
</document>
@@ -0,0 +1,30 @@
/*
Copyright 2016 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 "RoomTitleView.h"
@interface ExpandedRoomTitleView : RoomTitleView
@property (weak, nonatomic) IBOutlet MXKImageView *roomAvatar;
@property (weak, nonatomic) IBOutlet UIView *roomAvatarHeaderBackground;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *roomAvatarHeaderBackgroundHeightConstraint;
@property (weak, nonatomic) IBOutlet UILabel *roomTopic;
@property (weak, nonatomic) IBOutlet UILabel *roomMembers;
@property (weak, nonatomic) IBOutlet UIView *bottomBorderView;
@end
@@ -0,0 +1,127 @@
/*
Copyright 2016 OpenMarket Ltd
Copyright 2017 Vector Creations 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 "ExpandedRoomTitleView.h"
#import "RiotDesignValues.h"
#import "MXRoomSummary+Riot.h"
@implementation ExpandedRoomTitleView
+ (UINib *)nib
{
return [UINib nibWithNibName:NSStringFromClass([self class])
bundle:[NSBundle bundleForClass:[self class]]];
}
- (void)awakeFromNib
{
[super awakeFromNib];
}
-(void)customizeViewRendering
{
[super customizeViewRendering];
self.displayNameTextField.textColor = (self.mxRoom.summary.displayname.length ? kRiotPrimaryTextColor : kRiotSecondaryTextColor);
self.roomTopic.textColor = kRiotTopicTextColor;
self.roomMembers.textColor = kRiotColorGreen;
}
- (void)refreshDisplay
{
[super refreshDisplay];
if (self.mxRoom)
{
[self.mxRoom.summary setRoomAvatarImageIn:self.roomAvatar];
self.displayNameTextField.text = self.mxRoom.summary.displayname;
if (!self.displayNameTextField.text.length)
{
self.displayNameTextField.text = NSLocalizedStringFromTable(@"room_displayname_no_title", @"Vector", nil);
self.displayNameTextField.textColor = kRiotSecondaryTextColor;
}
else
{
self.displayNameTextField.textColor = kRiotPrimaryTextColor;
}
self.roomTopic.text = [MXTools stripNewlineCharacters:self.mxRoom.state.topic];
// Compute active members count
NSArray *members = [self.mxRoom.state membersWithMembership:MXMembershipJoin includeConferenceUser:NO];
NSUInteger activeCount = 0;
NSUInteger memberCount = 0;
for (MXRoomMember *mxMember in members)
{
memberCount ++;
// Get the user that corresponds to this member
MXUser *user = [self.mxRoom.mxSession userWithUserId:mxMember.userId];
// existing user ?
if (user && user.presence == MXPresenceOnline)
{
activeCount ++;
}
}
if (memberCount)
{
// Check whether the logged in user is alone in this room
if (memberCount == 1 && self.mxRoom.state.membership == MXMembershipJoin)
{
self.roomMembers.text = NSLocalizedStringFromTable(@"room_title_invite_members", @"Vector", nil);
}
else
{
if (activeCount > 1)
{
self.roomMembers.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_title_multiple_active_members", @"Vector", nil), @(activeCount), @(memberCount)];
}
else
{
self.roomMembers.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_title_one_active_member", @"Vector", nil), @(activeCount), @(memberCount)];
}
}
}
else
{
// Should not happen
self.roomMembers.text = nil;
}
}
else
{
self.roomAvatar.image = nil;
self.roomTopic.text = nil;
self.roomMembers.text = nil;
}
// Round image view for thumbnail
self.roomAvatar.layer.cornerRadius = self.roomAvatar.frame.size.width / 2;
self.roomAvatar.clipsToBounds = YES;
self.roomAvatar.defaultBackgroundColor = kRiotSecondaryBgColor;
// 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
@@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</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="193"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uSp-YH-L18">
<rect key="frame" x="0.0" y="0.0" width="600" height="95"/>
<subviews>
<view clipsSubviews="YES" contentMode="scaleAspectFill" translatesAutoresizingMaskIntoConstraints="NO" id="eEk-n9-4dA" customClass="MXKImageView">
<rect key="frame" x="258" y="11" width="84" height="84"/>
<color key="backgroundColor" red="0.6886889638" green="1" blue="0.74383144840000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="MemberAvatar"/>
<constraints>
<constraint firstAttribute="width" secondItem="eEk-n9-4dA" secondAttribute="height" multiplier="1:1" id="2HI-Mo-nH4"/>
<constraint firstAttribute="width" constant="84" id="Yye-G1-hCH"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="RoomAvatarHeaderBackground"/>
<constraints>
<constraint firstAttribute="height" constant="95" id="DzD-aR-3eV"/>
<constraint firstItem="eEk-n9-4dA" firstAttribute="centerX" secondItem="uSp-YH-L18" secondAttribute="centerX" id="W1w-ZX-f2d"/>
<constraint firstAttribute="bottom" secondItem="eEk-n9-4dA" secondAttribute="bottom" id="hXd-bM-Bbb"/>
</constraints>
</view>
<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">
<rect key="frame" x="249" y="103" width="103" height="23"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="DisplayNameTextField"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="18"/>
<textInputTraits key="textInputTraits" returnKeyType="next"/>
<connections>
<outlet property="delegate" destination="BkF-x3-7fX" id="xX7-jB-9va"/>
</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="131" width="36" height="17"/>
<accessibility key="accessibilityConfiguration" identifier="RoomTopic"/>
<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="162" width="36" height="17"/>
<accessibility key="accessibilityConfiguration" identifier="RoomMembers"/>
<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="members_list_icon.png" translatesAutoresizingMaskIntoConstraints="NO" id="S3Y-wJ-HOe">
<rect key="frame" x="260" y="163.5" width="15" height="15"/>
<accessibility key="accessibilityConfiguration" identifier="RoomMembersDetailsIcon"/>
<constraints>
<constraint firstAttribute="width" constant="15" id="XTx-6p-2wB"/>
<constraint firstAttribute="height" constant="15" id="tXh-eB-ave"/>
</constraints>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ckb-7c-sTg">
<rect key="frame" x="0.0" y="192" width="600" height="1"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<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="155"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="MFb-0F-eO8">
<rect key="frame" x="0.0" y="155" width="322" height="38"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="tsg-nl-P3k">
<rect key="frame" x="322" y="151.5" width="38" height="38"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="add_participant.png" translatesAutoresizingMaskIntoConstraints="NO" id="i40-fd-AlH">
<rect key="frame" x="10" y="10" width="18" height="18"/>
<constraints>
<constraint firstAttribute="width" constant="18" id="Jxs-fk-U04"/>
<constraint firstAttribute="width" secondItem="i40-fd-AlH" secondAttribute="height" multiplier="1:1" id="cuB-Hn-Dl3"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="38" id="E23-7d-llG"/>
<constraint firstItem="i40-fd-AlH" firstAttribute="centerX" secondItem="tsg-nl-P3k" secondAttribute="centerX" id="gK0-hw-x7R"/>
<constraint firstItem="i40-fd-AlH" firstAttribute="centerY" secondItem="tsg-nl-P3k" secondAttribute="centerY" id="tyV-XH-iOk"/>
<constraint firstAttribute="width" secondItem="tsg-nl-P3k" secondAttribute="height" multiplier="1:1" id="xH6-0P-TLQ"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="RoomTitle"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="uSp-YH-L18" secondAttribute="trailing" id="0UG-aH-hVB"/>
<constraint firstItem="qD3-kA-DSI" firstAttribute="centerX" secondItem="BkF-x3-7fX" secondAttribute="centerX" id="1MA-VE-nEM"/>
<constraint firstAttribute="bottom" secondItem="MFb-0F-eO8" secondAttribute="bottom" id="1W0-oZ-AQb"/>
<constraint firstItem="tsg-nl-P3k" firstAttribute="centerY" secondItem="ou0-3Z-weL" secondAttribute="centerY" id="3Pa-cx-AsC"/>
<constraint firstItem="6uH-I3-RQg" firstAttribute="centerX" secondItem="BkF-x3-7fX" secondAttribute="centerX" id="3uN-6W-rVZ"/>
<constraint firstItem="8HH-9b-1yH" firstAttribute="leading" secondItem="BkF-x3-7fX" secondAttribute="leading" id="49B-Gu-i1k"/>
<constraint firstItem="8HH-9b-1yH" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="top" id="4IU-hf-3R1"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="tsg-nl-P3k" secondAttribute="trailing" id="4Y7-tV-Spc"/>
<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="S3Y-wJ-HOe" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="BkF-x3-7fX" secondAttribute="leading" id="Dib-vF-l0D"/>
<constraint firstItem="qD3-kA-DSI" firstAttribute="top" secondItem="6uH-I3-RQg" secondAttribute="bottom" constant="5" id="IRZ-hl-lUU"/>
<constraint firstItem="MFb-0F-eO8" firstAttribute="leading" secondItem="BkF-x3-7fX" secondAttribute="leading" id="LTB-3D-soR"/>
<constraint firstItem="tsg-nl-P3k" firstAttribute="leading" secondItem="MFb-0F-eO8" secondAttribute="trailing" id="QOq-Cv-1pw"/>
<constraint firstItem="tsg-nl-P3k" firstAttribute="leading" secondItem="ou0-3Z-weL" secondAttribute="trailing" constant="4" id="RNc-DE-a8O"/>
<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="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="uSp-YH-L18" firstAttribute="leading" secondItem="BkF-x3-7fX" secondAttribute="leading" id="anE-Sc-Gsn"/>
<constraint firstItem="ou0-3Z-weL" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="BkF-x3-7fX" secondAttribute="leading" constant="31" id="c9h-h2-VEs"/>
<constraint firstItem="uSp-YH-L18" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="top" id="dn3-Hv-OyX"/>
<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="ou0-3Z-weL" firstAttribute="leading" secondItem="S3Y-wJ-HOe" secondAttribute="trailing" constant="7" id="iAL-UV-5nu"/>
<constraint firstItem="qD3-kA-DSI" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="BkF-x3-7fX" secondAttribute="leading" constant="31" id="jjG-gN-eIv"/>
<constraint firstItem="6uH-I3-RQg" firstAttribute="top" secondItem="uSp-YH-L18" secondAttribute="bottom" constant="8" id="rAh-mV-nb5"/>
<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 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="addParticipantMask" destination="tsg-nl-P3k" id="ADj-t1-9wf"/>
<outlet property="bottomBorderView" destination="Ckb-7c-sTg" id="2Ky-GN-bO0"/>
<outlet property="displayNameTextField" destination="6uH-I3-RQg" id="MfX-LQ-C2K"/>
<outlet property="roomAvatar" destination="eEk-n9-4dA" id="5jd-Dx-tXE"/>
<outlet property="roomAvatarHeaderBackground" destination="uSp-YH-L18" id="sfW-ED-5bD"/>
<outlet property="roomAvatarHeaderBackgroundHeightConstraint" destination="DzD-aR-3eV" id="SuC-mO-epX"/>
<outlet property="roomDetailsMask" destination="MFb-0F-eO8" id="ajK-sr-qf7"/>
<outlet property="roomMembers" destination="ou0-3Z-weL" id="FCF-ki-HuP"/>
<outlet property="roomTopic" destination="qD3-kA-DSI" id="mOj-AU-7LM"/>
<outlet property="titleMask" destination="8HH-9b-1yH" id="MFh-3r-I5e"/>
</connections>
</view>
</objects>
<resources>
<image name="add_participant.png" width="58" height="58"/>
<image name="members_list_icon.png" width="15" height="15"/>
</resources>
</document>
@@ -0,0 +1,41 @@
/*
Copyright 2016 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 "RoomTitleView.h"
@interface PreviewRoomTitleView : RoomTitleView
@property (weak, nonatomic) IBOutlet UIView *mainHeaderBackground;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *mainHeaderBackgroundHeightConstraint;
@property (weak, nonatomic) IBOutlet UIView *mainHeaderContainer;
@property (weak, nonatomic) IBOutlet MXKImageView *roomAvatar;
@property (weak, nonatomic) IBOutlet UITextView *roomTopic;
@property (weak, nonatomic) IBOutlet UILabel *roomMembers;
@property (weak, nonatomic) IBOutlet UIView *roomMembersDetailsIcon;
@property (weak, nonatomic) IBOutlet UILabel *previewLabel;
@property (weak, nonatomic) IBOutlet UIView *buttonsContainer;
@property (weak, nonatomic) IBOutlet UIButton *leftButton;
@property (weak, nonatomic) IBOutlet UIButton *rightButton;
@property (weak, nonatomic) IBOutlet UILabel *subNoticeLabel;
@property (weak, nonatomic) IBOutlet UIView *bottomBorderView;
@property (nonatomic) NSString *roomAvatarURL;
@property (nonatomic) UIImage *roomAvatarPlaceholder;
@end
@@ -0,0 +1,264 @@
/*
Copyright 2016 OpenMarket Ltd
Copyright 2017 Vector Creations 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 "PreviewRoomTitleView.h"
#import "RiotDesignValues.h"
#import "MXRoomSummary+Riot.h"
@implementation PreviewRoomTitleView
+ (UINib *)nib
{
return [UINib nibWithNibName:NSStringFromClass([self class])
bundle:[NSBundle bundleForClass:[self class]]];
}
- (void)awakeFromNib
{
[super awakeFromNib];
self.previewLabel.text = nil;
self.subNoticeLabel.text = nil;
[self.leftButton setTitle:NSLocalizedStringFromTable(@"decline", @"Vector", nil) forState:UIControlStateNormal];
[self.leftButton setTitle:NSLocalizedStringFromTable(@"decline", @"Vector", nil) forState:UIControlStateHighlighted];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(reportTapGesture:)];
[tap setNumberOfTouchesRequired:1];
[tap setNumberOfTapsRequired:1];
[tap setDelegate:self];
[self.leftButton addGestureRecognizer:tap];
self.leftButton.userInteractionEnabled = YES;
[self.rightButton setTitle:NSLocalizedStringFromTable(@"join", @"Vector", nil) forState:UIControlStateNormal];
[self.rightButton setTitle:NSLocalizedStringFromTable(@"join", @"Vector", nil) forState:UIControlStateHighlighted];
tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(reportTapGesture:)];
[tap setNumberOfTouchesRequired:1];
[tap setNumberOfTapsRequired:1];
[tap setDelegate:self];
[self.rightButton addGestureRecognizer:tap];
self.rightButton.userInteractionEnabled = YES;
}
-(void)customizeViewRendering
{
[super customizeViewRendering];
self.backgroundColor = kRiotPrimaryBgColor;
self.mainHeaderBackground.backgroundColor = kRiotSecondaryBgColor;
self.displayNameTextField.textColor = (self.mxRoom.summary.displayname.length ? kRiotPrimaryTextColor : kRiotSecondaryTextColor);
self.roomTopic.textColor = kRiotTopicTextColor;
self.roomMembers.textColor = kRiotColorGreen;
self.previewLabel.textColor = kRiotTopicTextColor;
self.previewLabel.numberOfLines = 0;
self.subNoticeLabel.textColor = kRiotSecondaryTextColor;
self.subNoticeLabel.numberOfLines = 0;
self.bottomBorderView.backgroundColor = kRiotSecondaryBgColor;
[self.leftButton.layer setCornerRadius:5];
self.leftButton.clipsToBounds = YES;
self.leftButton.backgroundColor = kRiotColorGreen;
[self.rightButton.layer setCornerRadius:5];
self.rightButton.clipsToBounds = YES;
self.rightButton.backgroundColor = kRiotColorGreen;
}
- (void)refreshDisplay
{
[super refreshDisplay];
// Consider in priority the preview data (if any)
if (self.roomPreviewData)
{
if (self.roomAvatarURL)
{
[self.roomAvatar setImageURL:self.roomAvatarURL withType:nil andImageOrientation:UIImageOrientationUp previewImage:[UIImage imageNamed:@"placeholder"]];
}
else
{
self.roomAvatar.image = self.roomAvatarPlaceholder;
}
// Room topic
self.roomTopic.text = self.roomPreviewData.roomTopic;
[UIView setAnimationsEnabled:NO];
[self.roomTopic scrollRangeToVisible:NSMakeRange(0, 0)];
[UIView setAnimationsEnabled:YES];
// Joined members count
if (self.roomPreviewData.numJoinedMembers > 1)
{
self.roomMembers.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_title_members", @"Vector", nil), @(self.roomPreviewData.numJoinedMembers)];
}
else if (self.roomPreviewData.numJoinedMembers == 1)
{
self.roomMembers.text = NSLocalizedStringFromTable(@"room_title_one_member", @"Vector", nil);
}
else
{
self.roomMembers.text = nil;
}
// Preview subtitle
if (self.roomPreviewData.roomDataSource)
{
// Display the default preview subtitle in case of peeking
self.subNoticeLabel.text = NSLocalizedStringFromTable(@"room_preview_subtitle", @"Vector", nil);
}
else
{
self.subNoticeLabel.text = nil;
}
if (self.roomPreviewData.emailInvitation.email)
{
// The user has been invited to join this room by email
self.previewLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_preview_invitation_format", @"Vector", nil), self.roomPreviewData.emailInvitation.inviterName];
// Warn the user that the email is not bound to his matrix account
self.subNoticeLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_preview_unlinked_email_warning", @"Vector", nil), self.roomPreviewData.emailInvitation.email];
}
else
{
// This is a room opened from a room link, or from the room search.
NSString *roomName = self.roomPreviewData.roomName;
if (!roomName)
{
roomName = NSLocalizedStringFromTable(@"room_preview_try_join_an_unknown_room_default", @"Vector", nil);
}
else if (roomName.length > 20)
{
// Would have been nice to get the cropped string displayed by
// self.displayNameTextField but the value is not accessible.
// Cut it off by hand
roomName = [NSString stringWithFormat:@"%@…",[roomName substringToIndex:20]];
}
self.previewLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_preview_try_join_an_unknown_room", @"Vector", nil), roomName];
}
}
else if (self.mxRoom)
{
[self.mxRoom.summary setRoomAvatarImageIn:self.roomAvatar];
// The user is here invited to join a room (This invitation has been received from server sync)
self.displayNameTextField.text = self.mxRoom.summary.displayname;
if (!self.displayNameTextField.text.length)
{
self.displayNameTextField.text = NSLocalizedStringFromTable(@"room_displayname_no_title", @"Vector", nil);
self.displayNameTextField.textColor = kRiotSecondaryTextColor;
}
else
{
self.displayNameTextField.textColor = kRiotPrimaryTextColor;
}
// Display room topic
self.roomTopic.text = [MXTools stripNewlineCharacters:self.mxRoom.state.topic];
// Compute active members count, and look for the inviter
NSArray *members = self.mxRoom.state.members;
NSUInteger activeCount = 0;
NSUInteger memberCount = 0;
NSString *inviter = nil;
for (MXRoomMember *mxMember in members)
{
if (mxMember.membership == MXMembershipJoin)
{
memberCount ++;
// Get the user that corresponds to this member
MXUser *user = [self.mxRoom.mxSession userWithUserId:mxMember.userId];
// existing user ?
if (user && user.presence == MXPresenceOnline)
{
activeCount ++;
}
// Presently only one member is available from invited room data
// This is the inviter
inviter = mxMember.displayname.length ? mxMember.displayname : mxMember.userId;
}
}
// FIXME: Display members status when it will be available
self.roomMembers.text = nil;
// if (memberCount)
// {
// if (activeCount > 1)
// {
// self.roomMembers.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_title_multiple_active_members", @"Vector", nil), @(activeCount), @(memberCount)];
// }
// else
// {
// self.roomMembers.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_title_one_active_member", @"Vector", nil), @(activeCount), @(memberCount)];
// }
// }
// else
// {
// // Should not happen
// self.roomMembers.text = nil;
// }
self.previewLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_preview_invitation_format", @"Vector", nil), inviter];
}
else
{
self.roomAvatar.image = self.roomAvatarPlaceholder;
self.roomMembers.text = nil;
self.roomTopic.text = nil;
self.previewLabel.text = nil;
}
// Round image view for thumbnail
self.roomAvatar.layer.cornerRadius = self.roomAvatar.frame.size.width / 2;
self.roomAvatar.clipsToBounds = YES;
self.roomAvatar.defaultBackgroundColor = kRiotSecondaryBgColor;
// 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)setRoomAvatarURL:(NSString *)roomAvatarURL
{
_roomAvatarURL = roomAvatarURL;
[self refreshDisplay];
}
- (void)setRoomAvatarPlaceholder:(UIImage *)roomAvatarPlaceholder
{
_roomAvatarPlaceholder = roomAvatarPlaceholder;
[self refreshDisplay];
}
@end
@@ -0,0 +1,202 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<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="355"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="y5s-FK-My4">
<rect key="frame" x="0.0" y="0.0" width="600" height="215"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<accessibility key="accessibilityConfiguration" identifier="MainHeaderBackground"/>
<constraints>
<constraint firstAttribute="height" constant="215" id="YtX-K2-uD7"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BkF-x3-7fX">
<rect key="frame" x="0.0" y="0.0" width="600" height="215"/>
<subviews>
<view clipsSubviews="YES" contentMode="scaleAspectFill" translatesAutoresizingMaskIntoConstraints="NO" id="4yt-FK-V2Z" customClass="MXKImageView">
<rect key="frame" x="258" y="34" width="84" height="84"/>
<color key="backgroundColor" red="0.6886889638" green="1" blue="0.74383144840000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="MemberAvatar"/>
<constraints>
<constraint firstAttribute="width" constant="84" id="bVm-6i-oVQ"/>
<constraint firstAttribute="width" secondItem="4yt-FK-V2Z" secondAttribute="height" multiplier="1:1" id="hvA-vY-Mhn"/>
</constraints>
</view>
<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">
<rect key="frame" x="249" y="126" width="103" height="22"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="DisplayNameTextField"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="18"/>
<textInputTraits key="textInputTraits" returnKeyType="next"/>
<connections>
<outlet property="delegate" destination="Cpa-Xt-cwB" id="BIq-nD-Pb9"/>
</connections>
</textField>
<textView opaque="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" editable="NO" text="Room Topic" textAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="Tk0-pA-9a0">
<rect key="frame" x="31" y="153" width="538" height="17"/>
<accessibility key="accessibilityConfiguration" identifier="RoomTopic"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="X members" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ou0-3Z-weL">
<rect key="frame" x="262" y="184" width="76" height="17"/>
<accessibility key="accessibilityConfiguration" identifier="RoomMembers"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="details_icon" translatesAutoresizingMaskIntoConstraints="NO" id="S3Y-wJ-HOe">
<rect key="frame" x="345" y="187" width="6" height="12"/>
<accessibility key="accessibilityConfiguration" identifier="RoomMembersDetailsIcon"/>
<constraints>
<constraint firstAttribute="width" constant="6" id="XTx-6p-2wB"/>
<constraint firstAttribute="height" constant="12" id="tXh-eB-ave"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="ou0-3Z-weL" firstAttribute="top" secondItem="Tk0-pA-9a0" secondAttribute="bottom" constant="14" id="2WN-tp-d7G"/>
<constraint firstItem="6uH-I3-RQg" firstAttribute="centerX" secondItem="BkF-x3-7fX" secondAttribute="centerX" id="3uN-6W-rVZ"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="S3Y-wJ-HOe" secondAttribute="trailing" id="3z3-Ye-wh3"/>
<constraint firstItem="Tk0-pA-9a0" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="BkF-x3-7fX" secondAttribute="leading" constant="31" id="6OL-4b-A5L"/>
<constraint firstItem="Tk0-pA-9a0" firstAttribute="centerX" secondItem="BkF-x3-7fX" secondAttribute="centerX" id="6na-SG-5Ih"/>
<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="S3Y-wJ-HOe" firstAttribute="leading" secondItem="ou0-3Z-weL" secondAttribute="trailing" constant="7" id="JrS-kW-PJv"/>
<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="Tk0-pA-9a0" secondAttribute="trailing" constant="31" id="RNL-2W-QLd"/>
<constraint firstItem="4yt-FK-V2Z" firstAttribute="centerX" secondItem="BkF-x3-7fX" secondAttribute="centerX" id="Scs-DA-3V9"/>
<constraint firstAttribute="bottom" secondItem="ou0-3Z-weL" secondAttribute="bottom" constant="14" id="Sxa-8V-tnQ"/>
<constraint firstItem="Tk0-pA-9a0" firstAttribute="top" secondItem="6uH-I3-RQg" secondAttribute="bottom" constant="5" id="TUS-xE-O6O"/>
<constraint firstItem="6uH-I3-RQg" firstAttribute="top" secondItem="4yt-FK-V2Z" secondAttribute="bottom" constant="8" id="Wsd-KT-hxy"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="6uH-I3-RQg" secondAttribute="trailing" constant="31" id="aK3-vQ-EVu"/>
<constraint firstItem="Tk0-pA-9a0" firstAttribute="width" secondItem="BkF-x3-7fX" secondAttribute="width" priority="750" id="bWP-2y-KTg"/>
<constraint firstItem="ou0-3Z-weL" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="BkF-x3-7fX" secondAttribute="leading" constant="31" id="c9h-h2-VEs"/>
<constraint firstItem="6uH-I3-RQg" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="BkF-x3-7fX" secondAttribute="leading" constant="31" id="gnq-cO-l4Y"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="ou0-3Z-weL" secondAttribute="trailing" constant="31" id="sPZ-Hp-JeH"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gIX-nY-f6M">
<rect key="frame" x="280" y="239" width="41" height="20"/>
<accessibility key="accessibilityConfiguration" identifier="PreviewLabel"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="16"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="WmW-5h-jL1" userLabel="buttonsContainer">
<rect key="frame" x="60" y="276" width="480" height="30"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="osd-JP-2az" userLabel="Left Button">
<rect key="frame" x="0.0" y="0.0" width="230" height="30"/>
<color key="backgroundColor" red="0.6886889638" green="1" blue="0.74383144840000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="LeftButton"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="16"/>
<state key="normal" title="Left button">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="461-vO-hLZ" userLabel="Right Button">
<rect key="frame" x="250" y="0.0" width="230" height="30"/>
<color key="backgroundColor" red="0.6886889638" green="1" blue="0.74383144840000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="RightButton"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="16"/>
<state key="normal" title="Right Button">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
</button>
</subviews>
<constraints>
<constraint firstItem="osd-JP-2az" firstAttribute="width" secondItem="WmW-5h-jL1" secondAttribute="width" multiplier="0.48" id="Adt-wu-iJh"/>
<constraint firstItem="461-vO-hLZ" firstAttribute="height" secondItem="WmW-5h-jL1" secondAttribute="height" id="Dej-B9-fae"/>
<constraint firstItem="osd-JP-2az" firstAttribute="leading" secondItem="WmW-5h-jL1" secondAttribute="leading" id="EDF-zP-qnv"/>
<constraint firstAttribute="height" constant="30" id="I6E-8A-bDh"/>
<constraint firstItem="461-vO-hLZ" firstAttribute="width" secondItem="WmW-5h-jL1" secondAttribute="width" multiplier="0.48" id="Ojm-gJ-cqD"/>
<constraint firstAttribute="trailing" secondItem="461-vO-hLZ" secondAttribute="trailing" id="PaD-1h-FPr"/>
<constraint firstItem="461-vO-hLZ" firstAttribute="top" secondItem="WmW-5h-jL1" secondAttribute="top" id="q34-ZM-ZO4"/>
<constraint firstItem="osd-JP-2az" firstAttribute="top" secondItem="WmW-5h-jL1" secondAttribute="top" id="sEC-cd-zNV"/>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="30" id="sHS-U2-VkI"/>
<constraint firstItem="osd-JP-2az" firstAttribute="height" secondItem="WmW-5h-jL1" secondAttribute="height" id="zHG-qI-kwU"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IwA-0X-IYb">
<rect key="frame" x="281" y="323" width="38" height="18"/>
<accessibility key="accessibilityConfiguration" identifier="SubNoticeLabel"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BCO-DT-F0C">
<rect key="frame" x="0.0" y="354" width="600" height="1"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="BottomBorderView"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="LTH-xc-zcs"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="RoomTitle"/>
<constraints>
<constraint firstItem="IwA-0X-IYb" firstAttribute="top" secondItem="WmW-5h-jL1" secondAttribute="bottom" constant="17" id="0ft-2Y-gk3"/>
<constraint firstAttribute="trailing" secondItem="WmW-5h-jL1" secondAttribute="trailing" constant="60" id="1b7-i7-NOb"/>
<constraint firstAttribute="trailing" secondItem="BkF-x3-7fX" secondAttribute="trailing" id="33r-D5-3uy"/>
<constraint firstItem="gIX-nY-f6M" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="Cpa-Xt-cwB" secondAttribute="leading" constant="31" id="7Kn-g9-Ya6"/>
<constraint firstItem="WmW-5h-jL1" firstAttribute="leading" secondItem="Cpa-Xt-cwB" secondAttribute="leading" constant="60" id="8dy-U2-a3G"/>
<constraint firstItem="BCO-DT-F0C" firstAttribute="top" secondItem="IwA-0X-IYb" secondAttribute="bottom" constant="13" id="G2S-aH-ycH"/>
<constraint firstItem="BCO-DT-F0C" firstAttribute="leading" secondItem="Cpa-Xt-cwB" secondAttribute="leading" id="H07-HA-2Px"/>
<constraint firstItem="y5s-FK-My4" firstAttribute="leading" secondItem="Cpa-Xt-cwB" secondAttribute="leading" id="IU0-R1-jNV"/>
<constraint firstAttribute="trailing" secondItem="BCO-DT-F0C" secondAttribute="trailing" id="Izl-ms-lGJ"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="gIX-nY-f6M" secondAttribute="trailing" constant="31" id="Ljb-d3-KKM"/>
<constraint firstItem="BkF-x3-7fX" firstAttribute="leading" secondItem="Cpa-Xt-cwB" secondAttribute="leading" id="Uvb-cK-dQf"/>
<constraint firstItem="BkF-x3-7fX" firstAttribute="top" secondItem="Cpa-Xt-cwB" secondAttribute="top" id="Zru-9A-ifB"/>
<constraint firstAttribute="trailing" secondItem="y5s-FK-My4" secondAttribute="trailing" id="d4g-19-C58"/>
<constraint firstItem="BkF-x3-7fX" firstAttribute="bottom" secondItem="y5s-FK-My4" secondAttribute="bottom" id="gzp-8c-3iR"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="IwA-0X-IYb" secondAttribute="trailing" constant="31" id="iGR-eh-0e9"/>
<constraint firstItem="WmW-5h-jL1" firstAttribute="top" secondItem="gIX-nY-f6M" secondAttribute="bottom" constant="17" id="ioD-jo-XQe"/>
<constraint firstItem="IwA-0X-IYb" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="Cpa-Xt-cwB" secondAttribute="leading" constant="31" id="lpD-yd-qgt"/>
<constraint firstItem="y5s-FK-My4" firstAttribute="top" secondItem="Cpa-Xt-cwB" secondAttribute="top" id="n0d-R8-HiM"/>
<constraint firstItem="gIX-nY-f6M" firstAttribute="top" secondItem="y5s-FK-My4" secondAttribute="bottom" constant="24" id="qwA-2S-BIP"/>
<constraint firstItem="IwA-0X-IYb" firstAttribute="centerX" secondItem="Cpa-Xt-cwB" secondAttribute="centerX" id="tJ8-2s-eo2"/>
<constraint firstItem="gIX-nY-f6M" firstAttribute="centerX" secondItem="Cpa-Xt-cwB" secondAttribute="centerX" id="ydM-eo-gTg"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="bottomBorderView" destination="BCO-DT-F0C" id="nfI-Pk-0et"/>
<outlet property="buttonsContainer" destination="WmW-5h-jL1" id="X5t-T9-BT5"/>
<outlet property="displayNameTextField" destination="6uH-I3-RQg" id="PgQ-tb-Qad"/>
<outlet property="displayNameTextFieldTopConstraint" destination="Piq-rp-Pae" id="9PR-H2-Nuv"/>
<outlet property="leftButton" destination="osd-JP-2az" id="HrL-Qy-UDt"/>
<outlet property="mainHeaderBackground" destination="y5s-FK-My4" id="pzg-kT-PSG"/>
<outlet property="mainHeaderBackgroundHeightConstraint" destination="YtX-K2-uD7" id="47y-aL-t94"/>
<outlet property="mainHeaderContainer" destination="BkF-x3-7fX" id="1fp-xz-ETJ"/>
<outlet property="previewLabel" destination="gIX-nY-f6M" id="Bxi-6M-rTb"/>
<outlet property="rightButton" destination="461-vO-hLZ" id="u8R-Rg-WAv"/>
<outlet property="roomAvatar" destination="4yt-FK-V2Z" id="epr-4f-7cE"/>
<outlet property="roomMembers" destination="ou0-3Z-weL" id="lRs-fz-QXc"/>
<outlet property="roomMembersDetailsIcon" destination="S3Y-wJ-HOe" id="QjQ-wY-EOS"/>
<outlet property="roomTopic" destination="Tk0-pA-9a0" id="iAe-bC-f6X"/>
<outlet property="subNoticeLabel" destination="IwA-0X-IYb" id="aUb-Pt-V44"/>
</connections>
</view>
</objects>
<resources>
<image name="details_icon" width="31" height="31"/>
</resources>
</document>
@@ -0,0 +1,58 @@
/*
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 "RoomPreviewData.h"
// We add here a protocol to handle tap gesture in title view.
@class RoomTitleView;
@protocol RoomTitleViewTapGestureDelegate <NSObject>
/**
Tells the delegate that a tap gesture has been recognized.
@param titleView the room title view.
@param tapGestureRecognizer the recognized gesture.
*/
- (void)roomTitleView:(RoomTitleView*)titleView recognizeTapGesture:(UITapGestureRecognizer*)tapGestureRecognizer;
@end
@interface RoomTitleView : MXKRoomTitleView <UIGestureRecognizerDelegate>
@property (weak, nonatomic) IBOutlet UIView *titleMask;
@property (weak, nonatomic) IBOutlet UIView *roomDetailsMask;
@property (weak, nonatomic) IBOutlet UIView *addParticipantMask;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *displayNameCenterXConstraint;
@property (weak, nonatomic) IBOutlet UIImageView *roomDetailsIconImageView;
/**
The room preview data may be used when mxRoom instance is not available
*/
@property (strong, nonatomic) RoomPreviewData *roomPreviewData;
/**
The tap gesture delegate.
*/
@property (nonatomic) id<RoomTitleViewTapGestureDelegate> tapGestureDelegate;
/**
The method used to handle the gesture recognized by a receiver.
*/
- (void)reportTapGesture:(UITapGestureRecognizer*)tapGestureRecognizer;
@end
@@ -0,0 +1,185 @@
/*
Copyright 2015 OpenMarket Ltd
Copyright 2017 Vector Creations 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 "RoomTitleView.h"
#import "RiotDesignValues.h"
@implementation RoomTitleView
+ (UINib *)nib
{
return [UINib nibWithNibName:NSStringFromClass([RoomTitleView class])
bundle:[NSBundle bundleForClass:[RoomTitleView class]]];
}
- (void)dealloc
{
_roomPreviewData = nil;
}
- (void)awakeFromNib
{
[super awakeFromNib];
if (_titleMask)
{
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(reportTapGesture:)];
[tap setNumberOfTouchesRequired:1];
[tap setNumberOfTapsRequired:1];
[tap setDelegate:self];
[self.titleMask addGestureRecognizer:tap];
self.titleMask.userInteractionEnabled = YES;
}
if (_roomDetailsMask)
{
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(reportTapGesture:)];
[tap setNumberOfTouchesRequired:1];
[tap setNumberOfTapsRequired:1];
[tap setDelegate:self];
[self.roomDetailsMask addGestureRecognizer:tap];
self.roomDetailsMask.userInteractionEnabled = YES;
}
if (_addParticipantMask)
{
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(reportTapGesture:)];
[tap setNumberOfTouchesRequired:1];
[tap setNumberOfTapsRequired:1];
[tap setDelegate:self];
[self.addParticipantMask addGestureRecognizer:tap];
self.addParticipantMask.userInteractionEnabled = YES;
}
}
- (void)layoutSubviews
{
[super layoutSubviews];
if (self.superview)
{
if (@available(iOS 11.0, *))
{
// Force the title view layout by adding 2 new constraints on the UINavigationBarContentView instance.
NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:self
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:self.superview
attribute:NSLayoutAttributeTop
multiplier:1.0f
constant:0.0f];
NSLayoutConstraint *centerXConstraint = [NSLayoutConstraint constraintWithItem:self
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:self.superview
attribute:NSLayoutAttributeCenterX
multiplier:1.0f
constant:0.0f];
[NSLayoutConstraint activateConstraints:@[topConstraint, centerXConstraint]];
}
else
{
// Center horizontally the display name into the navigation bar
CGRect frame = self.superview.frame;
// Look for the navigation bar.
UINavigationBar *navigationBar;
UIView *superView = self;
while (superView.superview)
{
if ([superView.superview isKindOfClass:[UINavigationBar class]])
{
navigationBar = (UINavigationBar*)superView.superview;
break;
}
superView = superView.superview;
}
if (navigationBar)
{
CGSize navBarSize = navigationBar.frame.size;
CGFloat superviewCenterX = frame.origin.x + (frame.size.width / 2);
// Check whether the view is not moving away (see navigation between view controllers).
if (superviewCenterX < navBarSize.width)
{
// Center the display name
self.displayNameCenterXConstraint.constant = (navBarSize.width / 2) - superviewCenterX;
}
}
}
}
}
-(void)customizeViewRendering
{
[super customizeViewRendering];
self.displayNameTextField.textColor = (self.mxRoom.summary.displayname.length ? kRiotPrimaryTextColor : kRiotSecondaryTextColor);
}
- (void)setRoomPreviewData:(RoomPreviewData *)roomPreviewData
{
_roomPreviewData = roomPreviewData;
[self refreshDisplay];
}
- (void)refreshDisplay
{
[super refreshDisplay];
// Consider in priority the preview data (if any)
if (self.roomPreviewData)
{
self.displayNameTextField.text = self.roomPreviewData.roomName;
}
else if (self.mxRoom)
{
self.displayNameTextField.text = self.mxRoom.summary.displayname;
if (!self.displayNameTextField.text.length)
{
self.displayNameTextField.text = NSLocalizedStringFromTable(@"room_displayname_no_title", @"Vector", nil);
self.displayNameTextField.textColor = kRiotSecondaryTextColor;
}
else
{
self.displayNameTextField.textColor = kRiotPrimaryTextColor;
}
}
}
- (void)destroy
{
self.tapGestureDelegate = nil;
[super destroy];
}
- (void)reportTapGesture:(UITapGestureRecognizer*)tapGestureRecognizer
{
if (self.tapGestureDelegate)
{
[self.tapGestureDelegate roomTitleView:self recognizeTapGesture:tapGestureRecognizer];
}
}
@end
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1108" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</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="RoomTitleView">
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
<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">
<rect key="frame" x="249" y="9" width="103" height="22"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="DisplayNameTextField"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="18"/>
<textInputTraits key="textInputTraits" returnKeyType="next"/>
<connections>
<outlet property="delegate" destination="BkF-x3-7fX" id="xX7-jB-9va"/>
</connections>
</textField>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="details_icon" translatesAutoresizingMaskIntoConstraints="NO" id="S3Y-wJ-HOe">
<rect key="frame" x="359" y="14" width="6" height="12"/>
<accessibility key="accessibilityConfiguration" identifier="RoomDetailsIconImageView"/>
<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="sD9-l7-azQ">
<rect key="frame" x="0.0" y="0.0" width="352" height="44"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="pFg-XE-6DB">
<rect key="frame" x="352" y="0.0" width="248" height="44"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="RoomTitle"/>
<constraints>
<constraint firstItem="6uH-I3-RQg" firstAttribute="centerX" secondItem="BkF-x3-7fX" secondAttribute="centerX" id="3uN-6W-rVZ"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="S3Y-wJ-HOe" secondAttribute="trailing" id="3z3-Ye-wh3"/>
<constraint firstAttribute="bottom" secondItem="sD9-l7-azQ" secondAttribute="bottom" id="4rX-5O-LrO"/>
<constraint firstItem="sD9-l7-azQ" firstAttribute="leading" secondItem="BkF-x3-7fX" secondAttribute="leading" id="AJc-Aa-sht"/>
<constraint firstItem="sD9-l7-azQ" firstAttribute="trailing" secondItem="6uH-I3-RQg" secondAttribute="trailing" id="DnD-l9-v0F"/>
<constraint firstItem="pFg-XE-6DB" firstAttribute="leading" secondItem="sD9-l7-azQ" secondAttribute="trailing" id="Gxi-oJ-gpi"/>
<constraint firstAttribute="bottom" secondItem="pFg-XE-6DB" secondAttribute="bottom" id="HEU-GL-4yt"/>
<constraint firstAttribute="trailing" secondItem="pFg-XE-6DB" secondAttribute="trailing" id="HPm-vM-32l"/>
<constraint firstItem="S3Y-wJ-HOe" firstAttribute="centerY" secondItem="6uH-I3-RQg" secondAttribute="centerY" id="Jjq-ss-0kj"/>
<constraint firstItem="6uH-I3-RQg" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="BkF-x3-7fX" secondAttribute="leading" constant="8" id="KW6-05-QLM"/>
<constraint firstItem="pFg-XE-6DB" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="top" id="M4X-tH-OCM"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="6uH-I3-RQg" secondAttribute="trailing" constant="8" id="PUM-di-dAZ"/>
<constraint firstItem="6uH-I3-RQg" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="top" constant="9" id="Piq-rp-Pae"/>
<constraint firstItem="sD9-l7-azQ" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="top" id="YrR-1c-h56"/>
<constraint firstItem="S3Y-wJ-HOe" firstAttribute="leading" secondItem="6uH-I3-RQg" secondAttribute="trailing" constant="7" id="qbS-km-tTO"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="displayNameCenterXConstraint" destination="3uN-6W-rVZ" id="rck-yU-24s"/>
<outlet property="displayNameTextField" destination="6uH-I3-RQg" id="MfX-LQ-C2K"/>
<outlet property="displayNameTextFieldTopConstraint" destination="Piq-rp-Pae" id="jnL-Hz-TWn"/>
<outlet property="roomDetailsIconImageView" destination="S3Y-wJ-HOe" id="bhR-6E-8St"/>
<outlet property="roomDetailsMask" destination="pFg-XE-6DB" id="7EF-K5-G0o"/>
<outlet property="titleMask" destination="sD9-l7-azQ" id="I9b-wF-iNH"/>
</connections>
</view>
</objects>
<resources>
<image name="details_icon" width="31" height="31"/>
</resources>
</document>
@@ -0,0 +1,27 @@
/*
Copyright 2016 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>
/**
This title view display the room display name only.
There is no user interaction in it except the back button.
*/
@interface SimpleRoomTitleView : MXKRoomTitleView <UIGestureRecognizerDelegate>
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *displayNameCenterXConstraint;
@end
@@ -0,0 +1,116 @@
/*
Copyright 2016 OpenMarket Ltd
Copyright 2017 Vector Creations 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 "SimpleRoomTitleView.h"
#import "RiotDesignValues.h"
@implementation SimpleRoomTitleView
+ (UINib *)nib
{
return [UINib nibWithNibName:NSStringFromClass([SimpleRoomTitleView class])
bundle:[NSBundle bundleForClass:[SimpleRoomTitleView class]]];
}
- (void)awakeFromNib
{
[super awakeFromNib];
}
- (void)layoutSubviews
{
[super layoutSubviews];
if (self.superview)
{
if (@available(iOS 11.0, *))
{
// Force the title view layout by adding 2 new constraints on the UINavigationBarContentView instance.
NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:self
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:self.superview
attribute:NSLayoutAttributeTop
multiplier:1.0f
constant:0.0f];
NSLayoutConstraint *centerXConstraint = [NSLayoutConstraint constraintWithItem:self
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:self.superview
attribute:NSLayoutAttributeCenterX
multiplier:1.0f
constant:0.0f];
[NSLayoutConstraint activateConstraints:@[topConstraint, centerXConstraint]];
}
else
{
// Center horizontally the display name into the navigation bar
CGRect frame = self.superview.frame;
UINavigationBar *navigationBar;
UIView *superView = self;
while (superView.superview)
{
if ([superView.superview isKindOfClass:[UINavigationBar class]])
{
navigationBar = (UINavigationBar*)superView.superview;
break;
}
superView = superView.superview;
}
if (navigationBar)
{
CGSize navBarSize = navigationBar.frame.size;
CGFloat superviewCenterX = frame.origin.x + (frame.size.width / 2);
// Center the display name
self.displayNameCenterXConstraint.constant = (navBarSize.width / 2) - superviewCenterX;
}
}
}
}
-(void)customizeViewRendering
{
[super customizeViewRendering];
self.displayNameTextField.textColor = (self.mxRoom.summary.displayname.length ? kRiotPrimaryTextColor : kRiotSecondaryTextColor);
}
- (void)refreshDisplay
{
[super refreshDisplay];
if (self.mxRoom)
{
self.displayNameTextField.text = self.mxRoom.summary.displayname;
if (!self.displayNameTextField.text.length)
{
self.displayNameTextField.text = NSLocalizedStringFromTable(@"room_displayname_no_title", @"Vector", nil);
self.displayNameTextField.textColor = kRiotSecondaryTextColor;
}
else
{
self.displayNameTextField.textColor = kRiotPrimaryTextColor;
}
}
}
@end
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1108" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</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="SimpleRoomTitleView">
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
<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">
<rect key="frame" x="249" y="9" width="103" height="22"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="DisplayNameTextField"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="18"/>
<textInputTraits key="textInputTraits" returnKeyType="next"/>
<connections>
<outlet property="delegate" destination="BkF-x3-7fX" id="xX7-jB-9va"/>
</connections>
</textField>
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="RoomTitle"/>
<constraints>
<constraint firstItem="6uH-I3-RQg" firstAttribute="centerX" secondItem="BkF-x3-7fX" secondAttribute="centerX" id="3uN-6W-rVZ"/>
<constraint firstItem="6uH-I3-RQg" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="BkF-x3-7fX" secondAttribute="leading" constant="8" id="KW6-05-QLM"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="6uH-I3-RQg" secondAttribute="trailing" constant="8" id="PUM-di-dAZ"/>
<constraint firstItem="6uH-I3-RQg" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="top" constant="9" id="Piq-rp-Pae"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="displayNameCenterXConstraint" destination="3uN-6W-rVZ" id="rck-yU-24s"/>
<outlet property="displayNameTextField" destination="6uH-I3-RQg" id="MfX-LQ-C2K"/>
<outlet property="displayNameTextFieldTopConstraint" destination="Piq-rp-Pae" id="jnL-Hz-TWn"/>
</connections>
</view>
</objects>
</document>