Browse Source

Avatar on Managed Account

Marino Faggiana 8 years ago
parent
commit
8967ca361c

+ 0 - 21
Libraries external/APAvatarImageView/APAvatarImageView.h

@@ -1,21 +0,0 @@
-//
-//  APAvatarImageView.h
-//  Avatar
-//
-//  Created by Ankur Patel on 10/19/13.
-//  Copyright (c) 2013 Patel Labs LLC. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-@interface APAvatarImageView : UIImageView
-
-@property (nonatomic, retain) UIColor *borderColor;
-@property (nonatomic, assign) float borderWidth;
-@property (nonatomic, assign) float cornerRadius;
-
-- (id)initWithFrame:(CGRect)frame borderColor:(UIColor*)borderColor borderWidth:(float)borderWidth;
-- (id)initWithImage:(UIImage *)image borderColor:(UIColor*)borderColor borderWidth:(float)borderWidth;
-- (id)initWithImage:(UIImage *)image highlightedImage:(UIImage *)highlightedImage borderColor:(UIColor*)borderColor borderWidth:(float)borderWidth;
-
-@end

+ 0 - 115
Libraries external/APAvatarImageView/APAvatarImageView.m

@@ -1,115 +0,0 @@
-//
-//  APAvatarImageView.m
-//  Avatar
-//
-//  Created by Ankur Patel on 10/19/13.
-//  Copyright (c) 2013 Patel Labs LLC. All rights reserved.
-//
-
-#import "APAvatarImageView.h"
-
-@interface APAvatarImageView ()
-
-- (void)draw;
-
-@end
-
-@implementation APAvatarImageView
-
-- (id)initWithFrame:(CGRect)frame
-{
-    self = [super initWithFrame:frame];
-    if (self) {
-        _cornerRadius = self.frame.size.height/2.0f;
-        [self draw];
-    }
-    return self;
-}
-
-- (id)initWithCoder:(NSCoder *)aDecoder
-{
-    self = [super initWithCoder:aDecoder];
-    if (self) {
-        _borderWidth = -1.0;
-        _cornerRadius = self.frame.size.height/2.0f;
-        [self draw];
-    }
-    return self;
-}
-
-- (id)initWithFrame:(CGRect)frame borderColor:(UIColor*)borderColor borderWidth:(float)borderWidth
-{
-    self = [super initWithFrame:frame];
-    if (self) {
-        _borderColor = borderColor;
-        _borderWidth = borderWidth;
-        _cornerRadius = self.frame.size.height/2.0f;
-        [self draw];
-    }
-    return self;
-}
-
-- (id)initWithImage:(UIImage *)image borderColor:(UIColor*)borderColor borderWidth:(float)borderWidth
-{
-    self = [super initWithImage:image];
-    if (self) {
-        _borderColor = borderColor;
-        _borderWidth = borderWidth;
-        _cornerRadius = self.frame.size.height/2.0f;
-        [self draw];
-    }
-    return self;
-}
-
-- (id)initWithImage:(UIImage *)image highlightedImage:(UIImage *)highlightedImage borderColor:(UIColor*)borderColor borderWidth:(float)borderWidth
-{
-    self = [super initWithImage:image highlightedImage:highlightedImage];
-    if (self) {
-        _borderColor = borderColor;
-        _borderWidth = borderWidth;
-        _cornerRadius = self.frame.size.height/2.0f;
-        [self draw];
-    }
-    return self;
-}
-
-- (void)setBorderColor:(UIColor *)borderColor
-{
-    _borderColor = borderColor;
-    [self draw];
-}
-
-- (void)setBorderWidth:(float)borderWidth
-{
-    _borderWidth = borderWidth;
-    [self draw];
-}
-
--(void)setCornerRadius:(float)cornerRadius
-{
-    _cornerRadius = cornerRadius;
-    [self draw];
-}
-
-- (void)draw
-{
-    CGRect frame = self.frame;
-    if (frame.size.width != frame.size.height) {
-        NSLog(@"Warning: Height and Width should be the same for image view");
-    }
-    CALayer *l = [self layer];
-    [l setMasksToBounds:YES];
-    [l setCornerRadius:_cornerRadius];
-    if (_borderWidth < 0) { // Default case
-        [l setBorderWidth:3.0];
-    } else {
-        [l setBorderWidth:_borderWidth];
-    }
-    if (_borderColor == nil) {
-        [l setBorderColor:[[UIColor lightGrayColor] CGColor]];
-    } else {
-        [l setBorderColor:[_borderColor CGColor]];
-    }
-}
-
-@end

+ 0 - 14
Nextcloud.xcodeproj/project.pbxproj

@@ -7,7 +7,6 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
-		F705723E1EA8DC4E00268E43 /* APAvatarImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = F705723D1EA8DC4E00268E43 /* APAvatarImageView.m */; };
 		F708CF6D1E56E8CC00271D8B /* TableMetadata+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = F708CF4E1E56E8CB00271D8B /* TableMetadata+CoreDataClass.m */; };
 		F708CF6E1E56E8CC00271D8B /* TableMetadata+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = F708CF4E1E56E8CB00271D8B /* TableMetadata+CoreDataClass.m */; };
 		F708CF6F1E56E8CC00271D8B /* TableMetadata+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = F708CF4E1E56E8CB00271D8B /* TableMetadata+CoreDataClass.m */; };
@@ -756,8 +755,6 @@
 		F70211FB1BAC56E9003FC03E /* CCMain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCMain.m; sourceTree = "<group>"; };
 		F7053E3C1C639DF500741EA5 /* CCUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCUtility.h; sourceTree = "<group>"; };
 		F7053E3D1C639DF500741EA5 /* CCUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCUtility.m; sourceTree = "<group>"; };
-		F705723C1EA8DC4E00268E43 /* APAvatarImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APAvatarImageView.h; sourceTree = "<group>"; };
-		F705723D1EA8DC4E00268E43 /* APAvatarImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APAvatarImageView.m; sourceTree = "<group>"; };
 		F706C5031EA61F54003A48A3 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/CTAssetsPicker.strings"; sourceTree = "<group>"; };
 		F706C5041EA61F54003A48A3 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/SwiftWebVC.strings"; sourceTree = "<group>"; };
 		F706C5051EA61F54003A48A3 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/BKPasscodeView.strings"; sourceTree = "<group>"; };
@@ -1756,15 +1753,6 @@
 			path = Main;
 			sourceTree = "<group>";
 		};
-		F705723B1EA8DC4E00268E43 /* APAvatarImageView */ = {
-			isa = PBXGroup;
-			children = (
-				F705723C1EA8DC4E00268E43 /* APAvatarImageView.h */,
-				F705723D1EA8DC4E00268E43 /* APAvatarImageView.m */,
-			);
-			path = APAvatarImageView;
-			sourceTree = "<group>";
-		};
 		F70784811A2C8A0D00AC9FFF /* UploadFromOtherUpp */ = {
 			isa = PBXGroup;
 			children = (
@@ -1780,7 +1768,6 @@
 			children = (
 				F70F02A91C889183008DAB36 /* AESCrypt-ObjC */,
 				F70F02B21C889183008DAB36 /* AFViewShaker */,
-				F705723B1EA8DC4E00268E43 /* APAvatarImageView */,
 				F7F06E291DBFACC600099AE9 /* CTAssetsPickerController */,
 				F73CCE221DC13788007E38D8 /* DZNEmptyDataSet */,
 				F7659A211DC0B726004860C4 /* EAIntroView */,
@@ -4188,7 +4175,6 @@
 				F73CCDFD1DC13776007E38D8 /* XLFormViewController.m in Sources */,
 				F73CCDDF1DC13776007E38D8 /* XLFormDateCell.m in Sources */,
 				F73CCE1B1DC13776007E38D8 /* XLFormValidationStatus.m in Sources */,
-				F705723E1EA8DC4E00268E43 /* APAvatarImageView.m in Sources */,
 				F77B0E441D118A16002130FE /* CCIntro.m in Sources */,
 				F77B0E451D118A16002130FE /* ReaderThumbRender.m in Sources */,
 				F77B0E481D118A16002130FE /* CCCrypto.m in Sources */,

+ 1 - 1
iOSClient/Settings/CCManageAccount.h

@@ -25,7 +25,7 @@
 #import "XLForm.h"
 #import "CCLogin.h"
 #import "CCCoreData.h"
-#import "APAvatarImageView.h"
+
 
 @interface CCManageAccount : XLFormViewController <CCLoginDelegate>
 

+ 1 - 1
iOSClient/Settings/CCManageAccount.m

@@ -381,7 +381,7 @@
     
     avatar = [CCGraphics scaleImage:avatar toSize:CGSizeMake(40, 40) isAspectRation:YES];
     
-    APAvatarImageView *avatarImageView = [[APAvatarImageView alloc] initWithImage:avatar borderColor:[UIColor lightGrayColor] borderWidth:0.5];
+    CCAvatar *avatarImageView = [[CCAvatar alloc] initWithImage:avatar borderColor:[UIColor lightGrayColor] borderWidth:0.5];
         
     CGSize imageSize = avatarImageView.bounds.size;
     UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);

+ 6 - 0
iOSClient/Utility/CCGraphics.h

@@ -41,3 +41,9 @@
 + (UIImage *)scaleImage:(UIImage *)image toSize:(CGSize)targetSize isAspectRation:(BOOL)aspect;
 
 @end
+
+@interface CCAvatar : UIImageView
+
+- (id)initWithImage:(UIImage *)image borderColor:(UIColor*)borderColor borderWidth:(float)borderWidth;
+
+@end

+ 25 - 0
iOSClient/Utility/CCGraphics.m

@@ -265,3 +265,28 @@
 }
 
 @end
+
+
+// ------------------------------------------------------------------------------------------------------
+// MARK: Avatar
+// ------------------------------------------------------------------------------------------------------
+
+@implementation CCAvatar
+
+- (id)initWithImage:(UIImage *)image borderColor:(UIColor*)borderColor borderWidth:(float)borderWidth
+{
+    self = [super initWithImage:image];
+    
+    float cornerRadius = self.frame.size.height/2.0f;
+    CALayer *layer = [self layer];
+        
+    [layer setMasksToBounds:YES];
+    [layer setCornerRadius: cornerRadius];
+    [layer setBorderWidth: borderWidth];
+    [layer setBorderColor:[borderColor CGColor]];
+    
+    return self;
+}
+
+@end
+