Skip to content

Commit

Permalink
Behavioral changes for FBProfilePictureView control
Browse files Browse the repository at this point in the history
Summary:
This is in advance of doing the changes for #1113853 about providing a high res square picture for FBProfilePictureView.

Our Profile Picture view control is messed up in a few ways:

* It is always resizing the profile picture to fit the available view.  In the case of profile pictures, this is almost always wrong due to what it does to image quality.

* It is conflating image size, with "cropping" (square, original).

* It isn't taking advantage of the fact that we can know the right image size to load, and placing that burden on the developer.

Thus, a few changes here:

* As soon as we know the image dimensions, we set the contentMode to ensure the image is never larger than its native size, and that it's never cropped by the view.
* We choose the right image variant to display based upon view size.
* We have a new enum for the "cropping"
* We entirely remove the "size" enumeration.  It's not useful for the developer to specify this.

As such, this control is a lot easier to reason about.  This will also extend well when we have multiple sizes of square images.

This change also adds a bunch of UI control to PictureProfileSample for playing with this.  And updating other controls that were setting the size param.

Test Plan: Scrumptious, SwitchUser, MyProfile, and ProfilePictureSample - both iPad and iPhone.

Reviewers: clang, jacl, mmarucheck

Reviewed By: clang

CC: msdkexp@

Differential Revision: https://phabricator.fb.com/D491131

Task ID: 1113853
  • Loading branch information
gregschechter committed Jun 12, 2012
1 parent 33f7e8e commit b67aec4
Show file tree
Hide file tree
Showing 10 changed files with 595 additions and 283 deletions.
4 changes: 1 addition & 3 deletions samples/MyProfileSample/MyProfileSample/MPViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

profilePic.pictureSize = FBProfilePictureSizeLarge;


// FBSample logic
// bootstrap call to updateForSessionChange gets a fresh new session object
[self updateForSessionChange];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#import "AppDelegate.h"
#import "ViewController.h"
#import <FBiOSSDK/FBProfilePictureView.h>
#import <FBiOSSDK/FacebookSDK.h>

@implementation AppDelegate

Expand All @@ -37,7 +37,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// wireup successfully.
// http://stackoverflow.com/questions/1725881/unknown-class-myclass-in-interface-builder-file-error-at-runtime
[FBProfilePictureView class];

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

// Override point for customization after application launch.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@
@interface ViewController : UIViewController

@property (retain, nonatomic) IBOutlet FBProfilePictureView *profilePictureView;
@property (retain, nonatomic) IBOutlet UIView *profilePictureOuterView;

- (IBAction)showJasonProfile:(id)sender;
- (IBAction)showMichaelProfile:(id)sender;
- (IBAction)showVijayeProfile:(id)sender;
- (IBAction)showRandomProfile:(id)sender;
- (IBAction)makePictureSmall:(id)sender;
- (IBAction)makePictureNormal:(id)sender;
- (IBAction)makePictureLarge:(id)sender;

- (IBAction)makePictureOriginal:(id)sender;
- (IBAction)makePictureSquare:(id)sender;

- (IBAction)makeViewSmall:(id)sender;
- (IBAction)makeViewLarge:(id)sender;

@end
29 changes: 19 additions & 10 deletions samples/ProfilePictureSample/ProfilePictureSample/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ @interface ViewController ()

@implementation ViewController
@synthesize profilePictureView;
@synthesize profilePictureOuterView;


- (IBAction)showJasonProfile:(id)sender
{
Expand All @@ -76,22 +78,29 @@ - (IBAction)showRandomProfile:(id)sender
encoding:NSASCIIStringEncoding];
}

- (IBAction)makePictureSmall:(id)sender
// Cropping selections

- (IBAction)makePictureOriginal:(id)sender
{
profilePictureView.pictureSize = FBProfilePictureSizeSmall;
profilePictureView.bounds = CGRectMake(0, 0, 40, 40);
profilePictureView.pictureCropping = FBProfilePictureCroppingOriginal;
}

- (IBAction)makePictureNormal:(id)sender
- (IBAction)makePictureSquare:(id)sender
{
profilePictureView.pictureCropping = FBProfilePictureCroppingSquare;
}


// View size mods

- (IBAction)makeViewSmall:(id)sender
{
profilePictureView.pictureSize = FBProfilePictureSizeNormal;
profilePictureView.bounds = CGRectMake(0, 0, 80, 80);
profilePictureOuterView.bounds = CGRectMake(0, 0, 100, 100);
}

- (IBAction)makePictureLarge:(id)sender
- (IBAction)makeViewLarge:(id)sender
{
profilePictureView.pictureSize = FBProfilePictureSizeLarge;
profilePictureView.bounds = CGRectMake(0, 0, 130, 130);
profilePictureOuterView.bounds = CGRectMake(0, 0, 220, 220);
}


Expand All @@ -102,7 +111,7 @@ - (void)viewDidLoad
{
[super viewDidLoad];

[self makePictureLarge:self];
// [self makePictureLarge:self];
profilePictureView.userID = @"45963418107"; // Hello world
}

Expand Down

0 comments on commit b67aec4

Please sign in to comment.