Create Flat UI rounded button class.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 3993035d98
commit 46d00383fd

@ -156,6 +156,8 @@ NS_ASSUME_NONNULL_BEGIN
[underscoreView autoSetDimension:ALDimensionHeight toSize:1.f];
const CGFloat kSubmitButtonHeight = 47.f;
// NOTE: We use ows_signalBrandBlueColor instead of ows_materialBlueColor
// throughout the onboarding flow to be consistent with the headers.
OWSFlatButton *submitButton =
[OWSFlatButton buttonWithTitle:NSLocalizedString(@"VERIFICATION_CHALLENGE_SUBMIT_CODE",
@"button text during registration to submit your SMS verification code.")

@ -38,7 +38,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
@property (nonatomic) UIImageView *cameraImageView;
@property (nonatomic) UIButton *saveButton;
@property (nonatomic) OWSFlatButton *saveButton;
@property (nonatomic, nullable) UIImage *avatar;
@ -209,21 +209,22 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
UIView *buttonRow = [UIView containerView];
[rows addObject:buttonRow];
UIButton *saveButton = [UIButton buttonWithType:UIButtonTypeCustom];
const CGFloat kButtonHeight = 47.f;
// NOTE: We use ows_signalBrandBlueColor instead of ows_materialBlueColor
// throughout the onboarding flow to be consistent with the headers.
OWSFlatButton *saveButton =
[OWSFlatButton buttonWithTitle:NSLocalizedString(@"PROFILE_VIEW_SAVE_BUTTON",
@"Button to save the profile view in the profile view.")
font:[OWSFlatButton fontForHeight:kButtonHeight]
titleColor:[UIColor whiteColor]
backgroundColor:[UIColor ows_signalBrandBlueColor]
target:self
selector:@selector(saveButtonPressed)];
self.saveButton = saveButton;
saveButton.backgroundColor = [UIColor ows_signalBrandBlueColor];
[saveButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
saveButton.titleLabel.font = [UIFont ows_boldFontWithSize:fontSizePoints];
[saveButton setTitle:NSLocalizedString(
@"PROFILE_VIEW_SAVE_BUTTON", @"Button to save the profile view in the profile view.")
forState:UIControlStateNormal];
[saveButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
[saveButton setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
[buttonRow addSubview:saveButton];
[saveButton autoPinLeadingAndTrailingToSuperview];
[saveButton autoPinHeightToSuperview];
[saveButton autoSetDimension:ALDimensionHeight toSize:47.f];
[saveButton addTarget:self action:@selector(saveButtonPressed) forControlEvents:UIControlEventTouchUpInside];
}
// Row Layout
@ -345,11 +346,11 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
// The save button is only used in "registration" and "upgrade or nag" modes.
if (self.hasUnsavedChanges) {
self.saveButton.enabled = YES;
self.saveButton.backgroundColor = [UIColor ows_signalBrandBlueColor];
[self.saveButton setBackgroundColors:[UIColor ows_signalBrandBlueColor]];
} else {
self.saveButton.enabled = NO;
self.saveButton.backgroundColor =
[[UIColor ows_signalBrandBlueColor] blendWithColor:[UIColor whiteColor] alpha:0.5f];
[self.saveButton
setBackgroundColors:[[UIColor ows_signalBrandBlueColor] blendWithColor:[UIColor whiteColor] alpha:0.5f]];
}
}

@ -199,6 +199,8 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
// Activate Button
const CGFloat kActivateButtonHeight = 47.f;
// NOTE: We use ows_signalBrandBlueColor instead of ows_materialBlueColor
// throughout the onboarding flow to be consistent with the headers.
OWSFlatButton *activateButton = [OWSFlatButton buttonWithTitle:NSLocalizedString(@"REGISTRATION_VERIFY_DEVICE", @"")
font:[OWSFlatButton fontForHeight:kActivateButtonHeight]
titleColor:[UIColor whiteColor]

@ -37,7 +37,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
@property (nonatomic) UITextField *phoneNumberTextField;
@property (nonatomic) UIButton *phoneNumberButton;
@property (nonatomic) OWSFlatButton *phoneNumberButton;
@property (nonatomic) UILabel *examplePhoneNumberLabel;
@ -172,24 +172,19 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
return _phoneNumberTextField;
}
- (UIButton *)phoneNumberButton
- (OWSFlatButton *)phoneNumberButton
{
if (!_phoneNumberButton) {
// TODO: Eventually we should make a view factory that will allow us to
// create views with consistent appearance across the app and move
// towards a "design language."
_phoneNumberButton = [UIButton buttonWithType:UIButtonTypeCustom];
_phoneNumberButton.titleLabel.font = [UIFont ows_mediumFontWithSize:18.f];
[_phoneNumberButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_phoneNumberButton setBackgroundColor:[UIColor ows_materialBlueColor]];
_phoneNumberButton.clipsToBounds = YES;
_phoneNumberButton.layer.cornerRadius = 3.f;
[_phoneNumberButton setTitle:[self.delegate phoneNumberButtonText] forState:UIControlStateNormal];
[_phoneNumberButton addTarget:self
action:@selector(phoneNumberButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
[_phoneNumberButton autoSetDimension:ALDimensionWidth toSize:140];
[_phoneNumberButton autoSetDimension:ALDimensionHeight toSize:40];
const CGFloat kButtonHeight = 40;
OWSFlatButton *button = [OWSFlatButton buttonWithTitle:[self.delegate phoneNumberButtonText]
font:[OWSFlatButton fontForHeight:kButtonHeight]
titleColor:[UIColor whiteColor]
backgroundColor:[UIColor ows_materialBlueColor]
target:self
selector:@selector(phoneNumberButtonPressed)];
_phoneNumberButton = button;
[button autoSetDimension:ALDimensionWidth toSize:140];
[button autoSetDimension:ALDimensionHeight toSize:kButtonHeight];
}
return _phoneNumberButton;
}
@ -275,7 +270,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
[self presentViewController:navigationController animated:YES completion:[UIUtil modalCompletionBlock]];
}
- (void)phoneNumberButtonPressed:(id)sender
- (void)phoneNumberButtonPressed
{
[self tryToSelectPhoneNumber];
}
@ -387,7 +382,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
BOOL isEnabled = [self hasValidPhoneNumber];
self.phoneNumberButton.enabled = isEnabled;
[self.phoneNumberButton
setBackgroundColor:(isEnabled ? [UIColor ows_signalBrandBlueColor] : [UIColor lightGrayColor])];
setBackgroundColors:(isEnabled ? [UIColor ows_signalBrandBlueColor] : [UIColor lightGrayColor])];
}
#pragma mark - CountryCodeViewControllerDelegate

Loading…
Cancel
Save