mirror of https://github.com/oxen-io/session-ios
Unifies bubble sizes for media bubbles
Media bubbles (for photo, video and animated) sizes are calculated using shared logic. The bubbles are fixed width and their height is calculated based on the aspect ratio of the underlying image (clamped to a reasonable min/max height). Fixes #1270 // FREEBIEpull/1/head
parent
bbfffdf79f
commit
c958c7909c
@ -0,0 +1,15 @@
|
||||
//
|
||||
// JSQMediaItem+OWS.h
|
||||
// Signal
|
||||
//
|
||||
// Created by Matthew Douglass on 10/18/16.
|
||||
// Copyright © 2016 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <JSQMessagesViewController/JSQMediaItem.h>
|
||||
|
||||
@interface JSQMediaItem (OWS)
|
||||
|
||||
- (CGSize)ows_adjustBubbleSize:(CGSize)bubbleSize forImage:(UIImage *)image;
|
||||
|
||||
@end
|
@ -0,0 +1,26 @@
|
||||
//
|
||||
// JSQMediaItem+OWS.m
|
||||
// Signal
|
||||
//
|
||||
// Created by Matthew Douglass on 10/18/16.
|
||||
// Copyright © 2016 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "JSQMediaItem+OWS.h"
|
||||
#import "UIDevice+TSHardwareVersion.h"
|
||||
#import "NumberUtil.h"
|
||||
|
||||
@implementation JSQMediaItem (OWS)
|
||||
|
||||
- (CGSize)ows_adjustBubbleSize:(CGSize)bubbleSize forImage:(UIImage *)image {
|
||||
if ([[UIDevice currentDevice] isiPhoneVersionSixOrMore]) {
|
||||
bubbleSize.width *= 1.1;
|
||||
} else {
|
||||
bubbleSize.width *= 0.7;
|
||||
}
|
||||
double aspectRatio = image.size.height / image.size.width;
|
||||
bubbleSize.height = (CGFloat)(bubbleSize.width * [NumberUtil clamp:aspectRatio toMin:0.5 andMax:1.5]);
|
||||
return bubbleSize;
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in New Issue