Chat: Expanded header

This commit is contained in:
giomfo
2016-02-10 10:59:48 +01:00
parent e16dae4caa
commit f5fb047062
16 changed files with 702 additions and 23 deletions
+5
View File
@@ -115,6 +115,11 @@
"room_event_action_cancel_upload" = "Cancel Upload";
"room_event_action_cancel_download" = "Cancel Download";
// Room Title
"room_title_new_room" = "New room";
"room_title_multiple_active_members" = "%d/%d active members";
"room_title_one_active_member" = "%d/%d active member";
// Settings
"account_logout_all" = "Logout all accounts";
+1
View File
@@ -34,6 +34,7 @@ extern UIColor *kVectorColorOrange;
#pragma mark - Vector Text Colors
extern UIColor *kVectorTextColorBlack;
extern UIColor *kVectorTextColorDarkGray;
extern UIColor *kVectorTextColorGray;
/**
+2
View File
@@ -23,6 +23,7 @@ UIColor *kVectorColorSiver;
UIColor *kVectorColorOrange;
UIColor *kVectorTextColorBlack;
UIColor *kVectorTextColorDarkGray;
UIColor *kVectorTextColorGray;
@implementation VectorDesignValues
@@ -39,6 +40,7 @@ UIColor *kVectorTextColorGray;
kVectorColorSiver = [UIColor colorWithRed:(199.0 / 255.0) green:(199.0 / 255.0) blue:(204.0 / 255.0) alpha:1.0];
kVectorTextColorBlack = [UIColor colorWithRed:(60.0 / 255.0) green:(60.0 / 255.0) blue:(60.0 / 255.0) alpha:1.0];
kVectorTextColorDarkGray = [UIColor colorWithRed:(74.0 / 255.0) green:(74.0 / 255.0) blue:(74.0 / 255.0) alpha:1.0];
kVectorTextColorGray = [UIColor colorWithRed:(157.0 / 255.0) green:(157.0 / 255.0) blue:(157.0 / 255.0) alpha:1.0];
// Colors copied from Vector web
+14 -1
View File
@@ -16,9 +16,22 @@
#import <MatrixKit/MatrixKit.h>
#import "RoomTitleView.h"
#import "UIViewController+VectorSearch.h"
@interface RoomViewController : MXKRoomViewController <UISearchBarDelegate, UIGestureRecognizerDelegate>
@interface RoomViewController : MXKRoomViewController <UISearchBarDelegate, UIGestureRecognizerDelegate, RoomTitleViewTapGestureDelegate>
// The expanded header
@property (weak, nonatomic) IBOutlet UIView *expandedHeaderContainer;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *expandedHeaderContainerHeightConstraint;
/**
Hide/Show the expanded header.
By default this header is hidden on new instantiated RoomViewController object.
*/
- (void)hideExpandedHeader:(BOOL)isHidden;
@end
+179 -16
View File
@@ -25,7 +25,8 @@
#import "RoomActivitiesView.h"
#import "RoomTitleView.h"
#import "RoomAvatarTitleView.h"
#import "ExpandedRoomTitleView.h"
#import "RoomParticipantsViewController.h"
@@ -55,8 +56,13 @@
#import "AvatarGenerator.h"
#import "VectorDesignValues.h"
@interface RoomViewController ()
{
// The expanded header
ExpandedRoomTitleView *expandedHeader;
// The customized room data source for Vector
RoomDataSource *customizedRoomDataSource;
@@ -76,6 +82,22 @@
@implementation RoomViewController
#pragma mark - Class methods
+ (UINib *)nib
{
return [UINib nibWithNibName:NSStringFromClass(self.class)
bundle:[NSBundle bundleForClass:self.class]];
}
+ (instancetype)roomViewController
{
return [[[self class] alloc] initWithNibName:NSStringFromClass(self.class)
bundle:[NSBundle bundleForClass:self.class]];
}
#pragma mark -
- (void)viewDidLoad
{
[super viewDidLoad];
@@ -101,15 +123,49 @@
// Set room title view
[self setRoomTitleViewClass:RoomTitleView.class];
// Listen to title view tap
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onRoomTitleViewTap:)];
[tapGesture setNumberOfTouchesRequired:1];
[tapGesture setNumberOfTapsRequired:1];
[tapGesture setDelegate:self];
[self.titleView addGestureRecognizer:tapGesture];
self.titleView.userInteractionEnabled = YES;
// Disable interaction with room name text field
self.titleView.displayNameTextField.userInteractionEnabled = NO;
((RoomTitleView*)self.titleView).tapGestureDelegate = self;
// Prepare expanded header
self.expandedHeaderContainer.backgroundColor = kVectorColorLightGrey;
self.expandedHeaderContainerHeightConstraint.constant = 237;
expandedHeader = [ExpandedRoomTitleView roomTitleView];
expandedHeader.delegate = self;
expandedHeader.tapGestureDelegate = self;
expandedHeader.translatesAutoresizingMaskIntoConstraints = NO;
[self.expandedHeaderContainer addSubview:expandedHeader];
// Force expanded header in full width
NSLayoutConstraint *leftConstraint = [NSLayoutConstraint constraintWithItem:expandedHeader
attribute:NSLayoutAttributeLeading
relatedBy:NSLayoutRelationEqual
toItem:self.expandedHeaderContainer
attribute:NSLayoutAttributeLeading
multiplier:1.0
constant:0];
NSLayoutConstraint *rightConstraint = [NSLayoutConstraint constraintWithItem:expandedHeader
attribute:NSLayoutAttributeTrailing
relatedBy:NSLayoutRelationEqual
toItem:self.expandedHeaderContainer
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]];
// Replace the default input toolbar view.
// Note: this operation will force the layout of subviews. That is why cell view classes must be registered before.
@@ -183,6 +239,9 @@
// Remove select event id
customizedRoomDataSource.selectedEventId = nil;
}
// Hide expanded header to restore navigation bar settings
[self hideExpandedHeader:YES];
}
- (void)viewDidAppear:(BOOL)animated
@@ -246,6 +305,10 @@
[super updateViewControllerAppearanceOnRoomDataSourceState];
self.navigationItem.rightBarButtonItem.enabled = (self.roomDataSource != nil);
self.titleView.editable = NO;
expandedHeader.mxRoom = self.roomDataSource.room;
}
- (BOOL)isIRCStyleCommand:(NSString*)string
@@ -302,6 +365,94 @@
[super destroy];
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
// Hide the expanded header in case of scrolling
[self hideExpandedHeader:YES];
}
#pragma mark - Hide/Show expanded header
- (void)hideExpandedHeader:(BOOL)isHidden
{
if (self.expandedHeaderContainer.isHidden != isHidden)
{
self.expandedHeaderContainer.hidden = isHidden;
// Retrieve the main navigation controller if the current view controller is embedded inside a split view controller.
UINavigationController *mainNavigationController = nil;
if (self.splitViewController)
{
mainNavigationController = self.navigationController;
UIViewController *parentViewController = self.parentViewController;
while (parentViewController)
{
if (parentViewController.navigationController)
{
mainNavigationController = parentViewController.navigationController;
parentViewController = parentViewController.parentViewController;
}
else
{
break;
}
}
}
// When the expanded header is displayed, we hide the bottom border of the navigation bar (the shadow image).
// The default shadow image is nil. When non-nil, this property represents a custom shadow image to show instead
// of the default. For a custom shadow image to be shown, a custom background image must also be set with the
// setBackgroundImage:forBarMetrics: method. If the default background image is used, then the default shadow
// image will be used regardless of the value of this property.
UIImage *shadowImage = nil;
MXKImageView *roomAvatarView = nil;
if (isHidden)
{
[self setRoomTitleViewClass:RoomTitleView.class];
((RoomTitleView*)self.titleView).tapGestureDelegate = self;
self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
}
else
{
[self setRoomTitleViewClass:RoomAvatarTitleView.class];
// Note the avatar title view does not define tap gesture.
self.navigationController.navigationBar.barTintColor = kVectorColorLightGrey;
roomAvatarView = ((RoomAvatarTitleView*)self.titleView).roomAvatar;
roomAvatarView.alpha = 0.0;
shadowImage = [[UIImage alloc] init];
}
// Report shadow image
[self.navigationController.navigationBar setShadowImage:shadowImage];
[self.navigationController.navigationBar setBackgroundImage:shadowImage forBarMetrics:UIBarMetricsDefault];
if (mainNavigationController)
{
mainNavigationController.navigationBar.barTintColor = self.navigationController.navigationBar.barTintColor;
[mainNavigationController.navigationBar setShadowImage:shadowImage];
[mainNavigationController.navigationBar setBackgroundImage:shadowImage forBarMetrics:UIBarMetricsDefault];
}
[UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseIn
animations:^{
self.bubblesTableViewTopConstraint.constant = (isHidden ? 0 : self.expandedHeaderContainerHeightConstraint.constant);
if (roomAvatarView)
{
roomAvatarView.alpha = 1;
}
// Force to render the view
[self.view layoutIfNeeded];
}
completion:^(BOOL finished){
}];
}
}
#pragma mark - MXKDataSourceDelegate
- (Class<MXKCellRendering>)cellViewClassForCellData:(MXKCellData*)cellData
@@ -877,12 +1028,6 @@
}
}
- (IBAction)onRoomTitleViewTap:(UITapGestureRecognizer*)sender
{
// Open room details
[self performSegueWithIdentifier:@"showRoomDetails" sender:self];
}
#pragma mark - UITableView delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
@@ -898,6 +1043,24 @@
return NO;
}
#pragma mark - RoomTitleViewTapGestureDelegate
- (void)roomTitleView:(RoomTitleView*)titleView recognizeTapGesture:(UITapGestureRecognizer*)tapGestureRecognizer
{
UIView *view = tapGestureRecognizer.view;
if (view == titleView.titleMask)
{
// Expand/shrink the header
[self hideExpandedHeader:!self.expandedHeaderContainer.isHidden];
}
else if (view == titleView.roomDetailsMask)
{
// Open room details
[self performSegueWithIdentifier:@"showRoomDetails" sender:self];
}
}
#pragma mark - typing management
- (void)removeTypingNotificationsListener
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RoomViewController">
<connections>
<outlet property="bubblesTableView" destination="BGD-sd-SQR" id="OG4-Tw-Ovt"/>
<outlet property="bubblesTableViewBottomConstraint" destination="Ksk-39-kfi" id="CTo-Ux-4NP"/>
<outlet property="bubblesTableViewTopConstraint" destination="X14-4s-uGM" id="Hic-6h-N05"/>
<outlet property="expandedHeaderContainer" destination="uK2-9a-rZj" id="0lY-NB-cR1"/>
<outlet property="expandedHeaderContainerHeightConstraint" destination="w9z-HS-7wJ" id="6uK-Bn-TcU"/>
<outlet property="roomActivitiesContainer" destination="XX4-n6-hCm" id="uD0-ab-8s8"/>
<outlet property="roomActivitiesContainerHeightConstraint" destination="E8v-l2-8eV" id="ebD-oV-ttx"/>
<outlet property="roomInputToolbarContainer" destination="nLd-BP-JAE" id="1dp-P1-0js"/>
<outlet property="roomInputToolbarContainerBottomConstraint" destination="kQ6-Cg-FMi" id="nHr-fR-XnV"/>
<outlet property="roomInputToolbarContainerHeightConstraint" destination="5eD-Fm-RDb" id="6ny-5w-1UA"/>
<outlet property="view" destination="iN0-l3-epB" id="ieV-u7-rXU"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<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"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="240" id="w9z-HS-7wJ"/>
</constraints>
</view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" keyboardDismissMode="interactive" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="BGD-sd-SQR">
<rect key="frame" x="0.0" y="0.0" width="600" height="559"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</tableView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XX4-n6-hCm" userLabel="Activities Container">
<rect key="frame" x="0.0" y="539" width="600" height="20"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="E8v-l2-8eV"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nLd-BP-JAE" userLabel="Room Input Toolbar Container">
<rect key="frame" x="0.0" y="559" width="600" height="41"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="41" id="5eD-Fm-RDb"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="BGD-sd-SQR" secondAttribute="trailing" id="0la-ok-MBr"/>
<constraint firstItem="nLd-BP-JAE" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="4Q7-hr-rqi"/>
<constraint firstAttribute="trailing" secondItem="uK2-9a-rZj" secondAttribute="trailing" id="HqC-Td-9HD"/>
<constraint firstAttribute="bottom" secondItem="BGD-sd-SQR" secondAttribute="bottom" constant="41" id="Ksk-39-kfi"/>
<constraint firstItem="XX4-n6-hCm" firstAttribute="bottom" secondItem="nLd-BP-JAE" secondAttribute="top" id="QO8-nF-xys"/>
<constraint firstItem="uK2-9a-rZj" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="Tne-Nc-sUu"/>
<constraint firstItem="XX4-n6-hCm" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="WhE-lH-ZtR"/>
<constraint firstItem="BGD-sd-SQR" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="X14-4s-uGM"/>
<constraint firstAttribute="trailing" secondItem="nLd-BP-JAE" secondAttribute="trailing" id="YAu-gd-ItG"/>
<constraint firstItem="XX4-n6-hCm" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="csl-KT-4s9"/>
<constraint firstItem="uK2-9a-rZj" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="glH-g0-CKA"/>
<constraint firstItem="BGD-sd-SQR" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="haP-Kv-OLI"/>
<constraint firstAttribute="bottom" secondItem="nLd-BP-JAE" secondAttribute="bottom" id="kQ6-Cg-FMi"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
</view>
</objects>
</document>
@@ -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 "RoomTitleView.h"
@interface ExpandedRoomTitleView : RoomTitleView
@property (weak, nonatomic) IBOutlet UILabel *roomTopic;
@property (weak, nonatomic) IBOutlet UILabel *roomMembers;
@end
@@ -0,0 +1,98 @@
/*
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 "ExpandedRoomTitleView.h"
#import "VectorDesignValues.h"
#import "MXRoom+Vector.h"
@implementation ExpandedRoomTitleView
+ (UINib *)nib
{
return [UINib nibWithNibName:NSStringFromClass([self class])
bundle:[NSBundle bundleForClass:[self class]]];
}
- (void)awakeFromNib
{
[super awakeFromNib];
self.displayNameTextField.textColor = kVectorTextColorBlack;
self.roomTopic.textColor = kVectorTextColorDarkGray;
self.roomMembers.textColor = kVectorColorGreen;
}
- (void)refreshDisplay
{
[super refreshDisplay];
if (self.mxRoom)
{
self.displayNameTextField.text = self.mxRoom.vectorDisplayname;
self.roomTopic.text = self.mxRoom.state.topic;
// Compute active members count
NSArray *members = self.mxRoom.state.members;
NSUInteger activeCount = 0;
NSUInteger memberCount = 0;
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 ++;
}
}
else if (mxMember.membership == MXMembershipJoin)
{
memberCount ++;
}
}
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;
}
}
else
{
self.roomTopic.text = nil;
self.roomMembers.text = nil;
}
}
@end
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
</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"/>
<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="126" width="103" height="22"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<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="153" width="36" height="34"/>
<constraints>
<constraint firstAttribute="height" constant="34" id="ix5-w4-Q3B"/>
</constraints>
<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>
<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"/>
<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="8HH-9b-1yH">
<rect key="frame" x="0.0" y="0.0" width="600" height="186"/>
<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"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<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="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="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 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="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 firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="6uH-I3-RQg" secondAttribute="trailing" constant="31" id="aK3-vQ-EVu"/>
<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 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 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"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<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="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="details_icon" width="31" height="31"/>
</resources>
</document>
@@ -0,0 +1,23 @@
/*
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 MXKImageView *roomAvatar;
@end
@@ -0,0 +1,57 @@
/*
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 "RoomAvatarTitleView.h"
#import "VectorDesignValues.h"
#import "MXRoom+Vector.h"
@implementation RoomAvatarTitleView
+ (UINib *)nib
{
return [UINib nibWithNibName:NSStringFromClass([self class])
bundle:[NSBundle bundleForClass:[self class]]];
}
- (void)awakeFromNib
{
[super awakeFromNib];
}
- (void)refreshDisplay
{
[super refreshDisplay];
if (self.mxRoom)
{
[self.mxRoom setRoomAvatarImageIn:self.roomAvatar];
// Round image view for thumbnail
self.roomAvatar.layer.cornerRadius = self.roomAvatar.frame.size.width / 2;
self.roomAvatar.clipsToBounds = YES;
}
else
{
self.roomAvatar.image = [UIImage imageNamed:@"placeholder"];
}
self.roomAvatar.backgroundColor = kVectorColorLightGrey;
}
@end
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9531"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</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="600" height="240"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7U9-Y6-cEm" customClass="MXKImageView">
<rect key="frame" x="251" y="13" width="84" height="84"/>
<color key="backgroundColor" red="0.6886889638" green="1" blue="0.74383144840000004" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" secondItem="7U9-Y6-cEm" secondAttribute="height" multiplier="1:1" id="9ct-O9-7am"/>
<constraint firstAttribute="width" constant="84" id="BeT-JY-cq1"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="7U9-Y6-cEm" firstAttribute="centerX" secondItem="BkF-x3-7fX" secondAttribute="centerX" constant="-7" id="C5g-ho-90L"/>
<constraint firstItem="7U9-Y6-cEm" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="top" constant="13" id="Kwt-Sd-REk"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="roomAvatar" destination="7U9-Y6-cEm" id="VWF-cH-9Jv"/>
</connections>
</view>
</objects>
</document>
+24 -1
View File
@@ -16,5 +16,28 @@
#import <MatrixKit/MatrixKit.h>
@interface RoomTitleView : MXKRoomTitleView
// 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;
/**
The tap gesture delegate.
*/
@property (nonatomic) id<RoomTitleViewTapGestureDelegate> tapGestureDelegate;
@end
+22
View File
@@ -33,6 +33,20 @@
[super awakeFromNib];
self.displayNameTextField.textColor = kVectorTextColorBlack;
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;
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;
}
- (void)refreshDisplay
@@ -45,4 +59,12 @@
}
}
- (void)reportTapGesture:(UITapGestureRecognizer*)tapGestureRecognizer
{
if (self.tapGestureDelegate)
{
[self.tapGestureDelegate roomTitleView:self recognizeTapGesture:tapGestureRecognizer];
}
}
@end
+23 -4
View File
@@ -12,7 +12,7 @@
<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="242" y="5" width="103" height="22"/>
<rect key="frame" x="242" y="9" width="103" height="22"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="18"/>
<textInputTraits key="textInputTraits" returnKeyType="next"/>
@@ -21,26 +21,45 @@
</connections>
</textField>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="details_icon" translatesAutoresizingMaskIntoConstraints="NO" id="S3Y-wJ-HOe">
<rect key="frame" x="352" y="10" width="6" height="12"/>
<rect key="frame" x="352" y="14" 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="sD9-l7-azQ">
<rect key="frame" x="0.0" y="0.0" width="345" height="44"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="pFg-XE-6DB">
<rect key="frame" x="345" y="0.0" width="255" height="44"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="6uH-I3-RQg" firstAttribute="centerX" secondItem="BkF-x3-7fX" secondAttribute="centerX" constant="-7" 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="top" secondItem="BkF-x3-7fX" secondAttribute="top" constant="5" id="Piq-rp-Pae"/>
<constraint firstItem="6uH-I3-RQg" firstAttribute="width" relation="lessThanOrEqual" secondItem="BkF-x3-7fX" secondAttribute="width" id="qUM-Zw-2QD"/>
<constraint firstItem="6uH-I3-RQg" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="BkF-x3-7fX" secondAttribute="leading" constant="31" 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="31" 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="displayNameTextField" destination="6uH-I3-RQg" id="MfX-LQ-C2K"/>
<outlet property="displayNameTextFieldTopConstraint" destination="Piq-rp-Pae" id="jnL-Hz-TWn"/>
<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>