| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/ui/autofill/cells/cvc_item.h" | 5 #import "ios/chrome/browser/ui/autofill/cells/cvc_item.h" |
| 6 | 6 |
| 7 #include "components/strings/grit/components_strings.h" | 7 #include "components/strings/grit/components_strings.h" |
| 8 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" | 8 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" |
| 9 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 9 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 10 #include "ios/chrome/grit/ios_strings.h" | 10 #include "ios/chrome/grit/ios_strings.h" |
| 11 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 11 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 12 #import "ios/public/provider/chrome/browser/ui/text_field_styling.h" | 12 #import "ios/public/provider/chrome/browser/ui/text_field_styling.h" |
| 13 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 13 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
| 14 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 14 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 16 | 16 |
| 17 #if !defined(__has_feature) || !__has_feature(objc_arc) | 17 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 18 #error "This file requires ARC support." | 18 #error "This file requires ARC support." |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 // Padding used on the leading and trailing edges of the cell. | 22 // Padding used on the leading and trailing edges of the cell. |
| 23 const CGFloat kHorizontalPadding = 16; | 23 const CGFloat kHorizontalPadding = 16; |
| 24 // Padding used on the top and bottom edges of the cell. | 24 // Padding used on the top and bottom edges of the cell. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 _CVCContainerLeadingConstraintWithDate; | 109 _CVCContainerLeadingConstraintWithDate; |
| 110 @synthesize CVCContainerLeadingConstraintWithoutDate = | 110 @synthesize CVCContainerLeadingConstraintWithoutDate = |
| 111 _CVCContainerLeadingConstraintWithoutDate; | 111 _CVCContainerLeadingConstraintWithoutDate; |
| 112 | 112 |
| 113 - (instancetype)initWithFrame:(CGRect)frame { | 113 - (instancetype)initWithFrame:(CGRect)frame { |
| 114 self = [super initWithFrame:frame]; | 114 self = [super initWithFrame:frame]; |
| 115 if (self) { | 115 if (self) { |
| 116 UIView* contentView = self.contentView; | 116 UIView* contentView = self.contentView; |
| 117 | 117 |
| 118 _instructionsTextLabel = [[UILabel alloc] init]; | 118 _instructionsTextLabel = [[UILabel alloc] init]; |
| 119 _instructionsTextLabel.font = | 119 _instructionsTextLabel.font = [MDCTypography body2Font]; |
| 120 [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14]; | |
| 121 _instructionsTextLabel.textColor = [[MDCPalette greyPalette] tint500]; | 120 _instructionsTextLabel.textColor = [[MDCPalette greyPalette] tint500]; |
| 122 _instructionsTextLabel.numberOfLines = 0; | 121 _instructionsTextLabel.numberOfLines = 0; |
| 123 _instructionsTextLabel.lineBreakMode = NSLineBreakByWordWrapping; | 122 _instructionsTextLabel.lineBreakMode = NSLineBreakByWordWrapping; |
| 124 _instructionsTextLabel.translatesAutoresizingMaskIntoConstraints = NO; | 123 _instructionsTextLabel.translatesAutoresizingMaskIntoConstraints = NO; |
| 125 [contentView addSubview:_instructionsTextLabel]; | 124 [contentView addSubview:_instructionsTextLabel]; |
| 126 | 125 |
| 127 _errorLabel = [[UILabel alloc] init]; | 126 _errorLabel = [[UILabel alloc] init]; |
| 128 _errorLabel.font = | 127 _errorLabel.font = [MDCTypography captionFont]; |
| 129 [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:12]; | |
| 130 _errorLabel.textColor = [[MDCPalette cr_redPalette] tint500]; | 128 _errorLabel.textColor = [[MDCPalette cr_redPalette] tint500]; |
| 131 _errorLabel.numberOfLines = 0; | 129 _errorLabel.numberOfLines = 0; |
| 132 _errorLabel.lineBreakMode = NSLineBreakByWordWrapping; | 130 _errorLabel.lineBreakMode = NSLineBreakByWordWrapping; |
| 133 _errorLabel.translatesAutoresizingMaskIntoConstraints = NO; | 131 _errorLabel.translatesAutoresizingMaskIntoConstraints = NO; |
| 134 [contentView addSubview:_errorLabel]; | 132 [contentView addSubview:_errorLabel]; |
| 135 | 133 |
| 136 _dateContainerView = [[UIView alloc] init]; | 134 _dateContainerView = [[UIView alloc] init]; |
| 137 _dateContainerView.translatesAutoresizingMaskIntoConstraints = NO; | 135 _dateContainerView.translatesAutoresizingMaskIntoConstraints = NO; |
| 138 [contentView addSubview:_dateContainerView]; | 136 [contentView addSubview:_dateContainerView]; |
| 139 | 137 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 _CVCInput.keyboardType = UIKeyboardTypeNumberPad; | 170 _CVCInput.keyboardType = UIKeyboardTypeNumberPad; |
| 173 _CVCInput.delegate = self; | 171 _CVCInput.delegate = self; |
| 174 _CVCInput.translatesAutoresizingMaskIntoConstraints = NO; | 172 _CVCInput.translatesAutoresizingMaskIntoConstraints = NO; |
| 175 [_CVCContainerView addSubview:_CVCInput]; | 173 [_CVCContainerView addSubview:_CVCInput]; |
| 176 | 174 |
| 177 _CVCImageView = [[UIImageView alloc] init]; | 175 _CVCImageView = [[UIImageView alloc] init]; |
| 178 _CVCImageView.translatesAutoresizingMaskIntoConstraints = NO; | 176 _CVCImageView.translatesAutoresizingMaskIntoConstraints = NO; |
| 179 [_CVCContainerView addSubview:_CVCImageView]; | 177 [_CVCContainerView addSubview:_CVCImageView]; |
| 180 | 178 |
| 181 _buttonForNewCard = [UIButton buttonWithType:UIButtonTypeCustom]; | 179 _buttonForNewCard = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 182 _buttonForNewCard.titleLabel.font = | 180 _buttonForNewCard.titleLabel.font = [MDCTypography captionFont]; |
| 183 [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:12]; | |
| 184 [_buttonForNewCard | 181 [_buttonForNewCard |
| 185 setTitle:l10n_util::GetNSString(IDS_AUTOFILL_CARD_UNMASK_NEW_CARD_LINK) | 182 setTitle:l10n_util::GetNSString(IDS_AUTOFILL_CARD_UNMASK_NEW_CARD_LINK) |
| 186 forState:UIControlStateNormal]; | 183 forState:UIControlStateNormal]; |
| 187 [_buttonForNewCard setTitleColor:[[MDCPalette cr_bluePalette] tint500] | 184 [_buttonForNewCard setTitleColor:[[MDCPalette cr_bluePalette] tint500] |
| 188 forState:UIControlStateNormal]; | 185 forState:UIControlStateNormal]; |
| 189 _buttonForNewCard.translatesAutoresizingMaskIntoConstraints = NO; | 186 _buttonForNewCard.translatesAutoresizingMaskIntoConstraints = NO; |
| 190 [contentView addSubview:_buttonForNewCard]; | 187 [contentView addSubview:_buttonForNewCard]; |
| 191 | 188 |
| 192 [NSLayoutConstraint activateConstraints:@[ | 189 [NSLayoutConstraint activateConstraints:@[ |
| 193 // Text label | 190 // Text label |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 replacementString:(NSString*)string { | 349 replacementString:(NSString*)string { |
| 353 if (textField == self.CVCInput || textField == self.yearInput) { | 350 if (textField == self.CVCInput || textField == self.yearInput) { |
| 354 return ([textField.text length] + [string length] - range.length) <= 4; | 351 return ([textField.text length] + [string length] - range.length) <= 4; |
| 355 } else if (textField == self.monthInput) { | 352 } else if (textField == self.monthInput) { |
| 356 return ([textField.text length] + [string length] - range.length) <= 2; | 353 return ([textField.text length] + [string length] - range.length) <= 2; |
| 357 } | 354 } |
| 358 return YES; | 355 return YES; |
| 359 } | 356 } |
| 360 | 357 |
| 361 @end | 358 @end |
| OLD | NEW |