mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-23 18:12:44 +02:00
Merge pull request #5598 from vector-im/steve/bubbles_move_files
Room timeline: Move files in relevant folders
This commit is contained in:
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 OpenMarket Ltd
|
||||
Copyright 2017 Vector Creations Ltd
|
||||
Copyright 2018 New Vector 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 <MatrixSDK/MatrixSDK.h>
|
||||
|
||||
#import "MXKView.h"
|
||||
|
||||
typedef NS_ENUM(NSInteger, ReadReceiptsAlignment)
|
||||
{
|
||||
/**
|
||||
The latest receipt is displayed on left
|
||||
*/
|
||||
ReadReceiptAlignmentLeft = 0,
|
||||
|
||||
/**
|
||||
The latest receipt is displayed on right
|
||||
*/
|
||||
ReadReceiptAlignmentRight = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
`MXKReceiptSendersContainer` is a view dedicated to display receipt senders by using their avatars.
|
||||
|
||||
This container handles automatically the number of visible avatars. A label is added when avatars are not all visible (see 'moreLabel' property).
|
||||
*/
|
||||
@interface MXKReceiptSendersContainer : MXKView
|
||||
|
||||
/**
|
||||
The maximum number of avatars displayed in the container. 3 by default.
|
||||
*/
|
||||
@property (nonatomic) NSInteger maxDisplayedAvatars;
|
||||
|
||||
/**
|
||||
The space between avatars. 2.0 points by default.
|
||||
*/
|
||||
@property (nonatomic) CGFloat avatarMargin;
|
||||
|
||||
/**
|
||||
The label added beside avatars when avatars are not all visible.
|
||||
*/
|
||||
@property (nonatomic) UILabel* moreLabel;
|
||||
|
||||
/**
|
||||
The more label text color (If set to nil `moreLabel.textColor` use `UIColor.blackColor` as default color).
|
||||
*/
|
||||
@property (nonatomic) UIColor* moreLabelTextColor;
|
||||
|
||||
/*
|
||||
The read receipt objects for details required in the details view
|
||||
*/
|
||||
@property (nonatomic) NSArray <MXReceiptData *> *readReceipts;
|
||||
|
||||
/*
|
||||
The array of the room members that will be displayed in the container
|
||||
*/
|
||||
@property (nonatomic, readonly) NSArray <MXRoomMember *> *roomMembers;
|
||||
|
||||
/*
|
||||
The placeholders of the room members that will be shown if the users don't have avatars
|
||||
*/
|
||||
@property (nonatomic, readonly) NSArray <UIImage *> *placeholders;
|
||||
|
||||
/**
|
||||
Initializes an `MXKReceiptSendersContainer` object with a frame and a media manager.
|
||||
|
||||
This is the designated initializer.
|
||||
|
||||
@param frame the container frame. Note that avatar will be displayed in full height in this container.
|
||||
@param mediaManager the media manager used to download the matrix user's avatar.
|
||||
@return The newly-initialized MXKReceiptSendersContainer instance
|
||||
*/
|
||||
- (instancetype)initWithFrame:(CGRect)frame andMediaManager:(MXMediaManager*)mediaManager;
|
||||
|
||||
/**
|
||||
Refresh the container content by using the provided room members.
|
||||
|
||||
@param roomMembers list of room members sorted from the latest receipt to the oldest receipt.
|
||||
@param placeHolders list of placeholders, one by room member. Used when url is nil, or during avatar download.
|
||||
@param alignment (see ReadReceiptsAlignment).
|
||||
*/
|
||||
- (void)refreshReceiptSenders:(NSArray<MXRoomMember*>*)roomMembers withPlaceHolders:(NSArray<UIImage*>*)placeHolders andAlignment:(ReadReceiptsAlignment)alignment;
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,174 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 OpenMarket Ltd
|
||||
Copyright 2018 New Vector 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 "MXKReceiptSendersContainer.h"
|
||||
|
||||
#import "MXKImageView.h"
|
||||
|
||||
static UIColor* kMoreLabelDefaultcolor;
|
||||
|
||||
@interface MXKReceiptSendersContainer ()
|
||||
|
||||
@property (nonatomic, readwrite) NSArray <MXRoomMember *> *roomMembers;
|
||||
@property (nonatomic, readwrite) NSArray <UIImage *> *placeholders;
|
||||
@property (nonatomic) MXMediaManager *mediaManager;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation MXKReceiptSendersContainer
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self == [MXKReceiptSendersContainer class])
|
||||
{
|
||||
kMoreLabelDefaultcolor = [UIColor blackColor];
|
||||
}
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame andMediaManager:(MXMediaManager*)mediaManager
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self)
|
||||
{
|
||||
_mediaManager = mediaManager;
|
||||
_maxDisplayedAvatars = 3;
|
||||
_avatarMargin = 2.0;
|
||||
_moreLabel = nil;
|
||||
_moreLabelTextColor = kMoreLabelDefaultcolor;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)refreshReceiptSenders:(NSArray<MXRoomMember*>*)roomMembers withPlaceHolders:(NSArray<UIImage*>*)placeHolders andAlignment:(ReadReceiptsAlignment)alignment
|
||||
{
|
||||
// Store the room members and placeholders for showing in the details view controller
|
||||
self.roomMembers = roomMembers;
|
||||
self.placeholders = placeHolders;
|
||||
|
||||
// Remove all previous content
|
||||
for (UIView* view in self.subviews)
|
||||
{
|
||||
[view removeFromSuperview];
|
||||
}
|
||||
if (_moreLabel)
|
||||
{
|
||||
[_moreLabel removeFromSuperview];
|
||||
_moreLabel = nil;
|
||||
}
|
||||
|
||||
CGRect globalFrame = self.frame;
|
||||
CGFloat side = globalFrame.size.height;
|
||||
CGFloat defaultMoreLabelWidth = side < 20 ? 20 : side;
|
||||
unsigned long count;
|
||||
unsigned long maxDisplayableItems = (int)((globalFrame.size.width - defaultMoreLabelWidth - _avatarMargin) / (side + _avatarMargin));
|
||||
|
||||
maxDisplayableItems = MIN(maxDisplayableItems, _maxDisplayedAvatars);
|
||||
count = MIN(roomMembers.count, maxDisplayableItems);
|
||||
|
||||
int index;
|
||||
|
||||
CGFloat xOff = 0;
|
||||
|
||||
if (alignment == ReadReceiptAlignmentRight)
|
||||
{
|
||||
xOff = globalFrame.size.width - (side + _avatarMargin);
|
||||
}
|
||||
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
MXRoomMember *roomMember = [roomMembers objectAtIndex:index];
|
||||
UIImage *preview = index < placeHolders.count ? placeHolders[index] : nil;
|
||||
|
||||
MXKImageView *imageView = [[MXKImageView alloc] initWithFrame:CGRectMake(xOff, 0, side, side)];
|
||||
imageView.defaultBackgroundColor = [UIColor clearColor];
|
||||
imageView.autoresizingMask = UIViewAutoresizingNone;
|
||||
|
||||
if (alignment == ReadReceiptAlignmentRight)
|
||||
{
|
||||
xOff -= side + _avatarMargin;
|
||||
}
|
||||
else
|
||||
{
|
||||
xOff += side + _avatarMargin;
|
||||
}
|
||||
|
||||
[self addSubview:imageView];
|
||||
imageView.enableInMemoryCache = YES;
|
||||
|
||||
[imageView setImageURI:roomMember.avatarUrl
|
||||
withType:nil
|
||||
andImageOrientation:UIImageOrientationUp
|
||||
toFitViewSize:CGSizeMake(side, side)
|
||||
withMethod:MXThumbnailingMethodCrop
|
||||
previewImage:preview
|
||||
mediaManager:_mediaManager];
|
||||
|
||||
[imageView.layer setCornerRadius:imageView.frame.size.width / 2];
|
||||
imageView.clipsToBounds = YES;
|
||||
}
|
||||
|
||||
// Check whether there are more than expected read receipts
|
||||
if (roomMembers.count > maxDisplayableItems)
|
||||
{
|
||||
// Add a more indicator
|
||||
|
||||
// In case of right alignment, adjust the current position by considering the default label width
|
||||
if (alignment == ReadReceiptAlignmentRight && side < defaultMoreLabelWidth)
|
||||
{
|
||||
xOff -= (defaultMoreLabelWidth - side);
|
||||
}
|
||||
|
||||
_moreLabel = [[UILabel alloc] initWithFrame:CGRectMake(xOff, 0, defaultMoreLabelWidth, side)];
|
||||
_moreLabel.text = [NSString stringWithFormat:(alignment == ReadReceiptAlignmentRight) ? @"%tu+" : @"+%tu", roomMembers.count - maxDisplayableItems];
|
||||
_moreLabel.font = [UIFont systemFontOfSize:11];
|
||||
_moreLabel.adjustsFontSizeToFitWidth = YES;
|
||||
_moreLabel.minimumScaleFactor = 0.6;
|
||||
|
||||
// In case of right alignment, adjust the horizontal position according to the actual label width
|
||||
if (alignment == ReadReceiptAlignmentRight)
|
||||
{
|
||||
[_moreLabel sizeToFit];
|
||||
CGRect frame = _moreLabel.frame;
|
||||
if (frame.size.width < defaultMoreLabelWidth)
|
||||
{
|
||||
frame.origin.x += (defaultMoreLabelWidth - frame.size.width);
|
||||
_moreLabel.frame = frame;
|
||||
}
|
||||
}
|
||||
|
||||
_moreLabel.textColor = self.moreLabelTextColor ?: kMoreLabelDefaultcolor;
|
||||
[self addSubview:_moreLabel];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
NSArray* subviews = self.subviews;
|
||||
for (UIView* view in subviews)
|
||||
{
|
||||
[view removeFromSuperview];
|
||||
}
|
||||
|
||||
if (_moreLabel)
|
||||
{
|
||||
[_moreLabel removeFromSuperview];
|
||||
_moreLabel = nil;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user