|
|
|
@ -6,6 +6,8 @@
|
|
|
|
|
#import "Environment.h"
|
|
|
|
|
#import "Signal-Swift.h"
|
|
|
|
|
#import "ThreadUtil.h"
|
|
|
|
|
#import "UIColor+OWS.h"
|
|
|
|
|
#import "UIFont+OWS.h"
|
|
|
|
|
#import <SignalServiceKit/OWSMessageSender.h>
|
|
|
|
|
#import <SignalServiceKit/TSThread.h>
|
|
|
|
|
|
|
|
|
@ -21,12 +23,18 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
@implementation SendExternalFileViewController
|
|
|
|
|
|
|
|
|
|
- (instancetype)init
|
|
|
|
|
{
|
|
|
|
|
if (self = [super init]) {
|
|
|
|
|
self.delegate = self;
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)loadView
|
|
|
|
|
{
|
|
|
|
|
[super loadView];
|
|
|
|
|
|
|
|
|
|
self.delegate = self;
|
|
|
|
|
|
|
|
|
|
_messageSender = [Environment getCurrent].messageSender;
|
|
|
|
|
|
|
|
|
|
self.title = NSLocalizedString(@"SEND_EXTERNAL_FILE_VIEW_TITLE", @"Title for the 'send external file' view.");
|
|
|
|
@ -51,7 +59,86 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
- (nullable UIView *)createHeader:(UIView *)superview
|
|
|
|
|
{
|
|
|
|
|
return nil;
|
|
|
|
|
OWSAssert(superview)
|
|
|
|
|
|
|
|
|
|
const CGFloat imageSize
|
|
|
|
|
= ScaleFromIPhone5To7Plus(40, 40);
|
|
|
|
|
const CGFloat imageLabelSpacing = ScaleFromIPhone5To7Plus(5, 5);
|
|
|
|
|
const CGFloat titleVSpacing = ScaleFromIPhone5To7Plus(10, 10);
|
|
|
|
|
const CGFloat contentVMargin = ScaleFromIPhone5To7Plus(20, 20);
|
|
|
|
|
|
|
|
|
|
UIView *header = [UIView new];
|
|
|
|
|
[superview addSubview:header];
|
|
|
|
|
[header autoPinWidthToSuperview];
|
|
|
|
|
[header autoPinToTopLayoutGuideOfViewController:self withInset:0];
|
|
|
|
|
|
|
|
|
|
UIView *titleLabel = [self createTitleLabel];
|
|
|
|
|
[header addSubview:titleLabel];
|
|
|
|
|
[titleLabel autoHCenterInSuperview];
|
|
|
|
|
[titleLabel autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:contentVMargin];
|
|
|
|
|
|
|
|
|
|
UIView *fileView = [UIView new];
|
|
|
|
|
[header addSubview:fileView];
|
|
|
|
|
[fileView autoHCenterInSuperview];
|
|
|
|
|
[fileView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:contentVMargin];
|
|
|
|
|
[fileView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:titleLabel withOffset:titleVSpacing];
|
|
|
|
|
|
|
|
|
|
UIImage *image = [UIImage imageNamed:@"file-thin-black-large"];
|
|
|
|
|
OWSAssert(image);
|
|
|
|
|
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
|
|
|
|
|
imageView.layer.minificationFilter = kCAFilterTrilinear;
|
|
|
|
|
imageView.layer.magnificationFilter = kCAFilterTrilinear;
|
|
|
|
|
[fileView addSubview:imageView];
|
|
|
|
|
[imageView autoSetDimension:ALDimensionWidth toSize:imageSize];
|
|
|
|
|
[imageView autoSetDimension:ALDimensionHeight toSize:imageSize];
|
|
|
|
|
[imageView autoPinEdgeToSuperviewEdge:ALEdgeLeft];
|
|
|
|
|
[imageView autoPinEdgeToSuperviewEdge:ALEdgeTop];
|
|
|
|
|
[imageView autoPinEdgeToSuperviewEdge:ALEdgeBottom];
|
|
|
|
|
|
|
|
|
|
UIView *fileNameLabel = [self createFileNameLabel];
|
|
|
|
|
[fileView addSubview:fileNameLabel];
|
|
|
|
|
[fileNameLabel autoAlignAxis:ALAxisHorizontal toSameAxisOfView:imageView];
|
|
|
|
|
[fileNameLabel autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:imageView withOffset:imageLabelSpacing];
|
|
|
|
|
[fileNameLabel autoPinEdgeToSuperviewEdge:ALEdgeRight];
|
|
|
|
|
|
|
|
|
|
return header;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString *)formattedFileName
|
|
|
|
|
{
|
|
|
|
|
OWSAssert(self.attachment) NSString *filename =
|
|
|
|
|
[self.attachment.filename stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
|
|
|
|
OWSAssert(filename.length > 0);
|
|
|
|
|
const NSUInteger kMaxFilenameLength = 50;
|
|
|
|
|
if (filename.length > kMaxFilenameLength) {
|
|
|
|
|
// Truncate the filename if necessary.
|
|
|
|
|
//
|
|
|
|
|
// TODO: Use l10n-safe truncation.
|
|
|
|
|
filename = [[[filename substringToIndex:kMaxFilenameLength / 2] stringByAppendingString:@"…"]
|
|
|
|
|
stringByAppendingString:[filename substringFromIndex:filename.length - kMaxFilenameLength / 2]];
|
|
|
|
|
}
|
|
|
|
|
return filename;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIView *)createFileNameLabel
|
|
|
|
|
{
|
|
|
|
|
UILabel *label = [UILabel new];
|
|
|
|
|
label.text = [self formattedFileName];
|
|
|
|
|
label.textColor = [UIColor ows_materialBlueColor];
|
|
|
|
|
label.font = [UIFont ows_regularFontWithSize:16.f];
|
|
|
|
|
label.lineBreakMode = NSLineBreakByTruncatingMiddle;
|
|
|
|
|
return label;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (UIView *)createTitleLabel
|
|
|
|
|
{
|
|
|
|
|
UILabel *label = [UILabel new];
|
|
|
|
|
label.text
|
|
|
|
|
= NSLocalizedString(@"SEND_EXTERNAL_FILE_HEADER_TITLE", @"Header title for the 'send external file' view.");
|
|
|
|
|
label.textColor = [UIColor blackColor];
|
|
|
|
|
label.font = [UIFont ows_mediumFontWithSize:18.f];
|
|
|
|
|
return label;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|