Skip to content
This repository was archived by the owner on Jan 16, 2021. It is now read-only.

Fixed not set fields when emailAsUsername is set before fields are set. #135

Merged
merged 1 commit into from
Aug 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ParseUI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
810D6C3119F7F379005B3DB2 /* PFProductTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 810D6C2F19F7F379005B3DB2 /* PFProductTableViewController.m */; };
810D6C3419F7F38B005B3DB2 /* PFPurchaseTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 810D6C3219F7F38B005B3DB2 /* PFPurchaseTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; };
810D6C3519F7F38B005B3DB2 /* PFPurchaseTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 810D6C3319F7F38B005B3DB2 /* PFPurchaseTableViewCell.m */; };
811EE7A31B8C17550058B3BE /* PFLogInView_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 811EE7A21B8C17550058B3BE /* PFLogInView_Private.h */; };
8129E5F21A9CB067006752BC /* ParseUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC07E0554694100DB518D /* ParseUI.framework */; };
8129E5F31A9CB067006752BC /* (null) in Frameworks */ = {isa = PBXBuildFile; };
8129E5F51A9CB067006752BC /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 81472FA71A1AB37500FD6EED /* Images.xcassets */; };
Expand Down Expand Up @@ -151,6 +152,7 @@
810D6C3219F7F38B005B3DB2 /* PFPurchaseTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFPurchaseTableViewCell.h; sourceTree = "<group>"; };
810D6C3319F7F38B005B3DB2 /* PFPurchaseTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PFPurchaseTableViewCell.m; sourceTree = "<group>"; };
811B095A1A0843B9008B3393 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = ParseUI/Resources/Info.plist; sourceTree = SOURCE_ROOT; };
811EE7A21B8C17550058B3BE /* PFLogInView_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFLogInView_Private.h; sourceTree = "<group>"; };
8129E6001A9CB067006752BC /* ParseUIDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ParseUIDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
8129E6081A9CB1BE006752BC /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
8129E6391A9CB320006752BC /* UIDemoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIDemoViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -630,6 +632,7 @@
81ED075319F68028009745F4 /* PFLogInViewController.h */,
81ED075419F68028009745F4 /* PFLogInViewController.m */,
81ED075119F68028009745F4 /* PFLogInView.h */,
811EE7A21B8C17550058B3BE /* PFLogInView_Private.h */,
81ED075219F68028009745F4 /* PFLogInView.m */,
);
path = LogInViewController;
Expand Down Expand Up @@ -751,6 +754,7 @@
81E9CD1419F56D6B00487B0F /* ParseUIConstants.h in Headers */,
8185BA7C1A642A8B002815C0 /* PFCollectionViewCell.h in Headers */,
810D6C1F19F7F006005B3DB2 /* PFImageCache.h in Headers */,
811EE7A31B8C17550058B3BE /* PFLogInView_Private.h in Headers */,
81E9CD1319F56D6B00487B0F /* ParseUI.h in Headers */,
810D6C3419F7F38B005B3DB2 /* PFPurchaseTableViewCell.h in Headers */,
81ED079619F6809F009745F4 /* PFImageView.h in Headers */,
Expand Down
160 changes: 109 additions & 51 deletions ParseUI/Classes/LogInViewController/PFLogInView.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@

@implementation PFLogInView

#pragma mark -
#pragma mark Class
///--------------------------------------
#pragma mark - Class
///--------------------------------------

+ (PFActionButtonConfiguration *)_defaultSignUpButtonConfiguration {
PFActionButtonConfiguration *configuration = [[PFActionButtonConfiguration alloc] initWithBackgroundImageColor:[PFColor signupButtonBackgroundColor]
Expand Down Expand Up @@ -76,8 +77,9 @@ + (PFActionButtonConfiguration *)_defaultTwitterButtonConfiguration {
return configuration;
}

#pragma mark -
#pragma mark Init
///--------------------------------------
#pragma mark - Init
///--------------------------------------

- (instancetype)initWithFields:(PFLogInFields)otherFields {
self = [super initWithFrame:CGRectZero];
Expand All @@ -94,67 +96,116 @@ - (instancetype)initWithFields:(PFLogInFields)otherFields {
_logo.contentMode = UIViewContentModeScaleAspectFit;
[self addSubview:_logo];

[self _updateAllFields];

return self;
}

///--------------------------------------
#pragma mark - Fields
///--------------------------------------

- (void)_updateAllFields {
if (_fields & PFLogInFieldsDismissButton) {
_dismissButton = [[PFDismissButton alloc] initWithFrame:CGRectZero];
[self addSubview:_dismissButton];
if (!_dismissButton) {
_dismissButton = [[PFDismissButton alloc] initWithFrame:CGRectZero];
[self addSubview:_dismissButton];
}
} else {
[_dismissButton removeFromSuperview];
_dismissButton = nil;
}

if (_fields & PFLogInFieldsUsernameAndPassword) {
_usernameField = [[PFTextField alloc] initWithFrame:CGRectZero
separatorStyle:(PFTextFieldSeparatorStyleTop |
PFTextFieldSeparatorStyleBottom)];
_usernameField.autocorrectionType = UITextAutocorrectionTypeNo;
_usernameField.autocapitalizationType = UITextAutocapitalizationTypeNone;
_usernameField.returnKeyType = UIReturnKeyNext;
[self addSubview:_usernameField];
[self _updateUsernameFieldStyle];
if (!_usernameField) {
_usernameField = [[PFTextField alloc] initWithFrame:CGRectZero
separatorStyle:(PFTextFieldSeparatorStyleTop |
PFTextFieldSeparatorStyleBottom)];
_usernameField.autocorrectionType = UITextAutocorrectionTypeNo;
_usernameField.autocapitalizationType = UITextAutocapitalizationTypeNone;
_usernameField.returnKeyType = UIReturnKeyNext;
[self addSubview:_usernameField];
[self _updateUsernameFieldStyle];
}

_passwordField = [[PFTextField alloc] initWithFrame:CGRectZero
separatorStyle:PFTextFieldSeparatorStyleBottom];
_passwordField.placeholder = NSLocalizedString(@"Password", @"Password");
_passwordField.secureTextEntry = YES;
_passwordField.autocorrectionType = UITextAutocorrectionTypeNo;
_passwordField.autocapitalizationType = UITextAutocapitalizationTypeNone;
_passwordField.returnKeyType = UIReturnKeyDone;
[self addSubview:_passwordField];
if (!_passwordField) {
_passwordField = [[PFTextField alloc] initWithFrame:CGRectZero
separatorStyle:PFTextFieldSeparatorStyleBottom];
_passwordField.placeholder = NSLocalizedString(@"Password", @"Password");
_passwordField.secureTextEntry = YES;
_passwordField.autocorrectionType = UITextAutocorrectionTypeNo;
_passwordField.autocapitalizationType = UITextAutocapitalizationTypeNone;
_passwordField.returnKeyType = UIReturnKeyDone;
[self addSubview:_passwordField];
}
} else {
[_usernameField removeFromSuperview];
_usernameField = nil;

[_passwordField removeFromSuperview];
_passwordField = nil;
}

if (_fields & PFLogInFieldsSignUpButton) {
_signUpButton = [[PFActionButton alloc] initWithConfiguration:[[self class] _defaultSignUpButtonConfiguration]
buttonStyle:PFActionButtonStyleNormal];
[self addSubview:_signUpButton];
if (!_signUpButton) {
_signUpButton = [[PFActionButton alloc] initWithConfiguration:[[self class] _defaultSignUpButtonConfiguration]
buttonStyle:PFActionButtonStyleNormal];
[self addSubview:_signUpButton];
}
} else {
[_signUpButton removeFromSuperview];
_signUpButton = nil;
}

if (_fields & PFLogInFieldsPasswordForgotten) {
_passwordForgottenButton = [[PFTextButton alloc] initWithFrame:CGRectZero];
[_passwordForgottenButton setTitle:NSLocalizedString(@"Forgot Password?", "Forgot Password?")
forState:UIControlStateNormal];
[self addSubview:_passwordForgottenButton];
if (_passwordForgottenButton) {
_passwordForgottenButton = [[PFTextButton alloc] initWithFrame:CGRectZero];
[_passwordForgottenButton setTitle:NSLocalizedString(@"Forgot Password?", "Forgot Password?")
forState:UIControlStateNormal];
[self addSubview:_passwordForgottenButton];
}
} else {
[_passwordForgottenButton removeFromSuperview];
_passwordForgottenButton = nil;
}

if (_fields & PFLogInFieldsLogInButton) {
_logInButton = [[PFPrimaryButton alloc] initWithBackgroundImageColor:[PFColor loginButtonBackgroundColor]];
[_logInButton setTitle:NSLocalizedString(@"Log In", @"Log In") forState:UIControlStateNormal];
[self addSubview:_logInButton];
if (!_logInButton) {
_logInButton = [[PFPrimaryButton alloc] initWithBackgroundImageColor:[PFColor loginButtonBackgroundColor]];
[_logInButton setTitle:NSLocalizedString(@"Log In", @"Log In") forState:UIControlStateNormal];
[self addSubview:_logInButton];
}
} else {
[_logInButton removeFromSuperview];
_logInButton = nil;
}

if (_fields & PFLogInFieldsFacebook) {
_facebookButton = [[PFActionButton alloc] initWithConfiguration:[[self class] _defaultFacebookButtonConfiguration]
buttonStyle:PFActionButtonStyleNormal];
[self addSubview:_facebookButton];
if (!_facebookButton) {
_facebookButton = [[PFActionButton alloc] initWithConfiguration:[[self class] _defaultFacebookButtonConfiguration]
buttonStyle:PFActionButtonStyleNormal];
[self addSubview:_facebookButton];
}
} else {
[_facebookButton removeFromSuperview];
_facebookButton = nil;
}

if (_fields & PFLogInFieldsTwitter) {
_twitterButton = [[PFActionButton alloc] initWithConfiguration:[[self class] _defaultTwitterButtonConfiguration]
buttonStyle:PFActionButtonStyleNormal];
[self addSubview:_twitterButton];
if (_twitterButton) {
_twitterButton = [[PFActionButton alloc] initWithConfiguration:[[self class] _defaultTwitterButtonConfiguration]
buttonStyle:PFActionButtonStyleNormal];
[self addSubview:_twitterButton];
}
} else {
[_twitterButton removeFromSuperview];
_twitterButton = nil;
}

return self;
}

#pragma mark -
#pragma mark UIView
///--------------------------------------
#pragma mark - UIView
///--------------------------------------

- (void)layoutSubviews {
[super layoutSubviews];
Expand Down Expand Up @@ -285,8 +336,7 @@ - (void)layoutSubviews {
if (_logInButton) {
CGFloat loginButtonTopInset = floorf(24.0f * contentSizeScale.height);

CGRect frame = PFRectMakeWithSizeCenteredInRect([_logInButton sizeThatFits:loginContentSize],
loginContentRect);;
CGRect frame = PFRectMakeWithSizeCenteredInRect([_logInButton sizeThatFits:loginContentSize], loginContentRect);
frame.origin.y = currentY + loginButtonTopInset;
_logInButton.frame = frame;

Expand Down Expand Up @@ -350,9 +400,7 @@ - (CGSize)_loginContentSizeThatFits:(CGSize)boundingSize withContentSizeScale:(C
}

- (CGSize)_maxContentSize {
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ?
CGSizeMake(420.0f, 550.0f) :
CGSizeMake(500.0f, 800.0f));
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? CGSizeMake(420.0f, 550.0f) : CGSizeMake(500.0f, 800.0f));
}

- (CGSize)_contentSizeScaleForContentSize:(CGSize)contentSize {
Expand All @@ -367,8 +415,17 @@ - (CGSize)_contentSizeScaleForContentSize:(CGSize)contentSize {
return contentSizeScale;
}

#pragma mark -
#pragma mark Accessors
///--------------------------------------
#pragma mark - Accessors
///--------------------------------------

- (void)setFields:(PFLogInFields)fields {
if (_fields != fields) {
_fields = fields;
[self _updateAllFields];
[self setNeedsLayout];
}
}

- (void)setLogo:(UIView *)logo {
if (self.logo != logo) {
Expand All @@ -388,8 +445,9 @@ - (void)setEmailAsUsername:(BOOL)otherEmailAsUsername {
}
}

#pragma mark -
#pragma mark Private
///--------------------------------------
#pragma mark - Private
///--------------------------------------

+ (void)_validateFields:(PFLogInFields)fields {
if (fields == PFLogInFieldsNone) {
Expand Down
Loading