mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 07:42:40 +00:00
Prepare Room Preview support.
This commit is contained in:
parent
59ebabceeb
commit
d68c017794
13 changed files with 787 additions and 74 deletions
|
@ -134,6 +134,8 @@
|
|||
F025290C1C11B6FC00E1FE1B /* voice_call_icon.png in Resources */ = {isa = PBXBuildFile; fileRef = F02528D01C11B6FC00E1FE1B /* voice_call_icon.png */; };
|
||||
F025290D1C11B6FC00E1FE1B /* voice_call_icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F02528D11C11B6FC00E1FE1B /* voice_call_icon@2x.png */; };
|
||||
F025290E1C11B6FC00E1FE1B /* voice_call_icon@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = F02528D21C11B6FC00E1FE1B /* voice_call_icon@3x.png */; };
|
||||
F02BB04B1CBE2EE70022A025 /* PreviewRoomTitleView.m in Sources */ = {isa = PBXBuildFile; fileRef = F02BB0491CBE2EE70022A025 /* PreviewRoomTitleView.m */; };
|
||||
F02BB04C1CBE2EE70022A025 /* PreviewRoomTitleView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F02BB04A1CBE2EE70022A025 /* PreviewRoomTitleView.xib */; };
|
||||
F02D87C69D1FFCD2C1531F3D /* libPods-Vector.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B179239B79688A61A3F465F /* libPods-Vector.a */; };
|
||||
F03FBCC51CBBF521000A5770 /* admin_icon.png in Resources */ = {isa = PBXBuildFile; fileRef = F03FBCB31CBBF521000A5770 /* admin_icon.png */; };
|
||||
F03FBCC61CBBF521000A5770 /* admin_icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F03FBCB41CBBF521000A5770 /* admin_icon@2x.png */; };
|
||||
|
@ -414,6 +416,9 @@
|
|||
F02528D01C11B6FC00E1FE1B /* voice_call_icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = voice_call_icon.png; sourceTree = "<group>"; };
|
||||
F02528D11C11B6FC00E1FE1B /* voice_call_icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "voice_call_icon@2x.png"; sourceTree = "<group>"; };
|
||||
F02528D21C11B6FC00E1FE1B /* voice_call_icon@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "voice_call_icon@3x.png"; sourceTree = "<group>"; };
|
||||
F02BB0481CBE2EE70022A025 /* PreviewRoomTitleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PreviewRoomTitleView.h; path = RoomTitle/PreviewRoomTitleView.h; sourceTree = "<group>"; };
|
||||
F02BB0491CBE2EE70022A025 /* PreviewRoomTitleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PreviewRoomTitleView.m; path = RoomTitle/PreviewRoomTitleView.m; sourceTree = "<group>"; };
|
||||
F02BB04A1CBE2EE70022A025 /* PreviewRoomTitleView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = PreviewRoomTitleView.xib; path = RoomTitle/PreviewRoomTitleView.xib; sourceTree = "<group>"; };
|
||||
F03FBCB31CBBF521000A5770 /* admin_icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = admin_icon.png; sourceTree = "<group>"; };
|
||||
F03FBCB41CBBF521000A5770 /* admin_icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "admin_icon@2x.png"; sourceTree = "<group>"; };
|
||||
F03FBCB51CBBF521000A5770 /* admin_icon@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "admin_icon@3x.png"; sourceTree = "<group>"; };
|
||||
|
@ -585,6 +590,9 @@
|
|||
71046D581C0C631100DCA984 /* RoomTitle */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F02BB0481CBE2EE70022A025 /* PreviewRoomTitleView.h */,
|
||||
F02BB0491CBE2EE70022A025 /* PreviewRoomTitleView.m */,
|
||||
F02BB04A1CBE2EE70022A025 /* PreviewRoomTitleView.xib */,
|
||||
32A8871E1C89B9580037DC17 /* SimpleRoomTitleView.h */,
|
||||
32A8871F1C89B9580037DC17 /* SimpleRoomTitleView.m */,
|
||||
32A887201C89B9580037DC17 /* SimpleRoomTitleView.xib */,
|
||||
|
@ -1214,6 +1222,7 @@
|
|||
F02528D81C11B6FC00E1FE1B /* camera_picture.png in Resources */,
|
||||
F02528E01C11B6FC00E1FE1B /* create_room.png in Resources */,
|
||||
F02528DF1C11B6FC00E1FE1B /* camera_video.png in Resources */,
|
||||
F02BB04C1CBE2EE70022A025 /* PreviewRoomTitleView.xib in Resources */,
|
||||
F056418C1C7CBEBD002276ED /* group.png in Resources */,
|
||||
F0C34B681C15C28300C36F09 /* RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.xib in Resources */,
|
||||
F0026B631C916E68001D2C04 /* priorityLow@3x.png in Resources */,
|
||||
|
@ -1481,6 +1490,7 @@
|
|||
71B2A3BB1C2013DC00472061 /* TableViewCellWithLabelAndMXKImageView.m in Sources */,
|
||||
F0D2D9851C197DCB007B8C96 /* RoomIncomingAttachmentWithoutSenderInfoBubbleCell.m in Sources */,
|
||||
71046D5E1C0C639300DCA984 /* RoomTitleView.m in Sources */,
|
||||
F02BB04B1CBE2EE70022A025 /* PreviewRoomTitleView.m in Sources */,
|
||||
F0C34B631C15C28300C36F09 /* RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.m in Sources */,
|
||||
F09EE0061C5134BE0078712F /* RoomOutgoingTextMsgWithoutSenderNameBubbleCell.m in Sources */,
|
||||
F09EE0081C5134BE0078712F /* RoomOutgoingTextMsgWithPaginationTitleWithoutSenderNameBubbleCell.m in Sources */,
|
||||
|
|
|
@ -33,7 +33,8 @@
|
|||
"cancel" = "Cancel";
|
||||
"save" = "Save";
|
||||
"join" = "Join";
|
||||
"reject" = "Reject";
|
||||
"decline" = "Decline";
|
||||
"preview" = "Preview";
|
||||
"camera" = "Camera";
|
||||
"voice" = "Voice";
|
||||
"video" = "Video";
|
||||
|
@ -152,6 +153,11 @@
|
|||
"room_title_multiple_active_members" = "%d/%d active members";
|
||||
"room_title_one_active_member" = "%d/%d active member";
|
||||
|
||||
// Room Preview
|
||||
"room_preview_invitation_format" = "You have been invited to join this room by %@";
|
||||
"room_preview_subtitle" = "This is a preview of this room. Files and other attachments have been disabled.";
|
||||
"room_preview_unlinked_email_warning" = "This invitation was sent to %@, which is not associated with this account.\nYou may wish to login with a different account, or add this email to your this account.";
|
||||
|
||||
// Settings
|
||||
"account_logout_all" = "Logout all accounts";
|
||||
|
||||
|
|
|
@ -18,20 +18,32 @@
|
|||
|
||||
#import "RoomTitleView.h"
|
||||
|
||||
#import "RoomEmailInvitation.h"
|
||||
|
||||
#import "UIViewController+VectorSearch.h"
|
||||
|
||||
@interface RoomViewController : MXKRoomViewController <UISearchBarDelegate, UIGestureRecognizerDelegate, RoomTitleViewTapGestureDelegate>
|
||||
|
||||
// The expanded header
|
||||
@property (weak, nonatomic) IBOutlet UIView *expandedHeaderContainer;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *expandedHeaderContainerHeightConstraint;
|
||||
|
||||
// The preview header
|
||||
@property (weak, nonatomic) IBOutlet UIView *previewHeaderContainer;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *previewHeaderContainerHeightConstraint;
|
||||
|
||||
/**
|
||||
Hide/Show the expanded header.
|
||||
Show/Hide the expanded header.
|
||||
By default this header is hidden on new instantiated RoomViewController object.
|
||||
*/
|
||||
- (void)hideExpandedHeader:(BOOL)isHidden;
|
||||
- (void)showExpandedHeader:(BOOL)isVisible;
|
||||
|
||||
/**
|
||||
Display an invitation preview.
|
||||
|
||||
@param emailInvitation the invitation received by email.
|
||||
*/
|
||||
- (void)displayEmailInvitation:(RoomEmailInvitation*)emailInvitation;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#import "RoomAvatarTitleView.h"
|
||||
#import "ExpandedRoomTitleView.h"
|
||||
#import "SimpleRoomTitleView.h"
|
||||
#import "PreviewRoomTitleView.h"
|
||||
|
||||
#import "RoomParticipantsViewController.h"
|
||||
|
||||
|
@ -67,6 +68,9 @@
|
|||
// The expanded header
|
||||
ExpandedRoomTitleView *expandedHeader;
|
||||
|
||||
// The preview header
|
||||
PreviewRoomTitleView *previewHeader;
|
||||
|
||||
// The content offset at the beginning of scrolling
|
||||
CGFloat storedContentOffset;
|
||||
|
||||
|
@ -85,6 +89,9 @@
|
|||
// The first tab is selected by default in room details screen in of case 'showRoomDetails' segue.
|
||||
// Use this flag to select a specific tab (0: people, 1: settings).
|
||||
NSUInteger selectedRoomDetailsIndex;
|
||||
|
||||
// The room invitation received by email
|
||||
RoomEmailInvitation *roomEmailInvitation;
|
||||
}
|
||||
|
||||
@property (strong, nonatomic) MXKAlert *currentAlert;
|
||||
|
@ -109,6 +116,32 @@
|
|||
|
||||
#pragma mark -
|
||||
|
||||
- (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil
|
||||
{
|
||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||
if (self)
|
||||
{
|
||||
// Disable auto join
|
||||
self.autoJoinInvitedRoom = NO;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder
|
||||
{
|
||||
self = [super initWithCoder:aDecoder];
|
||||
if (self)
|
||||
{
|
||||
// Disable auto join
|
||||
self.autoJoinInvitedRoom = NO;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
@ -177,6 +210,10 @@
|
|||
|
||||
[NSLayoutConstraint activateConstraints:@[leftConstraint, rightConstraint, topConstraint, bottomConstraint]];
|
||||
|
||||
// Prepare preview header container
|
||||
self.previewHeaderContainer.backgroundColor = kVectorColorLightGrey;
|
||||
self.previewHeaderContainerHeightConstraint.constant = 368;
|
||||
|
||||
// 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.
|
||||
[self setRoomInputToolbarViewClass:RoomInputToolbarView.class];
|
||||
|
@ -200,21 +237,7 @@
|
|||
if (self.roomDataSource)
|
||||
{
|
||||
// Set room title view
|
||||
if (self.roomDataSource.isLive)
|
||||
{
|
||||
self.navigationItem.rightBarButtonItem.enabled = YES;
|
||||
|
||||
[self setRoomTitleViewClass:RoomTitleView.class];
|
||||
((RoomTitleView*)self.titleView).tapGestureDelegate = self;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Hide the search button
|
||||
self.navigationItem.rightBarButtonItem = nil;
|
||||
|
||||
[self setRoomTitleViewClass:SimpleRoomTitleView.class];
|
||||
self.titleView.editable = NO;
|
||||
}
|
||||
[self refreshRoomTitle];
|
||||
|
||||
[self refreshRoomInputToolbar];
|
||||
}
|
||||
|
@ -259,8 +282,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
// Hide expanded header to restore navigation bar settings
|
||||
[self hideExpandedHeader:YES];
|
||||
// Hide expanded/preview header to restore navigation bar settings
|
||||
[self showExpandedHeader:NO];
|
||||
[self showPreviewHeader:NO];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
|
@ -316,7 +340,19 @@
|
|||
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
|
||||
{
|
||||
// Hide expanded header on device rotation
|
||||
[self hideExpandedHeader:YES];
|
||||
[self showExpandedHeader:NO];
|
||||
|
||||
// Hide preview header (if any) during device rotation
|
||||
BOOL isPreview = !self.previewHeaderContainer.isHidden;
|
||||
if (isPreview)
|
||||
{
|
||||
[self showPreviewHeader:NO];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)((coordinator.transitionDuration + 0.5) * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
|
||||
[self showPreviewHeader:YES];
|
||||
});
|
||||
}
|
||||
|
||||
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
||||
}
|
||||
|
@ -333,22 +369,9 @@
|
|||
{
|
||||
// This room view controller has its own typing management.
|
||||
self.roomDataSource.showTypingNotifications = NO;
|
||||
|
||||
if (self.roomDataSource.isLive)
|
||||
{
|
||||
self.navigationItem.rightBarButtonItem.enabled = YES;
|
||||
|
||||
[self setRoomTitleViewClass:RoomTitleView.class];
|
||||
((RoomTitleView*)self.titleView).tapGestureDelegate = self;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Hide the search button
|
||||
self.navigationItem.rightBarButtonItem = nil;
|
||||
|
||||
[self setRoomTitleViewClass:SimpleRoomTitleView.class];
|
||||
self.titleView.editable = NO;
|
||||
}
|
||||
|
||||
// Set room title view
|
||||
[self refreshRoomTitle];
|
||||
|
||||
// Store ref on customized room data source
|
||||
if ([dataSource isKindOfClass:RoomDataSource.class])
|
||||
|
@ -364,15 +387,46 @@
|
|||
[self refreshRoomInputToolbar];
|
||||
}
|
||||
|
||||
- (void)onRoomDataSourceReady
|
||||
{
|
||||
// Handle here invitation
|
||||
if (self.roomDataSource.room.state.membership == MXMembershipInvite)
|
||||
{
|
||||
self.navigationItem.rightBarButtonItem.enabled = NO;
|
||||
|
||||
// Show preview header
|
||||
[self showPreviewHeader:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[super onRoomDataSourceReady];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateViewControllerAppearanceOnRoomDataSourceState
|
||||
{
|
||||
[super updateViewControllerAppearanceOnRoomDataSourceState];
|
||||
|
||||
self.navigationItem.rightBarButtonItem.enabled = (self.roomDataSource != nil);
|
||||
|
||||
self.titleView.editable = NO;
|
||||
|
||||
expandedHeader.mxRoom = self.roomDataSource.room;
|
||||
if (self.isRoomPreview)
|
||||
{
|
||||
self.navigationItem.rightBarButtonItem.enabled = NO;
|
||||
|
||||
// Hide input tool bar and activity view. FIXME: These items should be removed instead of being hidden until they will be used for preview.
|
||||
self.inputToolbarView.hidden = YES;
|
||||
self.activitiesView.hidden = YES;
|
||||
|
||||
previewHeader.mxRoom = self.roomDataSource.room;
|
||||
}
|
||||
else
|
||||
{
|
||||
[self showPreviewHeader:NO];
|
||||
|
||||
self.navigationItem.rightBarButtonItem.enabled = (self.roomDataSource != nil);
|
||||
|
||||
self.titleView.editable = NO;
|
||||
|
||||
expandedHeader.mxRoom = self.roomDataSource.room;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isIRCStyleCommand:(NSString*)string
|
||||
|
@ -420,7 +474,7 @@
|
|||
// Dispatch this operation to prevent flickering in navigation bar.
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
[self hideExpandedHeader:YES];
|
||||
[self showExpandedHeader:NO];
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -442,11 +496,71 @@
|
|||
customizedRoomDataSource = nil;
|
||||
}
|
||||
|
||||
if (expandedHeader)
|
||||
{
|
||||
[expandedHeader removeFromSuperview];
|
||||
expandedHeader = nil;
|
||||
}
|
||||
|
||||
if (previewHeader)
|
||||
{
|
||||
[previewHeader removeFromSuperview];
|
||||
previewHeader = nil;
|
||||
}
|
||||
|
||||
[super destroy];
|
||||
}
|
||||
|
||||
#pragma mark - Internals
|
||||
|
||||
- (BOOL)isRoomPreview
|
||||
{
|
||||
if (self.roomDataSource && self.roomDataSource.state == MXKDataSourceStateReady && self.roomDataSource.room.state.membership == MXMembershipInvite)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
if (roomEmailInvitation)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)refreshRoomTitle
|
||||
{
|
||||
// Set the right room title view
|
||||
if (self.isRoomPreview)
|
||||
{
|
||||
// Disable the search button
|
||||
self.navigationItem.rightBarButtonItem.enabled = NO;
|
||||
|
||||
[self showPreviewHeader:YES];
|
||||
}
|
||||
else if (self.roomDataSource)
|
||||
{
|
||||
[self showPreviewHeader:NO];
|
||||
|
||||
if (self.roomDataSource.isLive)
|
||||
{
|
||||
// Enable the search button
|
||||
self.navigationItem.rightBarButtonItem.enabled = YES;
|
||||
|
||||
[self setRoomTitleViewClass:RoomTitleView.class];
|
||||
((RoomTitleView*)self.titleView).tapGestureDelegate = self;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Hide the search button
|
||||
self.navigationItem.rightBarButtonItem = nil;
|
||||
|
||||
[self setRoomTitleViewClass:SimpleRoomTitleView.class];
|
||||
self.titleView.editable = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)refreshRoomInputToolbar
|
||||
{
|
||||
// Check whether the input toolbar is ready before updating it.
|
||||
|
@ -478,16 +592,17 @@
|
|||
|
||||
#pragma mark - Hide/Show expanded header
|
||||
|
||||
- (void)hideExpandedHeader:(BOOL)isHidden
|
||||
- (void)showExpandedHeader:(BOOL)isVisible
|
||||
{
|
||||
// Check conditions before applying change on room header.
|
||||
// This operation is ignored:
|
||||
// - if a screen rotation is in progress.
|
||||
// - if the room data source has been removed.
|
||||
// - if the room data source does not manage a live timeline.
|
||||
if (self.expandedHeaderContainer.isHidden != isHidden && isSizeTransitionInProgress == NO && self.roomDataSource && self.roomDataSource.isLive)
|
||||
// - if the user's membership is not 'join'.
|
||||
if (self.expandedHeaderContainer.isHidden == isVisible && isSizeTransitionInProgress == NO && self.roomDataSource && self.roomDataSource.isLive && self.roomDataSource.room.state.membership == MXMembershipJoin)
|
||||
{
|
||||
self.expandedHeaderContainer.hidden = isHidden;
|
||||
self.expandedHeaderContainer.hidden = !isVisible;
|
||||
|
||||
// Consider the main navigation controller if the current view controller is embedded inside a split view controller.
|
||||
UINavigationController *mainNavigationController = self.navigationController;
|
||||
|
@ -504,12 +619,7 @@
|
|||
UIImage *shadowImage = nil;
|
||||
MXKImageView *roomAvatarView = nil;
|
||||
|
||||
if (isHidden)
|
||||
{
|
||||
[self setRoomTitleViewClass:RoomTitleView.class];
|
||||
((RoomTitleView*)self.titleView).tapGestureDelegate = self;
|
||||
}
|
||||
else
|
||||
if (isVisible)
|
||||
{
|
||||
[self setRoomTitleViewClass:RoomAvatarTitleView.class];
|
||||
// Note the avatar title view does not define tap gesture.
|
||||
|
@ -522,6 +632,11 @@
|
|||
// Dismiss the keyboard when header is expanded.
|
||||
[self.inputToolbarView dismissKeyboard];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setRoomTitleViewClass:RoomTitleView.class];
|
||||
((RoomTitleView*)self.titleView).tapGestureDelegate = self;
|
||||
}
|
||||
|
||||
// Report shadow image
|
||||
[mainNavigationController.navigationBar setShadowImage:shadowImage];
|
||||
|
@ -529,7 +644,7 @@
|
|||
|
||||
[UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseIn
|
||||
animations:^{
|
||||
self.bubblesTableViewTopConstraint.constant = (isHidden ? 0 : self.expandedHeaderContainerHeightConstraint.constant - self.bubblesTableView.contentInset.top);
|
||||
self.bubblesTableViewTopConstraint.constant = (isVisible ? self.expandedHeaderContainerHeightConstraint.constant - self.bubblesTableView.contentInset.top : 0);
|
||||
|
||||
if (roomAvatarView)
|
||||
{
|
||||
|
@ -544,6 +659,149 @@
|
|||
}
|
||||
}
|
||||
|
||||
#pragma mark - Hide/Show preview header
|
||||
|
||||
- (void)showPreviewHeader:(BOOL)isVisible
|
||||
{
|
||||
// Check conditions before applying change on room header.
|
||||
// This operation is ignored when a screen rotation is in progress.
|
||||
if (self.previewHeaderContainer.isHidden == isVisible && isSizeTransitionInProgress == NO)
|
||||
{
|
||||
if (isVisible && !previewHeader)
|
||||
{
|
||||
previewHeader = [PreviewRoomTitleView roomTitleView];
|
||||
previewHeader.delegate = self;
|
||||
previewHeader.tapGestureDelegate = self;
|
||||
previewHeader.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[self.previewHeaderContainer addSubview:previewHeader];
|
||||
// Force preview header in full width
|
||||
NSLayoutConstraint *leftConstraint = [NSLayoutConstraint constraintWithItem:previewHeader
|
||||
attribute:NSLayoutAttributeLeading
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:self.previewHeaderContainer
|
||||
attribute:NSLayoutAttributeLeading
|
||||
multiplier:1.0
|
||||
constant:0];
|
||||
NSLayoutConstraint *rightConstraint = [NSLayoutConstraint constraintWithItem:previewHeader
|
||||
attribute:NSLayoutAttributeTrailing
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:self.previewHeaderContainer
|
||||
attribute:NSLayoutAttributeTrailing
|
||||
multiplier:1.0
|
||||
constant:0];
|
||||
// Vertical constraints are required for iOS > 8
|
||||
NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:previewHeader
|
||||
attribute:NSLayoutAttributeTop
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:self.previewHeaderContainer
|
||||
attribute:NSLayoutAttributeTop
|
||||
multiplier:1.0
|
||||
constant:0];
|
||||
NSLayoutConstraint *bottomConstraint = [NSLayoutConstraint constraintWithItem:previewHeader
|
||||
attribute:NSLayoutAttributeBottom
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:self.previewHeaderContainer
|
||||
attribute:NSLayoutAttributeBottom
|
||||
multiplier:1.0
|
||||
constant:0];
|
||||
|
||||
[NSLayoutConstraint activateConstraints:@[leftConstraint, rightConstraint, topConstraint, bottomConstraint]];
|
||||
|
||||
if (self.roomDataSource)
|
||||
{
|
||||
previewHeader.mxRoom = self.roomDataSource.room;
|
||||
}
|
||||
else
|
||||
{
|
||||
previewHeader.emailInvitation = roomEmailInvitation;
|
||||
}
|
||||
}
|
||||
|
||||
self.previewHeaderContainer.hidden = !isVisible;
|
||||
|
||||
// Consider the main navigation controller if the current view controller is embedded inside a split view controller.
|
||||
UINavigationController *mainNavigationController = self.navigationController;
|
||||
if (self.splitViewController && self.splitViewController.isCollapsed && self.splitViewController.viewControllers.count)
|
||||
{
|
||||
mainNavigationController = self.splitViewController.viewControllers.firstObject;
|
||||
}
|
||||
|
||||
// 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 (isVisible)
|
||||
{
|
||||
[self setRoomTitleViewClass:RoomAvatarTitleView.class];
|
||||
// Note the avatar title view does not define tap gesture.
|
||||
|
||||
roomAvatarView = ((RoomAvatarTitleView*)self.titleView).roomAvatar;
|
||||
roomAvatarView.alpha = 0.0;
|
||||
|
||||
shadowImage = [[UIImage alloc] init];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setRoomTitleViewClass:RoomTitleView.class];
|
||||
// We don't want to handle tap gesture here
|
||||
}
|
||||
|
||||
// Report shadow image
|
||||
[mainNavigationController.navigationBar setShadowImage:shadowImage];
|
||||
[mainNavigationController.navigationBar setBackgroundImage:shadowImage forBarMetrics:UIBarMetricsDefault];
|
||||
|
||||
[UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseIn
|
||||
animations:^{
|
||||
self.bubblesTableViewTopConstraint.constant = (isVisible ? self.previewHeaderContainerHeightConstraint.constant - self.bubblesTableView.contentInset.top : 0);
|
||||
|
||||
if (roomAvatarView)
|
||||
{
|
||||
roomAvatarView.alpha = 1;
|
||||
}
|
||||
|
||||
// Force to render the view
|
||||
[self.view layoutIfNeeded];
|
||||
}
|
||||
completion:^(BOOL finished){
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Preview
|
||||
|
||||
- (void)displayEmailInvitation:(RoomEmailInvitation*)emailInvitation
|
||||
{
|
||||
if (emailInvitation)
|
||||
{
|
||||
roomEmailInvitation = emailInvitation;
|
||||
previewHeader.emailInvitation = emailInvitation;
|
||||
|
||||
[self refreshRoomTitle];
|
||||
|
||||
if (emailInvitation.roomAvatarUrl)
|
||||
{
|
||||
if ([self.titleView isKindOfClass:RoomAvatarTitleView.class])
|
||||
{
|
||||
RoomAvatarTitleView *roomAvatarTitleView = (RoomAvatarTitleView*)self.titleView;
|
||||
MXKImageView *roomAvatarView = roomAvatarTitleView.roomAvatar;
|
||||
NSString *roomAvatarUrl = [self.roomDataSource.mxSession.matrixRestClient urlOfContentThumbnail:emailInvitation.roomAvatarUrl toFitViewSize:roomAvatarView.frame.size withMethod:MXThumbnailingMethodCrop];
|
||||
|
||||
roomAvatarTitleView.roomAvatarURL = roomAvatarUrl;
|
||||
}
|
||||
}
|
||||
|
||||
if (emailInvitation.email)
|
||||
{
|
||||
// FIXME: Check whether the email is linked or not to the account
|
||||
// If it is not linked, use 'previewHeader.subInvitationLabel' to warm the user with predefined string 'room_preview_unlinked_email_warning'.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - MXKDataSourceDelegate
|
||||
|
||||
- (Class<MXKCellRendering>)cellViewClassForCellData:(MXKCellData*)cellData
|
||||
|
@ -1123,7 +1381,7 @@
|
|||
// Hide expanded header on scroll down
|
||||
if (storedContentOffset < scrollView.contentOffset.y)
|
||||
{
|
||||
[self hideExpandedHeader:YES];
|
||||
[self showExpandedHeader:NO];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1146,7 +1404,7 @@
|
|||
if (self.expandedHeaderContainer.isHidden)
|
||||
{
|
||||
// Expand the header
|
||||
[self hideExpandedHeader:NO];
|
||||
[self showExpandedHeader:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1161,6 +1419,50 @@
|
|||
selectedRoomDetailsIndex = 0;
|
||||
[self performSegueWithIdentifier:@"showRoomDetails" sender:self];
|
||||
}
|
||||
else if (view == previewHeader.leftButton)
|
||||
{
|
||||
if (roomEmailInvitation)
|
||||
{
|
||||
//FIXME Accept the invitation
|
||||
}
|
||||
else
|
||||
{
|
||||
[self joinRoom:^(BOOL succeed) {
|
||||
|
||||
if (succeed)
|
||||
{
|
||||
[self refreshRoomTitle];
|
||||
}
|
||||
|
||||
}];
|
||||
}
|
||||
}
|
||||
else if (view == previewHeader.rightButton)
|
||||
{
|
||||
if (roomEmailInvitation)
|
||||
{
|
||||
//FIXME Decline this invitation
|
||||
}
|
||||
else
|
||||
{
|
||||
[self startActivityIndicator];
|
||||
|
||||
[self.roomDataSource.room leave:^{
|
||||
|
||||
[self stopActivityIndicator];
|
||||
|
||||
// We remove the current view controller.
|
||||
// Pop to homes view controller
|
||||
[[AppDelegate theDelegate] restoreInitialDisplay:^{}];
|
||||
|
||||
} failure:^(NSError *error) {
|
||||
|
||||
[self stopActivityIndicator];
|
||||
NSLog(@"[Vector RoomVC] Failed to reject an invited room (%@) failed", self.roomDataSource.room.state.roomId);
|
||||
|
||||
}];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Typing management
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?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">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9532" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RoomViewController">
|
||||
|
@ -12,6 +12,8 @@
|
|||
<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="previewHeaderContainer" destination="54r-18-K1g" id="Klt-RV-V1E"/>
|
||||
<outlet property="previewHeaderContainerHeightConstraint" destination="goj-GZ-IkD" id="GbA-T9-kiL"/>
|
||||
<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"/>
|
||||
|
@ -36,6 +38,13 @@
|
|||
<constraint firstAttribute="height" constant="240" id="w9z-HS-7wJ"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="54r-18-K1g">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="368"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="368" id="goj-GZ-IkD"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<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"/>
|
||||
|
@ -57,15 +66,18 @@
|
|||
<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="54r-18-K1g" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="QGq-T0-Epo"/>
|
||||
<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 firstAttribute="trailing" secondItem="54r-18-K1g" secondAttribute="trailing" id="b8H-xp-RH3"/>
|
||||
<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"/>
|
||||
<constraint firstItem="54r-18-K1g" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="t02-d3-Zyf"/>
|
||||
</constraints>
|
||||
<nil key="simulatedStatusBarMetrics"/>
|
||||
</view>
|
||||
|
|
|
@ -34,16 +34,16 @@
|
|||
[self.leftButton.layer setCornerRadius:5];
|
||||
self.leftButton.clipsToBounds = YES;
|
||||
self.leftButton.backgroundColor = kVectorColorGreen;
|
||||
[self.leftButton setTitle:NSLocalizedStringFromTable(@"join", @"Vector", nil) forState:UIControlStateNormal];
|
||||
[self.leftButton setTitle:NSLocalizedStringFromTable(@"join", @"Vector", nil) forState:UIControlStateHighlighted];
|
||||
[self.leftButton setTitle:NSLocalizedStringFromTable(@"preview", @"Vector", nil) forState:UIControlStateNormal];
|
||||
[self.leftButton setTitle:NSLocalizedStringFromTable(@"preview", @"Vector", nil) forState:UIControlStateHighlighted];
|
||||
[self.leftButton addTarget:self action:@selector(onJoinPressed:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
|
||||
[self.rightButton.layer setCornerRadius:5];
|
||||
self.rightButton.clipsToBounds = YES;
|
||||
self.rightButton.backgroundColor = kVectorColorGreen;
|
||||
[self.rightButton setTitle:NSLocalizedStringFromTable(@"reject", @"Vector", nil) forState:UIControlStateNormal];
|
||||
[self.rightButton setTitle:NSLocalizedStringFromTable(@"reject", @"Vector", nil) forState:UIControlStateHighlighted];
|
||||
[self.rightButton setTitle:NSLocalizedStringFromTable(@"decline", @"Vector", nil) forState:UIControlStateNormal];
|
||||
[self.rightButton setTitle:NSLocalizedStringFromTable(@"decline", @"Vector", nil) forState:UIControlStateHighlighted];
|
||||
[self.rightButton addTarget:self action:@selector(onRejectedPressed:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
|
|
37
Vector/Views/RoomTitle/PreviewRoomTitleView.h
Normal file
37
Vector/Views/RoomTitle/PreviewRoomTitleView.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
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"
|
||||
|
||||
#import "RoomEmailInvitation.h"
|
||||
|
||||
@interface PreviewRoomTitleView : RoomTitleView
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIView *mainHeaderContainer;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UILabel *roomMembers;
|
||||
@property (weak, nonatomic) IBOutlet UIView *roomMembersDetailsIcon;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UILabel *invitationLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIView *buttonsContainer;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *leftButton;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *rightButton;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *subInvitationLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIView *bottomBorderView;
|
||||
|
||||
@property (strong, nonatomic) RoomEmailInvitation *emailInvitation;
|
||||
|
||||
@end
|
158
Vector/Views/RoomTitle/PreviewRoomTitleView.m
Normal file
158
Vector/Views/RoomTitle/PreviewRoomTitleView.m
Normal file
|
@ -0,0 +1,158 @@
|
|||
/*
|
||||
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 "PreviewRoomTitleView.h"
|
||||
|
||||
#import "VectorDesignValues.h"
|
||||
|
||||
#import "MXRoom+Vector.h"
|
||||
|
||||
@implementation PreviewRoomTitleView
|
||||
|
||||
+ (UINib *)nib
|
||||
{
|
||||
return [UINib nibWithNibName:NSStringFromClass([self class])
|
||||
bundle:[NSBundle bundleForClass:[self class]]];
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
[super awakeFromNib];
|
||||
|
||||
self.displayNameTextField.textColor = kVectorTextColorBlack;
|
||||
self.roomMembers.textColor = kVectorColorGreen;
|
||||
|
||||
self.invitationLabel.textColor = kVectorTextColorDarkGray;
|
||||
self.invitationLabel.numberOfLines = 0;
|
||||
self.subInvitationLabel.text = nil;
|
||||
|
||||
self.subInvitationLabel.textColor = kVectorTextColorGray;
|
||||
self.subInvitationLabel.numberOfLines = 0;
|
||||
|
||||
self.subInvitationLabel.text = nil;// FIXME: Use NSLocalizedStringFromTable(@"room_preview_subtitle", @"Vector", nil);
|
||||
|
||||
self.bottomBorderView.backgroundColor = kVectorColorLightGrey;
|
||||
|
||||
[self.leftButton.layer setCornerRadius:5];
|
||||
self.leftButton.clipsToBounds = YES;
|
||||
self.leftButton.backgroundColor = kVectorColorGreen;
|
||||
[self.leftButton setTitle:NSLocalizedStringFromTable(@"join", @"Vector", nil) forState:UIControlStateNormal];
|
||||
[self.leftButton setTitle:NSLocalizedStringFromTable(@"join", @"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.layer setCornerRadius:5];
|
||||
self.rightButton.clipsToBounds = YES;
|
||||
self.rightButton.backgroundColor = kVectorColorGreen;
|
||||
[self.rightButton setTitle:NSLocalizedStringFromTable(@"decline", @"Vector", nil) forState:UIControlStateNormal];
|
||||
[self.rightButton setTitle:NSLocalizedStringFromTable(@"decline", @"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)refreshDisplay
|
||||
{
|
||||
[super refreshDisplay];
|
||||
|
||||
if (self.mxRoom)
|
||||
{
|
||||
self.displayNameTextField.text = self.mxRoom.vectorDisplayname;
|
||||
if (!self.displayNameTextField.text.length)
|
||||
{
|
||||
self.displayNameTextField.text = NSLocalizedStringFromTable(@"room_displayname_no_title", @"Vector", nil);
|
||||
self.displayNameTextField.textColor = kVectorTextColorGray;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.displayNameTextField.textColor = kVectorTextColorBlack;
|
||||
}
|
||||
|
||||
// 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 rom 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.invitationLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_preview_invitation_format", @"Vector", nil), inviter];
|
||||
}
|
||||
else if (self.emailInvitation)
|
||||
{
|
||||
self.displayNameTextField.text = self.emailInvitation.roomName;
|
||||
self.roomMembers.text = nil;
|
||||
self.invitationLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_preview_invitation_format", @"Vector", nil), self.emailInvitation.inviterName];
|
||||
}
|
||||
else
|
||||
{
|
||||
self.roomMembers.text = nil;
|
||||
self.invitationLabel.text = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setEmailInvitation:(RoomEmailInvitation *)emailInvitation
|
||||
{
|
||||
_emailInvitation = emailInvitation;
|
||||
|
||||
[self refreshDisplay];
|
||||
}
|
||||
|
||||
@end
|
152
Vector/Views/RoomTitle/PreviewRoomTitleView.xib
Normal file
152
Vector/Views/RoomTitle/PreviewRoomTitleView.xib
Normal file
|
@ -0,0 +1,152 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9532" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
|
||||
<capability name="Constraints with non-1.0 multipliers" 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="Cpa-Xt-cwB" customClass="PreviewRoomTitleView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="368"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BkF-x3-7fX">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="187"/>
|
||||
<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="Cpa-Xt-cwB" id="BIq-nD-Pb9"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<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="153" 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 hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="details_icon" translatesAutoresizingMaskIntoConstraints="NO" id="S3Y-wJ-HOe">
|
||||
<rect key="frame" x="325" y="158" 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>
|
||||
</subviews>
|
||||
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||
<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="height" constant="187" id="4yY-Aa-tdH"/>
|
||||
<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="153" 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="6uH-I3-RQg" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="top" constant="126" id="Piq-rp-Pae"/>
|
||||
<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 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="211" width="41" height="20"/>
|
||||
<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="265" 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="calibratedRGB"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="16"/>
|
||||
<state key="normal" title="Left button">
|
||||
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</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="calibratedRGB"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="16"/>
|
||||
<state key="normal" title="Right Button">
|
||||
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</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="312" width="38" height="18"/>
|
||||
<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="367" width="600" height="1"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="1" id="LTH-xc-zcs"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<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="IwA-0X-IYb" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="bottom" constant="125" id="3h2-dy-8DW"/>
|
||||
<constraint firstItem="gIX-nY-f6M" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="Cpa-Xt-cwB" secondAttribute="leading" constant="31" id="7Kn-g9-Ya6"/>
|
||||
<constraint firstItem="gIX-nY-f6M" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="bottom" constant="24" id="7Rv-NQ-cUQ"/>
|
||||
<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="leading" secondItem="Cpa-Xt-cwB" secondAttribute="leading" id="H07-HA-2Px"/>
|
||||
<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 firstItem="WmW-5h-jL1" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="bottom" constant="78" id="cbq-4b-5RE"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="IwA-0X-IYb" secondAttribute="trailing" constant="31" id="iGR-eh-0e9"/>
|
||||
<constraint firstItem="IwA-0X-IYb" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="Cpa-Xt-cwB" secondAttribute="leading" constant="31" id="lpD-yd-qgt"/>
|
||||
<constraint firstAttribute="bottom" secondItem="BCO-DT-F0C" secondAttribute="bottom" id="mFA-ka-eVK"/>
|
||||
<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="invitationLabel" destination="gIX-nY-f6M" id="kcf-aA-DJN"/>
|
||||
<outlet property="leftButton" destination="osd-JP-2az" id="HrL-Qy-UDt"/>
|
||||
<outlet property="mainHeaderContainer" destination="BkF-x3-7fX" id="1fp-xz-ETJ"/>
|
||||
<outlet property="rightButton" destination="461-vO-hLZ" id="u8R-Rg-WAv"/>
|
||||
<outlet property="roomMembers" destination="ou0-3Z-weL" id="lRs-fz-QXc"/>
|
||||
<outlet property="roomMembersDetailsIcon" destination="S3Y-wJ-HOe" id="QjQ-wY-EOS"/>
|
||||
<outlet property="subInvitationLabel" destination="IwA-0X-IYb" id="dh4-pi-rLa"/>
|
||||
</connections>
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="details_icon" width="31" height="31"/>
|
||||
</resources>
|
||||
</document>
|
|
@ -21,4 +21,6 @@
|
|||
@property (weak, nonatomic) IBOutlet MXKImageView *roomAvatar;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *roomAvatarCenterXConstraint;
|
||||
|
||||
@property (nonatomic) NSString *roomAvatarURL;
|
||||
|
||||
@end
|
|
@ -77,6 +77,10 @@
|
|||
self.roomAvatar.clipsToBounds = YES;
|
||||
|
||||
}
|
||||
else if (self.roomAvatarURL)
|
||||
{
|
||||
[self.roomAvatar setImageURL:self.roomAvatarURL withType:nil andImageOrientation:UIImageOrientationUp previewImage:[UIImage imageNamed:@"placeholder"]];
|
||||
}
|
||||
else
|
||||
{
|
||||
self.roomAvatar.image = [UIImage imageNamed:@"placeholder"];
|
||||
|
@ -85,4 +89,11 @@
|
|||
self.roomAvatar.backgroundColor = kVectorColorLightGrey;
|
||||
}
|
||||
|
||||
- (void)setRoomAvatarURL:(NSString *)roomAvatarURL
|
||||
{
|
||||
_roomAvatarURL = roomAvatarURL;
|
||||
|
||||
[self refreshDisplay];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -41,4 +41,9 @@
|
|||
*/
|
||||
@property (nonatomic) id<RoomTitleViewTapGestureDelegate> tapGestureDelegate;
|
||||
|
||||
/**
|
||||
The method used to handle the gesture recognized by a receiver.
|
||||
*/
|
||||
- (void)reportTapGesture:(UITapGestureRecognizer*)tapGestureRecognizer;
|
||||
|
||||
@end
|
|
@ -34,19 +34,25 @@
|
|||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
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 (_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;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
|
|
Loading…
Reference in a new issue