Commit 2f2ef954 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

UI: account avatar

Fix image corners radius and limit size.

Change-Id: Ie7e0aaaf8244511a461e93c748af25c734c340fa
parent 6495de89
......@@ -42,6 +42,7 @@
#import "views/RoundedTextField.h"
#import "ExportPasswordWC.h"
#import "utils.h"
#import "Constants.h"
@interface AccRingGeneralVC ()
......@@ -114,7 +115,6 @@ typedef NS_ENUM(NSInteger, TagViews) {
- (void)awakeFromNib
{
[super awakeFromNib];
[photoView setBordered:YES];
[addProfilePhotoImage setWantsLayer: YES];
devicesTableView.delegate = self;
devicesTableView.dataSource = self;
......@@ -142,7 +142,7 @@ typedef NS_ENUM(NSInteger, TagViews) {
NSImage *image = [[NSImage alloc] initWithData:imageData];
if(image) {
[photoView setBordered:NO];
[photoView setImage: [image roundCorners: 350]];
[photoView setImage: [image roundCorners: image.size.height * 0.5]];
[addProfilePhotoImage setHidden:YES];
} else {
[photoView setImage:nil];
......@@ -241,8 +241,8 @@ typedef NS_ENUM(NSInteger, TagViews) {
}
if (auto outputImage = [picker outputImage]) {
auto image = [picker inputImage];
CGFloat newSize = MIN(image.size.height, image.size.width);
outputImage = [outputImage cropImageToSize:CGSizeMake(newSize, newSize)];
CGFloat newSize = MIN(MIN(image.size.height, image.size.width), MAX_IMAGE_SIZE);
outputImage = [outputImage imageResizeInsideMax: newSize];
[photoView setImage: [outputImage roundCorners: outputImage.size.height * 0.5]];
[photoView setBordered:NO];
[addProfilePhotoImage setHidden:YES];
......
......@@ -36,6 +36,7 @@
#import "AccSipGeneralVC.h"
#import "views/NSColor+RingTheme.h"
#import "views/NSImage+Extensions.h"
#import "Constants.h"
@interface AccSipGeneralVC ()
......@@ -76,7 +77,6 @@ typedef NS_ENUM(NSInteger, TagViews) {
-(void)viewDidLoad {
[super viewDidLoad];
[[self view] setAutoresizingMask: NSViewMinXMargin | NSViewMaxXMargin];
[photoView setBordered:YES];
[addProfilePhotoImage setWantsLayer: YES];
[self setEditingMode:NO];
[self updateView];
......@@ -93,8 +93,8 @@ typedef NS_ENUM(NSInteger, TagViews) {
if (auto outputImage = [picker outputImage]) {
[photoView setBordered:NO];
auto image = [picker inputImage];
CGFloat newSize = MIN(image.size.height, image.size.width);
outputImage = [outputImage cropImageToSize:CGSizeMake(newSize, newSize)];
CGFloat newSize = MIN(MIN(image.size.height, image.size.width), MAX_IMAGE_SIZE);
outputImage = [outputImage imageResizeInsideMax: newSize];
[photoView setImage: [outputImage roundCorners: outputImage.size.height * 0.5]];
[addProfilePhotoImage setHidden:YES];
auto imageToBytes = QByteArray::fromNSData([outputImage TIFFRepresentation]).toBase64();
......@@ -128,7 +128,7 @@ typedef NS_ENUM(NSInteger, TagViews) {
NSImage *image = [[NSImage alloc] initWithData:imageData];
if(image) {
[photoView setBordered:NO];
[photoView setImage: [image roundCorners: 350]];
[photoView setImage: [image roundCorners: image.size.height * 0.5]];
[addProfilePhotoImage setHidden:YES];
} else {
[photoView setImage:nil];
......
......@@ -29,6 +29,7 @@
//ring
#import "AddSIPAccountVC.h"
#import "views/NSImage+Extensions.h"
#import "Constants.h"
@interface AddSIPAccountVC () {
__unsafe_unretained IBOutlet NSButton* photoView;
......@@ -149,8 +150,8 @@ NSTimer* timeoutTimer;
if (auto outputImage = [picker outputImage]) {
[photoView setBordered:NO];
auto image = [picker inputImage];
CGFloat newSize = MIN(image.size.height, image.size.width);
outputImage = [outputImage cropImageToSize:CGSizeMake(newSize, newSize)];
CGFloat newSize = MIN(MIN(image.size.height, image.size.width), MAX_IMAGE_SIZE);
outputImage = [outputImage imageResizeInsideMax: newSize];
[photoView setImage:outputImage];
[addProfilePhotoImage setHidden:YES];
} else if(!photoView.image) {
......
......@@ -38,3 +38,5 @@ namespace Preferences {
/* download folder for incoming images*/
NSString * const DownloadFolder = @"download_folder";
}
const CGFloat MAX_IMAGE_SIZE = 1024;
......@@ -194,8 +194,8 @@ NSInteger const ERROR_REPEAT_MISMATCH = -2;
if (auto outputImage = [picker outputImage]) {
[photoView setBordered:NO];
auto image = [picker inputImage];
CGFloat newSize = MIN(image.size.height, image.size.width);
outputImage = [outputImage cropImageToSize:CGSizeMake(newSize, newSize)];
CGFloat newSize = MIN(MIN(image.size.height, image.size.width), MAX_IMAGE_SIZE);
outputImage = [outputImage imageResizeInsideMax: newSize];
[photoView setImage:outputImage];
[addProfilePhotoImage setHidden:YES];
} else if(!photoView.image) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment