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 #include "ios/chrome/grit/ios_strings.h" | 10 #include "ios/chrome/grit/ios_strings.h" |
10 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 11 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
11 #import "ios/public/provider/chrome/browser/ui/text_field_styling.h" | 12 #import "ios/public/provider/chrome/browser/ui/text_field_styling.h" |
12 #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" |
13 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 14 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" |
14 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
15 #include "ui/base/resource/resource_bundle.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. |
25 const CGFloat kVerticalPadding = 16; | 25 const CGFloat kVerticalPadding = 16; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 cell.CVCContainerLeadingConstraintWithDate.active = self.showDateInput; | 82 cell.CVCContainerLeadingConstraintWithDate.active = self.showDateInput; |
83 cell.CVCContainerLeadingConstraintWithoutDate.active = !self.showDateInput; | 83 cell.CVCContainerLeadingConstraintWithoutDate.active = !self.showDateInput; |
84 | 84 |
85 [cell.monthInput setUseErrorStyling:self.showDateInputError]; | 85 [cell.monthInput setUseErrorStyling:self.showDateInputError]; |
86 [cell.yearInput setUseErrorStyling:self.showDateInputError]; | 86 [cell.yearInput setUseErrorStyling:self.showDateInputError]; |
87 [cell.CVCInput setUseErrorStyling:self.showDateInputError]; | 87 [cell.CVCInput setUseErrorStyling:self.showDateInputError]; |
88 | 88 |
89 cell.buttonForNewCard.hidden = !self.showNewCardButton; | 89 cell.buttonForNewCard.hidden = !self.showNewCardButton; |
90 | 90 |
91 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 91 cell.CVCImageView.image = NativeImage(self.CVCImageResourceID); |
92 cell.CVCImageView.image = | |
93 rb.GetNativeImageNamed(self.CVCImageResourceID).ToUIImage(); | |
94 } | 92 } |
95 | 93 |
96 @end | 94 @end |
97 | 95 |
98 @implementation CVCCell | 96 @implementation CVCCell |
99 | 97 |
100 @synthesize instructionsTextLabel = _instructionsTextLabel; | 98 @synthesize instructionsTextLabel = _instructionsTextLabel; |
101 @synthesize errorLabel = _errorLabel; | 99 @synthesize errorLabel = _errorLabel; |
102 @synthesize monthInput = _monthInput; | 100 @synthesize monthInput = _monthInput; |
103 @synthesize yearInput = _yearInput; | 101 @synthesize yearInput = _yearInput; |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 replacementString:(NSString*)string { | 352 replacementString:(NSString*)string { |
355 if (textField == self.CVCInput || textField == self.yearInput) { | 353 if (textField == self.CVCInput || textField == self.yearInput) { |
356 return ([textField.text length] + [string length] - range.length) <= 4; | 354 return ([textField.text length] + [string length] - range.length) <= 4; |
357 } else if (textField == self.monthInput) { | 355 } else if (textField == self.monthInput) { |
358 return ([textField.text length] + [string length] - range.length) <= 2; | 356 return ([textField.text length] + [string length] - range.length) <= 2; |
359 } | 357 } |
360 return YES; | 358 return YES; |
361 } | 359 } |
362 | 360 |
363 @end | 361 @end |
OLD | NEW |