iOS: done #1122 (stretched user icon)

Fixed the social feed detail icon being stretched, and the avatar on the feeds list being missing.
This commit is contained in:
David Sinclair 2018-09-26 11:20:51 -07:00
parent c33e4cbf67
commit 2244830633
4 changed files with 12 additions and 8 deletions

View file

@ -328,12 +328,11 @@
spacerBarButton.width = -6;
NSString *feedIdStr = [NSString stringWithFormat:@"%@", [storiesCollection.activeFeed objectForKey:@"id"]];
UIImage *titleImage = [appDelegate getFavicon:feedIdStr isSocial:YES];
titleImage = [Utilities roundCorneredImage:titleImage radius:6];
titleImage = [Utilities roundCorneredImage:titleImage radius:6 convertToSize:CGSizeMake(32, 32)];
[((UIButton *)titleImageBarButton.customView).imageView removeFromSuperview];
titleImageBarButton = [UIBarButtonItem barItemWithImage:titleImage
target:self
action:@selector(showUserProfile)];
titleImageBarButton.customView.frame = CGRectMake(0, 0, 32, 32);
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:
spacerBarButton,
titleImageBarButton,

View file

@ -2131,6 +2131,7 @@ heightForHeaderInSection:(NSInteger)section {
target:self
action:@selector(showUserProfile)];
userAvatarButton.customView.frame = CGRectMake(0, yOffset + 1, 32, 32);
userAvatarButton.width = 32;
userAvatarButton.accessibilityLabel = @"User info";
userAvatarButton.accessibilityHint = @"Double-tap for information about your account.";
@ -2141,8 +2142,7 @@ heightForHeaderInSection:(NSInteger)section {
typeof(self) __weak weakSelf = self;
[avatarImageView setImageWithURLRequest:avatarRequest placeholderImage:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
typeof(weakSelf) __strong strongSelf = weakSelf;
image = [Utilities imageWithImage:image convertToSize:CGSizeMake(32, 32)];
image = [Utilities roundCorneredImage:image radius:6];
image = [Utilities roundCorneredImage:image radius:6 convertToSize:CGSizeMake(32, 32)];
[(UIButton *)strongSelf.userAvatarButton.customView setImage:image forState:UIControlStateNormal];
} failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nonnull response, NSError * _Nonnull error) {

View file

@ -17,6 +17,7 @@ void drawLinearGradient(CGContextRef context, CGRect rect, CGColorRef startColor
+ (void)drawLinearGradientWithRect:(CGRect)rect startColor:(CGColorRef)startColor endColor:(CGColorRef)endColor;
+ (UIImage *)roundCorneredImage:(UIImage *)orig radius:(CGFloat)r;
+ (UIImage *)roundCorneredImage: (UIImage*)orig radius:(CGFloat)r convertToSize:(CGSize)size;
+ (UIImage *)imageWithImage:(UIImage *)image convertToSize:(CGSize)size;
+ (NSString *)md5:(NSString *)string;
+ (NSString *)formatLongDateFromTimestamp:(NSInteger)timestamp;

View file

@ -58,12 +58,16 @@ void drawLinearGradient(CGContextRef context, CGRect rect, CGColorRef startColor
CGColorSpaceRelease(colorSpace);
}
+ (UIImage *)roundCorneredImage: (UIImage*) orig radius:(CGFloat) r {
+ (UIImage *)roundCorneredImage:(UIImage*)orig radius:(CGFloat)r {
return [self roundCorneredImage:orig radius:r convertToSize:orig.size];
}
+ (UIImage *)roundCorneredImage:(UIImage*)orig radius:(CGFloat)r convertToSize:(CGSize)size {
if (!orig) return nil;
UIGraphicsBeginImageContextWithOptions(orig.size, NO, 0);
[[UIBezierPath bezierPathWithRoundedRect:(CGRect){CGPointZero, orig.size}
UIGraphicsBeginImageContextWithOptions(size, NO, 0);
[[UIBezierPath bezierPathWithRoundedRect:(CGRect){CGPointZero, size}
cornerRadius:r] addClip];
[orig drawInRect:(CGRect){CGPointZero, orig.size}];
[orig drawInRect:(CGRect){CGPointZero, size}];
UIImage* result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return result;